public void Camouflage_Works(PBEBattleTerrain battleTerrain, PBEType expectedType, PBESpecies species) { #region Setup PBERandom.SetSeed(0); PBESettings settings = PBESettings.DefaultSettings; var p0 = new TestPokemonCollection(1); p0[0] = new TestPokemon(settings, species, 0, 100, PBEMove.Camouflage); var p1 = new TestPokemonCollection(1); p1[0] = new TestPokemon(settings, PBESpecies.Magikarp, 0, 100, PBEMove.Splash); var battle = new PBEBattle(PBEBattleFormat.Single, settings, new PBETrainerInfo(p0, "Trainer 0"), new PBETrainerInfo(p1, "Trainer 1"), battleTerrain: battleTerrain); battle.OnNewEvent += PBEBattle.ConsoleBattleEventHandler; battle.Begin(); PBETrainer t0 = battle.Trainers[0]; PBETrainer t1 = battle.Trainers[1]; PBEBattlePokemon camouflager = t0.Party[0]; PBEBattlePokemon magikarp = t1.Party[0]; #endregion #region Use Camouflage and check Assert.True(PBEBattle.SelectActionsIfValid(t0, new PBETurnAction(camouflager, PBEMove.Camouflage, PBETurnTarget.AllyCenter))); Assert.True(PBEBattle.SelectActionsIfValid(t1, new PBETurnAction(magikarp, PBEMove.Splash, PBETurnTarget.AllyCenter))); battle.RunTurn(); Assert.True(camouflager.Type1 == expectedType && camouflager.Type2 == PBEType.None); #endregion #region Cleanup battle.OnNewEvent -= PBEBattle.ConsoleBattleEventHandler; #endregion }
public PBEBattle(PBEBattleFormat battleFormat, PBESettings settings, IReadOnlyList <PBETrainerInfo> ti0, IReadOnlyList <PBETrainerInfo> ti1, PBEBattleTerrain battleTerrain = PBEBattleTerrain.Plain, PBEWeather weather = PBEWeather.None) { if (battleFormat >= PBEBattleFormat.MAX) { throw new ArgumentOutOfRangeException(nameof(battleFormat)); } if (battleTerrain >= PBEBattleTerrain.MAX) { throw new ArgumentOutOfRangeException(nameof(battleTerrain)); } if (weather >= PBEWeather.MAX) { throw new ArgumentOutOfRangeException(nameof(weather)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (!settings.IsReadOnly) { throw new ArgumentException("Settings must be read-only.", nameof(settings)); } if (ti0 == null || ti0.Any(t => t == null)) { throw new ArgumentNullException(nameof(ti0)); } if (ti1 == null || ti1.Any(t => t == null)) { throw new ArgumentNullException(nameof(ti1)); } BattleTerrain = battleTerrain; BattleFormat = battleFormat; Settings = settings; Weather = weather; Teams = new PBETeams(this, ti0, ti1, out ReadOnlyCollection <PBETrainer> trainers); Trainers = trainers; void QueueUp(PBETeam team, int i, PBEFieldPosition pos) { PBETrainer t; if (team.Trainers.Count == 1) { t = team.Trainers[0]; } else { t = team.GetTrainer(pos); i = 0; } PBEList <PBEBattlePokemon> party = t.Party; if (i < party.Count) { PBEBattlePokemon p = party[i]; p.Trainer.SwitchInQueue.Add((p, pos)); } } switch (BattleFormat) { case PBEBattleFormat.Single: { foreach (PBETeam team in Teams) { QueueUp(team, 0, PBEFieldPosition.Center); } break; } case PBEBattleFormat.Double: { foreach (PBETeam team in Teams) { QueueUp(team, 0, PBEFieldPosition.Left); QueueUp(team, 1, PBEFieldPosition.Right); } break; } case PBEBattleFormat.Triple: { foreach (PBETeam team in Teams) { QueueUp(team, 0, PBEFieldPosition.Left); QueueUp(team, 1, PBEFieldPosition.Center); QueueUp(team, 2, PBEFieldPosition.Right); } break; } case PBEBattleFormat.Rotation: { foreach (PBETeam team in Teams) { QueueUp(team, 0, PBEFieldPosition.Center); QueueUp(team, 1, PBEFieldPosition.Left); QueueUp(team, 2, PBEFieldPosition.Right); } break; } default: throw new ArgumentOutOfRangeException(nameof(BattleFormat)); } BattleState = PBEBattleState.ReadyToBegin; OnStateChanged?.Invoke(this); }
public PBEBattle(PBEBattleFormat battleFormat, PBESettings settings, PBETrainerInfo ti0, PBETrainerInfo ti1, PBEBattleTerrain battleTerrain = PBEBattleTerrain.Plain, PBEWeather weather = PBEWeather.None) : this(battleFormat, settings, new[] { ti0 }, new[] { ti1 }, battleTerrain : battleTerrain, weather : weather) { }