use of mage.game.permanent.token.DemonFlyingToken in project mage by magefree.
the class TivashGloomSummonerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
if (player == null || watcher == null) {
return false;
}
int lifeGained = watcher.getLifeGained(source.getControllerId());
Cost cost = new PayLifeCost(lifeGained);
if (!cost.canPay(source, source, source.getControllerId(), game) || !player.chooseUse(Outcome.PutCreatureInPlay, "Pay " + lifeGained + " life?", source, game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
new DemonFlyingToken(lifeGained).putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
use of mage.game.permanent.token.DemonFlyingToken in project mage by magefree.
the class ReignOfThePitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int totalPowerSacrificed = 0;
List<UUID> perms = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
while (!target.isChosen() && player.canRespond()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
perms.addAll(target.getTargets());
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
int power = permanent.getPower().getValue();
if (permanent.sacrifice(source, game)) {
totalPowerSacrificed += power;
}
}
}
new CreateTokenEffect(new DemonFlyingToken(totalPowerSacrificed)).apply(game, source);
return true;
}
Aggregations