Closed LAMaglan closed 5 months ago
The relevant code within battle_simulator is the following:
for atk_type in attacker.types:
# For now, take average of "physical" and "special" stats
attack_power = (
attacker.attack["base_stat"] + attacker.special_attack["base_stat"]
) / 2
defense_power = (
defender.defense["base_stat"] + defender.special_defense["base_stat"]
) / 2
damage = calculate_damage(attacker.level, attack_power, defense_power)
type_effectiveness = 1
for defending_type in defender.types:
type_effectiveness *= type_advantages.get(atk_type, {}).get(
defending_type, 1
)
# Apply type effectiveness to the damage
damage *= type_effectiveness
defender.hp["base_stat"] -= damage
pokemon1, pokemon2 = defender, attacker
This does take into account the cumulative effectiveness of the attack (with typeA) across all the types of the defender. However, with this implementation, the order of types the attacker attacks with matters.
Need to verify type advantage(s) get used in an OK way.
Otherwise, without moveset, should do "collective" type advantage. For now, I could take the average type advantages across all types that attacker has. But not sure what to do for defender (I.e. how type advantage for attacker works on "average" of defender?)
Need to research how it works in mainline games)