private ITypeEffectivenessDataSource CreateEffectivenessSource() { var effectivenessExample = new TypeEffectiveness( new[] { PokemonType.Flying, PokemonType.Water }, Enumerable.Empty <PokemonType>(), PokemonType.Electric ); var dataSource = Substitute.For <ITypeEffectivenessDataSource>(); dataSource.LoadTypeEffectivenessTable().Returns(new[] { effectivenessExample }); return(dataSource); }
private float CalculateDamageModifier(IndividualPokemon user, IndividualPokemon target, bool crit = false) { //Calculates the damage modifier, before the random modifier is applied float modifier = 1; //Apply same-type attack bonus if (type == user.pokedexEntry.typeA || type == user.pokedexEntry.typeB) { modifier *= STAB_MULTIPLIER; } //Apply critical hit multiplier if (crit) { modifier *= CRIT_MULTIPLIER; } //Apply type effectiveness multiplier modifier *= TypeEffectiveness.GetEffectiveness(type, target.pokedexEntry.typeA, target.pokedexEntry.typeB); return(modifier); }