public CircleOfProtectionArtifacts(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}"); // {2}: The next time an artifact source of your choice would deal damage to you this turn, prevent that damage. Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("2"))); }
if (((AlternativeSourceCosts) alternateSourceCostsAbility).isAvailable(ability, game)) { if (alternateSourceCostsAbility.getCosts().canPay(ability, playerId, playerId, game)) { ManaCostsImpl manaCosts = new ManaCostsImpl(); for (Cost cost : alternateSourceCostsAbility.getCosts()) { if (cost instanceof ManaCost) { manaCosts.add((ManaCost) cost); if (manaCosts.isEmpty()) { return true; } else { for (Mana mana : manaCosts.getOptions()) { for (Mana avail : available) { if (mana.enough(avail)) { if (alternateSourceCosts.isAvailable(ability, game)) { if (((Ability) alternateSourceCosts).getCosts().canPay(ability, playerId, playerId, game)) { ManaCostsImpl manaCosts = new ManaCostsImpl(); for (Cost cost : ((Ability) alternateSourceCosts).getCosts()) { if (cost instanceof ManaCost) { manaCosts.add((ManaCost) cost); if (manaCosts.isEmpty()) { return true; } else { for (Mana mana : manaCosts.getOptions()) { for (Mana avail : available) { if (mana.enough(avail)) {
@Override public boolean apply(Game game, Ability source) { ManaCostsImpl cost = new ManaCostsImpl("{X}"); cost.clearPaid(); if (cost.payOrRollback(source, game, source.getSourceId(), source.getControllerId())) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.gainLife(cost.getX(), game, source); return true; } } return false; }
@Override public final void load(String mana) { this.clear(); if (costs.containsKey(mana)) { ManaCosts<ManaCost> savedCosts = costs.get(mana); for (ManaCost cost : savedCosts) { this.add(cost.copy()); for (String symbol : symbols) { if (!symbol.isEmpty()) { if (symbol.length() == 1 || isNumeric(symbol)) { if (Character.isDigit(symbol.charAt(0))) { this.add(new GenericManaCost(Integer.valueOf(symbol))); } else if (symbol.equals("S")) { this.add(new SnowManaCost()); } else if (symbol.equals("C")) { this.add(new ColorlessManaCost(1)); } else if (!symbol.equals("X")) { this.add(new ColoredManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)))); } else // check X wasn't added before if (modifierForX == 0) { this.add(new VariableManaCost(modifierForX)); this.add(new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2)))); } else if (symbol.contains("P")) { this.add(new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)))); } else { this.add(new HybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)), ColoredManaSymbol.lookup(symbol.charAt(2))));
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { for (Target target : abilityToModify.getTargets()) { if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) { int additionalTargets = target.getTargets().size() - 1; StringBuilder sb = new StringBuilder(); for (int i = 0; i < additionalTargets; i++) { // Build up a string of strive costs for each target sb.append(striveCosts.getText()); } String finalCost = ManaUtil.condenseManaCostString(sb.toString()); abilityToModify.getManaCostsToPay().add(new ManaCostsImpl(finalCost)); return true; } } return false; }
int ageCounter = permanent.getCounters(game).getCount(CounterType.AGE); if (cumulativeCost instanceof ManaCost) { ManaCostsImpl totalCost = new ManaCostsImpl<>(); for (int i = 0; i < ageCounter; i++) { totalCost.add((ManaCost) cumulativeCost.copy()); if (player.chooseUse(Outcome.Benefit, "Pay " + totalCost.getText() + '?', source, game)) { totalCost.clearPaid(); if (totalCost.payOrRollback(source, game, source.getSourceId(), source.getControllerId())) { game.fireEvent(new ManaEvent(EventType.PAID_CUMULATIVE_UPKEEP, permanent.getId(), permanent.getId(), player.getId(), totalCost.getUsedManaToPay())); return true;
while (!paid) { payAmount = player.getAmount(0, creaturesNumber, message, game); ManaCostsImpl cost = new ManaCostsImpl(); cost.add(new GenericManaCost(payAmount)); cost.clearPaid(); if (cost.payOrRollback(source, game, source.getSourceId(), playerId)) { paid = true;
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); ManaCostsImpl cost = new ManaCostsImpl("{2}"); if (player != null) { if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? If you do, copy that ability. You may choose new targets for the copy.", source, game)) { if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { StackAbility ability = (StackAbility) getValue("stackAbility"); Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (ability != null && controller != null && sourcePermanent != null) { ability.createCopyOnStack(game, source, source.getControllerId(), true); game.informPlayers(sourcePermanent.getIdName() + ": " + controller.getLogName() + " copied activated ability"); return true; } return false; } } return true; } return false; } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(event.getPlayerId()); if (player != null) { int amount = xCosts.calculate(game, source, this); if (amount > 0) { String mana = "{" + amount + '}'; ManaCostsImpl cost = new ManaCostsImpl(mana); if (cost.canPay(source, source.getSourceId(), event.getPlayerId(), game) && player.chooseUse(Outcome.Benefit, "Pay " + mana + " to declare blocker?", source, game)) { if (cost.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) { return false; } } return true; } } return false; }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (this.isEmpty() || noMana) { setPaid(); return true; } Player player = game.getPlayer(controllerId); if (!player.getManaPool().isForcedToPay()) { assignPayment(game, ability, player.getManaPool(), this); } game.getState().getSpecialActions().removeManaActions(); while (!isPaid()) { ManaCost unpaid = this.getUnpaid(); String promptText = ManaUtil.addSpecialManaPayAbilities(ability, game, unpaid); if (player.playMana(ability, unpaid, promptText, game)) { assignPayment(game, ability, player.getManaPool(), this); } else { return false; } game.getState().getSpecialActions().removeManaActions(); } return true; }
private void handleForcedToPayOnlyForCurrentPayment(Game game, ManaPool pool, ManaCosts referenceCosts) { // for Word of Command if (pool.isForcedToPay()) { if (referenceCosts != null && this.getText().equals(referenceCosts.getText())) { UUID playerId = pool.getPlayerId(); Player player = game.getPlayer(playerId); if (player != null) { game.undo(playerId); this.clearPaid(); this.setX(referenceCosts.getX()); player.getManaPool().restoreMana(pool.getPoolBookmark()); game.bookmarkState(); } } } }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Player player = game.getPlayer(controllerId); if (player == null) { return false; } paid = false; manaCost.clearPaid(); if (manaCost.pay(ability, game, player.getId(), player.getId(), false) && player.canPayLifeCost() && player.getLife() >= 1 && lifeCost.pay(ability, game, player.getId(), player.getId(), false)) { paid = true; } return paid; }
/** * bookmarks the current state and restores it if player doesn't pay the * mana cost * * @param ability * @param game * @param sourceId * @param payingPlayerId * @return true if the cost was paid */ @Override public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId) { int bookmark = game.bookmarkState(); handlePhyrexianManaCosts(payingPlayerId, ability, game); if (pay(ability, game, sourceId, payingPlayerId, false, null)) { game.removeBookmark(bookmark); return true; } game.restoreState(bookmark, ability.getRule()); return false; }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) { return pay(ability, game, sourceId, controllerId, noMana, this); }
public ManaCostsImpl(final ManaCostsImpl<T> costs) { this.id = costs.id; for (T cost : costs) { this.add(cost.copy()); } }
public CircleOfProtectionShadow(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}"); // {1}: The next time a creature of your choice with shadow would deal damage to you this turn, prevent that damage. Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, filter); effect.setText("The next time a creature of your choice with shadow would deal damage to you this turn, prevent that damage"); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("1"))); }
ManaCostsImpl manaCosts = new ManaCostsImpl(); for (Cost cost : ability.getCosts()) { if (cost instanceof ManaCost) { manaCosts.add((ManaCost) cost); if (manaCosts.isEmpty()) { return true; } else { for (Mana mana : manaCosts.getOptions()) { for (Mana avail : available) { if (mana.enough(avail)) {
public DeepWater(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}"); // {U}: Until end of turn, if you tap a land you control for mana, it produces {U} instead of any other type. SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DeepWaterReplacementEffect(), new ManaCostsImpl("{U}")); this.addAbility(ability); }
public AndraditeLeech(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}"); this.subtype.add(SubType.LEECH); this.power = new MageInt(2); this.toughness = new MageInt(2); // Black spells you cast cost {B} more to cast. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SpellsCostIncreasementControllerEffect(filter, new ManaCostsImpl("{B}")))); // {B}: Andradite Leech gets +1/+1 until end of turn. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 1, Duration.EndOfTurn), new ManaCostsImpl("{B}"))); }
public DriftingDjinn(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{U}{U}"); this.subtype.add(SubType.DJINN); this.power = new MageInt(5); this.toughness = new MageInt(5); this.addAbility(FlyingAbility.getInstance()); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new ManaCostsImpl("{1}{U}")), TargetController.YOU, false)); this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); }