forked from External/mage
Tyvar Kell and gain ability fixes:
* GainAbilityTargetEffect - reworked to support static/dynamic targets, added support of spells (card + related permanent); * SpellCastControllerTriggeredAbility - now it can setup the target to a card instead a spell; * Added checks/errors on wrong ability adding code (example: if you add permanent's ability by game state instead permanent's method); * Tyvar Kell Emblem now use a standard code; * Test framework: added additional logs for some errors;
This commit is contained in:
parent
f131fd0d12
commit
6dcbcbe962
13 changed files with 291 additions and 140 deletions
|
|
@ -15,14 +15,14 @@ import mage.target.targetpointer.FixedTarget;
|
|||
public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private static final FilterSpell spellCard = new FilterSpell("a spell");
|
||||
|
||||
protected FilterSpell filter;
|
||||
protected String rule;
|
||||
|
||||
/**
|
||||
* If true, the source that triggered the ability will be set as target to
|
||||
* effect.
|
||||
*/
|
||||
// The source SPELL that triggered the ability will be set as target to effect
|
||||
protected boolean rememberSource = false;
|
||||
// Use it if you want remember CARD instead spell
|
||||
protected boolean rememberSourceAsCard = false;
|
||||
|
||||
public SpellCastControllerTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(Zone.BATTLEFIELD, effect, spellCard, optional, false);
|
||||
|
|
@ -42,16 +42,22 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
public SpellCastControllerTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, boolean rememberSource) {
|
||||
this(zone, effect, filter, optional, rememberSource, false);
|
||||
}
|
||||
|
||||
public SpellCastControllerTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, boolean rememberSource, boolean rememberSourceAsCard) {
|
||||
super(zone, effect, optional);
|
||||
this.filter = filter;
|
||||
this.rememberSource = rememberSource;
|
||||
this.rememberSourceAsCard = rememberSourceAsCard;
|
||||
}
|
||||
|
||||
public SpellCastControllerTriggeredAbility(final SpellCastControllerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter;
|
||||
this.rememberSource = ability.rememberSource;
|
||||
this.rule = ability.rule;
|
||||
this.rememberSource = ability.rememberSource;
|
||||
this.rememberSourceAsCard = ability.rememberSourceAsCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -65,7 +71,12 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) {
|
||||
if (rememberSource) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId(), game));
|
||||
if (rememberSourceAsCard) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getCard().getId(), game));
|
||||
} else {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId(), game));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue