use of mage.game.events.GameEvent 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());
}
use of mage.game.events.GameEvent in project mage by magefree.
the class Phase method endPhase.
public void endPhase(Game game, UUID activePlayerId) {
game.fireEvent(new GameEvent(postEvent, null, null, activePlayerId));
// e.g. tokens that left the battlefield
game.getState().getTriggers().removeAbilitiesOfNonExistingSources(game);
}
use of mage.game.events.GameEvent in project mage by magefree.
the class FirstCombatDamageStep method priority.
@Override
public void priority(Game game, UUID activePlayerId, boolean resuming) {
game.fireEvent(new GameEvent(GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY, null, null, activePlayerId));
super.priority(game, activePlayerId, resuming);
}
use of mage.game.events.GameEvent in project mage by magefree.
the class NashiMoonSagesScionPlayEffect method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.CLEANUP_STEP_POST) {
morMap.entrySet().removeIf(e -> !e.getKey().zoneCounterIsCurrent(game));
morMap.values().stream().flatMap(Collection::stream).map(set -> set.removeIf(mor -> !mor.zoneCounterIsCurrent(game)));
morMap.values().removeIf(Set::isEmpty);
return;
}
if (event.getType() != GameEvent.EventType.SPELL_CAST || event.getAdditionalReference() == null) {
return;
}
Spell spell = game.getSpell(event.getTargetId());
if (spell == null) {
return;
}
morMap.getOrDefault(event.getAdditionalReference().getApprovingMageObjectReference(), Collections.emptySet()).removeIf(set -> set.stream().anyMatch(mor -> mor.getSourceId().equals(spell.getMainCard().getId()) && mor.getZoneChangeCounter() + 1 == spell.getZoneChangeCounter(game)));
}
use of mage.game.events.GameEvent in project mage by magefree.
the class VeyranVoiceOfDualityEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
NumberOfTriggersEvent numberOfTriggersEvent = (NumberOfTriggersEvent) event;
GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent();
if (sourceEvent.getType() == GameEvent.EventType.SPELL_CAST || sourceEvent.getType() == GameEvent.EventType.COPIED_STACKOBJECT) {
Spell spell = game.getSpell(sourceEvent.getTargetId());
Permanent permanent = game.getPermanent(((NumberOfTriggersEvent) event).getSourceId());
return spell != null && permanent != null && spell.isInstantOrSorcery(game) && spell.isControlledBy(source.getControllerId()) && permanent.isControlledBy(source.getControllerId());
}
return false;
}
Aggregations