use of mage.abilities.common.LeavesBattlefieldTriggeredAbility in project mage by magefree.
the class StanggExileTokenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceObject != null) {
CreateTokenEffect effect = new CreateTokenEffect(new StanggTwinToken());
effect.apply(game, source);
game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + sourceObject.getName());
sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
game.addEffect(continuousEffect, source);
}
return true;
}
return false;
}
use of mage.abilities.common.LeavesBattlefieldTriggeredAbility in project mage by magefree.
the class FormOfTheSquirrelCantCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player sourceController = game.getPlayer(source.getControllerId());
if (sourceController != null) {
CreateTokenEffect effect = new CreateTokenEffect(new SquirrelToken());
effect.apply(game, source);
game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
Effect loseGameEffect = new LoseGameTargetPlayerEffect();
loseGameEffect.setTargetPointer(new FixedTarget(sourceController.getId(), game));
LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(loseGameEffect, false);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
game.addEffect(continuousEffect, source);
}
return true;
}
return false;
}
use of mage.abilities.common.LeavesBattlefieldTriggeredAbility in project mage by magefree.
the class RuneswordCantBeRegeneratedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
Permanent targetObject = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (sourceObject != null && targetObject != null) {
Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + sourceObject.getName());
sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
triggerAbility.setRuleVisible(false);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.EndOfTurn);
continuousEffect.setTargetPointer(new FixedTarget(targetObject, game));
game.addEffect(continuousEffect, source);
return true;
}
return false;
}
use of mage.abilities.common.LeavesBattlefieldTriggeredAbility in project mage by magefree.
the class OutcomesTest method test_FromEffects_Default.
@Test
public void test_FromEffects_Default() {
Ability ability = new LeavesBattlefieldTriggeredAbility(null, false);
Assert.assertEquals(0, ability.getEffects().getOutcomeScore(ability));
Assert.assertEquals(Outcome.Detriment, ability.getEffects().getOutcome(ability));
Assert.assertEquals(Outcome.BoostCreature, ability.getEffects().getOutcome(ability, Outcome.BoostCreature));
}
Aggregations