Removed unused code (optionalCost);

This commit is contained in:
Oleg Agafonov 2020-09-13 10:33:13 +04:00
parent 6e0c7e868c
commit c325a6d2f0
4 changed files with 0 additions and 81 deletions

View file

@ -139,23 +139,6 @@ public interface Ability extends Controllable, Serializable {
*/
void addManaCost(ManaCost cost);
/**
* TODO Method is unused, keep it around?
* <p>
* Gets all costs that are optional to this ability. These costs can be paid
* in addition to other costs to have other effects put into place.
*
* @return All {@link Costs} that can be paid above and beyond other costs.
*/
Costs<Cost> getOptionalCosts();
/**
* Adds a {@link Cost} that is optional to this ability.
*
* @param cost The {@link Cost} to add to the optional costs.
*/
void addOptionalCost(Cost cost);
/**
* Retrieves the effects that are put into the place by the resolution of
* this ability.

View file

@ -54,7 +54,6 @@ public abstract class AbilityImpl implements Ability {
protected ManaCosts<ManaCost> manaCosts;
protected ManaCosts<ManaCost> manaCostsToPay;
protected Costs<Cost> costs;
protected Costs<Cost> optionalCosts;
protected Modes modes; // access to it by GetModes only (it can be overridden by some abilities)
protected Zone zone;
protected String name;
@ -83,7 +82,6 @@ public abstract class AbilityImpl implements Ability {
this.manaCosts = new ManaCostsImpl<>();
this.manaCostsToPay = new ManaCostsImpl<>();
this.costs = new CostsImpl<>();
this.optionalCosts = new CostsImpl<>();
this.modes = new Modes();
}
@ -99,7 +97,6 @@ public abstract class AbilityImpl implements Ability {
this.manaCosts = ability.manaCosts;
this.manaCostsToPay = ability.manaCostsToPay.copy();
this.costs = ability.costs.copy();
this.optionalCosts = ability.optionalCosts.copy();
for (Watcher watcher : ability.getWatchers()) {
watchers.add(watcher.copy());
}
@ -353,16 +350,6 @@ public abstract class AbilityImpl implements Ability {
}
} // end modes
// TODO: Handle optionalCosts at the same time as already OptionalAdditionalSourceCosts are handled.
for (Cost cost : optionalCosts) {
if (cost instanceof ManaCost) {
cost.clearPaid();
if (controller.chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + '?', this, game)) {
manaCostsToPay.add((ManaCost) cost);
}
}
}
// this is a hack to prevent mana abilities with mana costs from causing endless loops - pay other costs first
if (this instanceof ActivatedManaAbilityImpl && !costs.pay(this, game, sourceId, controllerId, noMana, null)) {
logger.debug("activate mana ability failed - non mana costs");
@ -690,11 +677,6 @@ public abstract class AbilityImpl implements Ability {
return manaCostsToPay;
}
@Override
public Costs<Cost> getOptionalCosts() {
return optionalCosts;
}
@Override
public Effects getEffects() {
return getModes().getMode().getEffects();
@ -850,13 +832,6 @@ public abstract class AbilityImpl implements Ability {
}
}
@Override
public void addOptionalCost(Cost cost) {
if (cost != null) {
this.optionalCosts.add(cost);
}
}
@Override
public void addEffect(Effect effect) {
if (effect != null) {

View file

@ -219,9 +219,6 @@ public class Spell extends StackObjImpl implements Card {
if (spellAbilityCheckTargetsAndDeactivateModes(spellAbility, game)) {
for (UUID modeId : spellAbility.getModes().getSelectedModes()) {
spellAbility.getModes().setActiveMode(modeId);
if (spellAbility.getSpellAbilityType() != SpellAbilityType.SPLICE) {
updateOptionalCosts(index);
}
result |= spellAbility.resolve(game);
}
index++;
@ -242,7 +239,6 @@ public class Spell extends StackObjImpl implements Card {
return false;
} else if (this.isEnchantment() && this.hasSubtype(SubType.AURA, game)) {
if (ability.getTargets().stillLegal(ability, game)) {
updateOptionalCosts(0);
boolean bestow = SpellAbilityCastMode.BESTOW.equals(ability.getSpellAbilityCastMode());
if (bestow) {
// Must be removed first time, after that will be removed by continous effect
@ -274,7 +270,6 @@ public class Spell extends StackObjImpl implements Card {
}
// Aura has no legal target and its a bestow enchantment -> Add it to battlefield as creature
if (SpellAbilityCastMode.BESTOW.equals(this.getSpellAbility().getSpellAbilityCastMode())) {
updateOptionalCosts(0);
if (controller.moveCards(card, Zone.BATTLEFIELD, ability, game, false, faceDown, false, null)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent instanceof PermanentCard) {
@ -293,7 +288,6 @@ public class Spell extends StackObjImpl implements Card {
return false;
}
} else {
updateOptionalCosts(0);
return controller.moveCards(card, Zone.BATTLEFIELD, ability, game, false, faceDown, false, null);
}
}
@ -362,30 +356,6 @@ public class Spell extends StackObjImpl implements Card {
}
}
/**
* As we have ability in the stack, we need to update optional costs in
* original card. This information will be used later by effects, e.g. to
* determine whether card was kicked or not. E.g. Desolation Angel
*/
private void updateOptionalCosts(int index) {
spellCards.get(index).getAbilities().get(spellAbilities.get(index).getId()).ifPresent(abilityOrig
-> {
for (Object object : spellAbilities.get(index).getOptionalCosts()) {
Cost cost = (Cost) object;
for (Cost costOrig : abilityOrig.getOptionalCosts()) {
if (cost.getId().equals(costOrig.getId())) {
if (cost.isPaid()) {
costOrig.setPaid();
} else {
costOrig.clearPaid();
}
break;
}
}
}
});
}
@Override
public void counter(UUID sourceId, Game game) {
this.counter(sourceId, game, Zone.GRAVEYARD, false, ZoneDetail.NONE);

View file

@ -381,15 +381,6 @@ public class StackAbility extends StackObjImpl implements Ability {
}
}
@Override
public Costs<Cost> getOptionalCosts() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void addOptionalCost(Cost cost) {
}
@Override
public boolean checkIfClause(Game game) {
return true;