public Collection<Card> getUniqueCards(Game game) { Map<String, Card> cards = new HashMap<>(); for (UUID cardId : library) { Card card = game.getCard(cardId); if (card != null) { cards.putIfAbsent(card.getName(), card); } } return cards.values(); }
public OverloadAbility(Card card, Effect effect, ManaCosts costs, TimingRule timingRule) { super(costs, card.getName() + " with overload"); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.addEffect(effect); this.timing = timingRule; }
/** * Verifies if the non-basic land card supplied is valid for this pool of cards. * @param card the non-basic land card * @return if the land card generates the allowed colors for this pool. */ public boolean isValidLandCard(Card card) { int cardCount = getCardCount((card.getName())); // No need to check if the land is valid for the colors chosen // They are all filtered before searching for lands to include in the deck. return (cardCount < 4); }
@Override public boolean askUseOpeningHandAction(Card card, Player player, Game game) { return player.chooseUse(Outcome.PutCardInPlay, "Do you wish to put " + card.getName() + " on the battlefield?", this, game); }
public EmblemView(Emblem emblem, Card sourceCard) { id = emblem.getId(); name = "Emblem " + sourceCard.getName(); if (emblem.getExpansionSetCodeForImage() == null) { expansionSetCode = sourceCard.getExpansionSetCode(); } else { expansionSetCode = emblem.getExpansionSetCodeForImage(); } rules = emblem.getAbilities().getRules(sourceCard.getName()); }
public PlaneView(Plane plane, Card sourceCard) { id = plane.getId(); name = "Plane " + sourceCard.getName(); if (plane.getExpansionSetCodeForImage() == null) { expansionSetCode = sourceCard.getExpansionSetCode(); } else { expansionSetCode = plane.getExpansionSetCodeForImage(); } rules = plane.getAbilities().getRules(sourceCard.getName()); }
public DeckCardLists getDeckCardLists() { DeckCardLists deckCardLists = new DeckCardLists(); deckCardLists.setName(name); for (Card card : cards) { deckCardLists.getCards().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode())); } for (Card card : sideboard) { deckCardLists.getSideboard().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode())); } return deckCardLists; }
public PayMoreToCastAsThoughtItHadFlashAbility(Card card, ManaCosts<ManaCost> costsToAdd) { super(card.getSpellAbility().getManaCosts().copy(), card.getName() + " as though it had flash", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.costsToAdd = costsToAdd; this.timing = TimingRule.INSTANT; this.ruleAtTheTop = true; CardUtil.increaseCost(this, costsToAdd); }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if ((abilityToModify instanceof SpellAbility) && abilityToModify.isControlledBy(source.getControllerId())) { Card card = game.getCard(abilityToModify.getSourceId()); if (card != null) { String needName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); return CardUtil.haveSameNames(card.getName(), needName); } } return false; }
public CastCommanderAbility(Card card) { super(card.getManaCost(), card.getName(), Zone.COMMAND, SpellAbilityType.BASE); this.costs = card.getSpellAbility().getCosts().copy(); this.timing = TimingRule.SORCERY; this.usesStack = true; this.controllerId = card.getOwnerId(); this.sourceId = card.getId(); }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int value = 0; Permanent permanent = game.getPermanent(sourceAbility.getSourceId()); if (permanent != null && !permanent.getImprinted().isEmpty()) { FilterPermanent filterPermanent = new FilterPermanent(); filterPermanent.add(new NamePredicate(game.getCard(permanent.getImprinted().get(0)).getName())); value = game.getBattlefield().count(filterPermanent, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); } return value; }
public CardsView(Collection<? extends Ability> abilities, GameState state) { for (Ability ability : abilities) { Card sourceCard = state.getPermanent(ability.getSourceId()); if (sourceCard != null) { this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard))); } } }
@Override public boolean apply(Game game, Ability source) { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { if (permanent.isTransformable()) { permanent.transform(game); game.informPlayers(permanent.getName() + " transforms into " + permanent.getSecondCardFace().getName()); } } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null && controller.chooseUse(outcome, "Play " + card.getName() + " from your graveyard for free?", source, game)) { controller.playCard(card, game, true, true, new MageObjectReference(source.getSourceObject(game), game)); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Player player = game.getPlayer(source.getControllerId()); if (player != null && player.chooseUse(Outcome.Benefit, "Cast " + card.getName() + " without paying cost?", source, game)) { player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return false; } }
public EmergeAbility(Card card, ManaCosts<ManaCost> emergeCost) { super(emergeCost, card.getName() + " with emerge", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.timing = card.getSpellAbility().getTiming(); this.setRuleAtTheTop(true); this.emergeCost = emergeCost.copy(); }
public SpectacleAbility(Card card, ManaCost spectacleCosts) { super(spectacleCosts, card.getName() + " with spectacle", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); this.setRuleAtTheTop(true); this.rule = "Spectacle " + spectacleCosts.getText() + " <i>(You may cast this spell for its spectacle cost rather than its mana cost if an opponent lost life this turn.)</i>"; }
public SurgeAbility(Card card, String surgeCosts) { super(new ManaCostsImpl<>(surgeCosts), card.getName() + " with surge", Zone.HAND, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); this.setRuleAtTheTop(true); this.rule = "Surge " + surgeCosts + " <i>(You may cast this spell for its surge cost if you or a teammate has cast another spell this turn.)</i>"; }
public JumpStartAbility(Card card) { super(card.getManaCost(), card.getName() + " with jump-start", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); Cost cost = new DiscardTargetCost(new TargetCardInHand()); cost.setText(""); this.addCost(cost); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); }
public RetraceAbility(Card card) { super(card.getManaCost(), card.getName() + " with retrace", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE); this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); Cost cost = new DiscardTargetCost(new TargetCardInHand(new FilterLandCard())); cost.setText(""); this.addCost(cost); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.timing = card.getSpellAbility().getTiming(); }