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 {
sb.append(host);
}
if (o.getAbility().hasParam("MayPlayText")) {
sb.append(" (").append(o.getAbility().getParam("MayPlayText")).append(")");
}
}
sb.append(o.toString(false));
newSA.setDescription(sb.toString());

View File

@@ -111,8 +111,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private GameEntity mustAttackEntity = null;
private GameEntity mustAttackEntityThisTurn = null;
private final Map<StaticAbility, CardPlayOption> mayPlay = Maps.newTreeMap();
private int mayPlayTurn = 0;
private final Map<StaticAbility, CardPlayOption> mayPlay = Maps.newHashMap();
// changes by AF animate and continuous static effects - timestamp is the key of maps
private final Map<Long, CardChangedType> changedCardTypes = Maps.newTreeMap();
@@ -2459,16 +2458,10 @@ public class Card extends GameEntity implements Comparable<Card> {
this.mayPlay.remove(sta);
}
public int getMayPlayTurn() {
return mayPlayTurn;
}
public void incMayPlayTurn() {
this.mayPlayTurn++;
}
public void resetMayPlayTurn() {
this.mayPlayTurn = 0;
for (StaticAbility sta : getStaticAbilities()) {
sta.resetMayPlayTurn();
}
}
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 CardCollectionView ignoreEffectCards = new CardCollection();
private final List<Player> ignoreEffectPlayers = Lists.newArrayList();
private int mayPlayTurn = 0;
/**
* <p>
@@ -724,6 +725,19 @@ public class StaticAbility extends CardTraitBase implements Comparable<StaticAbi
return layers;
}
public int getMayPlayTurn() {
return mayPlayTurn;
}
public void incMayPlayTurn() {
this.mayPlayTurn++;
}
public void resetMayPlayTurn() {
this.mayPlayTurn = 0;
}
@Override
public int compareTo(StaticAbility arg0) {
return getHostCard().compareTo(arg0.getHostCard());

View File

@@ -750,7 +750,7 @@ public final class StaticAbilityContinuous {
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;
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) {
sp.getMayPlay().getHostCard().incMayPlayTurn();
sp.getMayPlay().incMayPlayTurn();
}
final SpellAbilityStackInstance si = new SpellAbilityStackInstance(sp);