Closed LAMaglan closed 8 months ago
Address https://github.com/LAMaglan/PokeFightSimulator/issues/29
Here is the logic of base stats:
def battle_simulator(pokemon1: Pokemon, pokemon2: Pokemon): if pokemon1.speed > pokemon2.speed: attacker = pokemon1 defender = pokemon2 else: attacker = pokemon2 defender = pokemon1 while pokemon1.hp > 0 and pokemon2.hp > 0: if attacker.attack > defender.defense: damage = attacker.attack - defender.defense defender.hp -= damage elif attacker.special_attack > defender.special_defense: damage = attacker.special_attack - defender.special_defense defender.hp -= damage attacker, defender = ( defender, attacker, ) # Players switch roles for the next round if pokemon1.hp <= 0: return pokemon2.name else: return pokemon1.name
Also created a Pokemon class Note: since inherits from BaseModel, and Pokemon is not defining the attributes as class attributes, have to use
class Config: allow_mutation = False
Note actually, allow_mutation was not necessary. See next PR
Address https://github.com/LAMaglan/PokeFightSimulator/issues/29
Here is the logic of base stats:
Also created a Pokemon class Note: since inherits from BaseModel, and Pokemon is not defining the attributes as class attributes, have to use
Note actually, allow_mutation was not necessary. See next PR