Battlefield Thaumaturge - fixed that it doesn't allow to cast spells without full available mana (#6698);

This commit is contained in:
Oleg Agafonov 2020-07-05 01:08:43 +04:00
parent 8e819ee614
commit 69d8fd1898
9 changed files with 144 additions and 32 deletions

View file

@ -190,13 +190,19 @@ public interface Ability extends Controllable, Serializable {
/**
* Retrieves all targets that must be satisfied before this ability is put
* onto the stack.
* onto the stack. Warning, return targets from first/current mode only.
*
* @return All {@link Targets} that must be satisfied before this ability is
* put onto the stack.
*/
Targets getTargets();
/**
* Retrieves all selected targets, read only. Multi-modes return different targets.
* Works on stack only (after real cast/activate)
*/
Targets getAllSelectedTargets();
/**
* Retrieves the {@link Target} located at the 0th index in the
* {@link Targets}. A call to the method is equivalent to
@ -525,6 +531,7 @@ public interface Ability extends Controllable, Serializable {
/**
* For mtg's instances search, see rules example in 112.10b
*
* @param ability
* @return
*/

View file

@ -846,6 +846,18 @@ public abstract class AbilityImpl implements Ability {
return new Targets();
}
@Override
public Targets getAllSelectedTargets() {
Targets res = new Targets();
for (UUID modeId : this.getModes().getSelectedModes()) {
Mode mode = this.getModes().get(modeId);
if (mode != null) {
res.addAll(mode.getTargets());
}
}
return res;
}
@Override
public UUID getFirstTarget() {
return getTargets().getFirstTarget();

View file

@ -23,7 +23,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
public static final UUID CHOOSE_OPTION_CANCEL_ID = UUID.fromString("0125bd0c-5610-4eba-bc80-fc6d0a7b9de6");
private Mode currentMode; // the current mode of the selected modes
private final List<UUID> selectedModes = new ArrayList<>(); // all selected modes (this + duplicate), for all code user getSelectedModes to keep modes order
private final List<UUID> selectedModes = new ArrayList<>(); // all selected modes (this + duplicate), use getSelectedModes all the time to keep modes order
private final Map<UUID, Mode> selectedDuplicateModes = new LinkedHashMap<>(); // for 2x selects: copy mode and put it to duplicate list
private final Map<UUID, UUID> selectedDuplicateToOriginalModeRefs = new LinkedHashMap<>(); // for 2x selects: stores ref from duplicate to original mode

View file

@ -1,9 +1,5 @@
package mage.game.stack;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
@ -34,6 +30,11 @@ import mage.util.GameLog;
import mage.util.SubTypeList;
import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -307,6 +308,11 @@ public class StackAbility extends StackObjImpl implements Ability {
return ability.getTargets();
}
@Override
public Targets getAllSelectedTargets() {
return ability.getAllSelectedTargets();
}
@Override
public void addTarget(Target target) {
}