Ejemplo n.º 1
0
        public void GetDamageAfterWeaknessAndResistance_Resistance_Modifier()
        {
            var attacker = new PokemonCard()
            {
                Type = EnergyTypes.Grass, Name = "Brock's Golem"
            };
            var defender = new PokemonCard()
            {
                Type = EnergyTypes.Grass, Resistance = EnergyTypes.Grass
            };
            var attack = new Attack()
            {
                ApplyResistance = false, ApplyWeakness = true
            };

            var modifier = new ResistanceModifierAbility()
            {
                Modifier     = 0,
                AttackerName = "Brock"
            };

            var result = DamageCalculator.GetDamageAfterWeaknessAndResistance(30, attacker, defender, attack, modifier);

            Assert.Equal(30, result);
        }
Ejemplo n.º 2
0
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            if (!CoinflipConditional.IsOk(game, caster))
            {
                return;
            }

            var target = Targeting.AskForTargetFromTargetingMode(TargetingMode, game, caster, opponent, pokemonSource);
            var heads  = game.FlipCoins(Coins);

            var damage = heads * Amount;

            if (applyWeaknessResistance)
            {
                damage = DamageCalculator.GetDamageAfterWeaknessAndResistance(damage, pokemonSource, target, null, null);
            }

            target.DealDamage(damage, game, pokemonSource, true);
        }
Ejemplo n.º 3
0
        public void GetDamageAfterWeaknessAndResistance_Wrong_Resistance()
        {
            var attacker = new PokemonCard()
            {
                Type = EnergyTypes.Grass
            };
            var defender = new PokemonCard()
            {
                Type = EnergyTypes.Grass, Resistance = EnergyTypes.Fire
            };
            var attack = new Attack()
            {
                ApplyResistance = true, ApplyWeakness = true
            };

            var result = DamageCalculator.GetDamageAfterWeaknessAndResistance(30, attacker, defender, attack, null);

            Assert.Equal(30, result);
        }
Ejemplo n.º 4
0
        protected override void Activate(Player owner, Player opponent, int damageTaken, GameField game)
        {
            if (CoinFlip && game.FlipCoins(1) == 0)
            {
                return;
            }

            if (requiredEffect != StatusEffect.None && !PokemonOwner.HaveStatus(RequiredEffect))
            {
                return;
            }

            if (attackBack)
            {
                var baseDamage = DamageReturned > 0 ? DamageReturned : damageTaken;
                var damage     = DamageCalculator.GetDamageAfterWeaknessAndResistance((int)(baseDamage * attackBackModifier), PokemonOwner, opponent.ActivePokemonCard, null, game.FindResistanceModifier());
                opponent.ActivePokemonCard.DealDamage(damage, game, PokemonOwner, true);
            }
            {
                opponent.ActivePokemonCard.DealDamage(DamageReturned, game, PokemonOwner, false);
            }
        }
Ejemplo n.º 5
0
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            if (Targeting.GetPossibleTargetsFromMode(TargetingMode, game, caster, opponent, pokemonSource).Count == 0)
            {
                return;
            }

            string yesNoInfo = EnergyToDiscard > 0 ? "Discard energy card?" : "Deal damage to a benched pokemon?";

            if (askYesNo && !game.AskYesNo(caster, yesNoInfo))
            {
                return;
            }

            if (energyToDiscard > 0)
            {
                var choices = pokemonSource.AttachedEnergy
                              .Where(e => EnergyType == EnergyTypes.All || EnergyType == EnergyTypes.None || e.EnergyType == EnergyType)
                              .OfType <Card>()
                              .ToList();

                var response = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(new PickFromListMessage(choices, energyToDiscard).ToNetworkMessage(game.Id));

                foreach (var id in response.Cards)
                {
                    var card = game.Cards[id];
                    pokemonSource.DiscardEnergyCard((EnergyCard)card, game);
                }
            }

            if (!CoinflipConditional.IsOk(game, caster))
            {
                return;
            }

            var target = Targeting.AskForTargetFromTargetingMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard);

            if (target == null)
            {
                return;
            }

            int damage;

            if (DamageModifier != null)
            {
                damage = DamageModifier.NewDamage;
            }
            else
            {
                damage = Amount;
            }

            if (ApplyWeaknessResistance)
            {
                damage = DamageCalculator.GetDamageAfterWeaknessAndResistance(damage, pokemonSource, target, null, game.FindResistanceModifier());
            }
            else
            {
                damage = Amount;
            }

            target.DealDamage(damage, game, pokemonSource, true);
        }
Ejemplo n.º 6
0
        public void GetDamageAfterWeaknessAndResistance_No_Attack()
        {
            var result = DamageCalculator.GetDamageAfterWeaknessAndResistance(30, null, null, null, null);

            Assert.Equal(30, result);
        }