Esempio n. 1
0
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            if (!CoinFlipConditional.IsOk(game, caster))
            {
                return;
            }

            if (opponent.BenchedPokemon.Count <= AmountOfTargets)
            {
                foreach (var pokemon in opponent.BenchedPokemon.ValidPokemonCards)
                {
                    pokemon.DealDamage(Damage, game, pokemonSource, true);
                }

                return;
            }

            var message  = new SelectFromOpponentBenchMessage(AmountOfTargets).ToNetworkMessage(game.Id);
            var response = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message);

            foreach (var pokemon in response.Cards.Select(id => game.Cards[id]).OfType <PokemonCard>())
            {
                pokemon.DealDamage(Damage, game, pokemonSource, true);
            }
        }
Esempio n. 2
0
        public static PokemonCard AskForTargetFromTargetingMode(TargetingMode targetingMode, GameField game, Player caster, Player opponent, PokemonCard pokemonOwner, string info = "", string nameFilter = "")
        {
            PokemonCard    target;
            NetworkMessage message;
            NetworkId      selectedId;
            IDeckFilter    filter = !string.IsNullOrEmpty(nameFilter) ? new PokemonWithNameOrTypeFilter(nameFilter, EnergyTypes.All) : null;

            switch (targetingMode)
            {
            case TargetingMode.Self:
                target = pokemonOwner;
                break;

            case TargetingMode.YourActive:
                target = caster.ActivePokemonCard;
                break;

            case TargetingMode.YourBench:
                if (caster.BenchedPokemon.Count == 0)
                {
                    return(null);
                }
                else if (caster.BenchedPokemon.Count == 1)
                {
                    return(caster.BenchedPokemon.GetFirst());
                }
                message = new SelectFromYourBenchMessage(1)
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.YourPokemon:
                message = new SelectFromYourPokemonMessage()
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.OpponentActive:
                target = opponent.ActivePokemonCard;
                break;

            case TargetingMode.OpponentBench:
                if (opponent.BenchedPokemon.Count == 0)
                {
                    return(null);
                }
                else if (opponent.BenchedPokemon.Count == 1)
                {
                    return(opponent.BenchedPokemon.GetFirst());
                }

                message = new SelectFromOpponentBenchMessage(1)
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.OpponentPokemon:
                message = new SelectOpponentPokemonMessage(1)
                {
                    Info = info, Filter = filter
                }.ToNetworkMessage(game.Id);
                selectedId = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();
                target     = (PokemonCard)game.Cards[selectedId];
                break;

            case TargetingMode.LastEffectTarget:
                target = game.LastTarget;
                break;

            case TargetingMode.AnyPokemon:
                throw new NotImplementedException("TargetingMode.AnyPokemon not implemented in Targeting");

            default:
                target = caster.ActivePokemonCard;
                break;
            }

            if (game != null)
            {
                game.LastTarget = target;
            }

            return(target);
        }
Esempio n. 3
0
        public void SelectFromOpponentBenchMessage()
        {
            var message = new SelectFromOpponentBenchMessage(1);

            Assert.NotNull(SerializeAndBack(message));
        }
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            if (!RequireTargetUsabled)
            {
                if (opponents && opponent.BenchedPokemon.Count == 0)
                {
                    return;
                }

                if (!opponents && caster.BenchedPokemon.Count == 0)
                {
                    return;
                }
            }

            if (OnlyOnCoinFlip && game.FlipCoins(1) == 0)
            {
                return;
            }

            if (IsChoice && !game.AskYesNo(caster, "Swap active Pokémon"))
            {
                return;
            }

            Player         selectedPlayer = opponentChooses ? opponent : caster;
            NetworkMessage message;

            if (selectedPlayer == caster)
            {
                if (opponents)
                {
                    message = new SelectFromOpponentBenchMessage(1).ToNetworkMessage(game.Id);
                    opponent.NetworkPlayer.Send(new InfoMessage("Opponent is selecting a new active pokemon for you").ToNetworkMessage(game.Id));
                }
                else
                {
                    message = new SelectFromYourBenchMessage(1).ToNetworkMessage(game.Id);
                    opponent.NetworkPlayer.Send(new InfoMessage("Opponent is selecting a new active pokemon").ToNetworkMessage(game.Id));
                }
            }
            else
            {
                if (opponents)
                {
                    message = new SelectFromYourBenchMessage(1).ToNetworkMessage(game.Id);
                    caster.NetworkPlayer.Send(new InfoMessage("Opponent is selecting a new active pokemon").ToNetworkMessage(game.Id));
                }
                else
                {
                    message = new SelectFromOpponentBenchMessage(1).ToNetworkMessage(game.Id);
                    caster.NetworkPlayer.Send(new InfoMessage("Opponent is selecting a new active pokemon for you").ToNetworkMessage(game.Id));
                }
            }

            NetworkId selectedId = selectedPlayer.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message).Cards.First();

            var targetPlayer = opponents ? opponent : caster;

            targetPlayer.ForceRetreatActivePokemon((PokemonCard)game.Cards[selectedId], game);
        }