def defend(): action, args = partition_action(choose_defensive_action()) if not action: offensive_mode() return combat_echo("No defensive action was set for this character, not defending.") if action.possible(*args) and not p.action_already_active(action, *args): p.act(action, *args) if char.health > char.offensive_health_level: offensive_mode()
def attack(): if char.health < char.defensive_health_level: defensive_mode() return action, args = partition_action(choose_offensive_action(s.target)) if not action: return combat_echo("No offensive action was set for this character, not attacking.") if action.possible(*args) and not p.action_already_active(action, *args): p.act(action, *args)