Пример #1
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
     if (((DamagedEvent) event).isCombatDamage()) {
       Permanent creature = game.getPermanent(event.getSourceId());
       if (creature != null
           && creature.getControllerId().equals(controllerId)
           && !damagedPlayerIds.contains(event.getTargetId())) {
         damagedPlayerIds.add(event.getTargetId());
         return true;
       }
     }
   }
   if (event.getType().equals(GameEvent.EventType.END_COMBAT_STEP_POST)) {
     damagedPlayerIds.clear();
   }
   if (event.getType().equals(GameEvent.EventType.ZONE_CHANGE)
       && event.getTargetId().equals(getSourceId())) {
     ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
     if (zEvent.getFromZone().equals(Zone.GRAVEYARD)) {
       damagedPlayerIds.clear();
     }
   }
   return false;
 }
Пример #2
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if ((event.getType() == GameEvent.EventType.PRECOMBAT_MAIN_PHASE_PRE
           || event.getType() == GameEvent.EventType.POSTCOMBAT_MAIN_PHASE_PRE)
       && event.getPlayerId().equals(this.controllerId)) {
     return true;
   }
   return false;
 }
Пример #3
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == EventType.ATTACKER_DECLARED
       && event.getSourceId().equals(this.getSourceId())) {
     return true;
   }
   return event.getType() == EventType.ENTERS_THE_BATTLEFIELD
       && event.getTargetId().equals(this.getSourceId());
 }
Пример #4
0
 @Override
 public void watch(GameEvent event, Game game) {
   if (event.getType() == EventType.DAMAGED_CREATURE
       || event.getType() == EventType.DAMAGED_PLANESWALKER
       || event.getType() == EventType.DAMAGED_PLAYER) {
     if (!damageSources.contains(event.getSourceId())) {
       damageSources.add(event.getSourceId());
     }
   }
 }
Пример #5
0
 private boolean checkAbilityStillExists(
     Ability ability, ContinuousEffect effect, GameEvent event, Game game) {
   switch (effect
       .getDuration()) { // effects with fixed duration don't need an object with the source
                         // ability (e.g. a silence cast with isochronic Scepter has no more a card
                         // object
     case EndOfCombat:
     case EndOfGame:
     case EndOfStep:
     case EndOfTurn:
     case OneUse:
     case Custom: // custom duration means the effect ends itself if needed
       return true;
   }
   if (ability.getSourceId() == null) { // commander replacement effect
     return true;
   }
   MageObject object;
   if (event.getType().equals(EventType.ZONE_CHANGE)
       && ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)
       && event.getTargetId().equals(ability.getSourceId())) {
     object = ((ZoneChangeEvent) event).getTarget();
   } else {
     object = game.getObject(ability.getSourceId());
   }
   if (object == null) {
     return false;
   }
   boolean exists = true;
   if (!object.getAbilities().contains(ability)) {
     exists = false;
     if (object instanceof PermanentCard) {
       PermanentCard permanent = (PermanentCard) object;
       if (permanent.canTransform() && event.getType() == GameEvent.EventType.TRANSFORMED) {
         exists = permanent.getCard().getAbilities().contains(ability);
       }
     }
   } else {
     if (object instanceof PermanentCard) {
       PermanentCard permanent = (PermanentCard) object;
       if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
         return false;
       }
     } else if (object instanceof Spell) {
       Spell spell = (Spell) object;
       if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
         return false;
       }
     }
   }
   return exists;
 }
Пример #6
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   return GameEvent.EventType.DISCARDED_CARD.equals(event.getType())
       && game.getOpponents(this.getControllerId())
           .contains(game.getControllerId(event.getSourceId()))
       && getSourceId().equals(event.getTargetId());
 }
