@Override public ManaCosts<ManaCost> getManaCosts() { return ability.getManaCosts(); }
protected void simulateVariableCosts(Ability ability, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); int start = 0; if (!(ability instanceof SpellAbility)) { //only use x=0 on spell abilities if (numAvailable == 0) return; else start = 1; } for (int i = start; i < numAvailable; i++) { Ability newAbility = ability.copy(); newAbility.getManaCostsToPay().add(new GenericManaCost(i)); allActions.add(newAbility); } }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { return sourceAbility.getManaCosts().getX() + 3; }
protected void simulateVariableCosts(Ability ability, List<Ability> options, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); int start = 0; if (!(ability instanceof SpellAbility)) { //only use x=0 on spell abilities if (numAvailable == 0) return; else start = 1; } for (int i = start; i < numAvailable; i++) { Ability newAbility = ability.copy(); newAbility.getManaCostsToPay().add(new GenericManaCost(i)); options.add(newAbility); } }
@Override public int announceXMana(int min, int max, String message, Game game, Ability ability) { log.debug("announceXMana"); //TODO: improve this int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); if (numAvailable < 0) { numAvailable = 0; } else { if (numAvailable < min) { numAvailable = min; } if (numAvailable > max) { numAvailable = max; } } return numAvailable; }
if (!ability.getManaCosts().getVariableCosts().isEmpty()) { int amount = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); if (amount > 0) { ability = ability.copy();
@Override public Cost getCost(Ability ability, Game game) { return new GenericManaCost(ability.getManaCosts().convertedManaCost()); }
@Override protected void addVariableXOptions(List<Ability> options, Ability ability, int targetNum, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost();
public AbilityView(Ability ability, String sourceName, CardView sourceCard) { this.id = ability.getId(); this.name = "Ability"; this.sourceName = sourceName; this.sourceCard = sourceCard; this.rules = new ArrayList<>(); rules.add(ability.getRule()); this.power = ""; this.toughness = ""; this.loyalty = ""; this.cardTypes = EnumSet.noneOf(CardType.class); this.subTypes = new SubTypeList(); this.superTypes =EnumSet.noneOf(SuperType.class); this.color = new ObjectColor(); this.manaCost = ability.getManaCosts().getSymbols(); }
@Override public String getText(Ability ability, Game game) { return "Pay " + getCost(ability, game).getText() + " rather than " + ability.getManaCosts().getText() + " for Samurai card?"; } }
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; }
@Override public boolean apply(Game game, Ability source) { if (AbilityType.SPELL == source.getAbilityType()) { MageObject object = game.getObject(source.getSourceId()); return object != null && object.getManaCost().getText().contains("X"); } else { return source.getManaCosts().getText().contains("X"); } } }
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 (root.abilities.size() == 1) { for (Ability ability : root.abilities) { if (ability.getManaCosts().convertedManaCost() == 0 && ability.getCosts().isEmpty()) { if (actionCache.contains(ability.getRule() + '_' + ability.getSourceId())) {
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { int blackSymbols = abilityToModify.getManaCosts().getMana().getBlack(); TargetControlledPermanent target = new TargetControlledPermanent(blackSymbols, blackSymbols, filter, true); target.setRequired(false); abilityToModify.addCost(new SacrificeTargetCost(target)); return true; }
/** * 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; }
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); } } }
case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { MageInt power = new MageInt(source.getManaCosts().getVariableCosts().get(0).getAmount()); MageInt toughness = new MageInt(source.getManaCosts().getVariableCosts().get(0).getAmount()); permanent.getPower().setValue(power.getValue()); permanent.getToughness().setValue(toughness.getValue());
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);