Ejemplo n.º 1
0
        public void EvolvePokemon(PokemonCard basePokemon, PokemonCard evolution, bool ignoreAllChecks = false)
        {
            if (!ignoreAllChecks && !ActivePlayer.Id.Equals(basePokemon.Owner.Id) || !ActivePlayer.Id.Equals(evolution.Owner.Id))
            {
                GameLog.AddMessage("Evolution stopped by epic 1337 anti-cheat");
                return;
            }

            if (!ignoreAllChecks && GetAllPassiveAbilities().Any(ability => ability.ModifierType == PassiveModifierType.StopEvolutions))
            {
                GameLog.AddMessage("Evolution stopped by ability");
                return;
            }

            if (!ignoreAllChecks && (!basePokemon.CanEvolve() || !basePokemon.CanEvolveTo(evolution)))
            {
                return;
            }

            GameLog.AddMessage($"Evolving {basePokemon.GetName()} to {evolution.GetName()}");

            if (ActivePlayer.ActivePokemonCard.Id.Equals(basePokemon.Id))
            {
                basePokemon.Evolve(evolution);
                ActivePlayer.ActivePokemonCard = evolution;
                evolution.EvolvedThisTurn      = true;
            }
            else
            {
                basePokemon.Evolve(evolution);
                evolution.EvolvedThisTurn = true;
                ActivePlayer.BenchedPokemon.ReplaceWith(basePokemon, evolution);
            }

            bool triggerEnterPlay = false;

            if (ActivePlayer.Hand.Contains(evolution))
            {
                ActivePlayer.Hand.Remove(evolution);
                triggerEnterPlay = true;
            }

            evolution.RevealToAll();

            SendEventToPlayers(new PokemonEvolvedEvent
            {
                TargetPokemonId = basePokemon.Id,
                NewPokemonCard  = evolution
            });

            if (triggerEnterPlay)
            {
                TriggerAbilityOfType(TriggerType.EnterPlay, evolution);
            }

            PushGameLogUpdatesToPlayers();
        }
Ejemplo n.º 2
0
        public void OnActivePokemonSelected(NetworkId ownerId, PokemonCard activePokemon)
        {
            Player owner = Players.First(p => p.Id.Equals(ownerId));

            if (GameState != GameFieldState.BothSelectingActive)
            {
                if (!ActivePlayer.Id.Equals(ownerId))
                {
                    GameLog.AddMessage($"{owner?.NetworkPlayer?.Name} tried to play a pokemon when not allowed");
                    return;
                }
            }

            if (activePokemon.Stage == 0)
            {
                GameLog.AddMessage($"{owner.NetworkPlayer?.Name} is setting {activePokemon.GetName()} as active");
                owner.SetActivePokemon(activePokemon);
                if (GameState != GameFieldState.BothSelectingActive)
                {
                    SendEventToPlayers(new PokemonBecameActiveEvent
                    {
                        NewActivePokemon = activePokemon
                    });
                }
            }
            else
            {
                return;
            }

            lock (lockObject)
            {
                if (GameState == GameFieldState.BothSelectingActive)
                {
                    if (!owner.Hand.OfType <PokemonCard>().Any(card => card.Stage == 0))
                    {
                        playersSetStartBench.Add(owner.Id);
                    }
                    if (Players.All(p => p.ActivePokemonCard != null))
                    {
                        if (playersSetStartBench.Count == 2)
                        {
                            foreach (var player in Players)
                            {
                                player.SetPrizeCards(PrizeCardCount);
                            }
                            GameState = GameFieldState.InTurn;
                            SendEventToPlayers(new GameSyncEvent {
                                Game = this
                            });
                        }
                        else
                        {
                            GameState = GameFieldState.BothSelectingBench;
                            SendEventToPlayers(new GameSyncEvent {
                                Game = this, Info = "Select Pokémons to add to your starting bench"
                            });
                            return;
                        }
                    }
                    else
                    {
                        PushInfoToPlayer("Opponent is selecting active...", owner);
                    }

                    SendEventMessage(new GameSyncEvent {
                        Game = this
                    }, Players.First(x => x.Id.Equals(ownerId)));
                }
            }

            PushGameLogUpdatesToPlayers();
        }