removed CardPrintedCharacteristics.java

new prefix for sealed magic product images (to store them in a different folder)
removed CardList.allAll(Array) and matching ctor, added addAll(Iterable<Card>) - in most cases of usage list was converted to array and while added to cardlist it was added to underlying list again.
This commit is contained in:
Maxmtg
2012-02-29 05:27:41 +00:00
parent 0926b5874d
commit 7f2e5c74b6
13 changed files with 29 additions and 112 deletions

1
.gitattributes vendored
View File

@@ -11469,7 +11469,6 @@ src/main/java/forge/gui/package-info.java svneol=native#text/plain
src/main/java/forge/item/BoosterPack.java -text
src/main/java/forge/item/CardDb.java -text
src/main/java/forge/item/CardPrinted.java -text
src/main/java/forge/item/CardPrintedCharacteristics.java -text
src/main/java/forge/item/FatPack.java -text
src/main/java/forge/item/InventoryItem.java -text
src/main/java/forge/item/InventoryItemFromSet.java -text

View File

@@ -8211,7 +8211,7 @@ public class Card extends GameEntity implements Comparable<Card> {
return 0;
}
final CardList auras = new CardList(this.getEnchantedBy().toArray());
final CardList auras = new CardList(this.getEnchantedBy());
if (auras.containsName("Treacherous Link")) {
this.getController().addDamage(damageIn, source);

View File

@@ -83,7 +83,7 @@ public class CardList implements Iterable<Card> {
* a {@link java.util.ArrayList} object.
*/
public CardList(final List<Card> al) {
this.addAll(al.toArray());
this.addAll(al);
}
/**
@@ -99,18 +99,6 @@ public class CardList implements Iterable<Card> {
}
}
/**
* <p>
* Constructor for CardList.
* </p>
*
* @param c
* an array of {@link java.lang.Object} objects.
*/
public CardList(final Object[] c) {
this.addAll(c);
}
/**
* Create a CardList from a finite generator of Card instances.
*
@@ -337,8 +325,10 @@ public class CardList implements Iterable<Card> {
* @param in
* - CardList to add to the current CardList
*/
public final void addAll(final CardList in) {
this.addAll(in.toArray());
public final void addAll(final Iterable<Card> in) {
for (final Card element : in) {
this.list.add(element);
}
}
/**
@@ -349,7 +339,7 @@ public class CardList implements Iterable<Card> {
* @param c
* an array of {@link java.lang.Object} objects.
*/
public final void addAll(final Object[] c) {
public final void addAll(final Card[] c) {
for (final Object element : c) {
this.list.add((Card) element);
}

View File

@@ -61,23 +61,6 @@ public final class CardUtil {
// This space intentionally left blank.
}
/**
* <p>
* getRandomIndex.
* </p>
*
* @param o
* an array of {@link java.lang.Object} objects.
* @return a int.
*/
public static int getRandomIndex(final Object[] o) {
if ((o == null) || (o.length == 0)) {
throw new RuntimeException("CardUtil : getRandomIndex() argument is null or length is 0");
}
return CardUtil.RANDOM.nextInt(o.length);
}
/**
* <p>
* getRandom.
@@ -87,8 +70,14 @@ public final class CardUtil {
* an array of {@link forge.Card} objects.
* @return a {@link forge.Card} object.
*/
public static Card getRandom(final Card[] o) {
return o[CardUtil.getRandomIndex(o)];
public static <T> T getRandom(final T[] o) {
if ( o == null ) throw new IllegalArgumentException("CardUtil : getRandom(T) recieved null instead of array.");
int len = o.length;
switch(len) {
case 0: throw new IllegalArgumentException("CardUtil : getRandom(T) recieved an empty array.");
case 1: return o[0];
default: return o[CardUtil.RANDOM.nextInt(len)];
}
}
/**

View File

@@ -1108,7 +1108,7 @@ public class GameAction {
}
if (c.isEnchanted()) {
CardList list = new CardList(c.getEnchantedBy().toArray());
CardList list = new CardList(c.getEnchantedBy());
list = list.filter(new CardListFilter() {
@Override
public boolean addCard(final Card crd) {
@@ -1291,7 +1291,7 @@ public class GameAction {
}
if (c.isEnchanted()) {
CardList list = new CardList(c.getEnchantedBy().toArray());
CardList list = new CardList(c.getEnchantedBy());
list = list.filter(new CardListFilter() {
@Override
public boolean addCard(final Card crd) {

View File

@@ -70,6 +70,7 @@ public class ImageCache {
/** Constant <code>NORMAL="#Normal"</code> */
/** Constant <code>TAPPED="#Tapped"</code>. */
private static final String TOKEN = "#Token", NORMAL = "#Normal", TAPPED = "#Tapped";
private static final String SEALED_PRODUCT = "sealed://";
static {
IMAGE_CACHE = CacheBuilder.newBuilder()
@@ -110,6 +111,9 @@ public class ImageCache {
if (key.endsWith(ImageCache.TOKEN)) {
key = key.substring(0, key.length() - ImageCache.TOKEN.length());
path = ForgeProps.getFile(NewConstants.IMAGE_TOKEN);
} else if (key.startsWith(SEALED_PRODUCT)) {
key = key.substring(SEALED_PRODUCT.length());
path = ForgeProps.getFile(NewConstants.IMAGE_BASE);
} else {
path = ForgeProps.getFile(NewConstants.IMAGE_BASE);
}

View File

@@ -2482,8 +2482,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
@Override
public void resolve() {
CardList enchantmentsInLibrary = source.getController().getCardsIn(Zone.Library);
final CardList enchantmentsAttached = new CardList(source.getEnchantingPlayer().getEnchantedBy()
.toArray());
final CardList enchantmentsAttached = new CardList(source.getEnchantingPlayer().getEnchantedBy());
enchantmentsInLibrary = enchantmentsInLibrary.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {

View File

@@ -1636,7 +1636,7 @@ public class AbilityFactory {
}
} else {
final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability);
list = new CardList(saTargeting.getTarget().getTargetCards().toArray());
list = new CardList(saTargeting.getTarget().getTargetCards());
}
} else {
final SpellAbility parent = AbilityFactory.findParentsTargetedCard(ability);
@@ -1650,7 +1650,7 @@ public class AbilityFactory {
}
} else {
final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability);
list = new CardList(saTargeting.getTarget().getTargetCards().toArray());
list = new CardList(saTargeting.getTarget().getTargetCards());
}
}
} else if (calcX[0].startsWith("Triggered")) {

View File

@@ -536,7 +536,7 @@ public class AbilityFactoryCounters {
if (abTgt == null) {
// No target. So must be defined
list = new CardList(AbilityFactory.getDefinedCards(source, params.get("Defined"), sa).toArray());
list = new CardList(AbilityFactory.getDefinedCards(source, params.get("Defined"), sa));
if (!mandatory) {
// TODO - If Trigger isn't mandatory, when wouldn't we want to

View File

@@ -398,9 +398,9 @@ public class AbilityFactoryGainControl {
tgtCards = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield);
tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa);
} else if ((tgt != null) && !this.params.containsKey("Defined")) {
tgtCards.addAll(tgt.getTargetCards().toArray());
tgtCards.addAll(tgt.getTargetCards());
} else {
tgtCards.addAll(AbilityFactory.getDefinedCards(this.hostCard, this.params.get("Defined"), sa).toArray());
tgtCards.addAll(AbilityFactory.getDefinedCards(this.hostCard, this.params.get("Defined"), sa));
}
// tgtCards.add(hostCard);

View File

@@ -127,7 +127,7 @@ public class CardFactoryUtil {
int curCMC = card.getCMC();
// Add all cost of all auras with the same controller
final CardList auras = new CardList(card.getEnchantedBy().toArray());
final CardList auras = new CardList(card.getEnchantedBy());
auras.getController(card.getController());
curCMC += auras.getTotalConvertedManaCost() + auras.size();

View File

@@ -252,7 +252,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
if (this.getIsPresent() != null) {
CardList list = new CardList();
if (this.getPresentDefined() != null) {
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa).toArray());
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa));
} else {
list = AllZoneUtil.getCardsIn(Zone.Battlefield);
}

View File

@@ -1,64 +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.item;
/**
* The Class CardPrintedCharacteristics.
*/
public class CardPrintedCharacteristics {
private String name;
private String cardSet;
/**
* Gets the name.
*
* @return the name
*/
public final String getName() {
return this.name;
}
/**
* Sets the name.
*
* @param name0
* the name to set
*/
public final void setName(final String name0) {
this.name = name0;
}
/**
* Gets the card set.
*
* @return the cardSet
*/
public final String getCardSet() {
return this.cardSet;
}
/**
* Sets the card set.
*
* @param cardSet0
* the cardSet to set
*/
public final void setCardSet(final String cardSet0) {
this.cardSet = cardSet0;
}
}