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 apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; spellAbility.getManaCostsToPay().add(new GenericManaCost(1)); return true; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; spellAbility.getManaCostsToPay().add(new GenericManaCost(3)); return true; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int newCount = mana.getGeneric() - 6; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int newCount = mana.getGeneric() - 6; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int newCount = mana.getGeneric() - 2; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int newCount = mana.getGeneric() - 6; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int count = game.getOpponents(source.getControllerId()).size(); int newCount = mana.getGeneric() - count; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility)abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int count = new DevotionCount(ColoredManaSymbol.B).calculate(game, source, this); int newCount = mana.getGeneric() - count; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); Player player = game.getPlayer(source.getControllerId()); if (mana.getGeneric() > 0 && player != null && player.getLife() < 4) { int newCount = mana.getGeneric() - 6; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public void watch(GameEvent event, Game game) { // Watcher saves all casts becaus of possible Clone cards that copy Jeleva if (event.getType() == GameEvent.EventType.SPELL_CAST) { if (!game.getStack().isEmpty()) { for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell) { Spell spell = (Spell) stackObject; manaSpendToCast.putIfAbsent(spell.getSourceId().toString() + spell.getCard().getZoneChangeCounter(game), spell.getSpellAbility().getManaCostsToPay().convertedManaCost()); } } } } }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility)abilityToModify; Mana mana = spellAbility.getManaCostsToPay().getMana(); if (mana.getGeneric() > 0) { int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); int newCount = mana.getGeneric() - count; if (newCount < 0) { newCount = 0; } mana.setGeneric(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; } return false; }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) { Spell spell = (Spell) game.getObject(event.getTargetId()); if (spell != null && this.getSourceId().equals(spell.getSourceId())) { payment = spell.getSpellAbility().getManaCostsToPay().getPayment(); } } if (event.getType() == GameEvent.EventType.ZONE_CHANGE && this.getSourceId().equals(event.getSourceId())) { if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) { payment = null; } } }
@Override public int calculate(Game game, Ability source, Effect effect) { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell == null) { MageObject mageObject = game.getLastKnownInformation(source.getSourceId(), Zone.STACK); if (mageObject instanceof Spell) { spell = (Spell) mageObject; } } if (spell != null) { // NOT the cmc of the spell on the stack return spell.getSpellAbility().getManaCostsToPay().convertedManaCost(); } return 0; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player == null) { return false; } Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY); if (!(obj instanceof SpellAbility)) { return false; } int halfCost = Math.floorDiv(((SpellAbility) obj).getManaCostsToPay().getX(), 2); player.drawCards(halfCost, game); player.gainLife(halfCost, game, source); return true; } }
public Imperiosaur(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}"); this.subtype.add(SubType.DINOSAUR); this.power = new MageInt(5); this.toughness = new MageInt(5); // Spend only mana produced by basic lands to cast Imperiosaur. this.addAbility(new ImperiosaurStaticAbility()); this.getSpellAbility().getManaCostsToPay().setSourceFilter(filter); this.getSpellAbility().getManaCosts().setSourceFilter(filter); }
public DrainLife(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{1}{B}"); // Spend only black mana on X. this.addAbility(new SimpleStaticAbility( Zone.ALL, new InfoEffect("Spend only black mana on X")).setRuleAtTheTop(true) ); // Drain Life deals X damage to any target. You gain life equal to the damage dealt, but not more life than the player's life total before Drain Life dealt damage or the creature's toughness. this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addEffect(new DrainLifeEffect()); VariableCost variableCost = this.getSpellAbility().getManaCostsToPay().getVariableCosts().get(0); if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setFilter(filterBlack); } }
public SoulBurn(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{2}{B}"); // Spend only black or red mana on X. this.addAbility(new SimpleStaticAbility( Zone.ALL, new InfoEffect("Spend only black or red mana on X")).setRuleAtTheTop(true) ); // Soul Burn deals X damage to any target. You gain life equal to the damage dealt for each black mana spent on X; not more life than the player's life total before Soul Burn dealt damage, or the creature's toughness. this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addEffect(new SoulBurnEffect()); VariableCost variableCost = this.getSpellAbility().getManaCostsToPay().getVariableCosts().get(0); if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setFilter(filterBlackOrRed); } }
public MyrSuperion(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{2}"); this.subtype.add(SubType.MYR); this.power = new MageInt(5); this.toughness = new MageInt(6); // Spend only mana produced by creatures to cast Myr Superion. this.addAbility(new SimpleStaticAbility(Zone.ALL, new InfoEffect("Spend only mana produced by creatures to cast {this}"))); this.getSpellAbility().getManaCostsToPay().setSourceFilter(StaticFilters.FILTER_PERMANENT_CREATURES); this.getSpellAbility().getManaCosts().setSourceFilter(StaticFilters.FILTER_PERMANENT_CREATURES); }
public ConsumeSpirit(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{1}{B}"); // Spend only black mana on X. this.addAbility(new SimpleStaticAbility( Zone.ALL, new InfoEffect("Spend only black mana on X")).setRuleAtTheTop(true) ); // Consume Spirit deals X damage to any target and you gain X life. this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addEffect(new DamageTargetEffect(ManacostVariableValue.instance)); this.getSpellAbility().addEffect(new GainLifeEffect(ManacostVariableValue.instance).concatBy("and")); VariableCost variableCost = this.getSpellAbility().getManaCostsToPay().getVariableCosts().get(0); if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setFilter(filterBlack); } }