Skip to content

Commit

Permalink
fix(combat): heal health up to max and improve enemy AI
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Sep 23, 2024
1 parent 5a43c96 commit 4f60e80
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 5 additions & 5 deletions game/combat/enemy_turn.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ label enemy_turn:

$ enemy_attack = renpy.random.randint(1 + victories, 5 + victories)
$ enemy_heal = renpy.random.randint(1 + victories, 5 + victories)
$ coinflip = renpy.random.choice([True, False])

if coinflip:
if enemy.health < enemy.health_max and coinflip():
"Enemy healed [enemy_heal] health."
$ enemy.health = enemy.health_max if enemy.health + enemy_heal >= enemy.health_max else enemy.health + enemy_heal

else:
"Enemy dealt [enemy_attack] damage to you."
show placeholder boy with vpunch
$ player.health -= enemy_attack
else:
"Enemy healed [enemy_heal] health."
$ enemy.health += enemy_heal

$ player.energy = player.energy_max

Expand Down
3 changes: 3 additions & 0 deletions game/combat/functions.rpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
init python:
def coinflip() -> bool:
return renpy.random.choice([True, False])
7 changes: 5 additions & 2 deletions game/combat/player_turn.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ label player_turn:
"You defeated the enemy!"
jump combat

if not player.energy:
jump enemy_turn

$ player_attack = renpy.random.randint(1, 5)
$ player_heal = renpy.random.randint(1, 5)

menu:
"Choose your action."

"{color=#EE4B2B}Attack [player_attack]\n{color=#add8e6}Energy -1" if player.energy >= 1:
$ enemy.health -= player_attack
$ player.energy -= 1
$ enemy.health -= player_attack

show placeholder boy at shake, center

Expand All @@ -23,8 +26,8 @@ label player_turn:
jump player_turn

"{color=#af0}Heal [player_heal]\n{color=#add8e6}Energy -2" if player.energy >= 2:
$ player.health += player_heal
$ player.energy -= 2
$ player.health = player.health_max if player.health + player_heal >= player.health_max else player.health + player_heal

"You healed [player_heal] health."

Expand Down
2 changes: 1 addition & 1 deletion game/combat/screens.rpy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
screen stat(name, current, max):
text "[name]: [current]"
text "[name]: [current]/[max]"
bar value AnimatedValue(current, max):
xalign 0.5
xsize 300
Expand Down

0 comments on commit 4f60e80

Please sign in to comment.