Search in sources :

Example 41 with GameEvent

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

the class AegarTheFreezingFlameWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) {
        return;
    }
    DamagedEvent dEvent = (DamagedEvent) event;
    MageObject sourceObject = game.getObject(event.getSourceId());
    if (sourceObject == null) {
        return;
    }
    if (game.getSpellOrLKIStack(event.getSourceId()) == null && !sourceObject.hasSubtype(SubType.GIANT, game) && !sourceObject.hasSubtype(SubType.WIZARD, game)) {
        return;
    }
    playerMap.computeIfAbsent(game.getControllerId(event.getSourceId()), x -> new HashSet<>()).add(new MageObjectReference(event.getTargetId(), game));
}
Also used : java.util(java.util) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) MageObjectReference(mage.MageObjectReference) MageInt(mage.MageInt) CardSetInfo(mage.cards.CardSetInfo) TriggeredAbilityImpl(mage.abilities.TriggeredAbilityImpl) Game(mage.game.Game) Watcher(mage.watchers.Watcher) GameEvent(mage.game.events.GameEvent) CardImpl(mage.cards.CardImpl) DamagedEvent(mage.game.events.DamagedEvent) MageObject(mage.MageObject) mage.constants(mage.constants) DamagedEvent(mage.game.events.DamagedEvent) MageObject(mage.MageObject) MageObjectReference(mage.MageObjectReference)

Example 42 with GameEvent

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

the class NimbleTrapfinderWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
        return;
    }
    Permanent permanent = game.getPermanent(event.getTargetId());
    if (!filter.match(permanent, game)) {
        return;
    }
    playerMap.computeIfAbsent(event.getPlayerId(), u -> new HashSet<>()).add(new MageObjectReference(permanent, game));
}
Also used : BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) java.util(java.util) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) DealsCombatDamageToAPlayerTriggeredAbility(mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility) MageObjectReference(mage.MageObjectReference) Predicates(mage.filter.predicate.Predicates) Hint(mage.abilities.hint.Hint) PartyCountHint(mage.abilities.hint.common.PartyCountHint) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) mage.constants(mage.constants) FullPartyCondition(mage.abilities.condition.common.FullPartyCondition) StaticFilters(mage.filter.StaticFilters) ConditionalRestrictionEffect(mage.abilities.decorator.ConditionalRestrictionEffect) Condition(mage.abilities.condition.Condition) CantBeBlockedSourceEffect(mage.abilities.effects.common.combat.CantBeBlockedSourceEffect) MageInt(mage.MageInt) ConditionHint(mage.abilities.hint.ConditionHint) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) Watcher(mage.watchers.Watcher) GameEvent(mage.game.events.GameEvent) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) Ability(mage.abilities.Ability) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) MageObjectReference(mage.MageObjectReference)

Example 43 with GameEvent

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

the class Step method priority.

public void priority(Game game, UUID activePlayerId, boolean resuming) {
    if (hasPriority) {
        stepPart = StepPart.PRIORITY;
        game.fireEvent(new GameEvent(stepEvent, null, null, activePlayerId));
        game.playPriority(activePlayerId, resuming);
    }
}
Also used : GameEvent(mage.game.events.GameEvent)

Example 44 with GameEvent

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

the class Step method endStep.

public void endStep(Game game, UUID activePlayerId) {
    stepPart = StepPart.POST;
    game.fireEvent(new GameEvent(postStepEvent, null, null, activePlayerId));
}
Also used : GameEvent(mage.game.events.GameEvent)

Example 45 with GameEvent

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

the class Step method beginStep.

public void beginStep(Game game, UUID activePlayerId) {
    stepPart = StepPart.PRE;
    game.fireEvent(new GameEvent(preStepEvent, null, null, activePlayerId));
}
Also used : GameEvent(mage.game.events.GameEvent)

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