Search in sources :

Example 1 with Modes

use of mage.abilities.Modes in project mage by magefree.

the class AdventureCardSpellAbility method getRule.

@Override
public String getRule() {
    StringBuilder sbRule = new StringBuilder();
    sbRule.append(this.nameFull);
    sbRule.append(" ");
    sbRule.append(manaCosts.getText());
    sbRule.append(" — ");
    Modes modes = this.getModes();
    if (modes.size() <= 1) {
        sbRule.append(modes.getMode().getEffects().getTextStartingUpperCase(modes.getMode()));
    } else {
        sbRule.append(getModes().getText());
    }
    sbRule.append(" <i>(Then exile this card. You may cast the creature later from exile.)</i>");
    return sbRule.toString();
}
Also used : Modes(mage.abilities.Modes)

Example 2 with Modes

use of mage.abilities.Modes in project mage by magefree.

the class StackAbilityView method updateTargets.

private void updateTargets(Game game, StackAbility ability) {
    List<String> names = new ArrayList<>();
    for (UUID modeId : ability.getModes().getSelectedModes()) {
        Mode mode = ability.getModes().get(modeId);
        if (!mode.getTargets().isEmpty()) {
            addTargets(mode.getTargets(), mode.getEffects(), ability, game);
        } else {
            List<UUID> targetList = new ArrayList<>();
            for (Effect effect : mode.getEffects()) {
                TargetPointer targetPointer = effect.getTargetPointer();
                if (targetPointer instanceof FixedTarget) {
                    targetList.add(((FixedTarget) targetPointer).getTarget());
                }
            }
            if (!targetList.isEmpty()) {
                overrideTargets(targetList);
                for (UUID uuid : targetList) {
                    MageObject mageObject = game.getObject(uuid);
                    if (mageObject != null) {
                        if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
                            continue;
                        }
                        String newName = GameLog.getColoredObjectIdNameForTooltip(mageObject);
                        if (!names.contains(newName)) {
                            names.add(newName);
                        }
                    }
                }
            }
        }
    }
    if (!names.isEmpty()) {
        getRules().add("<i>Related objects: " + names + "</i>");
    }
    // show for modal ability, which mode was choosen
    if (ability.isModal()) {
        Modes modes = ability.getModes();
        for (UUID modeId : modes.getSelectedModes()) {
            Mode mode = modes.get(modeId);
            this.rules.add("<span color='green'><i>Chosen mode: " + mode.getEffects().getText(mode) + "</i></span>");
        }
    }
    if (HintUtils.ABILITY_HINTS_ENABLE) {
        List<String> abilityHints = new ArrayList<>();
        for (Hint hint : ability.getHints()) {
            abilityHints.add(hint.getText(game, ability));
        }
        // total hints
        if (!abilityHints.isEmpty()) {
            rules.add(HintUtils.HINT_START_MARK);
            HintUtils.appendHints(rules, abilityHints);
        }
    }
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Modes(mage.abilities.Modes) Hint(mage.abilities.hint.Hint) Mode(mage.abilities.Mode) ArrayList(java.util.ArrayList) MageObject(mage.MageObject) Card(mage.cards.Card) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) TargetPointer(mage.target.targetpointer.TargetPointer)

Aggregations

Modes (mage.abilities.Modes)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 Mode (mage.abilities.Mode)1 Effect (mage.abilities.effects.Effect)1 Hint (mage.abilities.hint.Hint)1 Card (mage.cards.Card)1 FixedTarget (mage.target.targetpointer.FixedTarget)1 TargetPointer (mage.target.targetpointer.TargetPointer)1