use of mage.game.permanent.token.GeminiEngineTwinToken in project mage by magefree.
the class GeminiEngineCreateTokenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Token token;
if (permanent != null) {
token = new GeminiEngineTwinToken(permanent.getPower().getValue(), permanent.getToughness().getValue());
} else {
token = new GeminiEngineTwinToken(0, 0);
}
token.putOntoBattlefield(1, game, source, source.getControllerId(), false, true);
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent tokenPerm = game.getPermanent(tokenId);
if (tokenPerm != null) {
Effect effect = new SacrificeTargetEffect("sacrifice " + tokenPerm.getLogName(), player.getId());
effect.setTargetPointer(new FixedTarget(tokenPerm, game));
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(effect), source);
}
}
return true;
}
Aggregations