Search in sources :

Example 1 with ChainersTormentNightmareToken

use of mage.game.permanent.token.ChainersTormentNightmareToken in project mage by magefree.

the class ChainersTormentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = (int) Math.ceil((1.0 * Math.max(0, player.getLife())) / 2);
    CreateTokenEffect effect = new CreateTokenEffect(new ChainersTormentNightmareToken(xValue));
    if (effect.apply(game, source)) {
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent token = game.getPermanentOrLKIBattlefield(tokenId);
            if (token != null) {
                player.damage(xValue, tokenId, source, game);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ChainersTormentNightmareToken(mage.game.permanent.token.ChainersTormentNightmareToken) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 Permanent (mage.game.permanent.Permanent)1 ChainersTormentNightmareToken (mage.game.permanent.token.ChainersTormentNightmareToken)1 Player (mage.players.Player)1