mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
removed forge.Color, byte colorMask is used instead.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -13690,7 +13690,6 @@ src/main/java/forge/CardPowerToughness.java svneol=native#text/plain
|
||||
src/main/java/forge/CardPredicates.java svneol=native#text/plain
|
||||
src/main/java/forge/CardType.java svneol=native#text/plain
|
||||
src/main/java/forge/CardUtil.java svneol=native#text/plain
|
||||
src/main/java/forge/Color.java svneol=native#text/plain
|
||||
src/main/java/forge/ColorChanger.java -text
|
||||
src/main/java/forge/Command.java svneol=native#text/plain
|
||||
src/main/java/forge/Constant.java svneol=native#text/plain
|
||||
@@ -14608,7 +14607,6 @@ src/main/resources/proxy-template.ftl -text
|
||||
src/site/apt/index.apt -text
|
||||
src/test/java/forge/BoosterDraft1Test.java svneol=native#text/plain
|
||||
src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain
|
||||
src/test/java/forge/CardColorTest.java svneol=native#text/plain
|
||||
src/test/java/forge/GuiDownloadPicturesLQTest.java svneol=native#text/plain
|
||||
src/test/java/forge/GuiDownloadSetPicturesLQTest.java svneol=native#text/plain
|
||||
src/test/java/forge/GuiProgressBarWindowTest.java svneol=native#text/plain
|
||||
|
||||
@@ -50,7 +50,6 @@ import forge.card.ability.ApiType;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.replacement.ReplaceMoved;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.replacement.ReplacementResult;
|
||||
@@ -1537,7 +1536,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (s.equals("")) {
|
||||
s = "0";
|
||||
}
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(new ManaCostBeingPaid(s), this, false, true));
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(s, false, true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1555,11 +1554,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* a boolean.
|
||||
* @return a long.
|
||||
*/
|
||||
public final long addColor(final String s, final Card c, final boolean addToColors, final boolean bIncrease) {
|
||||
public final long addColor(final String s, final boolean addToColors, final boolean bIncrease) {
|
||||
if (bIncrease) {
|
||||
CardColor.increaseTimestamp();
|
||||
}
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(new ManaCostBeingPaid(s), c, addToColors, false));
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(s, addToColors, false));
|
||||
return CardColor.getTimestamp();
|
||||
}
|
||||
|
||||
@@ -1597,15 +1596,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*
|
||||
* @return a {@link forge.CardColor} object.
|
||||
*/
|
||||
public final CardColor determineColor() {
|
||||
public final ColorSet determineColor() {
|
||||
if (this.isImmutable()) {
|
||||
return new CardColor(this);
|
||||
return ColorSet.getNullColor();
|
||||
}
|
||||
|
||||
final List<CardColor> globalChanges = getOwner() == null ? new ArrayList<CardColor>() : getOwner().getGame().getColorChanger().getColorChanges();
|
||||
CardColor colors = this.determineColor(globalChanges);
|
||||
colors.fixColorless();
|
||||
return colors;
|
||||
return this.determineColor(globalChanges);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1639,8 +1636,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* an ArrayList<CardColor>
|
||||
* @return a CardColor
|
||||
*/
|
||||
final CardColor determineColor(final List<CardColor> globalChanges) {
|
||||
final CardColor colors = new CardColor(this);
|
||||
final ColorSet determineColor(final List<CardColor> globalChanges) {
|
||||
byte colors = 0;
|
||||
int i = this.getCharacteristics().getCardColor().size() - 1;
|
||||
int j = -1;
|
||||
if (globalChanges != null) {
|
||||
@@ -1659,29 +1656,29 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
j--;
|
||||
}
|
||||
|
||||
colors.addToCardColor(cc);
|
||||
if (!cc.getAdditional()) {
|
||||
return colors;
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
while (i >= 0) {
|
||||
final CardColor cc = this.getCharacteristics().getCardColor().get(i);
|
||||
i--;
|
||||
colors.addToCardColor(cc);
|
||||
if (!cc.getAdditional()) {
|
||||
return colors;
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
while (j >= 0) {
|
||||
final CardColor cc = globalChanges.get(j);
|
||||
j--;
|
||||
colors.addToCardColor(cc);
|
||||
if (!cc.getAdditional()) {
|
||||
return colors;
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
|
||||
return colors;
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,13 +17,9 @@
|
||||
*/
|
||||
package forge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostParser;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -33,32 +29,21 @@ import forge.card.mana.ManaCostBeingPaid;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CardColor implements Iterable<Color> {
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Color> iterator() {
|
||||
return col.iterator();
|
||||
}
|
||||
public class CardColor {
|
||||
private static long timeStamp = 0;
|
||||
public static long getTimestamp() { return CardColor.timeStamp; }
|
||||
static void increaseTimestamp() { CardColor.timeStamp++; }
|
||||
|
||||
// takes care of individual card color, for global color change effects use
|
||||
// AllZone.getGameInfo().getColorChanges()
|
||||
private final EnumSet<Color> col;
|
||||
private final boolean additional;
|
||||
private final byte colorMask;
|
||||
public final byte getColorMask() { return colorMask; }
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>additional</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean getAdditional() {
|
||||
private final boolean additional;
|
||||
public final boolean isAdditional() {
|
||||
return this.additional;
|
||||
}
|
||||
|
||||
private Card effectingCard = null;
|
||||
private long stamp = 0;
|
||||
|
||||
/**
|
||||
@@ -72,22 +57,6 @@ public class CardColor implements Iterable<Color> {
|
||||
return this.stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant <code>timeStamp=0</code>.
|
||||
*/
|
||||
private static long timeStamp = 0;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getTimestamp.
|
||||
* </p>
|
||||
*
|
||||
* @return a long.
|
||||
*/
|
||||
public static long getTimestamp() {
|
||||
return CardColor.timeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Card_Color.
|
||||
@@ -102,10 +71,10 @@ public class CardColor implements Iterable<Color> {
|
||||
* @param baseColor
|
||||
* a boolean.
|
||||
*/
|
||||
CardColor(final ManaCostBeingPaid mc, final Card c, final boolean addToColors, final boolean baseColor) {
|
||||
CardColor(final String colors, final boolean addToColors, final boolean baseColor) {
|
||||
this.additional = addToColors;
|
||||
this.col = Color.convertManaCostToColor(mc);
|
||||
this.effectingCard = c;
|
||||
ManaCost mc = new ManaCost(new ManaCostParser(colors));
|
||||
this.colorMask = mc.getColorProfile();
|
||||
if (baseColor) {
|
||||
this.stamp = 0;
|
||||
} else {
|
||||
@@ -113,65 +82,15 @@ public class CardColor implements Iterable<Color> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Card_Color.
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public CardColor(final Card c) {
|
||||
this.col = Color.colorless();
|
||||
public CardColor(byte mask) {
|
||||
this.colorMask = mask;
|
||||
this.additional = false;
|
||||
this.stamp = 0;
|
||||
this.effectingCard = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* addToCardColor.
|
||||
* </p>
|
||||
*
|
||||
* @param s
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final void addToCardColor(final String[] ss) {
|
||||
for (String s : ss) {
|
||||
final Color c = Color.convertFromString(s);
|
||||
if (!this.col.contains(c)) {
|
||||
this.col.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void addToCardColor(final Iterable<Color> cc) {
|
||||
for (Color c : cc) {
|
||||
if (!this.col.contains(c)) {
|
||||
this.col.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* fixColorless.
|
||||
* </p>
|
||||
*/
|
||||
public final void fixColorless() {
|
||||
if ((this.col.size() > 1) && this.col.contains(Color.Colorless)) {
|
||||
this.col.remove(Color.Colorless);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* increaseTimestamp.
|
||||
* </p>
|
||||
*/
|
||||
static void increaseTimestamp() {
|
||||
CardColor.timeStamp++;
|
||||
public CardColor() {
|
||||
this((byte)0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,38 +109,10 @@ public class CardColor implements Iterable<Color> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean equals(final String cost, final Card c, final boolean addToColors, final long time) {
|
||||
return (this.effectingCard == c) && (addToColors == this.additional) && (this.stamp == time);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* toStringArray.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final String[] toStringArray() {
|
||||
final String[] list = new String[this.col.size()];
|
||||
int i = 0;
|
||||
for (final Color c : this.col) {
|
||||
list[i++] = c.toString();
|
||||
}
|
||||
return list;
|
||||
return (addToColors == this.additional) && (this.stamp == time);
|
||||
}
|
||||
|
||||
public final ColorSet toColorSet() {
|
||||
int mask = 0;
|
||||
for (final Color c : this.col) {
|
||||
mask |= c.getMagicColor();
|
||||
}
|
||||
return ColorSet.fromMask(mask);
|
||||
}
|
||||
|
||||
public final List<String> toStringList() {
|
||||
final List<String> list = new ArrayList<String>(this.col.size());
|
||||
for (final Color c : this.col) {
|
||||
list.add(c.toString());
|
||||
}
|
||||
return list;
|
||||
return ColorSet.fromMask(colorMask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class CardUtil {
|
||||
private CardUtil() { }
|
||||
|
||||
public static ColorSet getColors(final Card c) {
|
||||
return c.determineColor().toColorSet();
|
||||
return c.determineColor();
|
||||
}
|
||||
|
||||
public static boolean isStackingKeyword(final String keyword) {
|
||||
@@ -135,7 +135,7 @@ public final class CardUtil {
|
||||
|
||||
// Determine the color for LKI copy, not just getColor
|
||||
ArrayList<CardColor> currentColor = new ArrayList<CardColor>();
|
||||
currentColor.add(in.determineColor());
|
||||
currentColor.add(new CardColor(in.determineColor().getColor()));
|
||||
newCopy.setColor(currentColor);
|
||||
newCopy.setReceivedDamageFromThisTurn(in.getReceivedDamageFromThisTurn());
|
||||
newCopy.getDamageHistory().setCreatureGotBlockedThisTurn(in.getDamageHistory().getCreatureGotBlockedThisTurn());
|
||||
@@ -162,19 +162,17 @@ public final class CardUtil {
|
||||
final List<Card> res = new ArrayList<Card>();
|
||||
|
||||
final GameState game = source.getGame();
|
||||
for (final CardColor col : origin.getColor()) {
|
||||
for (final String strCol : col.toStringList()) {
|
||||
if (strCol.equalsIgnoreCase("Colorless")) {
|
||||
ColorSet cs = CardUtil.getColors(origin);
|
||||
for (byte color : MagicColor.WUBRG) {
|
||||
if(!cs.hasAnyColor(color))
|
||||
continue;
|
||||
}
|
||||
for (final Card c : game.getColoredCardsInPlay(strCol)) {
|
||||
|
||||
for(final Card c : game.getColoredCardsInPlay(MagicColor.toLongString(color))) {
|
||||
if (!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) {
|
||||
res.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Color class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public enum Color {
|
||||
|
||||
/** The Colorless. */
|
||||
Colorless((byte)0),
|
||||
/** The White. */
|
||||
White(MagicColor.WHITE),
|
||||
/** The Green. */
|
||||
Green(MagicColor.GREEN),
|
||||
/** The Red. */
|
||||
Red(MagicColor.RED),
|
||||
/** The Black. */
|
||||
Black(MagicColor.BLACK),
|
||||
/** The Blue. */
|
||||
Blue(MagicColor.BLUE);
|
||||
|
||||
private final byte magicColor;
|
||||
private Color(final byte c) {
|
||||
this.magicColor = c;
|
||||
}
|
||||
|
||||
public static final ImmutableList<Color> WUBRG = ImmutableList.of( White, Blue, Black, Red, Green );
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Colorless.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.EnumSet} object.
|
||||
*/
|
||||
public static EnumSet<Color> colorless() {
|
||||
final EnumSet<Color> colors = EnumSet.of(Color.Colorless);
|
||||
return colors;
|
||||
}
|
||||
|
||||
public byte getMagicColor() {
|
||||
return magicColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ConvertStringsToColor.
|
||||
* </p>
|
||||
*
|
||||
* @param s
|
||||
* an array of {@link java.lang.String} objects.
|
||||
* @return a {@link java.util.EnumSet} object.
|
||||
*/
|
||||
public static EnumSet<Color> convertStringsToColor(final String[] s) {
|
||||
final EnumSet<Color> colors = EnumSet.of(Color.Colorless);
|
||||
|
||||
for (final String element : s) {
|
||||
colors.add(Color.convertFromString(element));
|
||||
}
|
||||
|
||||
if (colors.size() > 1) {
|
||||
colors.remove(Color.Colorless);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ConvertFromString.
|
||||
* </p>
|
||||
*
|
||||
* @param s
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link forge.Color} object.
|
||||
*/
|
||||
public static Color convertFromString(final String s) {
|
||||
|
||||
if (s.equals(Constant.Color.WHITE)) {
|
||||
return Color.White;
|
||||
} else if (s.equals(Constant.Color.GREEN)) {
|
||||
return Color.Green;
|
||||
} else if (s.equals(Constant.Color.RED)) {
|
||||
return Color.Red;
|
||||
} else if (s.equals(Constant.Color.BLACK)) {
|
||||
return Color.Black;
|
||||
} else if (s.equals(Constant.Color.BLUE)) {
|
||||
return Color.Blue;
|
||||
}
|
||||
|
||||
return Color.Colorless;
|
||||
}
|
||||
|
||||
public static EnumSet<Color> fromColorSet(ColorSet cc) {
|
||||
final EnumSet<Color> colors = EnumSet.of(Color.Colorless);
|
||||
for( int i = 0; i < MagicColor.NUMBER_OR_COLORS; i++ ) {
|
||||
if( cc.hasAnyColor(MagicColor.WUBRG[i]) )
|
||||
colors.add(Color.WUBRG.get(i));
|
||||
}
|
||||
if (colors.size() > 1) {
|
||||
colors.remove(Color.Colorless);
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ConvertManaCostToColor.
|
||||
* </p>
|
||||
*
|
||||
* @param m
|
||||
* a {@link forge.card.mana.ManaCostBeingPaid} object.
|
||||
* @return a {@link java.util.EnumSet} object.
|
||||
*/
|
||||
public static EnumSet<Color> convertManaCostToColor(final ManaCostBeingPaid m) {
|
||||
final EnumSet<Color> colors = EnumSet.of(Color.Colorless);
|
||||
|
||||
if (m.isColor("W")) {
|
||||
colors.add(Color.White);
|
||||
}
|
||||
if (m.isColor("G")) {
|
||||
colors.add(Color.Green);
|
||||
}
|
||||
if (m.isColor("R")) {
|
||||
colors.add(Color.Red);
|
||||
}
|
||||
if (m.isColor("B")) {
|
||||
colors.add(Color.Black);
|
||||
}
|
||||
if (m.isColor("U")) {
|
||||
colors.add(Color.Blue);
|
||||
}
|
||||
|
||||
if (colors.size() > 1) {
|
||||
colors.remove(Color.Colorless);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* toString.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.equals(Color.White)) {
|
||||
return Constant.Color.WHITE;
|
||||
} else if (this.equals(Color.Green)) {
|
||||
return Constant.Color.GREEN;
|
||||
} else if (this.equals(Color.Red)) {
|
||||
return Constant.Color.RED;
|
||||
} else if (this.equals(Color.Black)) {
|
||||
return Constant.Color.BLACK;
|
||||
} else if (this.equals(Color.Blue)) {
|
||||
return Constant.Color.BLUE;
|
||||
} else {
|
||||
return Constant.Color.COLORLESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,6 @@ package forge;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
|
||||
/**
|
||||
* class ColorChanger. TODO Write javadoc for this type.
|
||||
*
|
||||
@@ -44,11 +42,11 @@ public class ColorChanger {
|
||||
* a boolean.
|
||||
* @return a long.
|
||||
*/
|
||||
public final long addColorChanges(final String s, final Card c, final boolean addToColors, final boolean bIncrease) {
|
||||
public final long addColorChanges(final String s, final boolean addToColors, final boolean bIncrease) {
|
||||
if (bIncrease) {
|
||||
CardColor.increaseTimestamp();
|
||||
}
|
||||
this.globalColorChanges.add(new CardColor(new ManaCostBeingPaid(s), c, addToColors, false));
|
||||
this.globalColorChanges.add(new CardColor(s, addToColors, false));
|
||||
return CardColor.getTimestamp();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
|
||||
c.addHiddenExtrinsicKeyword(k);
|
||||
}
|
||||
|
||||
final long colorTimestamp = c.addColor(colors, c, !sa.hasParam("OverwriteColors"), true);
|
||||
final long colorTimestamp = c.addColor(colors, !sa.hasParam("OverwriteColors"), true);
|
||||
return colorTimestamp;
|
||||
}
|
||||
|
||||
|
||||
@@ -306,10 +306,10 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
if (colors.equals("ChosenColor")) {
|
||||
shortColors = CardUtil.getShortColorsString(tgtCard.getChosenColor());
|
||||
} else {
|
||||
shortColors = CardUtil.getShortColorsString(new ArrayList<String>(Arrays.asList(colors.split(","))));
|
||||
shortColors = CardUtil.getShortColorsString(Arrays.asList(colors.split(",")));
|
||||
}
|
||||
}
|
||||
tgtCard.addColor(shortColors, tgtCard, !sa.hasParam("OverwriteColors"), true);
|
||||
tgtCard.addColor(shortColors, !sa.hasParam("OverwriteColors"), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardColor;
|
||||
import forge.CardUtil;
|
||||
import forge.Color;
|
||||
import forge.Command;
|
||||
import forge.CounterType;
|
||||
import forge.ImageCache;
|
||||
@@ -154,7 +153,7 @@ public class CardFactory {
|
||||
}
|
||||
final String finalColors = tmp;
|
||||
|
||||
c.addColor(finalColors, c, !sourceSA.hasParam("OverwriteColors"), true);
|
||||
c.addColor(finalColors, !sourceSA.hasParam("OverwriteColors"), true);
|
||||
}
|
||||
|
||||
c.clearControllers();
|
||||
@@ -385,9 +384,8 @@ public class CardFactory {
|
||||
card.setManaCost(combinedManaCost);
|
||||
|
||||
// Combined card color
|
||||
CardColor combinedCardColor = new CardColor(card);
|
||||
combinedCardColor.addToCardColor(Color.fromColorSet(rules.getMainPart().getColor()));
|
||||
combinedCardColor.addToCardColor(Color.fromColorSet(rules.getOtherPart().getColor()));
|
||||
int combinedColor = rules.getMainPart().getColor().getColor() | rules.getOtherPart().getColor().getColor();
|
||||
CardColor combinedCardColor = new CardColor((byte)combinedColor);
|
||||
ArrayList<CardColor> combinedCardColorArr = new ArrayList<CardColor>();
|
||||
combinedCardColorArr.add(combinedCardColor);
|
||||
card.setColor(combinedCardColorArr);
|
||||
@@ -424,8 +422,7 @@ public class CardFactory {
|
||||
c.setType(coreTypes);
|
||||
|
||||
// What a perverted color code we have!
|
||||
CardColor col1 = new CardColor(c);
|
||||
col1.addToCardColor(Color.fromColorSet(face.getColor()));
|
||||
CardColor col1 = new CardColor(face.getColor().getColor());
|
||||
ArrayList<CardColor> ccc = new ArrayList<CardColor>();
|
||||
ccc.add(col1);
|
||||
c.setColor(ccc);
|
||||
|
||||
@@ -26,10 +26,11 @@ import java.util.Map.Entry;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardColor;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
@@ -804,17 +805,11 @@ public class ManaCostBeingPaid {
|
||||
if (getColorlessManaAmount() > 0) {
|
||||
usableColors.add("colorless");
|
||||
}
|
||||
for (final CardColor col : cardToConvoke.getColor()) {
|
||||
for (final String strCol : col.toStringList()) {
|
||||
if (strCol.equals("colorless")) {
|
||||
continue;
|
||||
ColorSet cs = CardUtil.getColors(cardToConvoke);
|
||||
for(byte color : MagicColor.WUBRG) {
|
||||
if( cs.hasAnyColor(color))
|
||||
usableColors.add(MagicColor.toLongString(color));
|
||||
}
|
||||
if (toString().contains(MagicColor.toShortString(strCol))) {
|
||||
usableColors.add(strCol.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return usableColors;
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ public class StaticAbilityContinuous {
|
||||
|
||||
// add colors
|
||||
if (addColors != null) {
|
||||
final long t = affectedCard.addColor(addColors, affectedCard, !se.isOverwriteColors(), true);
|
||||
final long t = affectedCard.addColor(addColors, !se.isOverwriteColors(), true);
|
||||
se.addTimestamp(affectedCard, t);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ package forge.game.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
@@ -32,7 +30,7 @@ import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.CardUtil;
|
||||
import forge.Color;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.effects.CharmEffect;
|
||||
@@ -1270,10 +1268,10 @@ public class ComputerUtil {
|
||||
{
|
||||
//Too many lands!
|
||||
//Init
|
||||
Map<Color,List<Card>> numProducers = new HashMap<Color,List<Card>>();
|
||||
for(Color col : Color.WUBRG)
|
||||
{
|
||||
numProducers.put(col, new ArrayList<Card>());
|
||||
int cntColors = MagicColor.WUBRG.length;
|
||||
List<List<Card>> numProducers = new ArrayList<List<Card>>(cntColors);
|
||||
for(byte col : MagicColor.WUBRG) {
|
||||
numProducers.add(col, new ArrayList<Card>());
|
||||
}
|
||||
|
||||
|
||||
@@ -1282,10 +1280,8 @@ public class ComputerUtil {
|
||||
for(SpellAbility sa : c.getManaAbility())
|
||||
{
|
||||
AbilityManaPart abmana = sa.getManaPart();
|
||||
for(Color col : Color.WUBRG)
|
||||
{
|
||||
if(abmana.canProduce(col.toString()))
|
||||
{
|
||||
for(byte col : MagicColor.WUBRG) {
|
||||
if(abmana.canProduce(MagicColor.toLongString(col))) {
|
||||
numProducers.get(col).add(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package forge.game.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -17,8 +17,10 @@ import com.google.common.collect.Iterables;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -823,27 +825,32 @@ public class ComputerUtilCard {
|
||||
}
|
||||
|
||||
public static List<String> getColorByProminence(final List<Card> list) {
|
||||
final HashMap<String, Integer> counts = new HashMap<String, Integer>();
|
||||
for (String color : Constant.Color.ONLY_COLORS) {
|
||||
counts.put(color, 0);
|
||||
}
|
||||
for (Card c : list) {
|
||||
List<String> colors = c.determineColor().toStringList();
|
||||
for (String col : colors) {
|
||||
if (counts.containsKey(col)) {
|
||||
counts.put(col.toString(), counts.get(col.toString()) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<String> res = new ArrayList<String>(counts.keySet());
|
||||
Collections.sort(res, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(final String a, final String b) {
|
||||
return counts.get(b) - counts.get(a);
|
||||
int cntColors = MagicColor.WUBRG.length;
|
||||
final Integer[] map = new Integer[cntColors];
|
||||
|
||||
for (final Card crd : list) {
|
||||
ColorSet color = CardUtil.getColors(crd);
|
||||
for(int i = 0; i < cntColors; i++) {
|
||||
if( color.hasAnyColor(MagicColor.WUBRG[i]))
|
||||
map[i]++;
|
||||
}
|
||||
} // for
|
||||
|
||||
Integer[] indices = new Integer[cntColors];
|
||||
for(int i = 0; i < cntColors; i++)
|
||||
indices[i] = Integer.valueOf(i);
|
||||
|
||||
// sort indices for WUBRG array, to get indices for most prominent colors first.
|
||||
Arrays.sort(indices, new Comparator<Integer>() {
|
||||
@Override public int compare(final Integer a, final Integer b) { return map[b] - map[a]; }
|
||||
});
|
||||
|
||||
return res;
|
||||
// fetch color names in the same order
|
||||
List<String> result = new ArrayList<String>(cntColors);
|
||||
for(Integer idx : indices) {
|
||||
result.add(MagicColor.toLongString(MagicColor.WUBRG[idx]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package forge;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
|
||||
/**
|
||||
* The Class CardColorTest.
|
||||
*/
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class CardColorTest {
|
||||
|
||||
/**
|
||||
* Card color test1.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000)
|
||||
public void cardColorTest1() {
|
||||
final ManaCostBeingPaid mc = new ManaCostBeingPaid("R W U");
|
||||
final EnumSet<Color> col = Color.convertManaCostToColor(mc);
|
||||
System.out.println(col.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user