Remove obsolete adjustCosts and adjustTargets methods from MageObject interface

This commit is contained in:
Alex W. Jackson 2022-03-12 19:01:59 -05:00
parent a5e21b8c9e
commit 79b7a0a627
15 changed files with 13 additions and 116 deletions

View file

@ -124,8 +124,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
// calculate the mana that can be used for the x part
int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().manaValue();
Card card = game.getCard(ability.getSourceId());
if (card != null && numAvailable > 0) {
if (numAvailable > 0) {
// check if variable mana costs is included and get the multiplier
VariableManaCost variableManaCost = null;
for (ManaCost cost : ability.getManaCostsToPay()) {
@ -159,7 +158,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
if (varCost != null) {
varCost.setPaid();
}
card.adjustTargets(newAbility, game);
newAbility.adjustTargets(game);
// add the different possible target option for the specific X value
if (!newAbility.getTargets().getUnchosen().isEmpty()) {
addTargetOptions(options, newAbility, targetNum, game);

View file

@ -178,7 +178,7 @@ class CardCanBeCastPredicate implements Predicate<Card> {
public boolean apply(Card input, Game game) {
SpellAbility ability = input.getSpellAbility().copy();
ability.setControllerId(controllerId);
input.adjustTargets(ability, game);
ability.adjustTargets(game);
return ability.canChooseTarget(game, controllerId);
}

View file

@ -116,25 +116,6 @@ public interface MageObject extends MageItem, Serializable, Copyable<MageObject>
void setStartingLoyalty(int startingLoyalty);
/**
* Dynamic cost modification for card (process only OWN abilities).
* <p>
* Usage example: if it need stack related info (like real targets) then must check two
* states (game.inCheckPlayableState):
* <p>
* 1. In playable state it must check all possible use cases (e.g. allow to
* reduce on any available target and modes)
* <p>
* 2. In real cast state it must check current use case (e.g. real selected
* targets and modes)
*
* @param ability
* @param game
*/
void adjustCosts(Ability ability, Game game);
void adjustTargets(Ability ability, Game game);
// memory object copy (not mtg)
@Override
MageObject copy();

View file

@ -234,16 +234,6 @@ public abstract class MageObjectImpl implements MageObject {
return 0;
}
@Override
public final void adjustCosts(Ability ability, Game game) {
ability.adjustCosts(game);
}
@Override
public final void adjustTargets(Ability ability, Game game) {
ability.adjustTargets(game);
}
@Override
public boolean hasSubtype(SubType value, Game game) {
if (value == null) {

View file

@ -360,8 +360,8 @@ public abstract class AbilityImpl implements Ability {
// and/or zones become the target of a spell trigger at this point; they'll wait to be put on
// the stack until the spell has finished being cast.)
if (sourceObject != null && this.getAbilityType() != AbilityType.TRIGGERED) { // triggered abilities check this already in playerImpl.triggerAbility
sourceObject.adjustTargets(this, game);
if (this.getAbilityType() != AbilityType.TRIGGERED) { // triggered abilities check this already in playerImpl.triggerAbility
adjustTargets(game);
}
if (!getTargets().isEmpty()) {
@ -387,8 +387,8 @@ public abstract class AbilityImpl implements Ability {
boolean needCostModification = !CardUtil.isFusedPartAbility(this, game);
//20101001 - 601.2e
if (needCostModification && sourceObject != null) {
sourceObject.adjustCosts(this, game); // still needed for CostAdjuster objects (to handle some types of dynamic costs)
if (needCostModification) {
adjustCosts(game); // still needed for CostAdjuster objects (to handle some types of dynamic costs)
game.getContinuousEffects().costModification(this, game);
}

View file

@ -38,7 +38,7 @@ public class PayLoyaltyCost extends CostImpl {
// apply cost modification
if (ability instanceof LoyaltyAbility) {
LoyaltyAbility copiedAbility = ((LoyaltyAbility) ability).copy();
planeswalker.adjustCosts(copiedAbility, game);
copiedAbility.adjustCosts(game);
game.getContinuousEffects().costModification(copiedAbility, game);
loyaltyCost = 0;
for (Cost cost : copiedAbility.getCosts()) {

View file

@ -62,7 +62,7 @@ public class PayVariableLoyaltyCost extends VariableCostImpl {
// apply cost modification
if (source instanceof LoyaltyAbility) {
LoyaltyAbility copiedAbility = ((LoyaltyAbility) source).copy();
permanent.adjustCosts(copiedAbility, game);
copiedAbility.adjustCosts(game);
game.getContinuousEffects().costModification(copiedAbility, game);
for (Cost cost : copiedAbility.getCosts()) {
if (cost instanceof PayVariableLoyaltyCost) {

View file

@ -222,14 +222,6 @@ public abstract class Designation implements MageObject {
public void setStartingLoyalty(int startingLoyalty) {
}
@Override
public void adjustCosts(Ability ability, Game game) {
}
@Override
public void adjustTargets(Ability ability, Game game) {
}
@Override
public int getZoneChangeCounter(Game game) {
return 1; // Emblems can't move zones until now so return always 1

View file

@ -272,14 +272,6 @@ public class Commander implements CommandObject {
public void setStartingLoyalty(int startingLoyalty) {
}
@Override
public void adjustCosts(Ability ability, Game game) {
}
@Override
public void adjustTargets(Ability ability, Game game) {
}
@Override
public UUID getId() {
return sourceObject.getId();

View file

@ -317,14 +317,6 @@ public class Dungeon implements CommandObject {
public void setStartingLoyalty(int startingLoyalty) {
}
@Override
public void adjustCosts(Ability ability, Game game) {
}
@Override
public void adjustTargets(Ability ability, Game game) {
}
@Override
public UUID getId() {
return this.id;

View file

@ -226,14 +226,6 @@ public class Emblem implements CommandObject {
public void setStartingLoyalty(int startingLoyalty) {
}
@Override
public void adjustCosts(Ability ability, Game game) {
}
@Override
public void adjustTargets(Ability ability, Game game) {
}
@Override
public UUID getId() {
return this.id;

View file

@ -235,14 +235,6 @@ public class Plane implements CommandObject {
public void setStartingLoyalty(int startingLoyalty) {
}
@Override
public void adjustCosts(Ability ability, Game game) {
}
@Override
public void adjustTargets(Ability ability, Game game) {
}
@Override
public UUID getId() {
return this.id;

View file

@ -815,20 +815,6 @@ public class Spell extends StackObjectImpl implements Card {
return spellCopy;
}
@Override
public void adjustCosts(Ability ability, Game game) {
if (card != null) {
card.adjustCosts(ability, game);
}
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (card != null) {
card.adjustTargets(ability, game);
}
}
@Override
public boolean removeFromZone(Game game, Zone fromZone, Ability source) {
return card.removeFromZone(game, fromZone, source);

View file

@ -388,22 +388,6 @@ public class StackAbility extends StackObjectImpl implements Ability {
this.expansionSetCode = expansionSetCode;
}
@Override
public void adjustCosts(Ability ability, Game game) {
Card card = game.getCard(ability.getSourceId());
if (card != null) {
card.adjustCosts(ability, game);
}
}
@Override
public void adjustTargets(Ability ability, Game game) {
Card card = game.getCard(ability.getSourceId());
if (card != null) {
card.adjustTargets(ability, game);
}
}
@Override
public boolean checkIfClause(Game game) {
return true;

View file

@ -1521,10 +1521,7 @@ public abstract class PlayerImpl implements Player, Serializable {
//20091005 - 603.3c, 603.3d
int bookmark = game.bookmarkState();
TriggeredAbility ability = triggeredAbility.copy();
MageObject sourceObject = ability.getSourceObject(game);
if (sourceObject != null) {
sourceObject.adjustTargets(ability, game);
}
ability.adjustTargets(game);
UUID triggerId = null;
if (ability.canChooseTarget(game, playerId)) {
if (ability.isUsesStack()) {
@ -3473,7 +3470,7 @@ public abstract class PlayerImpl implements Player, Serializable {
return false;
}
if (availableMana != null) {
sourceObject.adjustCosts(copy, game);
copy.adjustCosts(game);
game.getContinuousEffects().costModification(copy, game);
}
boolean canBeCastRegularly = true;
@ -3632,7 +3629,7 @@ public abstract class PlayerImpl implements Player, Serializable {
copyAbility = ability.copy();
copyAbility.getManaCostsToPay().clear();
copyAbility.getManaCostsToPay().addAll(manaCosts.copy());
sourceObject.adjustCosts(copyAbility, game);
copyAbility.adjustCosts(game);
game.getContinuousEffects().costModification(copyAbility, game);
// reduced all cost
@ -3681,7 +3678,7 @@ public abstract class PlayerImpl implements Player, Serializable {
copyAbility = ability.copy();
copyAbility.getManaCostsToPay().clear();
copyAbility.getManaCostsToPay().addAll(manaCosts.copy());
sourceObject.adjustCosts(copyAbility, game);
copyAbility.adjustCosts(game);
game.getContinuousEffects().costModification(copyAbility, game);
// reduced all cost