public void EndTurn() { if (GameState == GameFieldState.GameOver || GameState == GameFieldState.TurnEnding) { return; } GameState = GameFieldState.TurnEnding; var abilitiesToRemove = new List <Ability>(); foreach (var ability in TemporaryPassiveAbilities.OfType <PassiveAbility>()) { ability.TurnsLeft--; if (ability.TurnsLeft <= 0 && ability.LimitedByTime) { abilitiesToRemove.Add(ability); } } foreach (var ability in abilitiesToRemove) { TemporaryPassiveAbilities.Remove(ability); } EnergyRule = new StandardEnergyRule(); EnergyRule.Reset(); ActivePlayer.EndTurn(this); ActivePlayer.TurnsTaken++; foreach (var pokemon in ActivePlayer.GetAllPokemonCards()) { foreach (var attack in pokemon.Attacks) { attack.Disabled = false; } } foreach (var pokemon in ActivePlayer.GetAllPokemonCards()) { pokemon.AbilityDisabled = false; } NonActivePlayer.EndTurn(this); CheckDeadPokemon(); SwapActivePlayer(); FirstTurn = false; StartNextTurn(); PushGameLogUpdatesToPlayers(); SendEventToPlayers(new GameSyncEvent { Game = this }); }
public GameField() { Id = NetworkId.Generate(); playersSetStartBench = new HashSet <NetworkId>(); DamageStoppers = new List <DamageStopper>(); TemporaryPassiveAbilities = new List <Ability>(); GameState = GameFieldState.WaitingForConnection; GameLog = new GameLog(); forcedFlips = new Queue <bool>(); EnergyRule = new StandardEnergyRule(); Players = new Player[2]; }