mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
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:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -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/BoosterPack.java -text
|
||||||
src/main/java/forge/item/CardDb.java -text
|
src/main/java/forge/item/CardDb.java -text
|
||||||
src/main/java/forge/item/CardPrinted.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/FatPack.java -text
|
||||||
src/main/java/forge/item/InventoryItem.java -text
|
src/main/java/forge/item/InventoryItem.java -text
|
||||||
src/main/java/forge/item/InventoryItemFromSet.java -text
|
src/main/java/forge/item/InventoryItemFromSet.java -text
|
||||||
|
|||||||
@@ -8211,7 +8211,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CardList auras = new CardList(this.getEnchantedBy().toArray());
|
final CardList auras = new CardList(this.getEnchantedBy());
|
||||||
|
|
||||||
if (auras.containsName("Treacherous Link")) {
|
if (auras.containsName("Treacherous Link")) {
|
||||||
this.getController().addDamage(damageIn, source);
|
this.getController().addDamage(damageIn, source);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class CardList implements Iterable<Card> {
|
|||||||
* a {@link java.util.ArrayList} object.
|
* a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public CardList(final List<Card> al) {
|
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.
|
* Create a CardList from a finite generator of Card instances.
|
||||||
*
|
*
|
||||||
@@ -337,8 +325,10 @@ public class CardList implements Iterable<Card> {
|
|||||||
* @param in
|
* @param in
|
||||||
* - CardList to add to the current CardList
|
* - CardList to add to the current CardList
|
||||||
*/
|
*/
|
||||||
public final void addAll(final CardList in) {
|
public final void addAll(final Iterable<Card> in) {
|
||||||
this.addAll(in.toArray());
|
for (final Card element : in) {
|
||||||
|
this.list.add(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,7 +339,7 @@ public class CardList implements Iterable<Card> {
|
|||||||
* @param c
|
* @param c
|
||||||
* an array of {@link java.lang.Object} objects.
|
* 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) {
|
for (final Object element : c) {
|
||||||
this.list.add((Card) element);
|
this.list.add((Card) element);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,23 +61,6 @@ public final class CardUtil {
|
|||||||
// This space intentionally left blank.
|
// 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>
|
* <p>
|
||||||
* getRandom.
|
* getRandom.
|
||||||
@@ -87,8 +70,14 @@ public final class CardUtil {
|
|||||||
* an array of {@link forge.Card} objects.
|
* an array of {@link forge.Card} objects.
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public static Card getRandom(final Card[] o) {
|
public static <T> T getRandom(final T[] o) {
|
||||||
return o[CardUtil.getRandomIndex(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)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1108,7 +1108,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c.isEnchanted()) {
|
if (c.isEnchanted()) {
|
||||||
CardList list = new CardList(c.getEnchantedBy().toArray());
|
CardList list = new CardList(c.getEnchantedBy());
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card crd) {
|
public boolean addCard(final Card crd) {
|
||||||
@@ -1291,7 +1291,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c.isEnchanted()) {
|
if (c.isEnchanted()) {
|
||||||
CardList list = new CardList(c.getEnchantedBy().toArray());
|
CardList list = new CardList(c.getEnchantedBy());
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card crd) {
|
public boolean addCard(final Card crd) {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class ImageCache {
|
|||||||
/** Constant <code>NORMAL="#Normal"</code> */
|
/** Constant <code>NORMAL="#Normal"</code> */
|
||||||
/** Constant <code>TAPPED="#Tapped"</code>. */
|
/** Constant <code>TAPPED="#Tapped"</code>. */
|
||||||
private static final String TOKEN = "#Token", NORMAL = "#Normal", TAPPED = "#Tapped";
|
private static final String TOKEN = "#Token", NORMAL = "#Normal", TAPPED = "#Tapped";
|
||||||
|
private static final String SEALED_PRODUCT = "sealed://";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
IMAGE_CACHE = CacheBuilder.newBuilder()
|
IMAGE_CACHE = CacheBuilder.newBuilder()
|
||||||
@@ -110,6 +111,9 @@ public class ImageCache {
|
|||||||
if (key.endsWith(ImageCache.TOKEN)) {
|
if (key.endsWith(ImageCache.TOKEN)) {
|
||||||
key = key.substring(0, key.length() - ImageCache.TOKEN.length());
|
key = key.substring(0, key.length() - ImageCache.TOKEN.length());
|
||||||
path = ForgeProps.getFile(NewConstants.IMAGE_TOKEN);
|
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 {
|
} else {
|
||||||
path = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
path = ForgeProps.getFile(NewConstants.IMAGE_BASE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2482,8 +2482,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
CardList enchantmentsInLibrary = source.getController().getCardsIn(Zone.Library);
|
CardList enchantmentsInLibrary = source.getController().getCardsIn(Zone.Library);
|
||||||
final CardList enchantmentsAttached = new CardList(source.getEnchantingPlayer().getEnchantedBy()
|
final CardList enchantmentsAttached = new CardList(source.getEnchantingPlayer().getEnchantedBy());
|
||||||
.toArray());
|
|
||||||
enchantmentsInLibrary = enchantmentsInLibrary.filter(new CardListFilter() {
|
enchantmentsInLibrary = enchantmentsInLibrary.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
|
|||||||
@@ -1636,7 +1636,7 @@ public class AbilityFactory {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability);
|
final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability);
|
||||||
list = new CardList(saTargeting.getTarget().getTargetCards().toArray());
|
list = new CardList(saTargeting.getTarget().getTargetCards());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final SpellAbility parent = AbilityFactory.findParentsTargetedCard(ability);
|
final SpellAbility parent = AbilityFactory.findParentsTargetedCard(ability);
|
||||||
@@ -1650,7 +1650,7 @@ public class AbilityFactory {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability);
|
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")) {
|
} else if (calcX[0].startsWith("Triggered")) {
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ public class AbilityFactoryCounters {
|
|||||||
|
|
||||||
if (abTgt == null) {
|
if (abTgt == null) {
|
||||||
// No target. So must be defined
|
// 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) {
|
if (!mandatory) {
|
||||||
// TODO - If Trigger isn't mandatory, when wouldn't we want to
|
// TODO - If Trigger isn't mandatory, when wouldn't we want to
|
||||||
|
|||||||
@@ -398,9 +398,9 @@ public class AbilityFactoryGainControl {
|
|||||||
tgtCards = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield);
|
tgtCards = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield);
|
||||||
tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa);
|
tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa);
|
||||||
} else if ((tgt != null) && !this.params.containsKey("Defined")) {
|
} else if ((tgt != null) && !this.params.containsKey("Defined")) {
|
||||||
tgtCards.addAll(tgt.getTargetCards().toArray());
|
tgtCards.addAll(tgt.getTargetCards());
|
||||||
} else {
|
} 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);
|
// tgtCards.add(hostCard);
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class CardFactoryUtil {
|
|||||||
int curCMC = card.getCMC();
|
int curCMC = card.getCMC();
|
||||||
|
|
||||||
// Add all cost of all auras with the same controller
|
// 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());
|
auras.getController(card.getController());
|
||||||
curCMC += auras.getTotalConvertedManaCost() + auras.size();
|
curCMC += auras.getTotalConvertedManaCost() + auras.size();
|
||||||
|
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
|||||||
if (this.getIsPresent() != null) {
|
if (this.getIsPresent() != null) {
|
||||||
CardList list = new CardList();
|
CardList list = new CardList();
|
||||||
if (this.getPresentDefined() != null) {
|
if (this.getPresentDefined() != null) {
|
||||||
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa).toArray());
|
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa));
|
||||||
} else {
|
} else {
|
||||||
list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user