MayPlay: fixed mayPlay with multiple static abilities

This commit is contained in:
Hanmac
2018-04-14 09:24:26 +02:00
parent a280772be0
commit 32737ed9a3
6 changed files with 34 additions and 13 deletions

View File

@@ -177,6 +177,10 @@ public final class GameActionUtil {
} else { } else {
sb.append(host); sb.append(host);
} }
if (o.getAbility().hasParam("MayPlayText")) {
sb.append(" (").append(o.getAbility().getParam("MayPlayText")).append(")");
}
} }
sb.append(o.toString(false)); sb.append(o.toString(false));
newSA.setDescription(sb.toString()); newSA.setDescription(sb.toString());

View File

@@ -111,8 +111,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private GameEntity mustAttackEntity = null; private GameEntity mustAttackEntity = null;
private GameEntity mustAttackEntityThisTurn = null; private GameEntity mustAttackEntityThisTurn = null;
private final Map<StaticAbility, CardPlayOption> mayPlay = Maps.newTreeMap(); private final Map<StaticAbility, CardPlayOption> mayPlay = Maps.newHashMap();
private int mayPlayTurn = 0;
// changes by AF animate and continuous static effects - timestamp is the key of maps // changes by AF animate and continuous static effects - timestamp is the key of maps
private final Map<Long, CardChangedType> changedCardTypes = Maps.newTreeMap(); private final Map<Long, CardChangedType> changedCardTypes = Maps.newTreeMap();
@@ -2459,16 +2458,10 @@ public class Card extends GameEntity implements Comparable<Card> {
this.mayPlay.remove(sta); this.mayPlay.remove(sta);
} }
public int getMayPlayTurn() {
return mayPlayTurn;
}
public void incMayPlayTurn() {
this.mayPlayTurn++;
}
public void resetMayPlayTurn() { public void resetMayPlayTurn() {
this.mayPlayTurn = 0; for (StaticAbility sta : getStaticAbilities()) {
sta.resetMayPlayTurn();
}
} }
public final CardCollectionView getEquippedBy(boolean allowModify) { public final CardCollectionView getEquippedBy(boolean allowModify) {

View File

@@ -53,6 +53,7 @@ public class StaticAbility extends CardTraitBase implements Comparable<StaticAbi
private final Set<StaticAbilityLayer> layers; private final Set<StaticAbilityLayer> layers;
private CardCollectionView ignoreEffectCards = new CardCollection(); private CardCollectionView ignoreEffectCards = new CardCollection();
private final List<Player> ignoreEffectPlayers = Lists.newArrayList(); private final List<Player> ignoreEffectPlayers = Lists.newArrayList();
private int mayPlayTurn = 0;
/** /**
* <p> * <p>
@@ -724,6 +725,19 @@ public class StaticAbility extends CardTraitBase implements Comparable<StaticAbi
return layers; return layers;
} }
public int getMayPlayTurn() {
return mayPlayTurn;
}
public void incMayPlayTurn() {
this.mayPlayTurn++;
}
public void resetMayPlayTurn() {
this.mayPlayTurn = 0;
}
@Override @Override
public int compareTo(StaticAbility arg0) { public int compareTo(StaticAbility arg0) {
return getHostCard().compareTo(arg0.getHostCard()); return getHostCard().compareTo(arg0.getHostCard());

View File

@@ -750,7 +750,7 @@ public final class StaticAbilityContinuous {
affectedCard.setMayLookAt(p, true); affectedCard.setMayLookAt(p, true);
} }
} }
if (controllerMayPlay && (mayPlayLimit == null || hostCard.getMayPlayTurn() < mayPlayLimit)) { if (controllerMayPlay && (mayPlayLimit == null || stAb.getMayPlayTurn() < mayPlayLimit)) {
Player mayPlayController = params.containsKey("MayPlayCardOwner") ? affectedCard.getOwner() : controller; Player mayPlayController = params.containsKey("MayPlayCardOwner") ? affectedCard.getOwner() : controller;
affectedCard.setMayPlay(mayPlayController, mayPlayWithoutManaCost, mayPlayAltManaCost, mayPlayWithFlash, mayPlayGrantZonePermissions, stAb); affectedCard.setMayPlay(mayPlayController, mayPlayWithoutManaCost, mayPlayAltManaCost, mayPlayWithFlash, mayPlayGrantZonePermissions, stAb);
} }

View File

@@ -457,7 +457,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
} }
if (sp.isSpell() && sp.getMayPlay() != null) { if (sp.isSpell() && sp.getMayPlay() != null) {
sp.getMayPlay().getHostCard().incMayPlayTurn(); sp.getMayPlay().incMayPlayTurn();
} }
final SpellAbilityStackInstance si = new SpellAbilityStackInstance(sp); final SpellAbilityStackInstance si = new SpellAbilityStackInstance(sp);

View File

@@ -0,0 +1,10 @@
Name:Muldrotha, the Gravetide
ManaCost: 3 B G U
Types:Legendary Creature Elemental Avatar
PT:6/6
S:Mode$ Continuous | Affected$ Land.YouCtrl | Condition$ PlayerTurn | MayPlay$ True | MayPlayLimit$ 1 | MayPlayText$ Land | EffectZone$ Battlefield | AffectedZone$ Graveyard | Description$ During each of your turns, you may play up to one permanent card of each permanent type from your graveyard. (If a card has multiple permanent types, choose one as you play it.)
S:Mode$ Continuous | Affected$ Creature.YouCtrl | Condition$ PlayerTurn | MayPlay$ True | MayPlayLimit$ 1 | MayPlayText$ Creature | EffectZone$ Battlefield | AffectedZone$ Graveyard
S:Mode$ Continuous | Affected$ Planeswalker.YouCtrl | Condition$ PlayerTurn | MayPlay$ True | MayPlayLimit$ 1 | MayPlayText$ Planeswalker | EffectZone$ Battlefield | AffectedZone$ Graveyard
S:Mode$ Continuous | Affected$ Artifact.YouCtrl | Condition$ PlayerTurn | MayPlay$ True | MayPlayLimit$ 1 | MayPlayText$ Artifact | EffectZone$ Battlefield | AffectedZone$ Graveyard
S:Mode$ Continuous | Affected$ Enchantment.YouCtrl | Condition$ PlayerTurn | MayPlay$ True | MayPlayLimit$ 1 | MayPlayText$ Enchantment | EffectZone$ Battlefield | AffectedZone$ Graveyard
Oracle:During each of your turns, you may play up to one permanent card of each permanent type from your graveyard. (If a card has multiple permanent types, choose one as you play it.)