mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
Added support for casting modal spells or activating modal abilities with more than one mode to choose.
This commit is contained in:
parent
d520d63e2c
commit
853810ce45
8 changed files with 201 additions and 90 deletions
|
|
@ -47,6 +47,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.cards.SplitCard;
|
||||
|
|
@ -184,15 +185,19 @@ public class CardView extends SimpleCardView {
|
|||
if (card instanceof Spell) {
|
||||
Spell<?> spell = (Spell<?>) card;
|
||||
for (SpellAbility spellAbility: spell.getSpellAbilities()) {
|
||||
if (spellAbility.getTargets().size() > 0) {
|
||||
setTargets(spellAbility.getTargets());
|
||||
for(UUID modeId : spellAbility.getModes().getSelectedModes()) {
|
||||
spellAbility.getModes().setMode(spellAbility.getModes().get(modeId));
|
||||
if (spellAbility.getTargets().size() > 0) {
|
||||
setTargets(spellAbility.getTargets());
|
||||
}
|
||||
}
|
||||
}
|
||||
// show for modal spell, which mode was choosen
|
||||
if (spell.getSpellAbility().isModal()) {
|
||||
Mode activeMode = spell.getSpellAbility().getModes().getMode();
|
||||
if (activeMode != null) {
|
||||
this.rules.add("<span color='green'><i>Chosen mode: " + activeMode.getEffects().getText(activeMode)+"</i></span>");
|
||||
Modes modes = spell.getSpellAbility().getModes();
|
||||
for(UUID modeId : modes.getSelectedModes()) {
|
||||
modes.setMode(modes.get(modeId));
|
||||
this.rules.add("<span color='green'><i>Chosen mode: " + spell.getSpellAbility().getEffects().getText(modes.get(modeId))+"</i></span>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@
|
|||
|
||||
package mage.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.target.targetpointer.TargetPointer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -68,30 +68,43 @@ public class StackAbilityView extends CardView {
|
|||
}
|
||||
|
||||
private void updateTargets(Game game, StackAbility ability) {
|
||||
if (ability.getTargets().size() > 0) {
|
||||
setTargets(ability.getTargets());
|
||||
} else {
|
||||
List<UUID> targetList = new ArrayList<UUID>();
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
TargetPointer targetPointer = effect.getTargetPointer();
|
||||
if (targetPointer instanceof FixedTarget) {
|
||||
targetList.add(((FixedTarget) targetPointer).getTarget());
|
||||
}
|
||||
}
|
||||
if (targetList.size() > 0) {
|
||||
overrideTargets(targetList);
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (UUID uuid : targetList) {
|
||||
MageObject mageObject = game.getObject(uuid);
|
||||
if (mageObject != null) {
|
||||
names.add(mageObject.getName());
|
||||
List<String> names = new ArrayList<String>();
|
||||
for(UUID modeId : ability.getModes().getSelectedModes()) {
|
||||
ability.getModes().setMode(ability.getModes().get(modeId));
|
||||
if (ability.getTargets().size() > 0) {
|
||||
setTargets(ability.getTargets());
|
||||
} else {
|
||||
List<UUID> targetList = new ArrayList<UUID>();
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
TargetPointer targetPointer = effect.getTargetPointer();
|
||||
if (targetPointer instanceof FixedTarget) {
|
||||
targetList.add(((FixedTarget) targetPointer).getTarget());
|
||||
}
|
||||
}
|
||||
if (!names.isEmpty()) {
|
||||
getRules().add("<i>Targets: " + names.toString() + "</i>");
|
||||
if (targetList.size() > 0) {
|
||||
overrideTargets(targetList);
|
||||
|
||||
for (UUID uuid : targetList) {
|
||||
MageObject mageObject = game.getObject(uuid);
|
||||
if (mageObject != null) {
|
||||
names.add(mageObject.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!names.isEmpty()) {
|
||||
getRules().add("<i>Targets: " + names.toString() + "</i>");
|
||||
}
|
||||
// show for modal ability, which mode was choosen
|
||||
if (ability.isModal()) {
|
||||
Modes modes = ability.getModes();
|
||||
for(UUID modeId : modes.getSelectedModes()) {
|
||||
modes.setMode(modes.get(modeId));
|
||||
this.rules.add("<span color='green'><i>Chosen mode: " + ability.getEffects().getText(modes.get(modeId))+"</i></span>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CardView getSourceCard() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue