use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class BasriKetTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int attackingNonTokens = 0;
for (UUID attacker : game.getCombat().getAttackers()) {
Permanent permanent = game.getPermanent(attacker);
if (filter.match(permanent, game)) {
attackingNonTokens++;
}
}
if (attackingNonTokens > 0) {
this.getEffects().clear();
addEffect(new CreateTokenEffect(new SoldierToken(), attackingNonTokens, true, true));
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenEffect 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;
}
use of mage.abilities.effects.common.CreateTokenEffect in project mage by magefree.
the class BrokenVisageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent != null) {
permanent.destroy(source, game, true);
CreateTokenEffect effect = new CreateTokenEffect(new BrokenVisageSpiritToken(permanent.getPower().getValue(), permanent.getToughness().getValue()));
effect.apply(game, source);
for (UUID tokenId : effect.getLastAddedTokenIds()) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
return true;
}
Aggregations