public void addMana(ManaOptions options) { if (isEmpty()) { this.add(new Mana()); } if (!options.isEmpty()) { if (options.size() == 1) { //if there is only one mana option available add it to all the existing options addMana(options.get(0)); } else { //perform a union of all existing options and the new options List<Mana> copy = copy(); this.clear(); for (Mana addMana : options) { for (Mana mana : copy) { Mana newMana = new Mana(); newMana.add(mana); newMana.add(addMana); this.add(newMana); } } } } }
@Override public ManaOptions getOptions() { ManaOptions options = new ManaOptions(); for (ManaCost cost : this) { options.addMana(cost.getOptions()); } return options; }
public void addMana(List<ActivatedManaAbilityImpl> abilities, Game game) { if (isEmpty()) { this.add(new Mana()); if (!hasTapCost(abilities.get(0)) || checkTappedForManaReplacement(abilities.get(0), game, netManas.get(0))) { addMana(netManas.get(0)); List<Mana> copy = copy(); this.clear(); boolean hasTapCost = hasTapCost(abilities.get(0)); for (Mana netMana : netManas) { for (Mana mana : copy) { newMana.add(mana); newMana.add(netMana); this.add(newMana); List<Mana> copy = copy(); this.clear(); for (ActivatedManaAbilityImpl ability : abilities) { boolean hasTapCost = hasTapCost(ability); for (Mana netMana : ability.getNetMana(game)) { if (!hasTapCost || checkTappedForManaReplacement(ability, game, netMana)) { SkipAddMana: for (Mana mana : copy) { this.add(newMana);
public void removeDuplicated() { Set<String> list = new HashSet<>(); for (int i = this.size() - 1; i >= 0; i--) { String s = this.get(i).toString(); if (list.contains(s)) { // remove duplicated this.remove(i); } else { list.add(s); } } // Remove fully included variations for (int i = this.size() - 1; i >= 0; i--) { for (int ii = 0; ii < i; ii++) { Mana moreValuable = Mana.getMoreValuableMana(this.get(i), this.get(ii)); if (moreValuable != null) { this.get(ii).setToMana(moreValuable); this.remove(i); break; } } } } }
public void addManaWithCost(List<ActivatedManaAbilityImpl> abilities, Game game) { int replaces = 0; if (isEmpty()) { this.add(new Mana()); addMana(netManas.get(0)); } else { List<Mana> copy = copy(); this.clear(); for (Mana netMana : netManas) { for (Mana mana : copy) { newMana.add(mana); newMana.add(netMana); this.add(newMana); subtractCostAddMana(ability.getManaCosts().getMana(), netManas.get(0), ability.getCosts().isEmpty()); } else { List<Mana> copy = copy(); this.clear(); for (Mana netMana : netManas) { for (Mana mana : copy) { newMana.add(mana); newMana.add(netMana); subtractCostAddMana(ability.getManaCosts().getMana(), netMana, ability.getCosts().isEmpty()); List<Mana> copy = copy(); this.clear(); for (ActivatedManaAbilityImpl ability : abilities) {
public void subtractCostAddMana(Mana cost, Mana addMana, boolean onlyManaCosts) { if (isEmpty()) { this.add(new Mana()); List<Mana> copy = copy(); this.clear(); for (Mana mana : copy) { Mana oldMan = mana.copy(); mana.subtract(coloredCost); boolean oldManaWasReplaced = false; for (Mana payCombination : getPossiblePayCombinations(cost.getGeneric(), mana)) { Mana newMana = mana.copy(); newMana.subtract(payCombination); Mana moreValuable = Mana.getMoreValuableMana(oldMan, newMana); if (!oldMan.equals(moreValuable)) { this.add(newMana); if (moreValuable != null) { oldManaWasReplaced = true; // the new mana includes all possibilities of the old one this.add(oldMan); mana.setToMana(oldMan); this.add(mana);
@Override public ManaOptions getManaAvailable(Game game) { ManaOptions available = new ManaOptions(); available.addMana(manaAbilities, game); available.removeDuplicated(); available.addManaWithCost(manaAbilities, game); available.removeDuplicated();
public ColorlessManaCost(int mana) { this.mana = mana; this.cost = Mana.ColorlessMana(mana); this.options.addMana(Mana.ColorlessMana(mana)); }
Set<Card> nonLands = hand.getCards(new FilterNonlandCard(), game); ManaOptions available = getManaAvailable(game); available.addMana(manaPool.getMana()); if (abilityOptions.isEmpty()) { playableAbilities.add(ability); } else { if (ability.canActivate(playerId, game).canActivate()) { ManaOptions abilityOptions = ability.getManaCosts().getOptions(); if (abilityOptions.isEmpty()) { playableAbilities.add(ability); } else {
public ManaOptions(final ManaOptions options) { for (Mana mana : options) { this.add(mana.copy()); } }
if (manaOptions.size() == 1) { mana = newManaCosts.getMana(); } else {
if (abilityOptions.isEmpty()) { return true; } else {
public ManaOptions copy() { return new ManaOptions(this); }
public ManaCostImpl(final ManaCostImpl manaCost) { super(manaCost); this.payment = manaCost.payment.copy(); this.usedManaToPay = manaCost.usedManaToPay.copy(); this.cost = manaCost.cost.copy(); this.options = manaCost.options.copy(); if (manaCost.sourceFilter != null) { this.sourceFilter = manaCost.sourceFilter.copy(); } }
if (manaToPayFrom.getBlack() > 0 && !payCombinationsStrings.contains(existingMana.toString() + Mana.BlackMana(1).toString())) { manaToPayFrom.subtract(Mana.BlackMana(1)); addManaCombination(Mana.BlackMana(1), existingMana, payCombinations, payCombinationsStrings); addManaCombination(Mana.BlueMana(1), existingMana, payCombinations, payCombinationsStrings); addManaCombination(Mana.GreenMana(1), existingMana, payCombinations, payCombinationsStrings); addManaCombination(Mana.RedMana(1), existingMana, payCombinations, payCombinationsStrings); addManaCombination(Mana.WhiteMana(1), existingMana, payCombinations, payCombinationsStrings); addManaCombination(Mana.AnyMana(1), existingMana, payCombinations, payCombinationsStrings);
public GenericManaCost(int mana) { this.mana = mana; this.cost = Mana.GenericMana(mana); this.options.addMana(Mana.GenericMana(mana)); }
public PhyrexianManaCost(ColoredManaSymbol mana) { super(mana); options.add(Mana.GenericMana(0)); }
public ManaCostImpl() { payment = new Mana(); usedManaToPay = new Mana(); options = new ManaOptions(); }
public SnowManaCost() { this.cost = Mana.GenericMana(1); this.options.addMana(Mana.GenericMana(1)); this.setSourceFilter(filter); }