When I do exactly same thing while in renpy scrip game seems to run fine. Where is the problem?
Code: Select all
init python:
class Battle(object):
def __init__(self,characters):
self.characters = characters
@staticmethod
def character_status(characters): # Method used to check if character has more than 0 hp
for p in characters:
if p.hp > 0:
return "a"
return "d"
@staticmethod
def mainBattle():
x = 0 # I defined the numeric order in which every team member has its number from 0 to (number of player in list)
while x < len(team_members): # Every player in team_members needs to have his turn when it's over we jump to a next code
cp = team_members[x] # Here we define who is the current player
if cp.hp > 0: # If current player hp is 0 check if everyone else is alive in party if not jump to label
if Battle.character_status(team_members) == "d":
renpy.jump("game_over")
global player_turn
player_turn = True
target = ui.interact() # Selected enemy will be memorised and get attacked by current player
player_turn = False
cp.attack(enemy_members[target])
x += 1 # After this player attacked loop this code again until all players had their turn
label start:
"Game Starts"
"Game freezes in infinite loop causing it to crash!"
$ mainBattle()