コード例 #1
0
 public void SetBase(PokemonCard target)
 {
     DamageCounters = target.DamageCounters;
 }
コード例 #2
0
 public bool CanEvolveTo(PokemonCard evolution)
 {
     return(!string.IsNullOrWhiteSpace(evolution.EvolvesFrom) && evolution.EvolvesFrom == PokemonName);
 }
コード例 #3
0
        public int DealDamage(Damage damage, GameField game, PokemonCard source, bool preventable)
        {
            var totalDamage            = damage.DamageWithoutResistAndWeakness + damage.NormalDamage;
            var damageStoppersToRemove = new List <DamageStopper>();

            foreach (var damageStopper in DamageStoppers)
            {
                if (preventable && damageStopper.IsDamageIgnored(totalDamage))
                {
                    totalDamage -= damageStopper.Amount;

                    if (totalDamage <= 0)
                    {
                        game.GameLog.AddMessage(GetName() + " Takes no damage");
                        game?.SendEventToPlayers(new DamageTakenEvent()
                        {
                            Damage = 0, PokemonId = Id, DamageType = source != null ? source.Type : EnergyTypes.Colorless
                        });
                        return(0);
                    }
                    else
                    {
                        game.GameLog.AddMessage(GetName() + $" Takes {damageStopper.Amount} less damage");
                    }

                    if (damageStopper.LastsUntilDamageTaken)
                    {
                        damageStoppersToRemove.Add(damageStopper);
                    }
                }
            }

            foreach (var damagestopper in damageStoppersToRemove)
            {
                DamageStoppers.Remove(damagestopper);
            }

            if (source != null && preventable)
            {
                foreach (var ability in source.GetAllActiveAbilities(game, Owner, game.GetOpponentOf(Owner)).OfType <IDamageDealtModifier>())
                {
                    totalDamage = ability.GetModifiedDamage(totalDamage, game);
                }
            }
            if (preventable)
            {
                foreach (var ability in GetAllActiveAbilities(game, Owner, game?.Players.First(x => !x.Id.Equals(Owner.Id))).OfType <IDamageTakenModifier>())
                {
                    totalDamage = ability.GetModifiedDamage(totalDamage, source, game);
                }

                if (game != null)
                {
                    foreach (var ability in game.GetGlobalDamageTakenModifiers())
                    {
                        if (Ability == ablity)
                        {
                            //Self ability will already be triggered
                            continue;
                        }

                        totalDamage = ability.GetModifiedDamage(totalDamage, source, game);
                    }
                }
            }

            foreach (var pokemon in Owner.GetAllPokemonCards())
            {
                if (pokemon == this || !preventable)
                {
                    continue;
                }

                foreach (var ability in pokemon.GetAllActiveAbilities(game, Owner, game?.GetOpponentOf(Owner)).OfType <DamageRedirectorAbility>())
                {
                    if (totalDamage == 0)
                    {
                        continue;
                    }
                    if (ability.AskYesNo && !game.AskYesNo(Owner, $"Redirect damage to {ability.PokemonOwner.Name}"))
                    {
                        continue;
                    }

                    int damageToRedirect;

                    if (totalDamage >= ability.AmountToRedirect)
                    {
                        damageToRedirect = ability.AmountToRedirect;
                    }
                    else
                    {
                        damageToRedirect = totalDamage;
                    }

                    totalDamage -= damageToRedirect;
                    ability.PokemonOwner.DealDamage(damageToRedirect, game, ability.PokemonOwner, false);
                }
            }

            DamageCounters     += totalDamage;
            DamageTakenLastTurn = totalDamage;

            game?.SendEventToPlayers(new DamageTakenEvent()
            {
                Damage = totalDamage, PokemonId = Id, DamageType = source != null ? source.Type : EnergyTypes.Colorless
            });
            game?.GameLog.AddMessage(GetName() + $"Takes {totalDamage} damage");

            return(totalDamage);
        }