Search in sources :

Example 1 with CardUtil

use of mage.util.CardUtil in project mage by magefree.

the class HawkinsNationalLaboratoryWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.SACRIFICED_PERMANENT) {
        return;
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
    if (permanent == null || !permanent.hasSubtype(SubType.CLUE, game)) {
        return;
    }
    playerMap.compute(event.getPlayerId(), CardUtil::setOrIncrementValue);
}
Also used : Permanent(mage.game.permanent.Permanent) CardUtil(mage.util.CardUtil)

Example 2 with CardUtil

use of mage.util.CardUtil in project mage by magefree.

the class GyomeMasterChefWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
        return;
    }
    Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
    if (permanent == null || permanent instanceof PermanentToken || !permanent.isCreature(game)) {
        return;
    }
    playerMap.compute(event.getPlayerId(), CardUtil::setOrIncrementValue);
}
Also used : FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) PermanentToken(mage.game.permanent.PermanentToken) CardUtil(mage.util.CardUtil)

Example 3 with CardUtil

use of mage.util.CardUtil in project mage by magefree.

the class SerpentsSoulJarWatcher method addPlayable.

static void addPlayable(Ability source, Game game) {
    MageObjectReference mor = new MageObjectReference(source);
    game.getState().getWatcher(SerpentsSoulJarWatcher.class).morMap.computeIfAbsent(mor, m -> new HashMap<>()).compute(source.getControllerId(), CardUtil::setOrIncrementValue);
}
Also used : DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) PayLifeCost(mage.abilities.costs.common.PayLifeCost) MageObjectReference(mage.MageObjectReference) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) HashMap(java.util.HashMap) UUID(java.util.UUID) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) Watcher(mage.watchers.Watcher) TapSourceCost(mage.abilities.costs.common.TapSourceCost) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) ExileZone(mage.game.ExileZone) AsThoughEffectImpl(mage.abilities.effects.AsThoughEffectImpl) GameEvent(mage.game.events.GameEvent) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) Map(java.util.Map) Card(mage.cards.Card) mage.constants(mage.constants) Ability(mage.abilities.Ability) HashMap(java.util.HashMap) MageObjectReference(mage.MageObjectReference) CardUtil(mage.util.CardUtil)

Example 4 with CardUtil

use of mage.util.CardUtil in project mage by magefree.

the class IdolOfEnduranceWatcher method addPlayable.

static void addPlayable(Ability source, Game game) {
    MageObjectReference mor = new MageObjectReference(source);
    game.getState().getWatcher(IdolOfEnduranceWatcher.class).morMap.computeIfAbsent(mor, m -> new HashMap<>()).compute(source.getControllerId(), CardUtil::setOrIncrementValue);
}
Also used : MageObjectReference(mage.MageObjectReference) HashMap(java.util.HashMap) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TapSourceCost(mage.abilities.costs.common.TapSourceCost) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Map(java.util.Map) mage.constants(mage.constants) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterCard(mage.filter.FilterCard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) mage.cards(mage.cards) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) UUID(java.util.UUID) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) Watcher(mage.watchers.Watcher) ExileZone(mage.game.ExileZone) AsThoughEffectImpl(mage.abilities.effects.AsThoughEffectImpl) GameEvent(mage.game.events.GameEvent) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) Ability(mage.abilities.Ability) HashMap(java.util.HashMap) MageObjectReference(mage.MageObjectReference) CardUtil(mage.util.CardUtil)

Example 5 with CardUtil

use of mage.util.CardUtil in project mage by magefree.

the class ValiantRescuerWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ACTIVATED_ABILITY || game.getState().getStack().isEmpty()) {
        return;
    }
    StackObject item = game.getState().getStack().getFirst();
    if (item instanceof StackAbility && item.getStackAbility() instanceof CyclingAbility) {
        playerMap.computeIfAbsent(event.getPlayerId(), u -> new HashMap<>());
        playerMap.get(event.getPlayerId()).compute(event.getSourceId(), CardUtil::setOrIncrementValue);
    }
}
Also used : CyclingAbility(mage.abilities.keyword.CyclingAbility) StackObject(mage.game.stack.StackObject) StackAbility(mage.game.stack.StackAbility) CardUtil(mage.util.CardUtil)

Aggregations

CardUtil (mage.util.CardUtil)10 Ability (mage.abilities.Ability)6 Game (mage.game.Game)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 UUID (java.util.UUID)5 MageObjectReference (mage.MageObjectReference)4 AsThoughEffectImpl (mage.abilities.effects.AsThoughEffectImpl)4 CardImpl (mage.cards.CardImpl)4 CardSetInfo (mage.cards.CardSetInfo)4 mage.constants (mage.constants)4 GameEvent (mage.game.events.GameEvent)4 Permanent (mage.game.permanent.Permanent)4 Player (mage.players.Player)4 Watcher (mage.watchers.Watcher)4 OneShotEffect (mage.abilities.effects.OneShotEffect)3 Card (mage.cards.Card)3 Collectors (java.util.stream.Collectors)2 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)2 TapSourceCost (mage.abilities.costs.common.TapSourceCost)2