* GUI: added card icon for announced X value (card cast);

This commit is contained in:
Oleg Agafonov 2021-07-19 13:40:21 +04:00
parent fc0ff6c22d
commit 76082e1d7a
9 changed files with 353 additions and 12 deletions

View file

@ -7,7 +7,9 @@ import mage.game.Game;
import mage.watchers.common.ManaSpentToCastWatcher;
public enum ManacostVariableValue implements DynamicValue {
REGULAR, ETB;
REGULAR, // if you need X on cast/activate (in stack)
ETB; // if you need X after ETB (in battlefield)
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
@ -15,7 +17,10 @@ public enum ManacostVariableValue implements DynamicValue {
return sourceAbility.getManaCostsToPay().getX();
}
ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class);
return watcher != null ? watcher.getAndResetLastXValue(sourceAbility.getSourceId()) : sourceAbility.getManaCostsToPay().getX();
if (watcher != null) {
return watcher.getAndResetLastXValue(sourceAbility);
}
return 0;
}
@Override

View file

@ -32,6 +32,7 @@ public enum CardIconType {
ABILITY_CLASS_LEVEL("prepared/hexagon-fill.svg", CardIconCategory.ABILITY, 100),
//
OTHER_FACEDOWN("prepared/reply-fill.svg", CardIconCategory.ABILITY, 100),
OTHER_COST_X("prepared/square-fill.svg", CardIconCategory.ABILITY, 100),
//
SYSTEM_COMBINED("prepared/square-fill.svg", CardIconCategory.SYSTEM, 1000), // inner usage, must use last order
SYSTEM_DEBUG("prepared/link.svg", CardIconCategory.SYSTEM, 1000); // used for test render dialog

View file

@ -6,7 +6,7 @@ import mage.abilities.icon.CardIconType;
/**
* @author JayDi85
*/
public enum FaceDownStatusIcon implements CardIcon {
public enum FaceDownCardIcon implements CardIcon {
instance;
@Override

View file

@ -0,0 +1,16 @@
package mage.abilities.icon.other;
import mage.abilities.icon.CardIconImpl;
import mage.abilities.icon.CardIconType;
/**
* Showing x cost value
*
* @author JayDi85
*/
public class VariableCostCardIcon extends CardIconImpl {
public VariableCostCardIcon(int costX) {
super(CardIconType.OTHER_COST_X, "Announced X = " + costX, "x=" + costX);
}
}

View file

@ -81,7 +81,11 @@ public class CopyTokenFunction implements Function<Token, Card> {
for (Ability ability0 : sourceObj.getAbilities()) {
Ability ability = ability0.copy();
ability.newOriginalId(); // The token is independant from the copy from object so it need a new original Id, otherwise there are problems to check for created continuous effects to check if the source (the Token) has still this ability
// The token is independant from the copy from object so it need a new original Id,
// otherwise there are problems to check for created continuous effects to check if
// the source (the Token) has still this ability
ability.newOriginalId();
target.addAbility(ability);
}

View file

@ -1,6 +1,7 @@
package mage.watchers.common;
import mage.Mana;
import mage.abilities.Ability;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
@ -51,8 +52,14 @@ public class ManaSpentToCastWatcher extends Watcher {
return manaMap.getOrDefault(sourceId, null);
}
public int getAndResetLastXValue(UUID sourceId) {
return xValueMap.getOrDefault(sourceId, 0);
public int getAndResetLastXValue(Ability source) {
if (xValueMap.containsKey(source.getSourceId())) {
// cast normal way
return xValueMap.get(source.getSourceId());
} else {
// put to battlefield without cast (example: copied spell must keep announced X)
return source.getManaCostsToPay().getX();
}
}
@Override