forked from External/mage
[FIC] Implement G'raha Tia, Scion Reborn, rework DoIfCostPaid and "do only once" effects (#13660)
* rework effects with DoIfCostPaid and "do this only once each turn" * [FIC] Implement G'raha Tia, Scion Reborn * [FIC] Implement Emet Selch of the Third Seat * rework Emet-Selch * add test * add static methods to handle whether ability was used this turn
This commit is contained in:
parent
2bbc2cba00
commit
9e2a1a59e0
11 changed files with 361 additions and 50 deletions
|
|
@ -156,13 +156,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
|
||||
@Override
|
||||
public boolean checkUsedAlready(Game game) {
|
||||
if (!doOnlyOnceEachTurn) {
|
||||
return false;
|
||||
}
|
||||
Integer lastTurnUsed = (Integer) game.getState().getValue(
|
||||
CardUtil.getCardZoneString("lastTurnUsed" + getOriginalId(), sourceId, game)
|
||||
);
|
||||
return lastTurnUsed != null && lastTurnUsed == game.getTurnNum();
|
||||
return doOnlyOnceEachTurn && TriggeredAbility.checkDidThisTurn(this, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -209,7 +203,9 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
@Override
|
||||
public TriggeredAbility setDoOnlyOnceEachTurn(boolean doOnlyOnce) {
|
||||
this.doOnlyOnceEachTurn = doOnlyOnce;
|
||||
setOptional();
|
||||
if (CardUtil.castStream(this.getAllEffects(), DoIfCostPaid.class).noneMatch(DoIfCostPaid::isOptional)) {
|
||||
this.optional = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -268,11 +264,9 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (doOnlyOnceEachTurn) {
|
||||
game.getState().setValue(CardUtil.getCardZoneString(
|
||||
"lastTurnUsed" + getOriginalId(), sourceId, game
|
||||
), game.getTurnNum());
|
||||
if (doOnlyOnceEachTurn) {
|
||||
TriggeredAbility.setDidThisTurn(this, game);
|
||||
}
|
||||
}
|
||||
//20091005 - 603.4
|
||||
if (!super.resolve(game)) {
|
||||
|
|
@ -387,6 +381,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
|
||||
private static boolean startsWithVerb(String ruleLow) {
|
||||
return ruleLow.startsWith("attach")
|
||||
|| ruleLow.startsWith("cast")
|
||||
|| ruleLow.startsWith("change")
|
||||
|| ruleLow.startsWith("counter")
|
||||
|| ruleLow.startsWith("create")
|
||||
|
|
@ -501,20 +496,6 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
return optional;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggeredAbility setOptional() {
|
||||
this.optional = true;
|
||||
|
||||
if (getEffects().stream().anyMatch(
|
||||
effect -> effect instanceof DoIfCostPaid && ((DoIfCostPaid) effect).isOptional())) {
|
||||
throw new IllegalArgumentException(
|
||||
"DoIfCostPaid effect must have only one optional settings, but it have two (trigger + DoIfCostPaid): "
|
||||
+ this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggeredAbilityImpl setAbilityWord(AbilityWord abilityWord) {
|
||||
super.setAbilityWord(abilityWord);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue