[SNC] Implemented Riveteers Ascendancy

This commit is contained in:
Evan Kranzler 2022-04-22 09:17:09 -04:00
parent a3b1b825c0
commit 0b50f15923
8 changed files with 179 additions and 149 deletions

View file

@ -24,6 +24,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
protected boolean optional;
protected boolean leavesTheBattlefieldTrigger;
private boolean triggersOnce = false;
private boolean doOnlyOnce = false;
private GameEvent triggerEvent = null;
private String triggerPhrase = null;
@ -52,6 +53,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
this.optional = ability.optional;
this.leavesTheBattlefieldTrigger = ability.leavesTheBattlefieldTrigger;
this.triggersOnce = ability.triggersOnce;
this.doOnlyOnce = ability.doOnlyOnce;
this.triggerPhrase = ability.triggerPhrase;
}
@ -105,6 +107,23 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
return this;
}
@Override
public boolean checkUsedAlready(Game game) {
if (!doOnlyOnce) {
return true;
}
Integer lastTurnUsed = (Integer) game.getState().getValue(
CardUtil.getCardZoneString("lastTurnUsed" + originalId, sourceId, game)
);
return lastTurnUsed == null || lastTurnUsed != game.getTurnNum();
}
public TriggeredAbility setDoOnlyOnce(boolean doOnlyOnce) {
this.optional = true;
this.doOnlyOnce = doOnlyOnce;
return this;
}
@Override
public boolean checkInterveningIfClause(Game game) {
return true;
@ -112,22 +131,30 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
@Override
public boolean resolve(Game game) {
if (!checkInterveningIfClause(game)) {
return false;
}
if (isOptional()) {
MageObject object = game.getObject(getSourceId());
Player player = game.getPlayer(this.getControllerId());
if (player != null && object != null) {
if (!player.chooseUse(getEffects().getOutcome(this), this.getRule(object.getLogName()), this, game)) {
return false;
}
} else {
if (player == null || object == null
|| !player.chooseUse(
getEffects().getOutcome(this),
this.getRule(object.getLogName()), this, game
)) {
return false;
}
}
//20091005 - 603.4
if (checkInterveningIfClause(game)) {
return super.resolve(game);
if (!super.resolve(game)) {
return false;
}
return false;
if (doOnlyOnce) {
game.getState().setValue(CardUtil.getCardZoneString(
"lastTurnUsed" + originalId, sourceId, game
), game.getTurnNum());
}
return true;
}
@Override
@ -182,6 +209,9 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
if (triggersOnce) {
sb.append(" This ability triggers only once each turn.");
}
if (doOnlyOnce) {
sb.append(" Do this only once each turn.");
}
}
String prefix;
if (abilityWord != null) {