mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
ui-manapool: changed the keys used to identify colors into bytes (as defined in MagicColor)
This commit is contained in:
@@ -13,7 +13,6 @@ import forge.FThreads;
|
|||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.mana.ManaPool;
|
|
||||||
import forge.card.spellability.AbilityManaPart;
|
import forge.card.spellability.AbilityManaPart;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
@@ -57,8 +56,8 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
activateManaAbility(card, this.manaCost);
|
activateManaAbility(card, this.manaCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectManaPool(String color) {
|
public void selectManaPool(byte colorCode) {
|
||||||
useManaFromPool(color);
|
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
|
* @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(byte colorCode) { useManaFromPool(colorCode, manaCost); }
|
||||||
protected void useManaFromPool(String color, ManaCostBeingPaid manaCost) {
|
protected void useManaFromPool(byte colorCode, ManaCostBeingPaid manaCost) {
|
||||||
ManaPool mp = player.getManaPool();
|
|
||||||
|
|
||||||
// Convert Color to short String
|
// Convert Color to short String
|
||||||
String manaStr = "1";
|
player.getManaPool().payManaFromPool(saPaidFor, manaCost, MagicColor.toShortString(colorCode));
|
||||||
if (!color.equalsIgnoreCase("Colorless")) {
|
|
||||||
manaStr = CardUtil.getShortColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
mp.payManaFromPool(saPaidFor, manaCost, manaStr);
|
|
||||||
|
|
||||||
onManaAbilityPlayed(null);
|
onManaAbilityPlayed(null);
|
||||||
showMessage();
|
showMessage();
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectManaPool(String color) {
|
public void selectManaPool(byte colorCode) {
|
||||||
useManaFromPool(color, this.colorX.isEmpty() ? this.manaCost : new ManaCostBeingPaid(this.colorX));
|
useManaFromPool(colorCode, this.colorX.isEmpty() ? this.manaCost : new ManaCostBeingPaid(this.colorX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
if (CField.this.player == CField.this.playerViewer) {
|
||||||
final Input in = Singletons.getModel().getMatch().getInput().getInput();
|
final Input in = Singletons.getModel().getMatch().getInput().getInput();
|
||||||
if (in instanceof InputPayManaBase) {
|
if (in instanceof InputPayManaBase) {
|
||||||
// Do something
|
// 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);
|
((FLabel) this.view.getLblFlashback()).setHoverable(true);
|
||||||
this.view.getLblFlashback().addMouseListener(madFlashback);
|
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().setHoverable(true);
|
||||||
labelPair.getLeft().addMouseListener(new MouseAdapter() { @Override
|
labelPair.getLeft().addMouseListener(new MouseAdapter() { @Override
|
||||||
public void mousePressed(final MouseEvent e) {
|
public void mousePressed(final MouseEvent e) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import forge.Constant;
|
import forge.card.MagicColor;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.mana.ManaPool;
|
import forge.card.mana.ManaPool;
|
||||||
import forge.game.phase.PhaseType;
|
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 lblExile = getBuiltFLabel(FSkin.ZoneImages.ICO_EXILE, "99", "Exiled cards");
|
||||||
private FLabel lblFlashback = getBuiltFLabel(FSkin.ZoneImages.ICO_FLASHBACK, "99", "Flashback cards");
|
private FLabel lblFlashback = getBuiltFLabel(FSkin.ZoneImages.ICO_FLASHBACK, "99", "Flashback cards");
|
||||||
private FLabel lblPoison = getBuiltFLabel(FSkin.ZoneImages.ICO_POISON, "99", "Poison counters");
|
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
|
// Phase labels
|
||||||
private PhaseLabel lblUpkeep = new PhaseLabel("UP");
|
private PhaseLabel lblUpkeep = new PhaseLabel("UP");
|
||||||
@@ -126,12 +126,12 @@ public class VField implements IVDoc<CField> {
|
|||||||
if (playerOnwer != null) { tab.setText(playerOnwer.getName() + " Field"); }
|
if (playerOnwer != null) { tab.setText(playerOnwer.getName() + " Field"); }
|
||||||
else { tab.setText("NO PLAYER FOR " + docID.toString()); }
|
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_BLACK, "99", "Black mana"), MagicColor.BLACK));
|
||||||
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_BLUE, "99", "Blue mana"), Constant.Color.BLUE));
|
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"), Constant.Color.GREEN));
|
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"), Constant.Color.RED));
|
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"), Constant.Color.WHITE));
|
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"), Constant.Color.COLORLESS));
|
manaLabels.add(ImmutablePair.of(getBuiltFLabel(FSkin.ManaImages.IMG_COLORLESS, "99", "Colorless mana"), (byte)0));
|
||||||
|
|
||||||
// TODO player is hard-coded into tabletop...should be dynamic
|
// TODO player is hard-coded into tabletop...should be dynamic
|
||||||
// (haven't looked into it too deeply). Doublestrike 12-04-12
|
// (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) {
|
public void updateManaPool(final Player p0) {
|
||||||
ManaPool m = p0.getManaPool();
|
ManaPool m = p0.getManaPool();
|
||||||
for(Pair<FLabel, String> label : manaLabels)
|
for(Pair<FLabel, Byte> label : manaLabels)
|
||||||
label.getKey().setText(Integer.toString(m.getAmountOfColor(label.getRight())));
|
label.getKey().setText(Integer.toString(m.getAmountOfColor(MagicColor.toLongString(label.getRight()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//========= Retrieval methods
|
//========= Retrieval methods
|
||||||
@@ -435,7 +435,7 @@ public class VField implements IVDoc<CField> {
|
|||||||
return this.lblLibrary;
|
return this.lblLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Iterable<Pair<FLabel, String>> getManaLabels() {
|
public final Iterable<Pair<FLabel, Byte>> getManaLabels() {
|
||||||
return manaLabels;
|
return manaLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user