Search in sources :

Example 56 with GameEvent

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());
}
Also used : Player(mage.players.Player) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) GameEvent(mage.game.events.GameEvent) CopyStackObjectEvent(mage.game.events.CopyStackObjectEvent)

Example 57 with GameEvent

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);
}
Also used : GameEvent(mage.game.events.GameEvent)

Example 58 with GameEvent

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);
}
Also used : GameEvent(mage.game.events.GameEvent)

Example 59 with GameEvent

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)));
}
Also used : java.util(java.util) DealsCombatDamageToAPlayerTriggeredAbility(mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility) PayLifeCost(mage.abilities.costs.common.PayLifeCost) mage.cards(mage.cards) MageObjectReference(mage.MageObjectReference) OneShotEffect(mage.abilities.effects.OneShotEffect) NinjutsuAbility(mage.abilities.keyword.NinjutsuAbility) CardUtil(mage.util.CardUtil) MageInt(mage.MageInt) Costs(mage.abilities.costs.Costs) Collectors(java.util.stream.Collectors) Player(mage.players.Player) Cost(mage.abilities.costs.Cost) CostsImpl(mage.abilities.costs.CostsImpl) Game(mage.game.Game) Watcher(mage.watchers.Watcher) GameEvent(mage.game.events.GameEvent) CanPlayCardControllerEffect(mage.abilities.effects.common.asthought.CanPlayCardControllerEffect) Spell(mage.game.stack.Spell) mage.constants(mage.constants) Ability(mage.abilities.Ability) Spell(mage.game.stack.Spell)

Example 60 with GameEvent

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;
}
Also used : NumberOfTriggersEvent(mage.game.events.NumberOfTriggersEvent) Permanent(mage.game.permanent.Permanent) GameEvent(mage.game.events.GameEvent) Spell(mage.game.stack.Spell)

Aggregations

GameEvent (mage.game.events.GameEvent)82 Permanent (mage.game.permanent.Permanent)28 Player (mage.players.Player)24 PreventDamageEvent (mage.game.events.PreventDamageEvent)23 PreventedDamageEvent (mage.game.events.PreventedDamageEvent)23 Game (mage.game.Game)22 Ability (mage.abilities.Ability)15 MageInt (mage.MageInt)13 CardImpl (mage.cards.CardImpl)13 CardSetInfo (mage.cards.CardSetInfo)13 java.util (java.util)12 OneShotEffect (mage.abilities.effects.OneShotEffect)12 Watcher (mage.watchers.Watcher)12 MageObjectReference (mage.MageObjectReference)11 Card (mage.cards.Card)11 UUID (java.util.UUID)10 TriggeredAbilityImpl (mage.abilities.TriggeredAbilityImpl)10 mage.constants (mage.constants)10 MageObject (mage.MageObject)9 Spell (mage.game.stack.Spell)9