ui-manapool: changed the keys used to identify colors into bytes (as defined in MagicColor)

This commit is contained in:
Maxmtg
2013-05-07 14:04:35 +00:00
parent e1bc624869
commit cd0e94560e
4 changed files with 21 additions and 29 deletions

View File

@@ -13,7 +13,6 @@ import forge.FThreads;
import forge.card.MagicColor;
import forge.card.ability.ApiType;
import forge.card.mana.ManaCostBeingPaid;
import forge.card.mana.ManaPool;
import forge.card.spellability.AbilityManaPart;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
@@ -57,8 +56,8 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
activateManaAbility(card, this.manaCost);
}
public void selectManaPool(String color) {
useManaFromPool(color);
public void selectManaPool(byte colorCode) {
useManaFromPool(colorCode);
}
/**
@@ -117,17 +116,10 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
*
* @return ManaCost the amount of mana remaining to be paid after the mana is activated
*/
protected void useManaFromPool(String color) { useManaFromPool(color, manaCost); }
protected void useManaFromPool(String color, ManaCostBeingPaid manaCost) {
ManaPool mp = player.getManaPool();
protected void useManaFromPool(byte colorCode) { useManaFromPool(colorCode, manaCost); }
protected void useManaFromPool(byte colorCode, ManaCostBeingPaid manaCost) {
// Convert Color to short String
String manaStr = "1";
if (!color.equalsIgnoreCase("Colorless")) {
manaStr = CardUtil.getShortColor(color);
}
mp.payManaFromPool(saPaidFor, manaCost, manaStr);
player.getManaPool().payManaFromPool(saPaidFor, manaCost, MagicColor.toShortString(colorCode));
onManaAbilityPlayed(null);
showMessage();

View File

@@ -88,8 +88,8 @@ public class InputPayManaX extends InputPayManaBase {
}
@Override
public void selectManaPool(String color) {
useManaFromPool(color, this.colorX.isEmpty() ? this.manaCost : new ManaCostBeingPaid(this.colorX));
public void selectManaPool(byte colorCode) {
useManaFromPool(colorCode, this.colorX.isEmpty() ? this.manaCost : new ManaCostBeingPaid(this.colorX));
}

View File

@@ -195,12 +195,12 @@ public class CField implements ICDoc {
}
/** */
private void manaAction(String constantColor) {
private void manaAction(byte colorCode) {
if (CField.this.player == CField.this.playerViewer) {
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayManaBase) {
// Do something
((InputPayManaBase) in).selectManaPool(constantColor);
((InputPayManaBase) in).selectManaPool(colorCode);
}
}
}
@@ -243,7 +243,7 @@ public class CField implements ICDoc {
((FLabel) this.view.getLblFlashback()).setHoverable(true);
this.view.getLblFlashback().addMouseListener(madFlashback);
for(final Pair<FLabel, String> labelPair : this.view.getManaLabels()) {
for(final Pair<FLabel, Byte> labelPair : this.view.getManaLabels()) {
labelPair.getLeft().setHoverable(true);
labelPair.getLeft().addMouseListener(new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {

View File

@@ -38,7 +38,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import net.miginfocom.swing.MigLayout;
import forge.Constant;
import forge.card.MagicColor;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.mana.ManaPool;
import forge.game.phase.PhaseType;
@@ -90,7 +90,7 @@ public class VField implements IVDoc<CField> {
private FLabel lblExile = getBuiltFLabel(FSkin.ZoneImages.ICO_EXILE, "99", "Exiled cards");
private FLabel lblFlashback = getBuiltFLabel(FSkin.ZoneImages.ICO_FLASHBACK, "99", "Flashback cards");
private FLabel lblPoison = getBuiltFLabel(FSkin.ZoneImages.ICO_POISON, "99", "Poison counters");
private final List<Pair<FLabel, String>> manaLabels = new ArrayList<Pair<FLabel,String>>();
private final List<Pair<FLabel, Byte>> manaLabels = new ArrayList<Pair<FLabel,Byte>>();
// Phase labels
private PhaseLabel lblUpkeep = new PhaseLabel("UP");
@@ -126,12 +126,12 @@ public class VField implements IVDoc<CField> {
if (playerOnwer != null) { tab.setText(playerOnwer.getName() + " Field"); }
else { tab.setText("NO PLAYER FOR " + docID.toString()); }
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_BLACK, "99", "Black mana"), Constant.Color.BLACK));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_BLUE, "99", "Blue mana"), Constant.Color.BLUE));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_GREEN, "99", "Green mana"), Constant.Color.GREEN));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_RED, "99", "Red mana"), Constant.Color.RED));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_WHITE, "99", "White mana"), Constant.Color.WHITE));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_COLORLESS, "99", "Colorless mana"), Constant.Color.COLORLESS));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_BLACK, "99", "Black mana"), MagicColor.BLACK));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_BLUE, "99", "Blue mana"), MagicColor.BLUE));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_GREEN, "99", "Green mana"), MagicColor.GREEN));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_RED, "99", "Red mana"), MagicColor.RED));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_WHITE, "99", "White mana"), MagicColor.WHITE));
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_COLORLESS, "99", "Colorless mana"), (byte)0));
// TODO player is hard-coded into tabletop...should be dynamic
// (haven't looked into it too deeply). Doublestrike 12-04-12
@@ -384,8 +384,8 @@ public class VField implements IVDoc<CField> {
*/
public void updateManaPool(final Player p0) {
ManaPool m = p0.getManaPool();
for(Pair<FLabel, String> label : manaLabels)
label.getKey().setText(Integer.toString(m.getAmountOfColor(label.getRight())));
for(Pair<FLabel, Byte> label : manaLabels)
label.getKey().setText(Integer.toString(m.getAmountOfColor(MagicColor.toLongString(label.getRight()))));
}
//========= Retrieval methods
@@ -435,7 +435,7 @@ public class VField implements IVDoc<CField> {
return this.lblLibrary;
}
public final Iterable<Pair<FLabel, String>> getManaLabels() {
public final Iterable<Pair<FLabel, Byte>> getManaLabels() {
return manaLabels;
}