Package mage.abilities

Examples of mage.abilities.SpellAbility


      this.cardType.add(newCardType);
    this.manaCost.load(costs);
    if (cardType.contains(CardType.LAND))
      addAbility(new PlayLandAbility(name));
    else
      addAbility(new SpellAbility(manaCost, name));
  }
View Full Code Here


        Player controller = game.getPlayer(source.getControllerId());
        Card spliceCard = game.getCard(source.getSourceId());
        if (spliceCard != null && controller != null) {
            Spell spell = game.getStack().getSpell(abilityToModify.getId());
            if (spell != null) {
                SpellAbility splicedAbility = spliceCard.getSpellAbility().copy();
                splicedAbility.setSpellAbilityType(SpellAbilityType.SPLICE);
                splicedAbility.setSourceId(abilityToModify.getSourceId());
                spell.addSpellAbility(splicedAbility);
                for (Iterator it = ((SpliceOntoArcaneAbility) source).getSpliceCosts().iterator(); it.hasNext();) {
                    Cost cost = (Cost) it.next();
                    if (cost instanceof ManaCostsImpl) {
                        spell.getSpellAbility().getManaCostsToPay().add((ManaCostsImpl) cost.copy());
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Card card = (Card) game.getObject(source.getSourceId());
        if (card != null) {
            Player controller = game.getPlayer(source.getControllerId());
            if (controller != null) {
                SpellAbility spellAbility;
                switch(((FlashbackAbility) source).getSpellAbilityType()) {
                    case SPLIT_LEFT:
                        spellAbility = ((SplitCard)card).getLeftHalfCard().getSpellAbility();
                        break;
                    case SPLIT_RIGHT:
                        spellAbility = ((SplitCard)card).getRightHalfCard().getSpellAbility();
                        break;
                    default:
                        spellAbility = card.getSpellAbility();
                }

                spellAbility.clear();
                // used if flashbacked spell has a {X} cost
                int amount = source.getManaCostsToPay().getX();
                if (amount == 0) {
                    // add variable cost like Discard X cards to get the X value to the spell
                    // because there is currently no way to set the x value in anotehr way, it's set for the
                    // x mana value to be known by the spell
                    for (Cost cost:source.getCosts()) {
                        if (cost instanceof VariableCost && cost.isPaid()) {
                            amount = ((VariableCost) cost).getAmount();
                            break;
                        }
                    }                   
                }
                if (amount > 0) {
                    // multiplier must be taken into account because if the base spell has {X}{X} the x value would be wrongly halfed
                    for (VariableCost variableCost: spellAbility.getManaCostsToPay().getVariableCosts()) {
                        if (variableCost instanceof  VariableManaCost) {
                            amount = amount * ((VariableManaCost)variableCost).getMultiplier();
                            break;
                        }
                    }
                    spellAbility.getManaCostsToPay().setX(amount);
                }
                game.informPlayers(new StringBuilder(controller.getName()).append(" flashbacks ").append(card.getName()).toString());
                spellAbility.setCostModificationActive(false); // prevents to apply cost modification twice for flashbacked spells
                return controller.cast(spellAbility, game, true);
            }
        }
        return false;
    }
View Full Code Here

            Ability ability = new PlayLandAbility(name);
            ability.setSourceId(this.getId());
            abilities.add(ability);
        }
        else {           
            SpellAbility ability = new SpellAbility(manaCost, name, Zone.HAND, spellAbilityType);
            if (!cardType.contains(CardType.INSTANT)) {
                ability.setTiming(TimingRule.SORCERY);
            }
            ability.setSourceId(this.getId());
            abilities.add(ability);           
        }
        this.usesVariousArt = Character.isDigit(this.getClass().getName().charAt(this.getClass().getName().length()-1));
        this.counters = new Counters();
        this.morphCard = false;
View Full Code Here

            this.setRules(shortRules);
        } else {
            this.setRules(card.getRules());
        }

        SpellAbility spellAbility = card.getSpellAbility();
        if (spellAbility != null) {
            SpellAbilityType spellAbilityType = spellAbility.getSpellAbilityType();
            if (spellAbilityType == SpellAbilityType.SPLIT_LEFT || spellAbilityType == SpellAbilityType.SPLIT_RIGHT) {
                this.className = this.setCode + "." + this.name;
                this.splitCardHalf = true;
            }
        }
View Full Code Here

        return false;
    }

    private boolean checkSpell(Spell spell, Game game) {
        if (spell != null) {
            SpellAbility sa = spell.getSpellAbility();
            for (Target target : sa.getTargets()) {
                if (!target.isNotTarget() && target.getTargets().contains(this.getSourceId())) {
                    return true;
                }
            }
            for (Effect effect : sa.getEffects()) {
                for (UUID targetId : effect.getTargetPointer().getTargets(game, sa)) {
                    if (targetId.equals(this.getSourceId())) {
                        return true;
                    }
                }
View Full Code Here

        this.filter = effect.filter.copy();
    }

    @Override
    public boolean apply(Game game, Ability source, Ability abilityToModify) {
        SpellAbility spellAbility = (SpellAbility)abilityToModify;
        Mana mana = spellAbility.getManaCostsToPay().getMana();
        if (mana.getColorless() > 0) {
            int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
            int newCount = mana.getColorless() - count;
            if (newCount < 0) {
                newCount = 0;
            }
            mana.setColorless(newCount);
            spellAbility.getManaCostsToPay().load(mana.toString());
            return true;
        }
        return false;
    }
View Full Code Here

            return false;
        }
        Card reboundCard = zone.get(this.cardId, game);
        Player player = game.getPlayer(source.getControllerId());
        if (player != null && reboundCard != null) {
            SpellAbility ability = reboundCard.getSpellAbility();
            player.cast(ability, game, true);
            zone.remove(reboundCard.getId());
            return true;
        }
        return false;
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        Card cipherCard = game.getCard(cipherCardId);
        if (cipherCard != null) {
            Card copyCard = game.copyCard(cipherCard, source, controller.getId());
            SpellAbility ability = copyCard.getSpellAbility();
            // remove the cipher effect from the copy
            Effect cipherEffect = null;
            for (Effect effect :ability.getEffects()) {
                if (effect instanceof CipherEffect) {
                    cipherEffect = effect;
                }
            }
            ability.getEffects().remove(cipherEffect);
            if (ability != null && ability instanceof SpellAbility) {
                controller.cast(ability, game, true);
            }
        }
View Full Code Here

        super(effect);
    }

    @Override
    public boolean apply(Game game, Ability source, Ability abilityToModify) {
        SpellAbility spellAbility = (SpellAbility) abilityToModify;
        CardUtil.adjustCost(spellAbility, 2);
        return true;
    }
View Full Code Here

TOP

Related Classes of mage.abilities.SpellAbility

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.