public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource) { if (MayAbility && !game.AskYesNo(caster, "Discard attached energy?")) { return; } if (!CoinflipConditional.IsOk(game, caster)) { return; } if (Targeting.GetPossibleTargetsFromMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard, OnlyWithNameLike).All(x => x.AttachedEnergy.Count == 0)) { return; } int cardsDiscarded = 0; while (true) { PokemonCard target = Targeting.AskForTargetFromTargetingMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard, string.Empty, OnlyWithNameLike); if (target.AttachedEnergy.Count == 0) { continue; } if (Amount == -1 || target.AttachedEnergy.Count <= Amount) { while (target.AttachedEnergy.Count > 0) { target.DiscardEnergyCard(target.AttachedEnergy[0], game); cardsDiscarded++; } target.AttachedEnergy.Clear(); } else { var message = new PickFromListMessage(target.AttachedEnergy.OfType <Card>().ToList(), Amount); var ids = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message.ToNetworkMessage(game.Id)).Cards; var cards = target.AttachedEnergy.Where(x => ids.Contains(x.Id)).ToList(); foreach (var card in cards) { target.DiscardEnergyCard(card, game); cardsDiscarded++; } } break; } if (targetingMode == TargetingMode.Self || targetingMode == TargetingMode.YourActive || targetingMode == TargetingMode.YourBench || targetingMode == TargetingMode.YourPokemon) { game.LastDiscard = cardsDiscarded; } }
public bool CanCast(GameField game, Player caster, Player opponent) { foreach (var pokemon in Targeting.GetPossibleTargetsFromMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard)) { if (pokemon.AttachedEnergy.Count >= AmountToDiscard) { return(true); } } game.GameLog.AddMessage($"Cannot cast because no pokemon with atleast {AmountToDiscard} energy was found"); return(false); }
public bool CanCast(GameField game, Player caster, Player opponent) { return(Targeting.GetPossibleTargetsFromMode(TargetingMode, game, caster, opponent, caster.ActivePokemonCard, name).Count > 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); }