Skip to content

Commit

Permalink
Fixed Missing Skills, Battle Logic Improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoz committed Sep 28, 2024
1 parent c8c3e94 commit f7b3908
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
34 changes: 28 additions & 6 deletions cogs/palgame/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,45 @@ async def skill_callback(self, interaction, user, opponent_pal, skill, pal_data,

result_text = f"{pal_data['Name']} used {skill['Name']}! It dealt {damage} damage. {opponent_pal['Name']} has {opponent_hp} HP left."

async def skill_callback(self, interaction, user, opponent_pal, skill, pal_data, level, experience, user_hp, opponent_hp, user_stamina, opponent_stamina):
if user_stamina <= 0:
await interaction.response.send_message(f"{pal_data['Name']} is too exhausted to use {skill['Name']}! You need to rest.")
return

damage = self.calculate_damage(skill['Power'], 'Melee', user_pal=pal_data, opponent_pal=opponent_pal)
opponent_hp -= damage
user_stamina -= 10

result_text = f"{pal_data['Name']} used {skill['Name']}! It dealt {damage} damage. {opponent_pal['Name']} has {opponent_hp} HP left."

new_experience = experience

if opponent_hp <= 0:
result_text += f"\n{opponent_pal['Name']} has been defeated!"

base_experience = 50
rarity_multiplier = opponent_pal.get('Rarity', 1)
experience_gained = base_experience * rarity_multiplier
new_experience = experience + experience_gained
new_experience += experience_gained
result_text += f"\n{pal_data['Name']} gained {experience_gained} experience points."

required_experience = 1000 + (level - 1) * 200

leveled_up = False
if new_experience >= 1000:
await level_up(str(interaction.user.id), pal_data['Name'])
new_experience -= 1000
result_text += f"\n{pal_data['Name']} leveled up!"
while new_experience >= required_experience:
level += 1
new_experience -= required_experience
required_experience = 1000 + (level - 1) * 200
leveled_up = True

await add_experience(str(interaction.user.id), pal_data['Name'], experience_gained)
if leveled_up:
await level_up(str(interaction.user.id), pal_data['Name'])

if leveled_up:
result_text += f"\n{pal_data['Name']} leveled up to Level {level}!"
else:
result_text += f"\n{pal_data['Name']} is still at Level {level}."

base_points = random.randint(10, 20)
points_awarded = int(base_points * rarity_multiplier)
Expand All @@ -135,7 +157,7 @@ async def skill_callback(self, interaction, user, opponent_pal, skill, pal_data,
return

embed = nextcord.Embed(title="Battle Update", description=result_text, color=nextcord.Color.orange())
view = self.create_battle_view(pal_data, user, opponent_pal, level, experience, user_hp, opponent_hp, user_stamina, opponent_stamina)
view = self.create_battle_view(pal_data, user, opponent_pal, level, new_experience, user_hp, opponent_hp, user_stamina, opponent_stamina)
await interaction.response.edit_message(embed=embed, view=view)

def calculate_damage(self, skill_power, attack_type, user_pal, opponent_pal):
Expand Down
59 changes: 58 additions & 1 deletion gamedata/game.json
Original file line number Diff line number Diff line change
Expand Up @@ -12180,7 +12180,64 @@
"EnemyReceiveDamageRate": 1.0
},
"Rarity": 4,
"Skills": []
"Skills": [
{
"Name": "Sand Blast",
"Type": "Ground",
"Level": 1,
"Power": 40,
"Cooldown": 4,
"Description": "Hurls sticky mud at an enemy."
},
{
"Name": "Aqua Gun",
"Type": "Water",
"Level": 7,
"Power": 40,
"Cooldown": 4,
"Description": "Hurls a ball of water straight at an enemy."
},
{
"Name": "Stone Blast",
"Type": "Ground",
"Level": 15,
"Power": 55,
"Cooldown": 10,
"Description": "Fires a barrage of stones forward."
},
{
"Name": "Bubble Blast",
"Type": "Water",
"Level": 22,
"Power": 65,
"Cooldown": 13,
"Description": "Fires numerous bubbles that slowly pursue an enemy."
},
{
"Name": "Aqua Burst",
"Type": "Water",
"Level": 30,
"Power": 100,
"Cooldown": 30,
"Description": "Creates a giant ball of water and hurls it at an enemy."
},
{
"Name": "Rock Lance",
"Type": "Ground",
"Level": 40,
"Power": 150,
"Cooldown": 55,
"Description": "Generates a sharp rock spear under an enemy."
},
{
"Name": "Hydro Laser",
"Type": "Water",
"Level": 50,
"Power": 150,
"Cooldown": 55,
"Description": "Shoots pressurized water at extreme velocities, sweeping over a wide area in front of it."
}
]
},
{
"Name": "Flambelle",
Expand Down

0 comments on commit f7b3908

Please sign in to comment.