Removed deprecated AdjustingSourceCosts interface.

This commit is contained in:
LevelX2 2019-12-14 18:33:11 +01:00
parent 7c96171359
commit da9f24e008
11 changed files with 148 additions and 248 deletions

View file

@ -1,5 +1,8 @@
package mage.abilities;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostAdjuster;
@ -23,10 +26,6 @@ import mage.target.Targets;
import mage.target.targetadjustment.TargetAdjuster;
import mage.watchers.Watcher;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
/**
* Practically everything in the game is started from an Ability. This interface
* describes what an Ability is composed of at the highest level.
@ -47,8 +46,10 @@ public interface Ability extends Controllable, Serializable {
*
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
* mage.game.Game)
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
* @see
* mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
* @see
* mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
*/
void newId();
@ -57,8 +58,10 @@ public interface Ability extends Controllable, Serializable {
*
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
* mage.game.Game)
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
* @see
* mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
* @see
* mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
*/
void newOriginalId();
@ -264,15 +267,16 @@ public interface Ability extends Controllable, Serializable {
/**
* Activates this ability prompting the controller to pay any mandatory
*
* @param game A reference the {@link Game} for which this ability should be
* activated within.
* @param game A reference the {@link Game} for which this ability should be
* activated within.
* @param noMana Whether or not {@link ManaCosts} have to be paid.
* @return True if this ability was successfully activated.
* @see mage.players.PlayerImpl#cast(mage.abilities.SpellAbility,
* mage.game.Game, boolean)
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
* mage.game.Game)
* @see mage.players.PlayerImpl#triggerAbility(mage.abilities.TriggeredAbility,
* @see
* mage.players.PlayerImpl#triggerAbility(mage.abilities.TriggeredAbility,
* mage.game.Game)
*/
boolean activate(Game game, boolean noMana);
@ -286,7 +290,8 @@ public interface Ability extends Controllable, Serializable {
*
* @param game The {@link Game} for which this ability resolves within.
* @return Whether or not this ability successfully resolved.
* @see mage.players.PlayerImpl#playManaAbility(mage.abilities.mana.ManaAbility,
* @see
* mage.players.PlayerImpl#playManaAbility(mage.abilities.mana.ManaAbility,
* mage.game.Game)
* @see mage.players.PlayerImpl#specialAction(mage.abilities.SpecialAction,
* mage.game.Game)
@ -461,15 +466,6 @@ public interface Ability extends Controllable, Serializable {
*/
String getGameLogMessage(Game game);
/**
* Used to deactivate cost modification logic of ability activation for some
* special handling (e.g. FlashbackAbility gets cost modifiaction twice
* because of how it's handled now)
*
* @param active execute no cost modification
*/
void setCostModificationActive(boolean active);
boolean activateAlternateOrAdditionalCosts(MageObject sourceObject, boolean noMana, Player controller, Game game);
/**

View file

@ -1,5 +1,9 @@
package mage.abilities;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.Mana;
import mage.abilities.costs.*;
@ -17,7 +21,6 @@ import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.Card;
import mage.cards.SplitCard;
import mage.constants.*;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.command.Plane;
@ -35,11 +38,6 @@ import mage.util.ThreadLocalStringBuilder;
import mage.watchers.Watcher;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -66,7 +64,6 @@ public abstract class AbilityImpl implements Ability {
protected boolean ruleAtTheTop = false;
protected boolean ruleVisible = true;
protected boolean ruleAdditionalCostsVisible = true;
protected boolean costModificationActive = true;
protected boolean activated = false;
protected boolean worksFaceDown = false;
protected int sourceObjectZoneChangeCounter;
@ -116,7 +113,6 @@ public abstract class AbilityImpl implements Ability {
this.ruleAtTheTop = ability.ruleAtTheTop;
this.ruleVisible = ability.ruleVisible;
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
this.costModificationActive = ability.costModificationActive;
this.worksFaceDown = ability.worksFaceDown;
this.abilityWord = ability.abilityWord;
this.sourceObjectZoneChangeCounter = ability.sourceObjectZoneChangeCounter;
@ -356,30 +352,9 @@ public abstract class AbilityImpl implements Ability {
}
//20101001 - 601.2e
if (costModificationActive) {
// TODO: replace all AdjustingSourceCosts abilities to continuus effect, see Affinity example
//20100716 - 601.2e
if (sourceObject != null) {
sourceObject.adjustCosts(this, game);
if (sourceObject instanceof Card) {
for (Ability ability : ((Card) sourceObject).getAbilities(game)) {
if (ability instanceof AdjustingSourceCosts) {
((AdjustingSourceCosts) ability).adjustCosts(this, game);
}
}
} else {
for (Ability ability : sourceObject.getAbilities()) {
if (ability instanceof AdjustingSourceCosts) {
((AdjustingSourceCosts) ability).adjustCosts(this, game);
}
}
}
}
if (sourceObject != null) {
sourceObject.adjustCosts(this, game); // still needed
game.getContinuousEffects().costModification(this, game);
} else {
costModificationActive = true;
}
UUID activatorId = controllerId;
@ -542,15 +517,14 @@ public abstract class AbilityImpl implements Ability {
/**
* 601.2b If a cost that will be paid as the spell is being cast includes
* Phyrexian mana symbols, the player announces whether they intend to
* pay 2 life or the corresponding colored mana cost for each of those
* symbols.
* Phyrexian mana symbols, the player announces whether they intend to pay 2
* life or the corresponding colored mana cost for each of those symbols.
*/
private void handlePhyrexianManaCosts(Game game, UUID sourceId, Player controller) {
Iterator<ManaCost> costIterator = manaCostsToPay.iterator();
while (costIterator.hasNext()) {
ManaCost cost = costIterator.next();
if (cost instanceof PhyrexianManaCost) {
PhyrexianManaCost phyrexianManaCost = (PhyrexianManaCost) cost;
PayLifeCost payLifeCost = new PayLifeCost(2);
@ -1191,11 +1165,6 @@ public abstract class AbilityImpl implements Ability {
return sb.toString();
}
@Override
public void setCostModificationActive(boolean active) {
this.costModificationActive = active;
}
@Override
public boolean getWorksFaceDown() {
return worksFaceDown;

View file

@ -1,22 +0,0 @@
package mage.abilities.costs;
import mage.abilities.Ability;
import mage.game.Game;
/**
* Interface for abilities that adjust source and only source costs. For the
* cases when some permanent adjusts costs of other spells use
* {@link mage.abilities.effects.CostModificationEffect}.
* <p>
* Example of such source costs adjusting:
* {@link mage.abilities.keyword.AffinityForArtifactsAbility}
*
* @author nantuko
*/
@Deprecated
// replace all AdjustingSourceCosts with "extends CostModificationEffectImpl with zone.ALL" (see Affinity example)
@FunctionalInterface
public interface AdjustingSourceCosts {
void adjustCosts(Ability ability, Game game);
}

View file

@ -1,5 +1,9 @@
package mage.game.stack;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
@ -30,11 +34,6 @@ import mage.util.GameLog;
import mage.util.SubTypeList;
import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -481,11 +480,6 @@ public class StackAbility extends StackObjImpl implements Ability {
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setCostModificationActive(boolean active) {
throw new UnsupportedOperationException("Not supported. Only neede for flashbacked spells");
}
@Override
public boolean getWorksFaceDown() {
return this.ability.getWorksFaceDown();

View file

@ -1,6 +1,9 @@
package mage.players;
import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import mage.ConditionalMana;
import mage.MageObject;
import mage.MageObjectReference;
@ -32,8 +35,8 @@ import mage.counters.Counters;
import mage.designations.Designation;
import mage.designations.DesignationType;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.FilterMana;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreatureForCombat;
import mage.filter.common.FilterCreatureForCombatBlock;
@ -65,10 +68,6 @@ import mage.util.GameLog;
import mage.util.RandomUtil;
import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
public abstract class PlayerImpl implements Player, Serializable {
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
@ -3045,18 +3044,6 @@ public abstract class PlayerImpl implements Player, Serializable {
if (available != null) {
game.getContinuousEffects().costModification(copy, game);
}
Card card = game.getCard(ability.getSourceId());
if (card != null) {
for (Ability ability0 : card.getAbilities()) {
if (ability0 instanceof AdjustingSourceCosts) {
// A workaround for Issue#457
if (!(ability0 instanceof ConvokeAbility)) {
((AdjustingSourceCosts) ability0).adjustCosts(copy, game);
}
}
}
}
boolean canBeCastRegularly = true;
if (copy instanceof SpellAbility && copy.getManaCosts().isEmpty() && copy.getCosts().isEmpty()) {
// 117.6. Some mana costs contain no mana symbols. This represents an unpayable cost...
@ -3094,7 +3081,7 @@ public abstract class PlayerImpl implements Player, Serializable {
}
}
}
return canPlayCardByAlternateCost(card, available, ability, game);
return canPlayCardByAlternateCost(game.getCard(ability.getSourceId()), available, ability, game);
}
return false;
}
@ -3231,11 +3218,11 @@ public abstract class PlayerImpl implements Player, Serializable {
}
if (ability instanceof SpellAbility
&& null != game.getContinuousEffects().asThough(card.getId(),
AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, ability, getId(), game)) {
AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, ability, getId(), game)) {
playable.add(ability);
} else if (ability instanceof PlayLandAbility
&& null != game.getContinuousEffects().asThough(card.getId(),
AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, card.getSpellAbility(), getId(), game)) {
AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, card.getSpellAbility(), getId(), game)) {
playable.add(ability);
}
if (setControllerId) {