Exemplo n.º 1
0
 public Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone) {
   this.card = card;
   id = ability.getId();
   this.ability = ability;
   this.ability.setControllerId(controllerId);
   if (ability.getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
     spellCards.add(((SplitCard) card).getLeftHalfCard());
     spellAbilities.add(((SplitCard) card).getLeftHalfCard().getSpellAbility().copy());
     spellCards.add(((SplitCard) card).getRightHalfCard());
     spellAbilities.add(((SplitCard) card).getRightHalfCard().getSpellAbility().copy());
   } else {
     spellCards.add(card);
     spellAbilities.add(ability);
   }
   this.controllerId = controllerId;
   this.fromZone = fromZone;
 }
Exemplo n.º 2
0
 @Override
 public boolean resolve(Game game) {
   boolean result;
   if (this.getCardType().contains(CardType.INSTANT)
       || this.getCardType().contains(CardType.SORCERY)) {
     int index = 0;
     result = false;
     boolean legalParts = false;
     for (SpellAbility spellAbility : this.spellAbilities) {
       for (UUID modeId : spellAbility.getModes().getSelectedModes()) {
         spellAbility.getModes().setMode(spellAbility.getModes().get(modeId));
         if (spellAbility.getTargets().stillLegal(spellAbility, game)) {
           legalParts = true;
           if (!spellAbility.getSpellAbilityType().equals(SpellAbilityType.SPLICE)) {
             updateOptionalCosts(index);
           }
           result |= spellAbility.resolve(game);
         }
       }
       index++;
     }
     if (legalParts) {
       if (!copiedSpell) {
         for (Effect effect : ability.getEffects()) {
           if (effect instanceof PostResolveEffect) {
             ((PostResolveEffect) effect).postResolve(card, ability, controllerId, game);
             return result;
           }
         }
         if (!card.isCopy() && game.getState().getZone(card.getId()) == Zone.STACK) {
           card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
         }
       }
       return result;
     }
     // 20091005 - 608.2b
     game.informPlayers(getName() + " has been fizzled.");
     counter(null, game);
     return false;
   } else if (this.getCardType().contains(CardType.ENCHANTMENT)
       && this.getSubtype().contains("Aura")) {
     if (ability.getTargets().stillLegal(ability, game)) {
       updateOptionalCosts(0);
       if (card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId)) {
         return ability.resolve(game);
       }
       return false;
     }
     if (this.getCardType()
         .contains(
             CardType.CREATURE)) { // e.g. Creature with Bestow (rule confirmation yet missing)
       updateOptionalCosts(0);
       result = card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId);
       return result;
     } else {
       // 20091005 - 608.2b
       game.informPlayers(getName() + " has been fizzled.");
       counter(null, game);
       return false;
     }
   } else {
     updateOptionalCosts(0);
     result = card.putOntoBattlefield(game, fromZone, ability.getId(), controllerId);
     return result;
   }
 }