sql = "SELECT * FROM battle_unit_stats WHERE battle_id = %s AND team = %s AND slot = %s" params = (battle_id, team, unit) cursor.execute(sql, params) unit_stats = cursor.fetchone() if(unit_stats["health_current"] < 1): action_helper.dead_action_receipt(battle_id, team, unit, unit_stats["title"], turn) elif(unit_stats["energy_current"] < cost): action_helper.exhausted_action_receipt(battle_id, team, unit, unit_stats["title"], turn) else: action_helper.spend_energy(battle_id, team, unit, cost) sql = "SELECT * FROM battle_unit_stats WHERE battle_id = %s AND team = %s AND slot = %s" params = (battle_id, target_team, action_target_unit) cursor.execute(sql, params) target_stats = cursor.fetchone() damage = (15 + unit_stats["power_current"]) * action_helper.key_bonus_enemy( action_helper.key_difference(target_stats["song_key"], unit_stats["song_key"])) if(target_stats["defense_current"] > damage): damage = 1 else: damage = damage - target_stats["defense_current"] if(action_helper.is_immune(target_stats["immune"], battle_id, turn, target_stats["team"], target_stats["slot"]) == 0): damage = 0 damage_string = damage_string + str(damage) + " " newhealth = target_stats["health_current"] - damage energy_sap = target_stats["energy_current"] / 2 ''' This is the part where it updates some stuff in the receipt ''' effective_text = "" if(damage > target_stats["health_default"] * 0.2):
elif (unit_stats["energy_current"] < cost): action_helper.exhausted_action_receipt(battle_id, team, unit, unit_stats["title"], turn) else: action_helper.spend_energy(battle_id, team, unit, cost) sql = "SELECT * FROM battle_unit_stats WHERE battle_id = %s AND team = %s" params = (battle_id, target_team) cursor.execute(sql, params) target_stats_all = cursor.fetchall() for target_stats in target_stats_all: if (action_helper.is_immune(target_stats["immune"], battle_id, turn, target_stats["team"], target_stats["slot"]) == 0): damage = unit_stats[ "power_current"] * scale * action_helper.key_bonus_enemy( action_helper.key_difference(target_stats["song_key"], unit_stats["song_key"])) if (target_stats["defense_current"] > damage): damage = 1 damage_string = damage_string + str(damage) + " " newhealth = target_stats["health_current"] - \ (damage - target_stats["defense_current"]) if (newhealth < 0): newhealth = 0 else: damage = damage - target_stats["defense_current"] sql = "UPDATE battle_unit_stats SET health_current = %s WHERE battle_id = %s AND team = %s AND slot = %s" params = (newhealth, battle_id, target_team, target_stats["slot"]) summary_code += "t{}u{} -{}".format(target_team, target_stats["slot"],
sql = "SELECT * FROM battle_unit_stats WHERE battle_id = %s AND team = %s AND slot = %s" params = (battle_id, team, unit) cursor.execute(sql, params) unit_stats = cursor.fetchone() if(unit_stats["health_current"] < 1): action_helper.dead_action_receipt(battle_id, team, unit, unit_stats["title"], turn) elif(unit_stats["energy_current"] < cost): action_helper.exhausted_action_receipt(battle_id, team, unit, unit_stats["title"], turn) else: action_helper.spend_energy(battle_id, team, unit, cost) sql = "SELECT * FROM battle_unit_stats WHERE battle_id = %s AND team = %s AND slot = %s" params = (battle_id, target_team, action_target_unit) cursor.execute(sql, params) target_stats = cursor.fetchone() percent_mod = 1 - (0.2 + 0.01 * (unit_stats["power_current"] * action_helper.key_bonus_enemy( action_helper.key_difference(target_stats["song_key"], unit_stats["song_key"])) * scale)) sql = "UPDATE battle_unit_stats SET power_current = power_current*%s,defense_current = defense_current*%s,energy_current = energy_current*%s WHERE health_current > 0 AND battle_id = %s AND team = %s AND slot = %s" params = (percent_mod, percent_mod, percent_mod, battle_id, target_team, action_target_unit) cursor.execute(sql, params) ''' This part makes it skip turn next time.... ''' sql = "INSERT IGNORE INTO battle_action_queue (battle_id, turn, team, unit, unit_key, unit_speed, action_code, action_target_team, action_target_unit, processed) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);" params = (battle_id, str(int(turn) + 1), target_stats["team"], target_stats["slot"], target_stats[ "song_key"], target_stats["speed_current"], "Z0", -1, -1, 0) cursor.execute(sql, params) connection.commit() ''' This is the part where it updates some stuff in the receipt
for target_stats in target_stats_all: if (target_stats["health_current"] < lowest_health): lowest_health = target_stats["health_current"] lowest_health_slot = target_stats["slot"] for target_stats in target_stats_all: if (lowest_health_slot == target_stats["slot"]): if (action_helper.is_immune(target_stats["immune"], battle_id, turn, target_stats["team"], target_stats["slot"]) == 0): target_name = target_stats["title"] damage = ( (target_stats["health_default"] - target_stats["health_current"]) + unit_stats["power_current"] ) * action_helper.key_bonus_enemy( action_helper.key_difference(target_stats["song_key"], unit_stats["song_key"])) if (target_stats["defense_current"] > damage): damage = 1 else: damage = damage - target_stats["defense_current"] damage_string = damage_string + str(damage) + " " newhealth = target_stats["health_current"] + \ target_stats["defense_current"] - damage if (newhealth < 0): newhealth = 0 sql = "UPDATE battle_unit_stats SET health_current = %s WHERE battle_id = %s AND team = %s AND slot = %s" params = (newhealth, battle_id, target_team, target_stats["slot"]) summary_code += "t{}u{} -{}".format( target_team, target_stats["slot"], damage)