Пример #7
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if ((event.getType() == EventType.DAMAGED_PLAYER
           && event.getTargetId().equals(this.getControllerId()))
       && ((DamagedEvent) event).isCombatDamage()) {
     return true;
   }
   if (event.getType() == EventType.DAMAGED_PLANESWALKER
       && ((DamagedEvent) event).isCombatDamage()) {
     Permanent permanent = game.getPermanent(event.getTargetId());
     if (permanent != null && permanent.getControllerId().equals(this.getControllerId())) {
       return true;
     }
   }
   return false;
 }
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == EventType.DAMAGE_PLAYER) {
     DamageEvent damageEvent = (DamageEvent) event;
     UUID playerId = getSourceControllerId(event.getSourceId(), game);
     if (!damageEvent.isCombatDamage()
         && game.getOpponents(event.getTargetId()).contains(playerId)) {
       Player target = game.getPlayer(event.getTargetId());
       Player player = game.getPlayer(playerId);
       if (target != null && player != null) {
         int numPlaneswalkers = game.getBattlefield().countAll(filter, target.getId(), game);
         if (numPlaneswalkers > 0
             && player.chooseUse(outcome, "Redirect damage to planeswalker?", game)) {
           redirectTarget = new TargetPermanent(filter);
           if (numPlaneswalkers == 1) {
             redirectTarget.add(
                 game.getBattlefield()
                     .getAllActivePermanents(filter, target.getId(), game)
                     .get(0)
                     .getId(),
                 game);
           } else {
             player.choose(Outcome.Damage, redirectTarget, null, game);
           }
           return true;
         }
       }
     }
   }
   return false;
 }
Пример #9
0
 @Override
 public void watch(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.ZONE_CHANGE
       && ((ZoneChangeEvent) event).isDiesEvent()) {
     cards.add(event.getTargetId());
   }
 }
Пример #10
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   boolean isCombat = false;
   switch (event.getType()) {
     case DAMAGE_CREATURE:
     case DAMAGE_PLAYER:
     case DAMAGE_PLANESWALKER:
       if (event instanceof DamageCreatureEvent) {
         isCombat = ((DamageCreatureEvent) event).isCombatDamage();
       } else if (event instanceof DamageEvent) {
         isCombat = ((DamageEvent) event).isCombatDamage();
       }
       if (isCombat) {
         Permanent equipment = game.getPermanent(source.getSourceId());
         if (equipment != null && equipment.getAttachedTo() != null) {
           UUID attachedTo = equipment.getAttachedTo();
           if (event.getSourceId().equals(attachedTo)) {
             event.setAmount(event.getAmount() * 2);
           } else if (event.getTargetId().equals(attachedTo)) {
             event.setAmount(event.getAmount() * 2);
           }
         }
       }
   }
   return false;
 }
Пример #11
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == GameEvent.EventType.PREVENT_DAMAGE) {
     return true;
   }
   return false;
 }
Пример #12
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.SPELL_CAST) {
     this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
     return true;
   }
   return false;
 }
Пример #13
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE
       && game.getOpponents(controllerId).contains(event.getPlayerId())) {
     return true;
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.DREW_CARD
       && event.getPlayerId().equals(controllerId)) {
     return true;
   }
   return false;
 }
Пример #15
0
 @Override
 public void watch(GameEvent event, Game game) {
   if (condition == true) return;
   if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED
       && event.getSourceId().equals(sourceId)) {
     condition = true;
   }
 }
Пример #16
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
       && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
     Card c = game.getCard(event.getTargetId());
     if (c != null && c.getCardType().contains(CardType.CREATURE)) return true;
   }
   return false;
 }
Пример #17
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE
       && event.getTargetId().equals(this.sourceId)) {
     this.getEffects().get(0).setValue("damageAmount", event.getAmount());
     return true;
   }
   return false;
 }
Пример #18
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
     DamagedByWatcher watcher =
         (DamagedByWatcher)
             game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
     if (watcher != null) return watcher.damagedCreatures.contains(event.getTargetId());
   }
   return false;
 }
