Search in sources :

Example 1 with CopyStackObjectEvent

use of mage.game.events.CopyStackObjectEvent in project mage by magefree.

the class StackObjectImpl method createCopyOnStack.

@Override
public void createCopyOnStack(Game game, Ability source, UUID newControllerId, boolean chooseNewTargets, int amount, StackObjectCopyApplier applier) {
    GameEvent gameEvent = new CopyStackObjectEvent(source, this, newControllerId, amount);
    if (game.replaceEvent(gameEvent)) {
        return;
    }
    Iterator<MageObjectReferencePredicate> newTargetTypeIterator = new NewTargetTypeIterator(game, newControllerId, gameEvent.getAmount(), applier);
    for (int i = 0; i < gameEvent.getAmount(); i++) {
        createSingleCopy(newControllerId, applier, newTargetTypeIterator.next(), game, source, chooseNewTargets);
    }
    Player player = game.getPlayer(newControllerId);
    if (player == null) {
        return;
    }
    game.informPlayers(player.getName() + " created " + CardUtil.numberToText(gameEvent.getAmount(), "a") + " cop" + (gameEvent.getAmount() == 1 ? "y" : "ies") + " of " + getIdName());
}
Also used : Player(mage.players.Player) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) GameEvent(mage.game.events.GameEvent) CopyStackObjectEvent(mage.game.events.CopyStackObjectEvent)

Aggregations

MageObjectReferencePredicate (mage.filter.predicate.mageobject.MageObjectReferencePredicate)1 CopyStackObjectEvent (mage.game.events.CopyStackObjectEvent)1 GameEvent (mage.game.events.GameEvent)1 Player (mage.players.Player)1