public static string ChangeTempStats(IAttack attack, IPokemon attackingPokemon, IPokemon targetPokemon) { string[] boosts = attack.BoostStats.SplitBoosts(); string output = string.Empty; foreach (string boostString in boosts) { StatsBoost statsBoost = StatsBoostMapper.ToDomainObject(boostString); IPokemon affectedPokemon = statsBoost.Target == Target.Self ? attackingPokemon : targetPokemon; StatsChangeValidator statsChangeValidator = new StatsChangeValidator( affectedPokemon, statsBoost); if (statsChangeValidator.StatChangePossible()) { ChangeTempPokemonStats(affectedPokemon, statsBoost); string changeType = statsBoost.Value > 0 ? "increased" : "decreased"; output += $"{affectedPokemon.Name} {statsBoost.StatType.ToString()} {changeType}\n"; } else { return($"{affectedPokemon.Name} {statsBoost.StatType.ToString()} cannot go any higher"); } } return(output); }
public static StatsBoost ToDomainObject(string boostString) { string[] splittedBoosts = boostString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); StatsBoost boost = new StatsBoost() { Target = splittedBoosts[0] == "self" ? Target.Self : Target.Enemy, StatType = (StatType)Int32.Parse(splittedBoosts[1]), Value = Int32.Parse(splittedBoosts[2]) }; return(boost); }
// check the inventory to see what the player's stats should be void UpdateStats() { // sum all the stats var stats = new StatsBoost(); if (GameData.EquippedHelmet.Stats != null) { stats = EntityStats.SumStatsB(GameData.EquippedHelmet.Stats, stats); } if (GameData.EquippedChest.Stats != null) { stats = EntityStats.SumStatsB(GameData.EquippedChest.Stats, stats); } if (GameData.EquippedLegs.Stats != null) { stats = EntityStats.SumStatsB(GameData.EquippedLegs.Stats, stats); } // boost the player's stats this.player.EntityStats.Boosts = stats; }
public StatsChangeValidator(IPokemon affectedPokemon, StatsBoost statsBoost) { _affectedPokemon = affectedPokemon; _statType = statsBoost.StatType; _stageValue = statsBoost.Value; }
public static void ChangeTempPokemonStats(IPokemon affectedPokemon, StatsBoost statsBoost) { affectedPokemon.StatModifierStages[(int)statsBoost.StatType] += statsBoost.Value; }