use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class CurseOfDisturbanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet<>();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new CreateTokenTargetEffect(new ZombieToken());
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class KalitasTraitorOfGhetEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent != null) {
controller.moveCards(permanent, Zone.EXILED, source, game);
new CreateTokenEffect(new ZombieToken()).apply(game, source);
return true;
}
}
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class SyphonFleshEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && !playerId.equals(source.getControllerId())) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
int sacrificedAmount = perms.isEmpty() ? 0 : perms.size();
if (sacrificedAmount > 0) {
ZombieToken token = new ZombieToken();
token.putOntoBattlefield(sacrificedAmount, game, source, source.getControllerId());
}
return true;
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class AcererakTheArchlichEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int tokens = 0;
for (UUID playerId : game.getOpponents(source.getControllerId())) {
tokens++;
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
TargetPermanent target = new TargetControlledCreaturePermanent(0, 1);
target.setNotTarget(true);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null && permanent.sacrifice(source, game)) {
tokens--;
}
}
if (tokens > 0) {
new ZombieToken().putOntoBattlefield(tokens, game, source, source.getControllerId());
}
return true;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class CurseOfShallowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player attacker = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (attacker != null && attacker.chooseUse(outcome, "create a tapped 2/2 black Zombie creature token?", source, game)) {
Effect effect = new CreateTokenTargetEffect(new ZombieToken(), StaticValue.get(1), true, false);
effect.setTargetPointer(targetPointer);
return effect.apply(game, source);
}
return false;
}
Aggregations