コード例 #1
0
        public void ProcessEffectsTest_Heads()
        {
            var pokemon = new PokemonCard()
            {
                Hp = 100
            };
            var attack = new ApplyAttackFailOnTails();

            pokemon.Attacks.Add(attack);

            var player = new Player()
            {
                ActivePokemonCard = pokemon
            };
            var opponent = new Player
            {
                ActivePokemonCard = new PokemonCard()
                {
                    Hp = 100
                }
            };

            var game = new GameField();

            game.AddPlayer(player);
            game.AddPlayer(opponent);
            game.ActivePlayerIndex = 0;

            attack.ProcessEffects(game, player, opponent);

            Assert.Single(opponent.ActivePokemonCard.TemporaryAbilities);
        }
コード例 #2
0
        public static bool TryAddEffects(ref Attack baseAttack, PokemonTcgSdk.Models.Attack sdkAttack)
        {
            if (sdkAttack.Text.ToLower().StartsWith(firstPartApplyEffect.ToLower()))
            {
                StatusEffect?effect = stringToStatusEffect(baseAttack.Description.Substring(firstPartApplyEffect.Length));
                if (effect == null)
                {
                    return(false);
                }
                else
                {
                    baseAttack.Effects.Add(new ApplyStatusEffect()
                    {
                        CoinflipConditional = new CoinFlipConditional
                        {
                            FlipCoin = true
                        },
                        TargetingMode = TargetingMode.OpponentActive,
                        StatusEffect  = effect.Value
                    });
                    return(true);
                }
            }
            else if (sdkAttack.Text.ToLower().StartsWith(firstPartForceEffect.ToLower()))
            {
                StatusEffect?effect = stringToStatusEffect(baseAttack.Description.Substring(firstPartForceEffect.Length));
                if (effect == null)
                {
                    return(false);
                }
                else
                {
                    baseAttack.Effects.Add(new ApplyStatusEffect()
                    {
                        TargetingMode = TargetingMode.OpponentActive,
                        StatusEffect  = effect.Value
                    });
                    return(true);
                }
            }
            else if (Regex.IsMatch(sdkAttack.Text, @".*does \d+ damage to itself[.]"))
            {
                int damage = int.Parse(Regex.Matches(sdkAttack.Text, @"\d+")[0].Value);
                baseAttack.Effects.Add(new DamageEffect
                {
                    Amount        = damage,
                    TargetingMode = TargetingMode.YourActive
                });
                return(true);
            }
            else if (sdkAttack.Text.Trim() == "Flip a coin. If tails, this attack does nothing.")
            {
                var cost   = baseAttack.Cost.ToList();
                var damage = baseAttack.Damage;

                baseAttack = new AttackFailsOnTails
                {
                    Name        = sdkAttack.Name,
                    Description = sdkAttack.Text,
                    Cost        = new ObservableCollection <Energy>(cost),
                    Damage      = damage
                };
                return(true);
            }
            else if (Regex.IsMatch(sdkAttack.Text, @"Flip \d+ coins[.] This attack does \d+ damage times the number of heads[.]"))
            {
                var cost   = baseAttack.Cost.ToList();
                int coins  = int.Parse(Regex.Matches(sdkAttack.Text, @"\d+")[0].Value);
                int damage = int.Parse(Regex.Matches(sdkAttack.Text, @"\d+")[1].Value);

                baseAttack = new FlipCoinAttack
                {
                    Name        = sdkAttack.Name,
                    Description = sdkAttack.Text,
                    Coins       = coins,
                    Damage      = damage,
                    Cost        = new ObservableCollection <Energy>(cost)
                };
                return(true);
            }
            else if (Regex.IsMatch(sdkAttack.Text, @"Flip a coin[.] If heads[,] this attack does \d+ damage plus \d+ more damage; if tails, this attack does \d+ damage[.]"))
            {
                var cost          = baseAttack.Cost.ToList();
                int damage        = baseAttack.Damage;
                int extraForHeads = int.Parse(Regex.Matches(sdkAttack.Text, @"\d+")[0].Value) + int.Parse(Regex.Matches(sdkAttack.Text, @"\d+")[1].Value);
                int extraForTails = int.Parse(Regex.Matches(sdkAttack.Text, @"\d+")[2].Value);

                baseAttack = new FlipCoinPlusAttack
                {
                    Name          = sdkAttack.Name,
                    Description   = sdkAttack.Text,
                    Damage        = damage,
                    ExtraforHeads = extraForHeads,
                    ExtraforTails = extraForTails,
                    Cost          = new ObservableCollection <Energy>(cost)
                };
                return(true);
            }
            else if (sdkAttack.Text == "If the Defending Pokémon tries to attack during your opponent's next turn, your opponent flips a coin. If tails, that attack does nothing.")
            {
                var cost   = baseAttack.Cost.ToList();
                var damage = baseAttack.Damage;

                baseAttack = new ApplyAttackFailOnTails
                {
                    Name        = sdkAttack.Name,
                    Description = sdkAttack.Text,
                    Cost        = new ObservableCollection <Energy>(cost),
                    Damage      = damage
                };

                return(true);
            }
            else if (sdkAttack.Text.Trim() == "The Defending Pokémon can't retreat during your opponent's next turn.")
            {
                baseAttack.Effects.Add(new ApplyRetreatStopper()
                {
                    TargetingMode = TargetingMode.OpponentActive,
                    Turns         = 2
                });
                return(true);
            }

            return(false);
        }