Ejemplo n.º 1
0
        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
            });
        }
Ejemplo n.º 2
0
        public List <IDamageTakenModifier> GetGlobalDamageTakenModifiers()
        {
            var modifiers = new List <IDamageTakenModifier>();

            foreach (var pokemon in ActivePlayer.GetAllPokemonCards())
            {
                modifiers.AddRange(pokemon.GetAllActiveAbilities(this, ActivePlayer, NonActivePlayer).OfType <DamageTakenModifier>().Where(a => a.IsGlobal));
            }
            foreach (var pokemon in NonActivePlayer.GetAllPokemonCards())
            {
                modifiers.AddRange(pokemon.GetAllActiveAbilities(this, ActivePlayer, NonActivePlayer).OfType <DamageTakenModifier>().Where(a => a.IsGlobal));
            }

            return(modifiers);
        }
Ejemplo n.º 3
0
        public List <PassiveAbility> GetAllPassiveAbilities()
        {
            var passiveAbilities = new List <PassiveAbility>();

            if (ActivePlayer != null)
            {
                passiveAbilities.AddRange(ActivePlayer.GetAllPokemonCards().Where(p => p.Ability != null).Select(pokemon => pokemon.Ability).OfType <PassiveAbility>());
            }
            if (NonActivePlayer != null)
            {
                passiveAbilities.AddRange(NonActivePlayer.GetAllPokemonCards().Where(p => p.Ability != null).Select(pokemon => pokemon.Ability).OfType <PassiveAbility>());
            }

            if (StadiumCard != null && StadiumCard.Ability is PassiveAbility)
            {
                passiveAbilities.Add((PassiveAbility)StadiumCard.Ability);
            }

            passiveAbilities.AddRange(TemporaryPassiveAbilities.OfType <PassiveAbility>());

            if (passiveAbilities.Any(ability => ability.ModifierType == PassiveModifierType.NoPokemonPowers))
            {
                return new List <PassiveAbility>()
                       {
                           passiveAbilities.First(ability => ability.ModifierType == PassiveModifierType.NoPokemonPowers)
                       }
            }
            ;

            var idOfStopper = passiveAbilities.FirstOrDefault(x => x.ModifierType == PassiveModifierType.StopAbilities);

            if (idOfStopper != null)
            {
                return(passiveAbilities.Where(x => x.Id.Equals(idOfStopper) || x.IsBuff).ToList());
            }

            return(passiveAbilities.Where(a => a.CanActivate(this, a.GetActivator(ActivePlayer), GetOpponentOf(a.GetActivator(ActivePlayer)))).ToList());
        }