use of mage.game.permanent.token.SoldierToken in project mage by magefree.
the class AllianceOfArmsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", player, source, game);
}
}
}
if (xSum > 0) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
effect.setTargetPointer(new FixedTarget(playerId));
effect.apply(game, source);
}
}
// prevent undo
controller.resetStoredBookmark(game);
return true;
}
return false;
}
use of mage.game.permanent.token.SoldierToken in project mage by magefree.
the class DecreeOfJusticeCycleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || !player.chooseUse(Outcome.Benefit, "Pay {X} to create X tokens?", source, game)) {
return false;
}
int payCount = ManaUtil.playerPaysXGenericMana(true, "Decree of Justice", player, source, game);
if (payCount > 0) {
return new SoldierToken().putOntoBattlefield(payCount, game, source, source.getControllerId());
}
return false;
}
use of mage.game.permanent.token.SoldierToken in project mage by magefree.
the class ThroneOfEmpiresEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean scepter = false;
boolean crown = false;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent.getName().equals("Scepter of Empires")) {
scepter = true;
} else if (permanent.getName().equals("Crown of Empires")) {
crown = true;
}
if (scepter && crown)
break;
}
Token soldier = new SoldierToken();
int count = scepter && crown ? 5 : 1;
soldier.putOntoBattlefield(count, game, source, source.getControllerId());
return false;
}
use of mage.game.permanent.token.SoldierToken in project mage by magefree.
the class EntrapmentManeuverSacrificeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player == null) {
return false;
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(AttackingPredicate.instance);
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
if (realCount > 0) {
Target target = new TargetControlledPermanent(1, 1, filter, true);
while (player.canRespond() && !target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
int amount = permanent.getToughness().getValue();
permanent.sacrifice(source, game);
new CreateTokenEffect(new SoldierToken(), amount).apply(game, source);
} else {
return false;
}
}
return true;
}
use of mage.game.permanent.token.SoldierToken in project mage by magefree.
the class TimelyReinforcementsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean lessCreatures = false;
boolean lessLife = false;
FilterPermanent filter = new FilterCreaturePermanent();
int count = game.getBattlefield().countAll(filter, controller.getId(), game);
for (UUID uuid : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(uuid);
if (opponent != null) {
if (opponent.getLife() > controller.getLife()) {
lessLife = true;
}
if (game.getBattlefield().countAll(filter, uuid, game) > count) {
lessCreatures = true;
}
}
if (lessLife && lessCreatures) {
// no need to search further
break;
}
}
if (lessLife) {
controller.gainLife(6, game, source);
}
if (lessCreatures) {
Effect effect = new CreateTokenEffect(new SoldierToken(), 3);
effect.apply(game, source);
}
return true;
}
return false;
}
Aggregations