mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
rm ColorChanger.java (unused)
mv2core BoosterGenerator and UnOpenedProduct
This commit is contained in:
6
.gitattributes
vendored
6
.gitattributes
vendored
@@ -21,8 +21,10 @@ forge-core/.settings/org.eclipse.m2e.core.prefs -text
|
||||
forge-core/pom.xml -text
|
||||
forge-core/src/main/java/forge/Constant.java svneol=native#text/plain
|
||||
forge-core/src/main/java/forge/ICardStorageReader.java -text
|
||||
forge-core/src/main/java/forge/IProgressObserver.java -text
|
||||
forge-core/src/main/java/forge/StaticData.java -text
|
||||
forge-core/src/main/java/forge/card/AggregationMethod.java -text
|
||||
forge-core/src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plain
|
||||
forge-core/src/main/java/forge/card/BoosterSlots.java -text
|
||||
forge-core/src/main/java/forge/card/CardAiHints.java -text
|
||||
forge-core/src/main/java/forge/card/CardCharacteristicName.java -text
|
||||
@@ -48,6 +50,7 @@ forge-core/src/main/java/forge/card/ICardRawAbilites.java -text
|
||||
forge-core/src/main/java/forge/card/IUnOpenedProduct.java -text
|
||||
forge-core/src/main/java/forge/card/MagicColor.java -text
|
||||
forge-core/src/main/java/forge/card/PrintSheet.java -text
|
||||
forge-core/src/main/java/forge/card/UnOpenedProduct.java -text
|
||||
forge-core/src/main/java/forge/card/mana/IParserManaCost.java -text
|
||||
forge-core/src/main/java/forge/card/mana/ManaAtom.java -text
|
||||
forge-core/src/main/java/forge/card/mana/ManaCost.java -text
|
||||
@@ -14665,7 +14668,6 @@ forge-gui/src/main/java/forge/CardPowerToughness.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/CardPredicates.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/CardType.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/CardUtil.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/ColorChanger.java -text
|
||||
forge-gui/src/main/java/forge/Command.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/CounterType.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/FThreads.java -text
|
||||
@@ -14680,14 +14682,12 @@ forge-gui/src/main/java/forge/ImageLoader.java -text
|
||||
forge-gui/src/main/java/forge/Singletons.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/StaticEffect.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/StaticEffects.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/card/CardBlock.java -text
|
||||
forge-gui/src/main/java/forge/card/CardCharacteristics.java -text
|
||||
forge-gui/src/main/java/forge/card/CardEditionPredicates.java -text
|
||||
forge-gui/src/main/java/forge/card/MetaSet.java -text
|
||||
forge-gui/src/main/java/forge/card/TriggerReplacementBase.java -text
|
||||
forge-gui/src/main/java/forge/card/UnOpenedMeta.java -text
|
||||
forge-gui/src/main/java/forge/card/UnOpenedProduct.java -text
|
||||
forge-gui/src/main/java/forge/card/ability/AbilityApiBased.java -text
|
||||
forge-gui/src/main/java/forge/card/ability/AbilityFactory.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/card/ability/AbilityUtils.java -text
|
||||
|
||||
12
forge-core/src/main/java/forge/IProgressObserver.java
Normal file
12
forge-core/src/main/java/forge/IProgressObserver.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package forge;
|
||||
|
||||
public interface IProgressObserver{
|
||||
void setOperationName(String name, boolean usePercents);
|
||||
void report(int current, int total);
|
||||
|
||||
// does nothing, used when they pass null instead of an instance
|
||||
public final static IProgressObserver emptyObserver = new IProgressObserver() {
|
||||
@Override public void setOperationName(String name, boolean usePercents) {}
|
||||
@Override public void report(int current, int total) {}
|
||||
};
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.StaticData;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.util.TextUtil;
|
||||
@@ -53,7 +53,7 @@ public class BoosterGenerator {
|
||||
private final static Map<String, PrintSheet> cachedSheets = new TreeMap<String, PrintSheet>(String.CASE_INSENSITIVE_ORDER);
|
||||
private static final synchronized PrintSheet getPrintSheet(String key) {
|
||||
if( !cachedSheets.containsKey(key) )
|
||||
cachedSheets.put(key, makeSheet(key, Singletons.getMagicDb().getCommonCards().getAllCards()));
|
||||
cachedSheets.put(key, makeSheet(key, StaticData.instance().getCommonCards().getAllCards()));
|
||||
return cachedSheets.get(key);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BoosterGenerator {
|
||||
|
||||
String[] sType = TextUtil.splitWithParenthesis(slotType, ' ');
|
||||
String setCode = sType.length == 1 && booster.getEdition() != null ? booster.getEdition() : null;
|
||||
String sheetKey = Singletons.getMagicDb().getEditions().contains(setCode) ? slotType.trim() + " " + setCode: slotType.trim();
|
||||
String sheetKey = StaticData.instance().getEditions().contains(setCode) ? slotType.trim() + " " + setCode: slotType.trim();
|
||||
|
||||
PrintSheet ps = getPrintSheet(sheetKey);
|
||||
result.addAll(ps.random(numCards, true));
|
||||
@@ -88,7 +88,7 @@ public class BoosterGenerator {
|
||||
String mainCode = itMod.next();
|
||||
if ( mainCode.regionMatches(true, 0, "fromSheet", 0, 9)) { // custom print sheet
|
||||
String sheetName = StringUtils.strip(mainCode.substring(9), "()\" ");
|
||||
src = Singletons.getMagicDb().getPrintSheets().get(sheetName).toFlatList();
|
||||
src = StaticData.instance().getPrintSheets().get(sheetName).toFlatList();
|
||||
setPred = Predicates.alwaysTrue();
|
||||
|
||||
} else if (mainCode.startsWith("promo")) { // get exactly the named cards, that's a tiny inlined print sheet
|
||||
@@ -96,7 +96,7 @@ public class BoosterGenerator {
|
||||
String[] cardNames = TextUtil.splitWithParenthesis(list, ',', '"', '"');
|
||||
List<PaperCard> srcList = new ArrayList<PaperCard>();
|
||||
for(String cardName: cardNames)
|
||||
srcList.add(Singletons.getMagicDb().getCommonCards().getCard(cardName));
|
||||
srcList.add(StaticData.instance().getCommonCards().getCard(cardName));
|
||||
src = srcList;
|
||||
setPred = Predicates.alwaysTrue();
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.StaticData;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.ItemPoolView;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class UnOpenedProduct implements IUnOpenedProduct {
|
||||
}
|
||||
|
||||
public UnOpenedProduct(SealedProductTemplate sealedProductTemplate, Predicate<PaperCard> filterPrinted) {
|
||||
this(sealedProductTemplate, Iterables.filter(Singletons.getMagicDb().getCommonCards().getAllCards(), filterPrinted));
|
||||
this(sealedProductTemplate, Iterables.filter(StaticData.instance().getCommonCards().getAllCards(), filterPrinted));
|
||||
}
|
||||
|
||||
private void prebuildSheets(Iterable<PaperCard> sourceList) {
|
||||
@@ -1470,7 +1470,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (s.equals("")) {
|
||||
s = "0";
|
||||
}
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(s, false, true));
|
||||
ManaCost mc = new ManaCost(new ManaCostParser(s));
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(mc.getColorProfile()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1492,7 +1493,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (bIncrease) {
|
||||
CardColor.increaseTimestamp();
|
||||
}
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(s, addToColors, false));
|
||||
this.getCharacteristics().getCardColor().add(new CardColor(s, addToColors));
|
||||
return CardColor.getTimestamp();
|
||||
}
|
||||
|
||||
@@ -1523,22 +1524,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* determineColor.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.CardColor} object.
|
||||
*/
|
||||
public final ColorSet determineColor() {
|
||||
if (this.isImmutable()) {
|
||||
return ColorSet.getNullColor();
|
||||
}
|
||||
|
||||
final List<CardColor> globalChanges = getOwner() == null ? new ArrayList<CardColor>() : getOwner().getGame().getColorChanger().getColorChanges();
|
||||
return this.determineColor(globalChanges);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setColor.
|
||||
@@ -1570,48 +1555,21 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* an ArrayList<CardColor>
|
||||
* @return a CardColor
|
||||
*/
|
||||
final ColorSet determineColor(final List<CardColor> globalChanges) {
|
||||
public final ColorSet determineColor() {
|
||||
if (this.isImmutable()) {
|
||||
return ColorSet.getNullColor();
|
||||
}
|
||||
|
||||
List<CardColor> colorList = this.getCharacteristics().getCardColor();
|
||||
|
||||
byte colors = 0;
|
||||
int i = this.getCharacteristics().getCardColor().size() - 1;
|
||||
int j = -1;
|
||||
if (globalChanges != null) {
|
||||
j = globalChanges.size() - 1;
|
||||
}
|
||||
// if both have changes, see which one is most recent
|
||||
while ((i >= 0) && (j >= 0)) {
|
||||
CardColor cc = null;
|
||||
if (this.getCharacteristics().getCardColor().get(i).getStamp() > globalChanges.get(j).getStamp()) {
|
||||
// Card has a more recent color stamp
|
||||
cc = this.getCharacteristics().getCardColor().get(i);
|
||||
i--;
|
||||
} else {
|
||||
// Global effect has a more recent color stamp
|
||||
cc = globalChanges.get(j);
|
||||
j--;
|
||||
}
|
||||
|
||||
for(int i = colorList.size() - 1;i >= 0;i--) {
|
||||
final CardColor cc = colorList.get(i);
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
while (i >= 0) {
|
||||
final CardColor cc = this.getCharacteristics().getCardColor().get(i);
|
||||
i--;
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
while (j >= 0) {
|
||||
final CardColor cc = globalChanges.get(j);
|
||||
j--;
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,16 +71,12 @@ public class CardColor {
|
||||
* @param baseColor
|
||||
* a boolean.
|
||||
*/
|
||||
CardColor(final String colors, final boolean addToColors, final boolean baseColor) {
|
||||
CardColor(final String colors, final boolean addToColors) {
|
||||
this.additional = addToColors;
|
||||
ManaCost mc = new ManaCost(new ManaCostParser(colors));
|
||||
this.colorMask = mc.getColorProfile();
|
||||
if (baseColor) {
|
||||
this.stamp = 0;
|
||||
} else {
|
||||
this.stamp = CardColor.timeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
public CardColor(byte mask) {
|
||||
this.colorMask = mask;
|
||||
|
||||
@@ -1,109 +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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* class ColorChanger. TODO Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class ColorChanger {
|
||||
private final List<CardColor> globalColorChanges = new ArrayList<CardColor>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* addColorChanges.
|
||||
* </p>
|
||||
*
|
||||
* @param s
|
||||
* a {@link java.lang.String} object.
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* @param addToColors
|
||||
* a boolean.
|
||||
* @param bIncrease
|
||||
* a boolean.
|
||||
* @return a long.
|
||||
*/
|
||||
public final long addColorChanges(final String s, final boolean addToColors, final boolean bIncrease) {
|
||||
if (bIncrease) {
|
||||
CardColor.increaseTimestamp();
|
||||
}
|
||||
this.globalColorChanges.add(new CardColor(s, addToColors, false));
|
||||
return CardColor.getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* removeColorChanges.
|
||||
* </p>
|
||||
*
|
||||
* @param s
|
||||
* a {@link java.lang.String} object.
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
* @param addTo
|
||||
* a boolean.
|
||||
* @param timestamp
|
||||
* a long.
|
||||
*/
|
||||
public final void removeColorChanges(final String s, final Card c, final boolean addTo, final long timestamp) {
|
||||
CardColor removeCol = null;
|
||||
for (final CardColor cc : this.globalColorChanges) {
|
||||
if (cc.equals(s, c, addTo, timestamp)) {
|
||||
removeCol = cc;
|
||||
}
|
||||
}
|
||||
|
||||
if (removeCol != null) {
|
||||
this.globalColorChanges.remove(removeCol);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* reset = clearColorChanges.
|
||||
* </p>
|
||||
*/
|
||||
public final void reset() {
|
||||
this.clearColorChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* clearColorChanges.
|
||||
* </p>
|
||||
*/
|
||||
public final void clearColorChanges() {
|
||||
// clear the global color changes at end of each game
|
||||
this.globalColorChanges.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getColorChanges.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final List<CardColor> getColorChanges() {
|
||||
return this.globalColorChanges;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import com.google.common.eventbus.EventBus;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.ColorChanger;
|
||||
import forge.FThreads;
|
||||
import forge.GameLog;
|
||||
import forge.StaticEffects;
|
||||
@@ -72,7 +71,6 @@ public class Game {
|
||||
private final ReplacementHandler replacementHandler = new ReplacementHandler(this);
|
||||
private final EventBus events = new EventBus("game events");
|
||||
private final GameLog gameLog = new GameLog();
|
||||
private final ColorChanger colorChanger = new ColorChanger();
|
||||
|
||||
private final Zone stackZone = new Zone(ZoneType.Stack, this);
|
||||
|
||||
@@ -437,14 +435,6 @@ public class Game {
|
||||
return all;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public ColorChanger getColorChanger() {
|
||||
return colorChanger;
|
||||
}
|
||||
|
||||
public final GameAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user