[PIP] Implement Shaun, Father of Synths (#12109)

* Added method to set triggered abilities to optional

* TokenCopy effect now copies permanentModifier

* Implemented Shaun, Father of Synths

* remove TODO

* Made `setOptional` chainable
This commit is contained in:
Alexander Novotny 2024-04-12 19:41:58 -04:00 committed by GitHub
parent 96939b31eb
commit 8271686cb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 101 additions and 1 deletions

View file

@ -46,6 +46,8 @@ public interface TriggeredAbility extends Ability {
boolean isOptional();
TriggeredAbility setOptional();
boolean isLeavesTheBattlefieldTrigger();
void setLeavesTheBattlefieldTrigger(boolean leavesTheBattlefieldTrigger);

View file

@ -363,6 +363,21 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
return optional;
}
@Override
public TriggeredAbility setOptional() {
this.optional = true;
if (getEffects().stream().filter(
effect -> effect instanceof DoIfCostPaid && (this.optional && ((DoIfCostPaid) effect).isOptional()))
.findAny().isPresent()) {
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);

View file

@ -61,7 +61,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
private final int tokenPower;
private final int tokenToughness;
private boolean useLKI = false;
private PermanentModifier permanentModifier = null; // TODO: miss copy constructor? Make serializable?
private PermanentModifier permanentModifier = null;
// TODO: These constructors are a mess. Copy effects need to be reworked altogether, hopefully clean it up then.
@ -154,6 +154,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
this.tokenPower = effect.tokenPower;
this.tokenToughness = effect.tokenToughness;
this.useLKI = effect.useLKI;
this.permanentModifier = effect.permanentModifier;
}
@Override