mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08: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
|
// calculate the mana that can be used for the x part
|
||||||
int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().manaValue();
|
int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().manaValue();
|
||||||
|
|
||||||
Card card = game.getCard(ability.getSourceId());
|
if (numAvailable > 0) {
|
||||||
if (card != null && numAvailable > 0) {
|
|
||||||
// check if variable mana costs is included and get the multiplier
|
// check if variable mana costs is included and get the multiplier
|
||||||
VariableManaCost variableManaCost = null;
|
VariableManaCost variableManaCost = null;
|
||||||
for (ManaCost cost : ability.getManaCostsToPay()) {
|
for (ManaCost cost : ability.getManaCostsToPay()) {
|
||||||
|
|
@ -159,7 +158,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
|
||||||
if (varCost != null) {
|
if (varCost != null) {
|
||||||
varCost.setPaid();
|
varCost.setPaid();
|
||||||
}
|
}
|
||||||
card.adjustTargets(newAbility, game);
|
newAbility.adjustTargets(game);
|
||||||
// add the different possible target option for the specific X value
|
// add the different possible target option for the specific X value
|
||||||
if (!newAbility.getTargets().getUnchosen().isEmpty()) {
|
if (!newAbility.getTargets().getUnchosen().isEmpty()) {
|
||||||
addTargetOptions(options, newAbility, targetNum, game);
|
addTargetOptions(options, newAbility, targetNum, game);
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ class CardCanBeCastPredicate implements Predicate<Card> {
|
||||||
public boolean apply(Card input, Game game) {
|
public boolean apply(Card input, Game game) {
|
||||||
SpellAbility ability = input.getSpellAbility().copy();
|
SpellAbility ability = input.getSpellAbility().copy();
|
||||||
ability.setControllerId(controllerId);
|
ability.setControllerId(controllerId);
|
||||||
input.adjustTargets(ability, game);
|
ability.adjustTargets(game);
|
||||||
return ability.canChooseTarget(game, controllerId);
|
return ability.canChooseTarget(game, controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,25 +116,6 @@ public interface MageObject extends MageItem, Serializable, Copyable<MageObject>
|
||||||
|
|
||||||
void setStartingLoyalty(int startingLoyalty);
|
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)
|
// memory object copy (not mtg)
|
||||||
@Override
|
@Override
|
||||||
MageObject copy();
|
MageObject copy();
|
||||||
|
|
|
||||||
|
|
@ -234,16 +234,6 @@ public abstract class MageObjectImpl implements MageObject {
|
||||||
return 0;
|
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
|
@Override
|
||||||
public boolean hasSubtype(SubType value, Game game) {
|
public boolean hasSubtype(SubType value, Game game) {
|
||||||
if (value == null) {
|
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
|
// 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.)
|
// the stack until the spell has finished being cast.)
|
||||||
|
|
||||||
if (sourceObject != null && this.getAbilityType() != AbilityType.TRIGGERED) { // triggered abilities check this already in playerImpl.triggerAbility
|
if (this.getAbilityType() != AbilityType.TRIGGERED) { // triggered abilities check this already in playerImpl.triggerAbility
|
||||||
sourceObject.adjustTargets(this, game);
|
adjustTargets(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getTargets().isEmpty()) {
|
if (!getTargets().isEmpty()) {
|
||||||
|
|
@ -387,8 +387,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
boolean needCostModification = !CardUtil.isFusedPartAbility(this, game);
|
boolean needCostModification = !CardUtil.isFusedPartAbility(this, game);
|
||||||
|
|
||||||
//20101001 - 601.2e
|
//20101001 - 601.2e
|
||||||
if (needCostModification && sourceObject != null) {
|
if (needCostModification) {
|
||||||
sourceObject.adjustCosts(this, game); // still needed for CostAdjuster objects (to handle some types of dynamic costs)
|
adjustCosts(game); // still needed for CostAdjuster objects (to handle some types of dynamic costs)
|
||||||
game.getContinuousEffects().costModification(this, game);
|
game.getContinuousEffects().costModification(this, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class PayLoyaltyCost extends CostImpl {
|
||||||
// apply cost modification
|
// apply cost modification
|
||||||
if (ability instanceof LoyaltyAbility) {
|
if (ability instanceof LoyaltyAbility) {
|
||||||
LoyaltyAbility copiedAbility = ((LoyaltyAbility) ability).copy();
|
LoyaltyAbility copiedAbility = ((LoyaltyAbility) ability).copy();
|
||||||
planeswalker.adjustCosts(copiedAbility, game);
|
copiedAbility.adjustCosts(game);
|
||||||
game.getContinuousEffects().costModification(copiedAbility, game);
|
game.getContinuousEffects().costModification(copiedAbility, game);
|
||||||
loyaltyCost = 0;
|
loyaltyCost = 0;
|
||||||
for (Cost cost : copiedAbility.getCosts()) {
|
for (Cost cost : copiedAbility.getCosts()) {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class PayVariableLoyaltyCost extends VariableCostImpl {
|
||||||
// apply cost modification
|
// apply cost modification
|
||||||
if (source instanceof LoyaltyAbility) {
|
if (source instanceof LoyaltyAbility) {
|
||||||
LoyaltyAbility copiedAbility = ((LoyaltyAbility) source).copy();
|
LoyaltyAbility copiedAbility = ((LoyaltyAbility) source).copy();
|
||||||
permanent.adjustCosts(copiedAbility, game);
|
copiedAbility.adjustCosts(game);
|
||||||
game.getContinuousEffects().costModification(copiedAbility, game);
|
game.getContinuousEffects().costModification(copiedAbility, game);
|
||||||
for (Cost cost : copiedAbility.getCosts()) {
|
for (Cost cost : copiedAbility.getCosts()) {
|
||||||
if (cost instanceof PayVariableLoyaltyCost) {
|
if (cost instanceof PayVariableLoyaltyCost) {
|
||||||
|
|
|
||||||
|
|
@ -222,14 +222,6 @@ public abstract class Designation implements MageObject {
|
||||||
public void setStartingLoyalty(int startingLoyalty) {
|
public void setStartingLoyalty(int startingLoyalty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getZoneChangeCounter(Game game) {
|
public int getZoneChangeCounter(Game game) {
|
||||||
return 1; // Emblems can't move zones until now so return always 1
|
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) {
|
public void setStartingLoyalty(int startingLoyalty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return sourceObject.getId();
|
return sourceObject.getId();
|
||||||
|
|
|
||||||
|
|
@ -317,14 +317,6 @@ public class Dungeon implements CommandObject {
|
||||||
public void setStartingLoyalty(int startingLoyalty) {
|
public void setStartingLoyalty(int startingLoyalty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
|
|
|
||||||
|
|
@ -226,14 +226,6 @@ public class Emblem implements CommandObject {
|
||||||
public void setStartingLoyalty(int startingLoyalty) {
|
public void setStartingLoyalty(int startingLoyalty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
|
|
|
||||||
|
|
@ -235,14 +235,6 @@ public class Plane implements CommandObject {
|
||||||
public void setStartingLoyalty(int startingLoyalty) {
|
public void setStartingLoyalty(int startingLoyalty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
|
|
|
||||||
|
|
@ -815,20 +815,6 @@ public class Spell extends StackObjectImpl implements Card {
|
||||||
return spellCopy;
|
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
|
@Override
|
||||||
public boolean removeFromZone(Game game, Zone fromZone, Ability source) {
|
public boolean removeFromZone(Game game, Zone fromZone, Ability source) {
|
||||||
return card.removeFromZone(game, fromZone, source);
|
return card.removeFromZone(game, fromZone, source);
|
||||||
|
|
|
||||||
|
|
@ -388,22 +388,6 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
||||||
this.expansionSetCode = expansionSetCode;
|
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
|
@Override
|
||||||
public boolean checkIfClause(Game game) {
|
public boolean checkIfClause(Game game) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1521,10 +1521,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
//20091005 - 603.3c, 603.3d
|
//20091005 - 603.3c, 603.3d
|
||||||
int bookmark = game.bookmarkState();
|
int bookmark = game.bookmarkState();
|
||||||
TriggeredAbility ability = triggeredAbility.copy();
|
TriggeredAbility ability = triggeredAbility.copy();
|
||||||
MageObject sourceObject = ability.getSourceObject(game);
|
ability.adjustTargets(game);
|
||||||
if (sourceObject != null) {
|
|
||||||
sourceObject.adjustTargets(ability, game);
|
|
||||||
}
|
|
||||||
UUID triggerId = null;
|
UUID triggerId = null;
|
||||||
if (ability.canChooseTarget(game, playerId)) {
|
if (ability.canChooseTarget(game, playerId)) {
|
||||||
if (ability.isUsesStack()) {
|
if (ability.isUsesStack()) {
|
||||||
|
|
@ -3473,7 +3470,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (availableMana != null) {
|
if (availableMana != null) {
|
||||||
sourceObject.adjustCosts(copy, game);
|
copy.adjustCosts(game);
|
||||||
game.getContinuousEffects().costModification(copy, game);
|
game.getContinuousEffects().costModification(copy, game);
|
||||||
}
|
}
|
||||||
boolean canBeCastRegularly = true;
|
boolean canBeCastRegularly = true;
|
||||||
|
|
@ -3632,7 +3629,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
copyAbility = ability.copy();
|
copyAbility = ability.copy();
|
||||||
copyAbility.getManaCostsToPay().clear();
|
copyAbility.getManaCostsToPay().clear();
|
||||||
copyAbility.getManaCostsToPay().addAll(manaCosts.copy());
|
copyAbility.getManaCostsToPay().addAll(manaCosts.copy());
|
||||||
sourceObject.adjustCosts(copyAbility, game);
|
copyAbility.adjustCosts(game);
|
||||||
game.getContinuousEffects().costModification(copyAbility, game);
|
game.getContinuousEffects().costModification(copyAbility, game);
|
||||||
|
|
||||||
// reduced all cost
|
// reduced all cost
|
||||||
|
|
@ -3681,7 +3678,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
copyAbility = ability.copy();
|
copyAbility = ability.copy();
|
||||||
copyAbility.getManaCostsToPay().clear();
|
copyAbility.getManaCostsToPay().clear();
|
||||||
copyAbility.getManaCostsToPay().addAll(manaCosts.copy());
|
copyAbility.getManaCostsToPay().addAll(manaCosts.copy());
|
||||||
sourceObject.adjustCosts(copyAbility, game);
|
copyAbility.adjustCosts(game);
|
||||||
game.getContinuousEffects().costModification(copyAbility, game);
|
game.getContinuousEffects().costModification(copyAbility, game);
|
||||||
|
|
||||||
// reduced all cost
|
// reduced all cost
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue