mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
converted sunburstMap to byte (from strings and hashmaps)
This commit is contained in:
@@ -190,7 +190,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
private int replicateMagnitude = 0;
|
private int replicateMagnitude = 0;
|
||||||
|
|
||||||
private int sunburstValue = 0;
|
private int sunburstValue = 0;
|
||||||
private String colorsPaid = "";
|
private byte colorsPaid = 0;
|
||||||
|
|
||||||
private Player owner = null;
|
private Player owner = null;
|
||||||
private Player controller = null;
|
private Player controller = null;
|
||||||
@@ -876,7 +876,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Append colors instead of replacing
|
// TODO: Append colors instead of replacing
|
||||||
public final void setColorsPaid(final String s) {
|
public final void setColorsPaid(final byte s) {
|
||||||
this.colorsPaid = s;
|
this.colorsPaid = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -887,7 +887,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*
|
*
|
||||||
* @return a String.
|
* @return a String.
|
||||||
*/
|
*/
|
||||||
public final String getColorsPaid() {
|
public final byte getColorsPaid() {
|
||||||
return this.colorsPaid;
|
return this.colorsPaid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,19 +294,21 @@ public abstract class TriggerReplacementBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("ManaSpent")) {
|
if (params.containsKey("ManaSpent")) {
|
||||||
if (!this.getHostCard().getColorsPaid().contains(params.get("ManaSpent"))) {
|
byte spent = MagicColor.fromName(params.get("ManaSpent"));
|
||||||
|
if ( 0 == (this.getHostCard().getColorsPaid() & spent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("ManaNotSpent")) {
|
if (params.containsKey("ManaNotSpent")) {
|
||||||
if (this.getHostCard().getColorsPaid().contains(params.get("ManaNotSpent"))) {
|
byte spent = MagicColor.fromName(params.get("ManaSpent"));
|
||||||
|
if ( 0 != (this.getHostCard().getColorsPaid() & spent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("WerewolfTransformCondition")) {
|
if (params.containsKey("WerewolfTransformCondition")) {
|
||||||
if (CardUtil.getLastTurnCast("Card", this.getHostCard()).size() > 0) {
|
if (!CardUtil.getLastTurnCast("Card", this.getHostCard()).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class ManaCostBeingPaid {
|
|||||||
// holds Mana_Part objects
|
// holds Mana_Part objects
|
||||||
// ManaPartColor is stored before ManaPartColorless
|
// ManaPartColor is stored before ManaPartColorless
|
||||||
private final HashMap<ManaCostShard, Integer> unpaidShards = new HashMap<ManaCostShard, Integer>();
|
private final HashMap<ManaCostShard, Integer> unpaidShards = new HashMap<ManaCostShard, Integer>();
|
||||||
private final HashMap<String, Integer> sunburstMap = new HashMap<String, Integer>();
|
private byte sunburstMap = 0;
|
||||||
private int cntX = 0;
|
private int cntX = 0;
|
||||||
private final String sourceRestriction;
|
private final String sourceRestriction;
|
||||||
|
|
||||||
@@ -146,9 +146,7 @@ public class ManaCostBeingPaid {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public final int getSunburst() {
|
public final int getSunburst() {
|
||||||
final int ret = this.sunburstMap.size();
|
return ColorSet.fromMask(sunburstMap).countColors();
|
||||||
this.sunburstMap.clear();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,26 +156,8 @@ public class ManaCostBeingPaid {
|
|||||||
*
|
*
|
||||||
* @return a String.
|
* @return a String.
|
||||||
*/
|
*/
|
||||||
public final String getColorsPaid() {
|
public final byte getColorsPaid() {
|
||||||
String s = "";
|
return sunburstMap;
|
||||||
for (final String key : this.sunburstMap.keySet()) {
|
|
||||||
if (key.equalsIgnoreCase("black") || key.equalsIgnoreCase("B")) {
|
|
||||||
s += "B";
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("blue") || key.equalsIgnoreCase("U")) {
|
|
||||||
s += "U";
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("green") || key.equalsIgnoreCase("G")) {
|
|
||||||
s += "G";
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("red") || key.equalsIgnoreCase("R")) {
|
|
||||||
s += "R";
|
|
||||||
}
|
|
||||||
if (key.equalsIgnoreCase("white") || key.equalsIgnoreCase("W")) {
|
|
||||||
s += "W";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -470,13 +450,7 @@ public class ManaCostBeingPaid {
|
|||||||
this.increaseColorlessMana(1);
|
this.increaseColorlessMana(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mana.equals(Constant.Color.COLORLESS)) {
|
this.sunburstMap |= colorMask;
|
||||||
if (this.sunburstMap.containsKey(mana)) {
|
|
||||||
this.sunburstMap.put(mana, this.sunburstMap.get(mana) + 1);
|
|
||||||
} else {
|
|
||||||
this.sunburstMap.put(mana, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,20 +524,13 @@ public class ManaCostBeingPaid {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String manaColor = mana.getColor();
|
|
||||||
|
|
||||||
decreaseShard(choice, 1);
|
decreaseShard(choice, 1);
|
||||||
if (choice.isOr2Colorless() && choice.getColorMask() != mana.getColorCode() ) {
|
if (choice.isOr2Colorless() && choice.getColorMask() != mana.getColorCode() ) {
|
||||||
this.increaseColorlessMana(1);
|
this.increaseColorlessMana(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mana.isColor(Constant.Color.COLORLESS)) {
|
this.sunburstMap |= mana.getColorCode();
|
||||||
if (this.sunburstMap.containsKey(manaColor)) {
|
|
||||||
this.sunburstMap.put(manaColor, this.sunburstMap.get(manaColor) + 1);
|
|
||||||
} else {
|
|
||||||
this.sunburstMap.put(manaColor, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
@@ -315,11 +318,11 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != this.getManaSpent()) {
|
if (StringUtils.isNotEmpty(this.getManaSpent())) {
|
||||||
if (!sa.getSourceCard().getColorsPaid().contains(this.getManaSpent())) {
|
byte manaSpent = MagicColor.fromName(getManaSpent()); // they always check for single color
|
||||||
|
if( 0 == (manaSpent & sa.getSourceCard().getColorsPaid())) // no match of colors
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getsVarToCheck() != null) {
|
if (this.getsVarToCheck() != null) {
|
||||||
final int svarValue = AbilityUtils.calculateAmount(sa.getSourceCard(), this.getsVarToCheck(), sa);
|
final int svarValue = AbilityUtils.calculateAmount(sa.getSourceCard(), this.getsVarToCheck(), sa);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
import forge.card.ColorSet;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.view.ButtonUtil;
|
import forge.view.ButtonUtil;
|
||||||
@@ -13,7 +14,7 @@ import forge.view.ButtonUtil;
|
|||||||
public class InputPayManaX extends InputPayManaBase {
|
public class InputPayManaX extends InputPayManaBase {
|
||||||
private static final long serialVersionUID = -6900234444347364050L;
|
private static final long serialVersionUID = -6900234444347364050L;
|
||||||
private int xPaid = 0;
|
private int xPaid = 0;
|
||||||
private String colorsPaid;
|
private byte colorsPaid;
|
||||||
private final String manaCostStr;
|
private final String manaCostStr;
|
||||||
private final boolean xCanBe0;
|
private final boolean xCanBe0;
|
||||||
private boolean canceled = false;
|
private boolean canceled = false;
|
||||||
@@ -85,9 +86,7 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
@Override
|
@Override
|
||||||
protected void onManaAbilityPaid() {
|
protected void onManaAbilityPaid() {
|
||||||
if (this.manaCost.isPaid()) {
|
if (this.manaCost.isPaid()) {
|
||||||
if (!this.colorsPaid.contains(this.manaCost.getColorsPaid())) {
|
this.colorsPaid |= manaCost.getColorsPaid();
|
||||||
this.colorsPaid += this.manaCost.getColorsPaid();
|
|
||||||
}
|
|
||||||
this.manaCost = new ManaCostBeingPaid(manaCostStr);
|
this.manaCost = new ManaCostBeingPaid(manaCostStr);
|
||||||
this.xPaid++;
|
this.xPaid++;
|
||||||
}
|
}
|
||||||
@@ -116,7 +115,7 @@ public class InputPayManaX extends InputPayManaBase {
|
|||||||
final Card card = saPaidFor.getSourceCard();
|
final Card card = saPaidFor.getSourceCard();
|
||||||
card.setXManaCostPaid(this.xPaid);
|
card.setXManaCostPaid(this.xPaid);
|
||||||
card.setColorsPaid(this.colorsPaid);
|
card.setColorsPaid(this.colorsPaid);
|
||||||
card.setSunburstValue(this.colorsPaid.length());
|
card.setSunburstValue(ColorSet.fromMask(this.colorsPaid).countColors());
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user