mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Remove obsolete adjustCosts and adjustTargets methods from MageObject interface
This commit is contained in:
parent
a5e21b8c9e
commit
79b7a0a627
15 changed files with 13 additions and 116 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue