Mostly cosmetic changes to color code

This commit is contained in:
elcnesh
2015-05-06 16:26:45 +00:00
parent fd4f55d9df
commit 658fd8f953
15 changed files with 123 additions and 143 deletions

View File

@@ -176,29 +176,25 @@ public class SFilterUtil {
if (wantMulticolor) {
if (colors == 0) { //handle showing all multi-color cards if all 5 colors are filtered
result = color.isMulticolor() || (wantColorless && color.isColorless());
}
else if (colors != MagicColor.ALL_COLORS) {
} else if (colors != ColorSet.ALL_COLORS.getColor()) {
if (useColorIdentity) {
result = color.hasAllColors(colors);
}
else {
} else {
result = rules.canCastWithAvailable(colors);
}
}
}
else {
} else {
result = !color.isMulticolor();
if (colors != MagicColor.ALL_COLORS) {
if (colors != ColorSet.ALL_COLORS.getColor()) {
if (useColorIdentity) {
result = result && color.hasAnyColor(colors);
}
else {
} else {
result = result && rules.canCastWithAvailable(colors);
}
}
}
if (!wantColorless) {
if (colors != 0 && colors != MagicColor.ALL_COLORS) {
if (colors != 0 && colors != ColorSet.ALL_COLORS.getColor()) {
//if colorless filtered out ensure phyrexian cards don't appear
//unless at least one of their colors is selected
result = result && color.hasAnyColor(colors);

View File

@@ -6,75 +6,67 @@
* 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.limited;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.card.mana.ManaCost;
import forge.item.IPaperCard;
import java.util.List;
/**
* Created by IntelliJ IDEA. User: dhudson Date: 6/24/11 Time: 8:42 PM To change
* this template use File | Settings | File Templates.
*/
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.item.IPaperCard;
class DeckColors {
private ColorSet chosen;
private int colorMask;
public final static int MAX_COLORS = 2;
// public String Splash = "none";
public ColorSet getChosenColors() {
if ( null == chosen )
if (null == chosen) {
chosen = ColorSet.fromMask(colorMask);
return chosen;
}
return chosen;
}
/**
* TODO: Write javadoc for this method.
* @param pickedCard
*/
public void addColorsOf(IPaperCard pickedCard) {
ManaCost colorsInCard = pickedCard.getRules().getManaCost();
int colorsCanAdd = MagicColor.ALL_COLORS & ~getChosenColors().getColor();
int colorsWantAdd = colorsInCard.getColorProfile() & colorsCanAdd;
ColorSet toAdd = ColorSet.fromMask(colorsWantAdd);
public void addColorsOf(final IPaperCard pickedCard) {
final ColorSet colorsCanAdd = chosen.inverse();
final ColorSet toAdd = colorsCanAdd.getSharedColors(pickedCard.getRules().getColor());
int cntColorsAssigned = getChosenColors().countColors();
boolean haveSpace = cntColorsAssigned < MAX_COLORS;
if( !haveSpace || toAdd.isColorless() )
final boolean haveSpace = cntColorsAssigned < MAX_COLORS;
if (!haveSpace || toAdd.isColorless()) {
return;
}
for(int i = 0; i < MagicColor.NUMBER_OR_COLORS && cntColorsAssigned < MAX_COLORS; i++ )
if (( colorsWantAdd & MagicColor.WHITE << i ) > 0) {
colorMask |= MagicColor.WHITE << i;
chosen = null; // invalidate color set
cntColorsAssigned++;
for (final byte color : MagicColor.WUBRG) {
if (toAdd.hasAnyColor(color)) {
colorMask |= color;
chosen = null; // invalidate color set
cntColorsAssigned++;
}
if (cntColorsAssigned >= MAX_COLORS) {
break;
}
}
}
public void setColorsByList(List<Byte> colors) {
public void setColorsByList(final List<Byte> colors) {
colorMask = 0;
for (Byte col : colors) {
colorMask |= col;
for (final Byte col : colors) {
colorMask |= col.byteValue();
}
chosen = null;
}
public boolean canChoseMoreColors() {
return getChosenColors().countColors() < MAX_COLORS;
}

View File

@@ -233,7 +233,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
// If the card has any ability that tracks mana spent, skip express Mana choice
if (saPaidFor.tracksManaSpent()) {
colorCanUse = MagicColor.ALL_COLORS;
colorCanUse = ColorSet.ALL_COLORS.getColor();
guessAbilityWithRequiredColors = false;
}

View File

@@ -93,7 +93,7 @@ public enum ConquestPlane {
new Region("Auntie's Hovel", "Auntie's Hovel", MagicColor.BLACK | MagicColor.RED),
new Region("Gilt-Leaf Palace", "Gilt-Leaf Palace", MagicColor.BLACK | MagicColor.GREEN),
new Region("Murmuring Bosk", "Murmuring Bosk", MagicColor.WHITE | MagicColor.BLACK | MagicColor.GREEN),
new Region("Primal Beyond", "Primal Beyond", MagicColor.ALL_COLORS),
new Region("Primal Beyond", "Primal Beyond", ColorSet.ALL_COLORS.getColor()),
new Region("Rustic Clachan", "Rustic Clachan", MagicColor.GREEN | MagicColor.WHITE),
new Region("Secluded Glen", "Secluded Glen", MagicColor.BLUE | MagicColor.BLACK),
new Region("Wanderwine Hub", "Wanderwine Hub", MagicColor.WHITE | MagicColor.BLUE),
@@ -116,7 +116,7 @@ public enum ConquestPlane {
new Region("Ish Sah", "Vault of Whispers", MagicColor.BLACK),
new Region("Kuldotha", "Great Furnace", MagicColor.RED),
new Region("Tel-Jilad", "Tree of Tales", MagicColor.GREEN),
new Region("Glimmervoid", "Glimmervoid", MagicColor.ALL_COLORS)
new Region("Glimmervoid", "Glimmervoid", ColorSet.ALL_COLORS.getColor())
}),
Rath("Rath", new String[] {
"TMP", "STH", "EXO"
@@ -299,7 +299,7 @@ public enum ConquestPlane {
name = name0;
artCardName = artCardName0;
pred = pred0;
colorSet = ColorSet.fromMask(MagicColor.ALL_COLORS);
colorSet = ColorSet.fromMask(ColorSet.ALL_COLORS.getColor());
}
public String getName() {

View File

@@ -102,8 +102,8 @@ public class ConquestUtil {
availableCards.remove(commander);
//remove any cards that aren't allowed in deck due to color identity
byte colorIdentity = commander.getRules().getColorIdentity().getColor();
if (colorIdentity != MagicColor.ALL_COLORS) {
final ColorSet colorIdentity = commander.getRules().getColorIdentity();
if (!colorIdentity.equals(ColorSet.ALL_COLORS)) {
List<PaperCard> invalidCards = new ArrayList<PaperCard>();
for (PaperCard pc : availableCards) {
if (!pc.getRules().getColorIdentity().hasNoColorsExcept(colorIdentity)) {
@@ -119,7 +119,7 @@ public class ConquestUtil {
String setCode = FModel.getConquest().getModel().getCurrentPlane().getEditions().get(0).getCode();
for (int i = 0; i < MagicColor.WUBRG.length; i++) {
if ((colorIdentity & MagicColor.WUBRG[i]) != 0) {
if (colorIdentity.hasAnyColor(MagicColor.WUBRG[i])) {
pool.add(MagicColor.Constant.BASIC_LANDS.get(i), setCode, 50);
}
}