示例#1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player you = game.getPlayer(source.getControllerId());
   if (you != null) {
     Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
     if (spell != null) {
       ObjectColor color1 =
           new ObjectColor((String) game.getState().getValue(source.getSourceId() + "_color1"));
       ObjectColor color2 =
           new ObjectColor((String) game.getState().getValue(source.getSourceId() + "_color2"));
       int amount = 0;
       if (spell.getColor(game).contains(color1)) {
         ++amount;
       }
       if (spell.getColor(game).contains(color2)) {
         ++amount;
       }
       if (amount > 0) {
         you.gainLife(amount, game);
         return true;
       }
     }
   }
   return false;
 }
示例#2
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   Spell spell = game.getStack().getSpell(event.getTargetId());
   if (spell != null && spell.getCardType().contains(CardType.CREATURE)) {
     return true;
   }
   return false;
 }
示例#3
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   Spell spell = game.getStack().getSpell(event.getTargetId());
   if (spell != null && spell.getCardType().contains(CardType.ARTIFACT)) {
     this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
     return true;
   }
   return false;
 }
示例#4
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;
 }
示例#5
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;
     }
   }
 }
示例#6
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;
 }
示例#7
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.getConvertedManaCost() <= 3) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
       }
       return true;
     }
   }
   return false;
 }
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   BoseijuWhoSheltersAllWatcher watcher =
       (BoseijuWhoSheltersAllWatcher)
           game.getState().getWatchers().get("ManaPaidFromBoseijuWhoSheltersAllWatcher");
   Spell spell = game.getStack().getSpell(event.getTargetId());
   if (spell != null && watcher.spells.contains(spell.getId())) {
     if (filter.match(spell.getCard(), game)) {
       return true;
     }
   }
   return false;
 }
示例#9
0
  @Override
  public boolean apply(Game game, Ability source) {

    List<Spell> spellsToCounter = new LinkedList<Spell>();
    for (StackObject stackObject : game.getStack()) {
      if (stackObject instanceof Spell
          && !stackObject.getControllerId().equals(source.getControllerId())) {
        spellsToCounter.add((Spell) stackObject);
      }
    }
    for (Spell spell : spellsToCounter) {
      game.getStack().counter(spell.getId(), source.getSourceId(), game);
    }
    return true;
  }
 @Override
 public boolean apply(MageObject input, Game game) {
   Spell spell = game.getStack().getSpell(input.getId());
   if (spell != null) {
     Targets spellTargets = spell.getSpellAbility().getTargets();
     int numberOfTargets = 0;
     for (Target target : spellTargets) {
       numberOfTargets += target.getTargets().size();
     }
     if (numberOfTargets == targets) {
       return true;
     }
   }
   return false;
 }
示例#11
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getZone() == Zone.HAND) {
     Spell spell = game.getStack().getSpell(event.getTargetId());
     if (spell != null
         && !spell.isCopy()
         && (spell.getCardType().contains(CardType.INSTANT)
             || spell.getCardType().contains(CardType.SORCERY))) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getTargetId()));
       }
       return true;
     }
   }
   return false;
 }
 @Override
 public boolean apply(Game game, Ability source) {
   Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
   if (spell == null) {
     spell =
         (Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK);
   }
   if (spell != null) {
     Spell copy = spell.copySpell();
     copy.setControllerId(source.getControllerId());
     copy.setCopiedSpell(true);
     game.getStack().push(copy);
     copy.chooseNewTargets(game, source.getControllerId());
     Player player = game.getPlayer(source.getControllerId());
     String activateMessage = copy.getActivatedMessage(game);
     if (activateMessage.startsWith(" casts ")) {
       activateMessage = activateMessage.substring(6);
     }
     if (!game.isSimulation()) {
       game.informPlayers(player.getLogName() + activateMessage);
     }
     return true;
   }
   return false;
 }
示例#13
0
 private void checkPaid(UUID uuid, Spell spell) {
   for (Cost cost : spell.getSpellAbility().getManaCostsToPay()) {
     if (!cost.isPaid()) {
       return;
     }
   }
   CardView cardView = stack.get(uuid);
   cardView.paid = true;
 }
示例#14
0
 @Override
 public boolean apply(Game game, Ability source) {
   Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
   if (spell != null) {
     Spell copy = spell.copySpell(source.getControllerId());
     ;
     game.getStack().push(copy);
     copy.chooseNewTargets(game, source.getControllerId());
     Player player = game.getPlayer(source.getControllerId());
     String activateMessage = copy.getActivatedMessage(game);
     if (activateMessage.startsWith(" casts ")) {
       activateMessage = activateMessage.substring(6);
     }
     game.informPlayers(player.getLogName() + " copies " + activateMessage);
     return true;
   }
   return false;
 }
示例#15
0
  @Override
  public boolean apply(Spell input, Game game) {
    CastSpellLastTurnWatcher watcher =
        (CastSpellLastTurnWatcher)
            game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());

    if (watcher.getSpellOrder(new MageObjectReference(input.getId(), game), game) == 2) {
      return true;
    }

    return false;
  }
