@Override public ManaCosts<ManaCost> getManaCost() { if (faceDown) { // face down permanent has always {0} mana costs manaCost.clear(); return manaCost; } return super.getManaCost(); }
/** * Adjusts ability cost to be paid. * * @param ability * @param reduceCount */ private static void adjustAbilityCost(Ability ability, int reduceCount) { ManaCosts<ManaCost> adjustedCost = adjustCost(ability.getManaCostsToPay(), reduceCount); ability.getManaCostsToPay().clear(); ability.getManaCostsToPay().addAll(adjustedCost); }
public static void increaseCost(SpellAbility spellAbility, ManaCosts<ManaCost> manaCostsToIncrease) { ManaCosts<ManaCost> increasedCost = spellAbility.getManaCostsToPay().copy(); for (ManaCost manaCost : manaCostsToIncrease) { increasedCost.add(manaCost.copy()); } spellAbility.getManaCostsToPay().clear(); spellAbility.getManaCostsToPay().addAll(increasedCost); }
@Override public boolean askToActivateAlternativeCosts(Ability ability, Game game) { if (ability instanceof SpellAbility) { Player player = game.getPlayer(controllerId); if (player != null) { this.resetEvoke(); for (AlternativeCost2 evokeCost : evokeCosts) { if (evokeCost.canPay(ability, sourceId, controllerId, game) && player.chooseUse(Outcome.Benefit, new StringBuilder(EVOKE_KEYWORD).append(" the creature for ").append(evokeCost.getText(true)).append(" ?").toString(), ability, game)) { activateEvoke(evokeCost, game); ability.getManaCostsToPay().clear(); ability.getCosts().clear(); for (Iterator it = ((Costs) evokeCost).iterator(); it.hasNext();) { Cost cost = (Cost) it.next(); if (cost instanceof ManaCostsImpl) { ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy()); } else { ability.getCosts().add(cost.copy()); } } } } } } return isActivated(ability, game); }
@Override public void adjustCosts(Ability ability, Game game) { Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); if (sourcePermanent == null || sourcePermanent.getImprinted() == null || sourcePermanent.getImprinted().isEmpty()) { return; } Card imprintedInstant = game.getCard(sourcePermanent.getImprinted().get(0)); if (imprintedInstant == null) { return; } int cmc = imprintedInstant.getConvertedManaCost(); if (cmc > 0) { ability.getManaCostsToPay().clear(); ability.getManaCostsToPay().add(new GenericManaCost(cmc)); } } }
@Override public void adjustCosts(Ability ability, Game game) { if (ability instanceof SimpleActivatedAbility) { Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); if (sourcePermanent != null) { int pin = sourcePermanent.getCounters(game).getCount(CounterType.PIN); ability.getManaCostsToPay().clear(); ability.getManaCostsToPay().add(0, new GenericManaCost(pin * 2)); } } }
@Override public void adjustCosts(Ability ability, Game game) { if (ability instanceof SimpleActivatedAbility) { Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); if (sourcePermanent != null) { if (!sourcePermanent.getImprinted().isEmpty()) { Card imprinted = game.getCard(sourcePermanent.getImprinted().get(0)); if (imprinted != null) { ability.getManaCostsToPay().clear(); ability.getManaCostsToPay().add(0, new GenericManaCost(imprinted.getConvertedManaCost())); } } } // no {X} anymore as we already have imprinted the card with defined manacost for (ManaCost cost : ability.getManaCostsToPay()) { if (cost instanceof VariableCost) { cost.setPaid(); } } } }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { for (Permanent entering : game.getPermanentsEntering().values()) { if (entering.getId().equals(copyToObjectId) && entering instanceof PermanentToken) { UUID originalCardId = ((PermanentToken) entering).getToken().getCopySourceCard().getId(); EmbalmedThisTurnWatcher watcher = game.getState().getWatcher(EmbalmedThisTurnWatcher.class); if (watcher != null) { for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) { if (mor.getSourceId().equals(originalCardId) && game.getState().getZoneChangeCounter(originalCardId) == mor.getZoneChangeCounter()) { permanent.getManaCost().clear(); if (!permanent.hasSubtype(SubType.ZOMBIE, game)) { permanent.getSubtype(game).add(SubType.ZOMBIE); } permanent.getColor(game).setColor(ObjectColor.WHITE); } } } } } return true; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { Player controller = game.getPlayer(abilityToModify.getControllerId()); if (controller != null) { if ((abilityToModify instanceof ActivatedAbility && ((ActivatedAbility) abilityToModify).isCheckPlayableMode()) || controller.chooseUse(Outcome.PlayForFree, "Pay {0} to cycle?", source, game)) { abilityToModify.getCosts().clear(); abilityToModify.getManaCostsToPay().clear(); abilityToModify.getCosts().add(new CyclingDiscardCost()); } return true; } return false; }
@Override public boolean askToActivateAlternativeCosts(Ability ability, Game game) { if (ability instanceof SpellAbility) { Player player = game.getPlayer(controllerId); if (player != null) { this.resetDash(); for (AlternativeCost2 dashCost : alternativeSourceCosts) { if (dashCost.canPay(ability, sourceId, controllerId, game) && player.chooseUse(Outcome.Benefit, KEYWORD + " the creature for " + dashCost.getText(true) + " ?", ability, game)) { activateDash(dashCost, game); ability.getManaCostsToPay().clear(); ability.getCosts().clear(); for (Iterator it = ((Costs) dashCost).iterator(); it.hasNext();) { Cost cost = (Cost) it.next(); if (cost instanceof ManaCostsImpl) { ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy()); } else { ability.getCosts().add(cost.copy()); } } } } } } return isActivated(ability, game); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); // use target pointer here, so it's the same card that triggered the event (not gone back to library e.g.) Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (controller != null && card != null) { SpellAbility abilityToCast = card.getSpellAbility().copy(); ManaCosts<ManaCost> costRef = abilityToCast.getManaCostsToPay(); // replace with the new cost costRef.clear(); costRef.add(miracleCosts); controller.cast(abilityToCast, game, false, new MageObjectReference(source.getSourceObject(game), game)); return true; } return false; } }
private void copyFromToken(Token token, Game game, boolean reset) { this.name = token.getName(); this.abilities.clear(); if (reset) { this.abilities.addAll(token.getAbilities()); } else { // first time -> create ContinuousEffects only once for (Ability ability : token.getAbilities()) { this.addAbility(ability, game); } } this.abilities.setControllerId(this.controllerId); this.manaCost.clear(); for (ManaCost cost : token.getManaCost()) { this.getManaCost().add(cost.copy()); } this.cardType.clear(); this.cardType.addAll(token.getCardType()); this.color = token.getColor(game).copy(); this.frameColor = token.getFrameColor(game); this.frameStyle = token.getFrameStyle(); this.supertype.clear(); this.supertype.addAll(token.getSuperType()); this.subtype.clear(); this.subtype.addAll(token.getSubtype(game)); this.isAllCreatureTypes = token.isAllCreatureTypes(); this.tokenDescriptor = token.getTokenDescriptor(); }
@Override public boolean apply(Game game, Ability source) { Player owner = null; Card card = game.getCard(source.getSourceId()); if (card != null) { owner = game.getPlayer(card.getOwnerId()); } if (owner != null && card != null && owner.chooseUse(outcome, "Cast " + card.getLogName() + " by madness?", source, game)) { // replace with the new cost SpellAbility castByMadness = card.getSpellAbility().copy(); ManaCosts<ManaCost> costRef = castByMadness.getManaCostsToPay(); castByMadness.setSpellAbilityType(SpellAbilityType.BASE_ALTERNATE); castByMadness.setSpellAbilityCastMode(SpellAbilityCastMode.MADNESS); costRef.clear(); costRef.add(madnessCost); boolean result = owner.cast(castByMadness, game, false, new MageObjectReference(source.getSourceObject(game), game)); return result; } return false; }
public static void setPermanentToFaceDownCreature(MageObject mageObject) { mageObject.getPower().modifyBaseValue(2); mageObject.getToughness().modifyBaseValue(2); mageObject.getAbilities().clear(); mageObject.getColor(null).setColor(new ObjectColor()); mageObject.setName(""); mageObject.getCardType().clear(); mageObject.addCardType(CardType.CREATURE); mageObject.getSubtype(null).clear(); mageObject.getSuperType().clear(); mageObject.getManaCost().clear(); if (mageObject instanceof Permanent) { ((Permanent) mageObject).setExpansionSetCode(""); ((Permanent) mageObject).setRarity(Rarity.SPECIAL); } } }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); if (card == null) { return false; } Player controller = game.getPlayer(card.getOwnerId()); if (controller == null) { return false; } EmptyToken token = new EmptyToken(); CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer) token.getColor(game).setColor(ObjectColor.WHITE); if (!token.hasSubtype(SubType.ZOMBIE, game)) { token.getSubtype(game).add(0, SubType.ZOMBIE); } token.getManaCost().clear(); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EMBALMED_CREATURE, token.getId(), source.getSourceId(), controller.getId())); token.putOntoBattlefield(1, game, source.getSourceId(), controller.getId(), false, false, null); // Probably it makes sense to remove also the Embalm ability (it's not shown on the token cards). // Also it can never get active or? But it's not mentioned in the reminder text. return true; } }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); if (card == null) { return false; } Player controller = game.getPlayer(card.getOwnerId()); if (controller == null) { return false; } EmptyToken token = new EmptyToken(); CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer) token.getColor(game).setColor(ObjectColor.BLACK); if (!token.hasSubtype(SubType.ZOMBIE, game)) { token.getSubtype(game).add(0, SubType.ZOMBIE); } token.getManaCost().clear(); token.removePTCDA(); token.getPower().modifyBaseValue(4); token.getToughness().modifyBaseValue(4); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ETERNALIZED_CREATURE, token.getId(), source.getSourceId(), controller.getId())); token.putOntoBattlefield(1, game, source.getSourceId(), controller.getId(), false, false, null); // Probably it makes sense to remove also the Eternalize ability (it's not shown on the token cards). // Also it can never get active or? But it's not mentioned in the reminder text. return true; } }
if (permanent != null && layer == Layer.CopyEffects_1) { permanent.setName(copied.getName()); permanent.getManaCost().clear(); permanent.getManaCost().addAll(copied.getManaCost()); permanent.setExpansionSetCode(copied.getExpansionSetCode());
permanent.getManaCost().clear(); permanent.getManaCost().add(sourceCard.getManaCost()); permanent.getCardType().clear();
permanent.getToughness().setValue(card.getToughness().getValue()); permanent.getColor(game).setColor(card.getColor(game)); permanent.getManaCost().clear(); permanent.getManaCost().add(card.getManaCost()); permanent.getCardType().clear();