@Override public List<VariableCost> getVariableCosts() { List<VariableCost> variableCosts = new ArrayList<>(); for (T cost : this) { if (cost instanceof VariableCost) { variableCosts.add((VariableCost) cost); } if (cost instanceof ManaCosts) { variableCosts.addAll(((ManaCosts) cost).getVariableCosts()); } } return variableCosts; }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { ManaCosts manaCosts = sourceAbility.getManaCostsToPay(); if (manaCosts.getVariableCosts().isEmpty()) { return 2; } return sourceAbility.getManaCostsToPay().getX(); }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { ManaCosts manaCosts = sourceAbility.getManaCostsToPay(); if (manaCosts.getVariableCosts().isEmpty()) { return 3; } return sourceAbility.getManaCostsToPay().getX(); }
public List<Ability> getPlayableOptions(Game game) { List<Ability> all = new ArrayList<>(); List<Ability> playables = getPlayableAbilities(game); for (Ability ability: playables) { List<Ability> options = game.getPlayer(playerId).getPlayableOptions(ability, game); if (options.isEmpty()) { if (!ability.getManaCosts().getVariableCosts().isEmpty()) { simulateVariableCosts(ability, all, game); } else { all.add(ability); } } else { for (Ability option: options) { if (!ability.getManaCosts().getVariableCosts().isEmpty()) { simulateVariableCosts(option, all, game); } else { all.add(option); } } } } return all; }
List<Ability> options = game.getPlayer(playerId).getPlayableOptions(ability, game); if (options.isEmpty()) { if (!ability.getManaCosts().getVariableCosts().isEmpty()) { simulateVariableCosts(ability, game); if (!ability.getManaCosts().getVariableCosts().isEmpty()) { simulateVariableCosts(option, game);
if (!ability.getManaCosts().getVariableCosts().isEmpty()) { int amount = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); if (amount > 0) {
/** * Only used for AIs * * @param ability * @param game * @return */ @Override public List<Ability> getPlayableOptions(Ability ability, Game game) { List<Ability> options = new ArrayList<>(); if (ability.isModal()) { addModeOptions(options, ability, game); } else if (!ability.getTargets().getUnchosen().isEmpty()) { // TODO: Handle other variable costs than mana costs if (!ability.getManaCosts().getVariableCosts().isEmpty()) { addVariableXOptions(options, ability, 0, game); } else { addTargetOptions(options, ability, 0, game); } } else if (!ability.getCosts().getTargets().getUnchosen().isEmpty()) { addCostTargetOptions(options, ability, 0, game); } return options; }
public MindGrind(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}{B}"); // Each opponent reveals cards from the top of their library until he or she reveals X land cards, then puts all cards revealed this way into their graveyard. X can't be 0. this.getSpellAbility().addEffect(new MindGrindEffect()); for (VariableCost cost : this.getSpellAbility().getManaCosts().getVariableCosts()) { if (cost instanceof VariableManaCost) { ((VariableManaCost) cost).setMinX(1); break; } } }
@Override public void adjustCosts(Ability ability, Game game) { Player controller = game.getPlayer(ability.getControllerId()); if (controller == null) { return; } for (VariableCost variableCost : ability.getManaCostsToPay().getVariableCosts()) { if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setMaxX(controller.getGraveyard().size()); } } } }
private void addModeOptions(List<Ability> options, Ability option, Game game) { // TODO: Support modal spells with more than one selectable mode for (Mode mode : option.getModes().values()) { Ability newOption = option.copy(); newOption.getModes().getSelectedModes().clear(); newOption.getModes().getSelectedModes().add(mode.getId()); newOption.getModes().setActiveMode(mode); if (!newOption.getTargets().getUnchosen().isEmpty()) { if (!newOption.getManaCosts().getVariableCosts().isEmpty()) { addVariableXOptions(options, newOption, 0, game); } else { addTargetOptions(options, newOption, 0, game); } } else if (!newOption.getCosts().getTargets().getUnchosen().isEmpty()) { addCostTargetOptions(options, newOption, 0, game); } else { options.add(newOption); } } }
public CryptRats(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}"); this.subtype.add(SubType.RAT); this.power = new MageInt(1); this.toughness = new MageInt(1); // {X}: Crypt Rats deals X damage to each creature and each player. Spend only black mana on X. Effect effect = new DamageEverythingEffect(ManacostVariableValue.instance); effect.setText("{this} deals X damage to each creature and each player. Spend only black mana on X"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect,new ManaCostsImpl("{X}")); VariableCost variableCost = ability.getManaCostsToPay().getVariableCosts().get(0); if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setFilter(filterBlack); } this.addAbility(ability); }
@Override public void adjustCosts(Ability ability, Game game) { if (ability instanceof SimpleActivatedAbility && ability.getModes().size() == 3) { Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); if (sourcePermanent != null) { int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); if (amount > 0) { for (VariableCost cost : ability.getManaCostsToPay().getVariableCosts()) { if (cost instanceof VariableManaCost) { ((VariableManaCost) cost).setMaxX(amount); break; } } } } } }
@Override public void init(Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int maxToughness = 2; ManaCosts manaCosts = source.getManaCostsToPay(); if (!manaCosts.getVariableCosts().isEmpty()) { maxToughness = source.getManaCostsToPay().getX(); } Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null && permanent.getToughness().getValue() > maxToughness) { this.discard(); return; } } super.init(source, game); }
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 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); } }
public CrimsonHellkite(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{6}{R}{R}{R}"); this.subtype.add(SubType.DRAGON); this.power = new MageInt(6); this.toughness = new MageInt(6); // Flying this.addAbility(FlyingAbility.getInstance()); // {X}, {tap}: Crimson Hellkite deals X damage to target creature. Spend only red mana on X. Effect effect = new DamageTargetEffect(ManacostVariableValue.instance); effect.setText("{this} deals X damage to target creature. Spend only red mana on X"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}")); ability.addCost(new TapSourceCost()); VariableCost variableCost = ability.getManaCostsToPay().getVariableCosts().get(0); if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setFilter(filterRedMana); } ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); }
public AtalyaSamiteMaster(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.CLERIC); this.power = new MageInt(2); this.toughness = new MageInt(3); // {X}, {tap}: Choose one - Prevent the next X damage that would be dealt to target creature this turn; or you gain X life. Spend only white mana on X. PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, ManacostVariableValue.instance); effect.setText("Prevent the next X damage that would be dealt to target creature this turn. Spend only white mana on X."); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}")); ability.addCost(new TapSourceCost()); VariableCost variableCost = ability.getManaCostsToPay().getVariableCosts().get(0); if (variableCost instanceof VariableManaCost) { ((VariableManaCost) variableCost).setFilter(filterWhiteMana); } ability.addTarget(new TargetCreaturePermanent()); // or you gain X life Mode mode = new Mode(); mode.addEffect(new GainLifeEffect(ManacostVariableValue.instance).setText("You gain X life. Spend only white mana on X.")); ability.addMode(mode); this.addAbility(ability); }
public VoodooDoll(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{6}"); // At the beginning of your upkeep, put a pin counter on Voodoo Doll. this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.PIN.createInstance()), TargetController.YOU, false)); // At the beginning of your end step, if Voodoo Doll is untapped, destroy Voodoo Doll and it deals damage to you equal to the number of pin counters on it. Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new DestroySourceEffect(), TargetController.YOU, new InvertCondition(SourceTappedCondition.instance), false); ability.addEffect(new DamageControllerEffect(new CountersSourceCount(CounterType.PIN))); this.addAbility(ability); // {X}{X}, {T}: Voodoo Doll deals damage equal to the number of pin counters on it to any target. X is the number of pin counters on Voodoo Doll. Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new CountersSourceCount(CounterType.PIN)), new ManaCostsImpl("{X}{X}")); ability2.addCost(new TapSourceCost()); ability2.addTarget(new TargetAnyTarget()); for (VariableCost cost : ability2.getManaCosts().getVariableCosts()) { if (cost instanceof VariableManaCost) { ((VariableManaCost) cost).setMaxX(0); break; } } this.addAbility(ability2); }
for (VariableCost cost : ability.getManaCosts().getVariableCosts()) { if (cost instanceof VariableManaCost) { ((VariableManaCost) cost).setMinX(1);