示例#16
0
 private String getOptionalTextSuffix(Game game, Spell spell) {
   StringBuilder sb = new StringBuilder();
   for (Ability ability : spell.getAbilities()) {
     if (ability instanceof OptionalAdditionalSourceCosts) {
       sb.append(((OptionalAdditionalSourceCosts) ability).getCastMessageSuffix());
     }
     if (ability instanceof AlternativeSourceCosts
         && ((AlternativeSourceCosts) ability).isActivated(this, game)) {
       sb.append(((AlternativeSourceCosts) ability).getCastMessageSuffix(game));
     }
   }
   return sb.toString();
 }
示例#17
0
 protected String getMessageText(Game game) {
   StringBuilder sb = threadLocalBuilder.get();
   MageObject object = game.getObject(this.sourceId);
   if (object != null) {
     if (object instanceof StackAbility) {
       Card card = game.getCard(((StackAbility) object).getSourceId());
       if (card != null) {
         sb.append(GameLog.getColoredObjectIdName(card));
       } else {
         sb.append(GameLog.getColoredObjectIdName(object));
       }
     } else if (object instanceof Spell) {
       Spell spell = (Spell) object;
       String castText = spell.getSpellCastText(game);
       sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText));
       if (spell.getFromZone() == Zone.GRAVEYARD) {
         sb.append(" from graveyard");
       }
       sb.append(getOptionalTextSuffix(game, spell));
     } else {
       sb.append(GameLog.getColoredObjectIdName(object));
     }
   } else {
     sb.append("unknown");
   }
   if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) {
     if (((Spell) object)
         .getSpellAbility()
         .getSpellAbilityType()
         .equals(SpellAbilityType.SPLIT_FUSED)) {
       Spell spell = (Spell) object;
       int i = 0;
       for (SpellAbility spellAbility : spell.getSpellAbilities()) {
         i++;
         String half;
         if (i == 1) {
           half = " left";
         } else {
           half = " right";
         }
         if (spellAbility.getTargets().size() > 0) {
           sb.append(half).append(" half targeting ");
           for (Target target : spellAbility.getTargets()) {
             sb.append(target.getTargetedName(game));
           }
         }
       }
     } else {
       Spell spell = (Spell) object;
       int i = 0;
       for (SpellAbility spellAbility : spell.getSpellAbilities()) {
         i++;
         if (i > 1) {
           sb.append(" splicing ");
           if (spellAbility.name.length() > 5 && spellAbility.name.startsWith("Cast ")) {
             sb.append(spellAbility.name.substring(5));
           } else {
             sb.append(spellAbility.name);
           }
         }
         sb.append(getTargetDescriptionForLog(spellAbility.getTargets(), game));
       }
     }
   } else if (object instanceof Spell
       && ((Spell) object).getSpellAbility().getModes().size() > 1) {
     Modes spellModes = ((Spell) object).getSpellAbility().getModes();
     for (Mode selectedMode : spellModes.getSelectedModes()) {
       int item = 0;
       for (Mode mode : spellModes.values()) {
         item++;
         if (mode.getId().equals(selectedMode.getId())) {
           sb.append(" (mode ").append(item).append(")");
           sb.append(getTargetDescriptionForLog(selectedMode.getTargets(), game));
           break;
         }
       }
     }
   } else {
     sb.append(getTargetDescriptionForLog(getTargets(), game));
   }
   return sb.toString();
 }
示例#18
0
  @Override
  public boolean apply(Game game, Ability source) {
    Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
    Permanent eyeOfTheStorm = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (spell != null && eyeOfTheStorm != null) {
      Player spellController = game.getPlayer(spell.getControllerId());
      Card card = spell.getCard();
      if (spellController == null || card == null || !instantOrSorceryfilter.match(card, game)) {
        return false;
      }

      UUID exileZoneId =
          CardUtil.getExileZoneId(
              game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game));
      if (spellController.moveCardsToExile(
          spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName())) {
        eyeOfTheStorm.imprint(card.getId(), game);

        if (eyeOfTheStorm.getImprinted() != null && eyeOfTheStorm.getImprinted().size() > 0) {
          CardsImpl copiedCards = new CardsImpl();
          for (UUID uuid : eyeOfTheStorm.getImprinted()) {
            card = game.getCard(uuid);

            // Check if owner of card is still in game
            if (card != null && game.getPlayer(card.getOwnerId()) != null) {
              if (card.isSplitCard()) {
                copiedCards.add(((SplitCard) card).getLeftHalfCard());
                copiedCards.add(((SplitCard) card).getRightHalfCard());
              } else {
                copiedCards.add(card);
              }
            }
          }

          boolean continueCasting = true;
          while (continueCasting) {
            continueCasting =
                copiedCards.size() > 1
                    && spellController.chooseUse(
                        outcome,
                        "Cast one of the copied cards without paying its mana cost?",
                        source,
                        game);

            Card cardToCopy;
            if (copiedCards.size() == 1) {
              cardToCopy = copiedCards.getCards(game).iterator().next();
            } else {
              TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy"));
              spellController.choose(Outcome.Copy, copiedCards, target, game);
              cardToCopy = copiedCards.get(target.getFirstTarget(), game);
              copiedCards.remove(cardToCopy);
            }
            if (cardToCopy != null) {
              Card copy = game.copyCard(cardToCopy, source, source.getControllerId());
              if (spellController.chooseUse(
                  outcome, "Cast the copied card without paying mana cost?", source, game)) {
                spellController.cast(copy.getSpellAbility(), game, true);
              }
            }
          }
          return true;
        }
      }
    }
    return false;
  }