[NCC] Implement several cards (#9328)

Many associated refactors too. See full PR for detail.
This commit is contained in:
Alex Vasile 2022-09-22 21:38:29 -04:00 committed by GitHub
parent b7151cfa58
commit fd16f2a16b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
104 changed files with 6091 additions and 1069 deletions

View file

@ -18,37 +18,60 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
protected FilterSpell filter;
protected SetTargetPointer setTargetPointer;
private final boolean onlyFromNonHand;
public SpellCastOpponentTriggeredAbility(Effect effect, boolean optional) {
this(effect, StaticFilters.FILTER_SPELL_A, optional);
this(effect, optional, false);
}
public SpellCastOpponentTriggeredAbility(Effect effect, boolean optional, boolean onlyFromNonHand) {
this(effect, StaticFilters.FILTER_SPELL_A, optional, onlyFromNonHand);
}
public SpellCastOpponentTriggeredAbility(Effect effect, FilterSpell filter, boolean optional) {
this(Zone.BATTLEFIELD, effect, filter, optional);
this(effect, filter, optional, false);
}
public SpellCastOpponentTriggeredAbility(Effect effect, FilterSpell filter, boolean optional, boolean onlyFromNonHand) {
this(Zone.BATTLEFIELD, effect, filter, optional, onlyFromNonHand);
}
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional) {
this(zone, effect, filter, optional, SetTargetPointer.NONE);
this(zone, effect, filter, optional, false);
}
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, boolean onlyFromNonHand) {
this(zone, effect, filter, optional, SetTargetPointer.NONE, onlyFromNonHand);
}
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, SetTargetPointer setTargetPointer) {
this(zone, effect, filter, optional, setTargetPointer, false);
}
/**
* @param zone
* @param effect
* @param filter
* @param optional
* @param setTargetPointer Supported: SPELL, PLAYER
* @param zone The zone in which the source permanent has to be in for the ability to trigger
* @param effect The effect to apply if condition is met
* @param filter Filter for matching the spell cast
* @param optional Whether the player can choose to apply the effect
* @param onlyFromNonHand Whether to trigger only when spells are cast from not the hand
* @param setTargetPointer Supported: SPELL, PLAYER
*/
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, SetTargetPointer setTargetPointer) {
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, SetTargetPointer setTargetPointer, boolean onlyFromNonHand) {
super(zone, effect, optional);
this.filter = filter;
this.setTargetPointer = setTargetPointer;
setTriggerPhrase("Whenever an opponent casts " + filter.getMessage() + ", ");
this.onlyFromNonHand = onlyFromNonHand;
setTriggerPhrase("Whenever an opponent casts "
+ filter.getMessage()
+ (onlyFromNonHand ? " from anywhere other than their hand" : "")
+ ", ");
}
public SpellCastOpponentTriggeredAbility(final SpellCastOpponentTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.setTargetPointer = ability.setTargetPointer;
this.onlyFromNonHand = ability.onlyFromNonHand;
}
@Override
@ -65,6 +88,11 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
if (!filter.match(spell, getControllerId(), this, game)) {
return false;
}
if (onlyFromNonHand && spell.getFromZone() == Zone.HAND) {
return false;
}
getEffects().setValue("spellCast", spell);
switch (setTargetPointer) {
case NONE: