use of mage.abilities.effects.common.LoseGameTargetPlayerEffect 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;
}
Aggregations