Пример #19
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.TAPPED) {
     Permanent p = game.getPermanent(event.getTargetId());
     if (p != null && p.getCardType().contains(CardType.CREATURE)) {
       if (game.getOpponents(this.controllerId).contains(p.getControllerId())) return true;
     }
   }
   return false;
 }
Пример #20
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (!this.used) {
     if (event.getType().equals(GameEvent.EventType.DAMAGE_CREATURE)
         || event.getType().equals(GameEvent.EventType.DAMAGE_PLANESWALKER)
         || event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)) {
       if (event.getSourceId().equals(targetPointer.getFirst(game, source))) {
         // check source
         MageObject object = game.getObject(event.getSourceId());
         if (object == null) {
           game.informPlayers("Couldn't find source of damage");
           return false;
         }
         return true;
       }
     }
   }
   return false;
 }
Пример #21
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == GameEvent.EventType.ZONE_CHANGE
       && event.getTargetId().equals(source.getFirstTarget())
       && ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)
       && !((ZoneChangeEvent) event).getToZone().equals(Zone.EXILED)) {
     return true;
   }
   return false;
 }
Пример #22
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.SPELL_CAST) {
     Spell spell = game.getStack().getSpell(event.getTargetId());
     if (spell != null && spell.getColor().contains(ObjectColor.GREEN)) {
       return true;
     }
   }
   return false;
 }
Пример #23
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == GameEvent.EventType.SEARCH_LIBRARY) {
     Player controller = game.getPlayer(source.getControllerId());
     if (controller != null && game.isOpponent(controller, event.getPlayerId())) {
       return true;
     }
   }
   return false;
 }
Пример #24
0
 @Override
 public void watch(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.SPELL_CAST
       && game.getActivePlayerId().equals(event.getPlayerId())
       && game.getOpponents(controllerId).contains(event.getPlayerId())) {
     Spell spell = (Spell) game.getObject(event.getTargetId());
     if (spell.getCardType().contains(CardType.CREATURE)) {
       condition = true;
     }
   }
 }
Пример #25
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.DECLARED_BLOCKERS) {
     for (CombatGroup combatGroup : game.getCombat().getGroups()) {
       if (!combatGroup.getBlockers().isEmpty()) {
         return true;
       }
     }
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == EventType.ZONE_CHANGE
       && event.getTargetId().equals(this.getSourceId())) {
     ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
     if ((fromZone == null || zEvent.getFromZone() == fromZone)
         && (toZone == null || zEvent.getToZone() == toZone)) {
       return true;
     }
   }
   return false;
 }
Пример #27
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if (event.getType() == EventType.CAST_SPELL
       && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
     MageObject object = game.getObject(event.getSourceId());
     if (object != null
         && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) {
       return true;
     }
   }
   return false;
 }
Пример #28
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
     if (event.getSourceId().equals(this.getSourceId())) {
       StackObject object = game.getStack().getStackObject(event.getSourceId());
       if (object != null && object.getStackAbility() instanceof CyclingAbility) {
         return true;
       }
     }
   }
   return false;
 }
Пример #29
0
 @Override
 public void watch(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.MANA_PAYED) {
     MageObject object = game.getObject(event.getSourceId());
     // TODO: Replace identification by name by better method that also works if ability is copied
     // from other land with other name
     if (object != null
         && object.getName().equals("Boseiju, Who Shelters All")
         && event.getFlag()) {
       spells.add(event.getTargetId());
     }
   }
 }
Пример #30
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   if ((event.getType() == GameEvent.EventType.CAST_SPELL)
       && event.getPlayerId() == source.getControllerId()) {
     MageObject spellObject = game.getObject(event.getSourceId());
     if (spellObject != null
         && spellObject.getCardType().contains(CardType.CREATURE)
         && spellObject.getCardType().contains(CardType.ARTIFACT)) {
       return true;
     }
   }
   return false;
 }