@Override public ObjectColor getColor(Game game) { return sourceObject.getColor(game); }
@Override public boolean canTarget(UUID id, Game game) { if (super.canTarget(id, game)) { Card card = game.getCard(id); if (card != null) { if (targets.size() == 1) { Card card2 = game.getCard(targets.entrySet().iterator().next().getKey()); if (card2 != null && card2.getColor(game).equals(card.getColor(game))) { return true; } } else { FilterCard colorFilter = new FilterCard(); colorFilter.add(new ColorPredicate(card.getColor(game))); Player player = game.getPlayer(card.getOwnerId()); if (player.getHand().getCards(colorFilter, game).size() > 1) { return true; } } } } return false; }
public CardAttribute(Card card, Game game) { color = card.getColor(null).copy(); subtype = new SubTypeList(); subtype.addAll(card.getSubtype(game)); }
if (chosenCard != null) { for (UUID cardToCheck : cardsToCheck) { if (!cardToCheck.equals(chosenCard.getId()) && chosenCard.getColor(game).equals(game.getCard(cardToCheck).getColor(game))) { newPossibleTargets.add(cardToCheck); for (UUID cardToCheck : cardsToCheck) { FilterCard colorFilter = new FilterCard(); colorFilter.add(new ColorPredicate(game.getCard(cardToCheck).getColor(game))); if (cardsToCheck.count(colorFilter, game) > 1) { newPossibleTargets.add(cardToCheck);
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Card card = player.getLibrary().getFromTop(game); if (card != null) { return card.getColor(game).isBlack(); } } return false; } }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netMana = new ArrayList<>(); Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { List<UUID> imprinted = permanent.getImprinted(); if (imprinted != null && !imprinted.isEmpty()) { Card imprintedCard = game.getCard(imprinted.get(0)); if (imprintedCard != null) { ObjectColor color = imprintedCard.getColor(game); if (color.isBlack()) { netMana.add(Mana.BlackMana(1)); } if (color.isRed()) { netMana.add(Mana.RedMana(1)); } if (color.isBlue()) { netMana.add(Mana.BlueMana(1)); } if (color.isGreen()) { netMana.add(Mana.GreenMana(1)); } if (color.isWhite()) { netMana.add(Mana.WhiteMana(1)); } } } } return netMana; }
private static Card takeAttributesFromSpell(Card card, ZoneChangeEvent event, Game game) { card = card.copy(); if (Zone.STACK == event.getFromZone()) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && !spell.isFaceDown(game)) { if (!card.getColor(game).equals(spell.getColor(game))) { // the card that is referenced to in the permanent is copied and the spell attributes are set to this copied card card.getColor(game).setColor(spell.getColor(game)); } } } return card; }
public Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone) { this.card = card; this.color = card.getColor(null).copy(); this.frameColor = card.getFrameColor(null).copy(); this.frameStyle = card.getFrameStyle(); id = ability.getId(); this.ability = ability; this.ability.setControllerId(controllerId); if (ability.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) { spellCards.add(((SplitCard) card).getLeftHalfCard()); spellAbilities.add(((SplitCard) card).getLeftHalfCard().getSpellAbility().copy()); spellCards.add(((SplitCard) card).getRightHalfCard()); spellAbilities.add(((SplitCard) card).getRightHalfCard().getSpellAbility().copy()); } else { spellCards.add(card); spellAbilities.add(ability); } this.controllerId = controllerId; this.fromZone = fromZone; this.countered = false; }
@Override public boolean apply(Game game, Ability source) { int damageToDeal = 2; outerloop: for (Cost cost : source.getCosts()) { if (cost instanceof DiscardCardCost) { for (Card card : ((DiscardCardCost) cost).getCards()) { if (card.getColor(game).isMulticolored()) { damageToDeal = 4; break outerloop; } } } } return new DamageTargetEffect(damageToDeal).apply(game, source); } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); // spell is not on the stack yet, so we have to check the card Card card = game.getCard(event.getSourceId()); if (chosenColor != null && card != null && card.getColor(game).contains(chosenColor)) { return true; } } return false; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getSourceId()); if (card != null) { LastSpellCastWatcher watcher = game.getState().getWatcher(LastSpellCastWatcher.class); if (watcher != null && watcher.lastSpellCast != null) { return !card.getColor(game).intersection(watcher.lastSpellCast.getColor(game)).isColorless(); } } return false; }
@Override public boolean apply(MageObject input, Game game) { // 708.3. Each split card that consists of two halves with different colored mana symbols in their mana costs // is a multicolored card while it's not a spell on the stack. While it's a spell on the stack, it's only the // color or colors of the half or halves being cast. # if (input instanceof SplitCardHalf && game.getState().getZone(input.getId()) != Zone.STACK) { return 1 < ((SplitCardHalf) input).getMainCard().getColor(game).getColorCount(); } else { return 1 < input.getColor(game).getColorCount(); } }
@Override public boolean apply(Game game, Ability source) { Card card = (Card) this.getValue("discardedCard"); if (card != null && card.getColor(game).isRed()) { Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null) { permanent.damage(4, source.getSourceId(), game, false, true); return true; } Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { player.damage(4, source.getSourceId(), game, false, true); return true; } } return false; } }
@Override public boolean canChoose(UUID sourceControllerId, Game game) { Cards cardsToCheck = new CardsImpl(); Player player = game.getPlayer(sourceControllerId); for (Card card : player.getHand().getCards(filter, game)) { cardsToCheck.add(card.getId()); } int possibleCards = 0; for (UUID cardToCheck : cardsToCheck) { FilterCard colorFilter = new FilterCard(); colorFilter.add(new ColorPredicate(game.getCard(cardToCheck).getColor(game))); if (cardsToCheck.count(colorFilter, game) > 1) { ++possibleCards; } } return possibleCards > 0; }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); if (you != null) { Card topCard = you.getLibrary().getFromTop(game); if (topCard != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game)) { if (permanent.getColor(game).shares(topCard.getColor(game)) && !permanent.getColor(game).isColorless()) { permanent.addPower(power.calculate(game, source, this)); permanent.addToughness(toughness.calculate(game, source, this)); } } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); ChoiceColor choice = new ChoiceColor(); if (controller != null && sourceObject != null && targetPlayer != null && controller.choose(outcome, choice, game)) { Cards hand = targetPlayer.getHand(); targetPlayer.revealCards(sourceObject.getIdName(), hand, game); Set<Card> cards = hand.getCards(game); for (Card card : cards) { if (card != null && card.getColor(game).shares(choice.getColor())) { targetPlayer.discard(card, source, game); } } return true; } return false; } }
if (card != null) { for (ObjectColor color : card.getColor(game).getColors()) { if (color.isWhite()) { types.setWhite(1);
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); ChoiceColor choice = new ChoiceColor(); if (controller == null || opponent == null || !controller.choose(outcome, choice, game)) { return false; } int cardsWithColor = 0; Cards cardsToExile = new CardsImpl(); cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX())); for (Card card : cardsToExile.getCards(game)) { if (card != null && card.getColor(game).contains(choice.getColor())) { cardsWithColor++; } } controller.moveCards(cardsToExile, Zone.EXILED, source, game); if (cardsWithColor > 0) { new CreateTokenEffect(new OonaQueenFaerieToken(), cardsWithColor).apply(game, source); } game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created"); return true; } }
@Override public void init(Ability source, Game game) { ObjectColor colorsAmongImprinted = new ObjectColor(); Permanent sourceObject = game.getPermanent(source.getSourceId()); ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId())); if (sourceObject == null || sourceObject.getImprinted() == null) { noneExiled = true; return; } for (UUID imprinted : sourceObject.getImprinted()){ if (imprinted != null && exileZone.contains(imprinted)){ Card card = game.getCard(imprinted); if (card != null) { colorsAmongImprinted = colorsAmongImprinted.union(card.getColor(game)); } } } FilterObject filterObject = new FilterObject("a source of your choice that shares a color with the exiled card"); filterObject.add(new SharesColorPredicate(colorsAmongImprinted)); this.target = new TargetSource(filterObject); this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game); if (target.getFirstTarget() != null) { mageObjectReference = new MageObjectReference(target.getFirstTarget(), game); } else { mageObjectReference = null; } }
permanent.getColor(game).setColor(card.getColor(game)); permanent.getManaCost().clear(); permanent.getManaCost().add(card.getManaCost());