mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Benthic Explorer - Fixed mana type calculation.
* DynamicManaEffect - Fixed mana type calculation. Some code clean up.
This commit is contained in:
parent
66d5b915db
commit
457557852e
7 changed files with 148 additions and 193 deletions
|
|
@ -92,41 +92,10 @@ public abstract class ManaEffect extends OneShotEffect {
|
|||
* @return
|
||||
*/
|
||||
public Set<ManaType> getProducableManaTypes(Game game, Ability source) {
|
||||
return getManaTypesFromManaList(getNetMana(game, source));
|
||||
}
|
||||
|
||||
public static Set<ManaType> getManaTypesFromManaList(List<Mana> manaList) {
|
||||
Set<ManaType> manaTypes = new HashSet<>();
|
||||
for (Mana mana : manaList) {
|
||||
if (mana.getAny() > 0) {
|
||||
manaTypes.add(ManaType.BLACK);
|
||||
manaTypes.add(ManaType.BLUE);
|
||||
manaTypes.add(ManaType.GREEN);
|
||||
manaTypes.add(ManaType.WHITE);
|
||||
manaTypes.add(ManaType.RED);
|
||||
}
|
||||
if (mana.getBlack() > 0) {
|
||||
manaTypes.add(ManaType.BLACK);
|
||||
}
|
||||
if (mana.getBlue() > 0) {
|
||||
manaTypes.add(ManaType.BLUE);
|
||||
}
|
||||
if (mana.getGreen() > 0) {
|
||||
manaTypes.add(ManaType.GREEN);
|
||||
}
|
||||
if (mana.getWhite() > 0) {
|
||||
manaTypes.add(ManaType.WHITE);
|
||||
}
|
||||
if (mana.getRed() > 0) {
|
||||
manaTypes.add(ManaType.RED);
|
||||
}
|
||||
if (mana.getColorless() > 0) {
|
||||
manaTypes.add(ManaType.COLORLESS);
|
||||
}
|
||||
}
|
||||
return manaTypes;
|
||||
return ManaType.getManaTypesFromManaList(getNetMana(game, source));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Produced the mana the effect can produce (DO NOT add it to mana pool --
|
||||
* return all added as mana object to process by replace events)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import mage.players.Player;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import mage.constants.ManaType;
|
||||
|
||||
/**
|
||||
* @author North
|
||||
|
|
@ -116,6 +118,11 @@ public class DynamicManaEffect extends ManaEffect {
|
|||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ManaType> getProducableManaTypes(Game game, Ability source) {
|
||||
return ManaType.getManaTypesFromManaList(baseMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana computedMana = new Mana();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
|
|
@ -101,29 +99,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netManas = new ArrayList<>();
|
||||
if (game != null) {
|
||||
Set<ManaType> manaTypes = getManaTypes(game, source);
|
||||
if ((manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS)) || manaTypes.size() == 6) { // GENERIC should never be returned from getManaTypes
|
||||
netManas.add(Mana.AnyMana(1));
|
||||
} else {
|
||||
if (manaTypes.contains(ManaType.BLACK)) {
|
||||
netManas.add(Mana.BlackMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.RED)) {
|
||||
netManas.add(Mana.RedMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.BLUE)) {
|
||||
netManas.add(Mana.BlueMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.GREEN)) {
|
||||
netManas.add(Mana.GreenMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.WHITE)) {
|
||||
netManas.add(Mana.WhiteMana(1));
|
||||
}
|
||||
}
|
||||
if (!onlyColors && manaTypes.contains(ManaType.COLORLESS)) {
|
||||
netManas.add(Mana.ColorlessMana(1));
|
||||
}
|
||||
netManas = ManaType.getManaListFromManaTypes(getManaTypes(game, source), onlyColors);
|
||||
}
|
||||
return netManas;
|
||||
}
|
||||
|
|
@ -134,28 +110,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Set<ManaType> types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
choice.setMessage("Pick a mana " + (onlyColors ? "color" : "type"));
|
||||
if (types.contains(ManaType.BLACK)) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
if (types.contains(ManaType.RED)) {
|
||||
choice.getChoices().add("Red");
|
||||
}
|
||||
if (types.contains(ManaType.BLUE)) {
|
||||
choice.getChoices().add("Blue");
|
||||
}
|
||||
if (types.contains(ManaType.GREEN)) {
|
||||
choice.getChoices().add("Green");
|
||||
}
|
||||
if (types.contains(ManaType.WHITE)) {
|
||||
choice.getChoices().add("White");
|
||||
}
|
||||
if (types.contains(ManaType.COLORLESS)) {
|
||||
choice.getChoices().add("Colorless");
|
||||
}
|
||||
Choice choice = ManaType.getChoiceOfManaTypes(getManaTypes(game, source), onlyColors);
|
||||
if (!choice.getChoices().isEmpty()) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (choice.getChoices().size() == 1) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
package mage.constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import mage.Mana;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
|
@ -24,4 +33,95 @@ public enum ManaType {
|
|||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public static Choice getChoiceOfManaTypes(Set<ManaType> types, boolean onlyColors) {
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
choice.setMessage("Pick a mana " + (onlyColors ? "color" : "type"));
|
||||
if (types.contains(ManaType.BLACK)) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
if (types.contains(ManaType.RED)) {
|
||||
choice.getChoices().add("Red");
|
||||
}
|
||||
if (types.contains(ManaType.BLUE)) {
|
||||
choice.getChoices().add("Blue");
|
||||
}
|
||||
if (types.contains(ManaType.GREEN)) {
|
||||
choice.getChoices().add("Green");
|
||||
}
|
||||
if (types.contains(ManaType.WHITE)) {
|
||||
choice.getChoices().add("White");
|
||||
}
|
||||
if (types.contains(ManaType.COLORLESS)) {
|
||||
choice.getChoices().add("Colorless");
|
||||
}
|
||||
return choice;
|
||||
}
|
||||
|
||||
public static List<Mana> getManaListFromManaTypes(Set<ManaType> manaTypes, boolean onlyColors) {
|
||||
List<Mana> netManas = new ArrayList<>();
|
||||
if ((manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS)) || manaTypes.size() == 6) { // GENERIC should never be returned from getManaTypes
|
||||
netManas.add(Mana.AnyMana(1));
|
||||
} else {
|
||||
if (manaTypes.contains(ManaType.BLACK)) {
|
||||
netManas.add(Mana.BlackMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.RED)) {
|
||||
netManas.add(Mana.RedMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.BLUE)) {
|
||||
netManas.add(Mana.BlueMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.GREEN)) {
|
||||
netManas.add(Mana.GreenMana(1));
|
||||
}
|
||||
if (manaTypes.contains(ManaType.WHITE)) {
|
||||
netManas.add(Mana.WhiteMana(1));
|
||||
}
|
||||
}
|
||||
if (!onlyColors && manaTypes.contains(ManaType.COLORLESS)) {
|
||||
netManas.add(Mana.ColorlessMana(1));
|
||||
}
|
||||
|
||||
return netManas;
|
||||
}
|
||||
|
||||
public static Set<ManaType> getManaTypesFromManaList(Mana mana) {
|
||||
Set<ManaType> manaTypes = EnumSet.noneOf(ManaType.class);
|
||||
if (mana.getAny() > 0) {
|
||||
manaTypes.add(ManaType.BLACK);
|
||||
manaTypes.add(ManaType.BLUE);
|
||||
manaTypes.add(ManaType.GREEN);
|
||||
manaTypes.add(ManaType.WHITE);
|
||||
manaTypes.add(ManaType.RED);
|
||||
}
|
||||
if (mana.getBlack() > 0) {
|
||||
manaTypes.add(ManaType.BLACK);
|
||||
}
|
||||
if (mana.getBlue() > 0) {
|
||||
manaTypes.add(ManaType.BLUE);
|
||||
}
|
||||
if (mana.getGreen() > 0) {
|
||||
manaTypes.add(ManaType.GREEN);
|
||||
}
|
||||
if (mana.getWhite() > 0) {
|
||||
manaTypes.add(ManaType.WHITE);
|
||||
}
|
||||
if (mana.getRed() > 0) {
|
||||
manaTypes.add(ManaType.RED);
|
||||
}
|
||||
if (mana.getColorless() > 0) {
|
||||
manaTypes.add(ManaType.COLORLESS);
|
||||
}
|
||||
return manaTypes;
|
||||
}
|
||||
|
||||
public static Set<ManaType> getManaTypesFromManaList(List<Mana> manaList) {
|
||||
Set<ManaType> manaTypes = new HashSet<>();
|
||||
for (Mana mana : manaList) {
|
||||
manaTypes.addAll(getManaTypesFromManaList(mana));
|
||||
}
|
||||
return manaTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue