mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
added cost adjustment framework
This commit is contained in:
parent
57470be67f
commit
9d9c7b0242
4 changed files with 66 additions and 34 deletions
|
|
@ -1,10 +1,8 @@
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.costs.CostAdjuster;
|
||||||
import mage.abilities.costs.Costs;
|
import mage.abilities.costs.Costs;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
|
|
@ -24,6 +22,10 @@ import mage.target.Targets;
|
||||||
import mage.target.targetadjustment.TargetAdjuster;
|
import mage.target.targetadjustment.TargetAdjuster;
|
||||||
import mage.watchers.Watcher;
|
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
|
* Practically everything in the game is started from an Ability. This interface
|
||||||
* describes what an Ability is composed of at the highest level.
|
* describes what an Ability is composed of at the highest level.
|
||||||
|
|
@ -44,10 +46,8 @@ public interface Ability extends Controllable, Serializable {
|
||||||
*
|
*
|
||||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
||||||
* mage.game.Game)
|
* mage.game.Game)
|
||||||
* @see
|
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
||||||
* mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||||
* @see
|
|
||||||
* mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
|
||||||
*/
|
*/
|
||||||
void newId();
|
void newId();
|
||||||
|
|
||||||
|
|
@ -56,10 +56,8 @@ public interface Ability extends Controllable, Serializable {
|
||||||
*
|
*
|
||||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
||||||
* mage.game.Game)
|
* mage.game.Game)
|
||||||
* @see
|
* @see mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
||||||
* mage.game.GameImpl#addTriggeredAbility(mage.abilities.TriggeredAbility)
|
* @see mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
||||||
* @see
|
|
||||||
* mage.game.GameImpl#addDelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)
|
|
||||||
*/
|
*/
|
||||||
void newOriginalId();
|
void newOriginalId();
|
||||||
|
|
||||||
|
|
@ -143,7 +141,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Method is unused, keep it around?
|
* TODO Method is unused, keep it around?
|
||||||
*
|
* <p>
|
||||||
* Gets all costs that are optional to this ability. These costs can be paid
|
* 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.
|
* in addition to other costs to have other effects put into place.
|
||||||
*
|
*
|
||||||
|
|
@ -208,7 +206,6 @@ public interface Ability extends Controllable, Serializable {
|
||||||
*
|
*
|
||||||
* @return The {@link java.util.UUID} of the first target within the targets
|
* @return The {@link java.util.UUID} of the first target within the targets
|
||||||
* list.
|
* list.
|
||||||
*
|
|
||||||
* @see mage.target.Target
|
* @see mage.target.Target
|
||||||
*/
|
*/
|
||||||
UUID getFirstTarget();
|
UUID getFirstTarget();
|
||||||
|
|
@ -270,13 +267,11 @@ public interface Ability extends Controllable, Serializable {
|
||||||
* activated within.
|
* activated within.
|
||||||
* @param noMana Whether or not {@link ManaCosts} have to be paid.
|
* @param noMana Whether or not {@link ManaCosts} have to be paid.
|
||||||
* @return True if this ability was successfully activated.
|
* @return True if this ability was successfully activated.
|
||||||
*
|
|
||||||
* @see mage.players.PlayerImpl#cast(mage.abilities.SpellAbility,
|
* @see mage.players.PlayerImpl#cast(mage.abilities.SpellAbility,
|
||||||
* mage.game.Game, boolean)
|
* mage.game.Game, boolean)
|
||||||
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
* @see mage.players.PlayerImpl#playAbility(mage.abilities.ActivatedAbility,
|
||||||
* mage.game.Game)
|
* mage.game.Game)
|
||||||
* @see
|
* @see mage.players.PlayerImpl#triggerAbility(mage.abilities.TriggeredAbility,
|
||||||
* mage.players.PlayerImpl#triggerAbility(mage.abilities.TriggeredAbility,
|
|
||||||
* mage.game.Game)
|
* mage.game.Game)
|
||||||
*/
|
*/
|
||||||
boolean activate(Game game, boolean noMana);
|
boolean activate(Game game, boolean noMana);
|
||||||
|
|
@ -290,9 +285,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
*
|
*
|
||||||
* @param game The {@link Game} for which this ability resolves within.
|
* @param game The {@link Game} for which this ability resolves within.
|
||||||
* @return Whether or not this ability successfully resolved.
|
* @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)
|
* mage.game.Game)
|
||||||
* @see mage.players.PlayerImpl#specialAction(mage.abilities.SpecialAction,
|
* @see mage.players.PlayerImpl#specialAction(mage.abilities.SpecialAction,
|
||||||
* mage.game.Game)
|
* mage.game.Game)
|
||||||
|
|
@ -380,7 +373,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for the ruleAtTheTop attribute
|
* Sets the value for the ruleAtTheTop attribute
|
||||||
*
|
* <p>
|
||||||
* true = show the rule at the top position of the rules
|
* true = show the rule at the top position of the rules
|
||||||
*
|
*
|
||||||
* @param ruleAtTheTop
|
* @param ruleAtTheTop
|
||||||
|
|
@ -398,7 +391,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for the worksFaceDown flag
|
* Sets the value for the worksFaceDown flag
|
||||||
*
|
* <p>
|
||||||
* true = the ability works also if the object is face down
|
* true = the ability works also if the object is face down
|
||||||
*
|
*
|
||||||
* @param worksFaceDown
|
* @param worksFaceDown
|
||||||
|
|
@ -414,7 +407,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for the ruleVisible attribute
|
* Sets the value for the ruleVisible attribute
|
||||||
*
|
* <p>
|
||||||
* true = rule will be shown for the card / permanent false = rule won't be
|
* true = rule will be shown for the card / permanent false = rule won't be
|
||||||
* shown
|
* shown
|
||||||
*
|
*
|
||||||
|
|
@ -432,7 +425,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for the additional costs rule attribute
|
* Sets the value for the additional costs rule attribute
|
||||||
*
|
* <p>
|
||||||
* true = rule will be shown for the card / permanent false = rule won't be
|
* true = rule will be shown for the card / permanent false = rule won't be
|
||||||
* shown
|
* shown
|
||||||
*
|
*
|
||||||
|
|
@ -451,7 +444,7 @@ public interface Ability extends Controllable, Serializable {
|
||||||
* Sets the ability word for the given ability. An ability word is a word
|
* Sets the ability word for the given ability. An ability word is a word
|
||||||
* that, in essence, groups, and reminds players of, cards that have a
|
* that, in essence, groups, and reminds players of, cards that have a
|
||||||
* common functionality and does not imply any particular rules.
|
* common functionality and does not imply any particular rules.
|
||||||
*
|
* <p>
|
||||||
* --- Not usable yet for rule text generation of triggered abilities ---
|
* --- Not usable yet for rule text generation of triggered abilities ---
|
||||||
*
|
*
|
||||||
* @param abilityWord
|
* @param abilityWord
|
||||||
|
|
@ -531,4 +524,10 @@ public interface Ability extends Controllable, Serializable {
|
||||||
TargetAdjuster getTargetAdjuster();
|
TargetAdjuster getTargetAdjuster();
|
||||||
|
|
||||||
void adjustTargets(Game game);
|
void adjustTargets(Game game);
|
||||||
|
|
||||||
|
void setCostAdjuster(CostAdjuster costAdjuster);
|
||||||
|
|
||||||
|
CostAdjuster getCostAdjuster();
|
||||||
|
|
||||||
|
void adjustCosts(Game game);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
|
@ -15,8 +11,8 @@ import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.Effects;
|
import mage.abilities.effects.Effects;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.mana.DynamicManaEffect;
|
|
||||||
import mage.abilities.effects.common.ManaEffect;
|
import mage.abilities.effects.common.ManaEffect;
|
||||||
|
import mage.abilities.effects.mana.DynamicManaEffect;
|
||||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.SplitCard;
|
import mage.cards.SplitCard;
|
||||||
|
|
@ -38,6 +34,11 @@ import mage.util.ThreadLocalStringBuilder;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
import org.apache.log4j.Logger;
|
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
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -73,6 +74,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
protected List<Ability> subAbilities = null;
|
protected List<Ability> subAbilities = null;
|
||||||
protected boolean canFizzle = true;
|
protected boolean canFizzle = true;
|
||||||
protected TargetAdjuster targetAdjuster = null;
|
protected TargetAdjuster targetAdjuster = null;
|
||||||
|
protected CostAdjuster costAdjuster = null;
|
||||||
|
|
||||||
public AbilityImpl(AbilityType abilityType, Zone zone) {
|
public AbilityImpl(AbilityType abilityType, Zone zone) {
|
||||||
this.id = UUID.randomUUID();
|
this.id = UUID.randomUUID();
|
||||||
|
|
@ -1240,4 +1242,21 @@ public abstract class AbilityImpl implements Ability {
|
||||||
targetAdjuster.adjustTargets(this, game);
|
targetAdjuster.adjustTargets(this, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCostAdjuster(CostAdjuster costAdjuster) {
|
||||||
|
this.costAdjuster = costAdjuster;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CostAdjuster getCostAdjuster() {
|
||||||
|
return costAdjuster;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustCosts(Game game) {
|
||||||
|
if (costAdjuster != null) {
|
||||||
|
costAdjuster.adjustCosts(this, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
Mage/src/main/java/mage/abilities/costs/CostAdjuster.java
Normal file
12
Mage/src/main/java/mage/abilities/costs/CostAdjuster.java
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
package mage.abilities.costs;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public interface CostAdjuster {
|
||||||
|
|
||||||
|
void adjustCosts(Ability ability, Game game);
|
||||||
|
}
|
||||||
|
|
@ -327,9 +327,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
return spellAbility;
|
return spellAbility;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public void adjustCosts(Ability ability, Game game) {
|
public void adjustCosts(Ability ability, Game game) {
|
||||||
// }
|
ability.adjustCosts(game);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
ability.adjustTargets(game);
|
ability.adjustTargets(game);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue