mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
Added effect to Xantcha, Sleeper Agent. Now this creature can't attack its owner or planeswalkers its owner controls.
This commit is contained in:
parent
f4515efe41
commit
8c8a73c791
1 changed files with 47 additions and 3 deletions
|
@ -7,6 +7,7 @@ import mage.abilities.common.*;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.RestrictionEffect;
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.effects.common.InfoEffect;
|
import mage.abilities.effects.common.InfoEffect;
|
||||||
import mage.abilities.effects.common.LoseLifePermanentControllerEffect;
|
import mage.abilities.effects.common.LoseLifePermanentControllerEffect;
|
||||||
|
@ -42,10 +43,13 @@ public final class XantchaSleeperAgent extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Xantcha attacks each combat if able and can’t attack its owner or planeswalkers its owner controls.
|
// Xantcha attacks each combat if able and can’t attack its owner or planeswalkers its owner controls.
|
||||||
this.addAbility(new AttacksEachCombatStaticAbility());
|
ability = new AttacksEachCombatStaticAbility();
|
||||||
|
Effect effect = new XantchaSleeperAgentAttackRestrictionEffect();
|
||||||
|
ability.addEffect(effect);
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
// {3}: Xantcha’s controller loses 2 life and you draw a card. Any player may activate this ability.
|
// {3}: Xantcha’s controller loses 2 life and you draw a card. Any player may activate this ability.
|
||||||
Effect effect = new LoseLifePermanentControllerEffect(2);
|
effect = new LoseLifePermanentControllerEffect(2);
|
||||||
effect.setText("Xantcha’s controller loses 2 life");
|
effect.setText("Xantcha’s controller loses 2 life");
|
||||||
SimpleActivatedAbility simpleAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{3}"));
|
SimpleActivatedAbility simpleAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{3}"));
|
||||||
|
|
||||||
|
@ -96,3 +100,43 @@ class XantchaSleeperAgentChangeControlEffect extends ContinuousEffectImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class XantchaSleeperAgentAttackRestrictionEffect extends RestrictionEffect {
|
||||||
|
|
||||||
|
XantchaSleeperAgentAttackRestrictionEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield);
|
||||||
|
staticText = "and can't attack its owner or planeswalkers its owner controls.";
|
||||||
|
}
|
||||||
|
|
||||||
|
XantchaSleeperAgentAttackRestrictionEffect(final XantchaSleeperAgentAttackRestrictionEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XantchaSleeperAgentAttackRestrictionEffect copy() {
|
||||||
|
return new XantchaSleeperAgentAttackRestrictionEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) {
|
||||||
|
|
||||||
|
boolean allowAttack = true;
|
||||||
|
UUID ownerPlayerId = source.getSourcePermanentIfItStillExists(game).getOwnerId();
|
||||||
|
|
||||||
|
if (defenderId.equals(ownerPlayerId)) {
|
||||||
|
allowAttack = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Permanent planeswalker = game.getPermanent(defenderId);
|
||||||
|
if (planeswalker != null && planeswalker.isControlledBy(ownerPlayerId)) {
|
||||||
|
allowAttack = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allowAttack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue