public List <Ability> GetAllActiveAbilities(GameField game, Player caster, Player opponent) { var abilities = new List <Ability>(); var areAbilitiesBlocked = game == null ? false : game.IsAbilitiesBlocked(); if (Ability != null && game != null && !areAbilitiesBlocked && Ability.CanActivate(game, caster, opponent)) { abilities.Add(Ability); } if (game != null) { abilities.AddRange(game.TemporaryPassiveAbilities); } abilities.AddRange(TemporaryAbilities.Where(x => x.CanActivate(game, caster, opponent)).ToList()); return(abilities); }
public void DiscardEnergyCard(EnergyCard energyCard, GameField game, bool isExtraCost = false) { if (!isExtraCost) { var preventer = TemporaryAbilities.OfType <EffectPreventer>().FirstOrDefault(); if (preventer != null) { game.GameLog.AddMessage($"Discard energy card prevented by {preventer.Name}"); return; } } AttachedEnergy.Remove(energyCard); Owner.DiscardPile.Add(energyCard); game?.SendEventToPlayers(new AttachedEnergyDiscardedEvent { FromPokemonId = Id, DiscardedCard = energyCard }); energyCard.OnPutInDiscard(Owner); }
public bool CanAttack() { return(!IsParalyzed && !IsAsleep && !TemporaryAbilities.OfType <PassiveAbility>().Any(x => x.ModifierType == PassiveModifierType.StopAttack)); }
public virtual void EndTurn(GameField game) { if (TemporaryAbilities == null) { TemporaryAbilities = new List <Ability>(); } foreach (var ability in TemporaryAbilities) { ability.EndTurn(); if (ability.TurnDuration <= 0) { ability.OnDestroyed(game); } } TemporaryAbilities = TemporaryAbilities.Where(x => x.TurnDuration > 0).ToList(); foreach (var attack in Attacks) { attack.DamageModifier?.ReduceTurnCount(); if (attack.DamageModifier != null && attack.DamageModifier.TurnsLeft <= 0) { attack.DamageModifier = null; } foreach (var effect in attack.Effects.OfType <DamageEffect>()) { effect.DamageModifier?.ReduceTurnCount(); } } PlayedThisTurn = false; EvolvedThisTurn = false; if (!ParalyzedThisTurn) { IsParalyzed = false; } if (IsBurned) { DealDamage(20, game, new PokemonCard() { Type = EnergyTypes.Fire }, false); IsBurned = game.FlipCoins(1) == 0; } if (IsPoisoned) { DealDamage(DoublePoison ? 20 : 10, game, new PokemonCard() { Type = EnergyTypes.Psychic }, false); } if (IsAsleep) { IsAsleep = game.FlipCoins(1) == 0; } if (Ability != null) { Ability.UsedTimes = 0; Ability.EndTurn(); } ParalyzedThisTurn = false; AttachedTools = AttachedTools.Where(tool => !Owner.DiscardPile.Contains(tool)).ToList(); foreach (var damagestopper in DamageStoppers) { if (!damagestopper.LastsUntilDamageTaken) { damagestopper.TurnsLeft--; } } DamageStoppers = DamageStoppers.Where(x => x.TurnsLeft > 0).ToList(); }