From c325a6d2f004b37d93c82d0172b90fabf4caebf1 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 13 Sep 2020 10:33:13 +0400 Subject: [PATCH] Removed unused code (optionalCost); --- .../src/main/java/mage/abilities/Ability.java | 17 ----------- .../main/java/mage/abilities/AbilityImpl.java | 25 ---------------- Mage/src/main/java/mage/game/stack/Spell.java | 30 ------------------- .../java/mage/game/stack/StackAbility.java | 9 ------ 4 files changed, 81 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/Ability.java b/Mage/src/main/java/mage/abilities/Ability.java index 829c1f3c2b3..e2c0bffdf73 100644 --- a/Mage/src/main/java/mage/abilities/Ability.java +++ b/Mage/src/main/java/mage/abilities/Ability.java @@ -139,23 +139,6 @@ public interface Ability extends Controllable, Serializable { */ void addManaCost(ManaCost cost); - /** - * TODO Method is unused, keep it around? - *

- * 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 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. diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index eb33a433bab..0532ae212ab 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -54,7 +54,6 @@ public abstract class AbilityImpl implements Ability { protected ManaCosts manaCosts; protected ManaCosts manaCostsToPay; protected Costs costs; - protected Costs 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 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) { diff --git a/Mage/src/main/java/mage/game/stack/Spell.java b/Mage/src/main/java/mage/game/stack/Spell.java index c6bd85ed48f..969c5cbe67f 100644 --- a/Mage/src/main/java/mage/game/stack/Spell.java +++ b/Mage/src/main/java/mage/game/stack/Spell.java @@ -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); diff --git a/Mage/src/main/java/mage/game/stack/StackAbility.java b/Mage/src/main/java/mage/game/stack/StackAbility.java index 68e465fd12e..329634eb54b 100644 --- a/Mage/src/main/java/mage/game/stack/StackAbility.java +++ b/Mage/src/main/java/mage/game/stack/StackAbility.java @@ -381,15 +381,6 @@ public class StackAbility extends StackObjImpl implements Ability { } } - @Override - public Costs getOptionalCosts() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void addOptionalCost(Cost cost) { - } - @Override public boolean checkIfClause(Game game) { return true;