mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
merge latest trunk
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -553,6 +553,7 @@ res/cardsfolder/a/aspect_of_wolf.txt svneol=native#text/plain
|
||||
res/cardsfolder/a/assassinate.txt svneol=native#text/plain
|
||||
res/cardsfolder/a/assassins_blade.txt svneol=native#text/plain
|
||||
res/cardsfolder/a/assassins_strike.txt -text
|
||||
res/cardsfolder/a/assault__battery.txt -text
|
||||
res/cardsfolder/a/assault_griffin.txt svneol=native#text/plain
|
||||
res/cardsfolder/a/assault_strobe.txt svneol=native#text/plain
|
||||
res/cardsfolder/a/assault_zeppelid.txt svneol=native#text/plain
|
||||
@@ -3604,6 +3605,7 @@ res/cardsfolder/f/fire_dragon.txt svneol=native#text/plain
|
||||
res/cardsfolder/f/fire_drake.txt svneol=native#text/plain
|
||||
res/cardsfolder/f/fire_elemental.txt svneol=native#text/plain
|
||||
res/cardsfolder/f/fire_field_ogre.txt svneol=native#text/plain
|
||||
res/cardsfolder/f/fire_ice.txt -text
|
||||
res/cardsfolder/f/fire_imp.txt svneol=native#text/plain
|
||||
res/cardsfolder/f/fire_juggler.txt -text
|
||||
res/cardsfolder/f/fire_lit_thicket.txt svneol=native#text/plain
|
||||
|
||||
18
res/cardsfolder/a/assault__battery.txt
Normal file
18
res/cardsfolder/a/assault__battery.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
Name:Assault
|
||||
ManaCost:R
|
||||
AlternateMode: Split
|
||||
Types:Sorcery
|
||||
A:SP$ DealDamage | Cost$ R | NumDmg$ 2 | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | SpellDescription$ Assault deals 2 damage to target creature or player.
|
||||
SetInfo:INV Uncommon
|
||||
SetInfo:TSB Uncommon
|
||||
SetInfo:HOP Uncommon
|
||||
Oracle:Assault deals 2 damage to target creature or player.
|
||||
|
||||
ALTERNATE
|
||||
|
||||
Name:Battery
|
||||
ManaCost:3 G
|
||||
Types:Sorcery
|
||||
A:SP$ Token | Cost$ 3 G | TokenAmount$ 1 | TokenName$ Elephant| TokenTypes$ Creature,Elephant| TokenOwner$ You | TokenColors$ Green | TokenPower$ 3 | TokenToughness$ 3 | TokenImage$ g 3 3 elephant | SpellDescription$ Put a 3/3 green Elephant creature token onto the battlefield.
|
||||
Oracle:Put a 3/3 green Elephant creature token onto the battlefield.
|
||||
End
|
||||
@@ -2,8 +2,9 @@ Name:Conjurer's Closet
|
||||
ManaCost:5
|
||||
Types:Artifact
|
||||
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ ConjurerExile | OptionalDecider$ You | TriggerDescription$ At the beginning of your end step, you may exile target creature you control, then return it to the battlefield under your control.
|
||||
SVar:ConjurerExile:AB$ChangeZone | Cost$ 0 | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control to flicker | Origin$ Battlefield | Destination$ Exile | SubAbility$ ConjurerReturn
|
||||
SVar:ConjurerReturn:DB$ChangeZone | Defined$ Targeted | Origin$ Exile | Destination$ Battlefield | GainControl$ True
|
||||
SVar:ConjurerExile:AB$ ChangeZone | Cost$ 0 | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control to flicker | Origin$ Battlefield | Destination$ Exile | RememberChanged$ True | SubAbility$ ConjurerReturn
|
||||
SVar:ConjurerReturn:DB$ ChangeZone | Defined$ Remembered | Origin$ Exile | Destination$ Battlefield | GainControl$ True | SubAbility$ DBCleanup
|
||||
SVar:DBCleanup:DB$Cleanup | ClearRemembered$ True
|
||||
SVar:RemAIDeck:True
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/conjurers_closet.jpg
|
||||
Oracle:At the beginning of your end step, you may exile target creature you control, then return that card to the battlefield under your control.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Name:Covenant of Minds
|
||||
ManaCost:4 U
|
||||
Types:Sorcery
|
||||
A:SP$ Dig | Cost$ 2 B | DigNum$ 3 | NoMove$ True | Reveal$ True | DestinationZone$ Library | LibraryPosition$ 0 | LibraryPosition2$ 0 | SubAbility$ DBChoice | RememberRevealed$ True | SpellDescription$ Reveal the top three cards of your library. Target opponent may choose to put those cards into your hand. If he or she doesn't, put those cards into your graveyard and draw five cards.
|
||||
A:SP$ Dig | Cost$ 4 U | DigNum$ 3 | NoMove$ True | Reveal$ True | DestinationZone$ Library | LibraryPosition$ 0 | LibraryPosition2$ 0 | SubAbility$ DBChoice | RememberRevealed$ True | SpellDescription$ Reveal the top three cards of your library. Target opponent may choose to put those cards into your hand. If he or she doesn't, put those cards into your graveyard and draw five cards.
|
||||
SVar:DBChoice:DB$ GenericChoice | ValidTgts$ Opponent | Choices$ CovenantDraw,CovenantMillDraw
|
||||
SVar:CovenantDraw:DB$ Draw | Defined$ SourceController | NumCards$ X | References$ X | ChoiceDescription$ You may choose to put those cards into that player's hand.
|
||||
SVar:CovenantMillDraw:DB$ Mill | Defined$ SourceController | NumCards$ X | References$ X | SubAbility$ DBDraw | ChoiceDescription$ If you don't, put those cards into that player's graveyard and that player draws five cards.
|
||||
|
||||
19
res/cardsfolder/f/fire_ice.txt
Normal file
19
res/cardsfolder/f/fire_ice.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Name:Fire
|
||||
ManaCost:1 R
|
||||
AlternateMode: Split
|
||||
Types:Instant
|
||||
A:SP$ DealDamage | Cost$ 1 R | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player to distribute damage to | NumDmg$ 2 | TargetMin$ 1 | TargetMax$ 2 | DividedAsYouChoose$ 2 | SpellDescription$ Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
|
||||
SetInfo:APC Uncommon
|
||||
SetInfo:COM Uncommon
|
||||
SetInfo:DDJ Uncommon
|
||||
Oracle:Fire deals 2 damage divided as you choose among one or two target creatures and/or players.
|
||||
|
||||
ALTERNATE
|
||||
|
||||
Name:Ice
|
||||
ManaCost:1 U
|
||||
Types:Instant
|
||||
A:SP$ Tap | Cost$ 1 U | ValidTgts$ Permanent | TgtPrompt$ Select target permanent | SubAbility$ DBDraw | SpellDescription$ Tap target permanent. Draw a card.
|
||||
SVar:DBDraw:DB$ Draw | NumCards$ 1
|
||||
Oracle:Tap target permanent.\nDraw a card.
|
||||
End
|
||||
@@ -4,7 +4,7 @@ Types:Instant
|
||||
K:Cycling:5 R B G
|
||||
A:SP$ DealDamage | Cost$ 2 R | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | NumDmg$ 3 | SpellDescription$ CARDNAME deals 3 damage to target creature or player.
|
||||
T:Mode$ Cycled | ValidCard$ Card.Self | Execute$ TrigDamage | TriggerDescription$ When you cycle CARDNAME, it deals 6 damage to target creature or player.
|
||||
SVar:TrigDamage:SP$DealDamage | Cost$ 0 | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | NumDmg$ 6
|
||||
SVar:TrigDamage:AB$ DealDamage | Cost$ 0 | ValidTgts$ Creature,Player | TgtPrompt$ Select target creature or player | NumDmg$ 6
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/resounding_thunder.jpg
|
||||
Oracle:Resounding Thunder deals 3 damage to target creature or player.\nCycling {5}{B}{R}{G} ({5}{B}{R}{G}, Discard this card: Draw a card.)\nWhen you cycle Resounding Thunder, it deals 6 damage to target creature or player.
|
||||
SetInfo:ALA Common
|
||||
@@ -3,7 +3,7 @@
|
||||
Name=Bart Simpson 2
|
||||
Title=Bart Simpson
|
||||
Difficulty=medium
|
||||
Description=WUG deck with Minister of Impediments and Paralyzing Grasp
|
||||
Description=WUG Tap deck with Minister of Impediments and Paralyzing Grasp
|
||||
Icon=Bart Simpson.jpg
|
||||
Deck Type=constructed
|
||||
[main]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Name=Bart Simpson 3
|
||||
Title=Bart Simpson
|
||||
Difficulty=hard
|
||||
Description=WUG deck with Harrier Griffin and Entangling Vines
|
||||
Description=WUG Tap deck with Harrier Griffin and Entangling Vines
|
||||
Icon=Bart Simpson.jpg
|
||||
Deck Type=constructed
|
||||
[main]
|
||||
|
||||
@@ -28,7 +28,7 @@ Deck Type=constructed
|
||||
2 Skeletal Changeling
|
||||
1 Enfeeblement
|
||||
1 Cessation
|
||||
1 Darksteel Ingot
|
||||
1 Manalith
|
||||
1 Despondency
|
||||
1 Greel's Caress
|
||||
2 Druid's Call
|
||||
|
||||
@@ -23,9 +23,10 @@ Deck Type=constructed
|
||||
3 Vithian Renegades
|
||||
4 Boartusk Liege
|
||||
4 Bloodbraid Elf
|
||||
2 Rumbling Slum
|
||||
1 Rumbling Slum
|
||||
2 Spellbreaker Behemoth
|
||||
1 Sarkhan Vol
|
||||
3 Runes of the Deus
|
||||
2 Deus of Calamity
|
||||
1 Ghor-Clan Rampager
|
||||
[sideboard]
|
||||
|
||||
@@ -11,7 +11,7 @@ Deck Type=constructed
|
||||
2 Beasts of Bogardan
|
||||
1 Air Elemental
|
||||
3 Plains|M11
|
||||
2 Darksteel Ingot
|
||||
2 Manalith
|
||||
3 Island|M11
|
||||
1 Threaten
|
||||
2 Oraxid
|
||||
|
||||
@@ -37,6 +37,7 @@ import forge.CardPredicates.Presets;
|
||||
import forge.card.CardCharacteristics;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -233,7 +234,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
// Soulbond pairing card
|
||||
private Card pairedWith = null;
|
||||
|
||||
|
||||
// Enumeration for CMC request types
|
||||
public enum SplitCMCMode {
|
||||
CurrentSideCMC,
|
||||
CombinedCMC,
|
||||
LeftSplitCMC,
|
||||
RightSplitCMC
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new card.
|
||||
@@ -7051,16 +7058,30 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
} else if (property.startsWith("greatestCMC")) {
|
||||
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||
for (final Card crd : list) {
|
||||
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
|
||||
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > this.getCMC()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (crd.getCMC() > this.getCMC()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("lowestCMC")) {
|
||||
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card crd : list) {
|
||||
if (!crd.isLand() && !crd.isImmutable() && (crd.getCMC() < this.getCMC())) {
|
||||
if (!crd.isLand() && !crd.isImmutable()) {
|
||||
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
|
||||
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) < this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) < this.getCMC()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (crd.getCMC() < this.getCMC()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("enchanted")) {
|
||||
if (!this.isEnchanted()) {
|
||||
@@ -7110,6 +7131,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
|| property.startsWith("cmc") || property.startsWith("totalPT")) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int y2 = -1; // alternative value for the second split face of a split card
|
||||
String rhs = "";
|
||||
|
||||
if (property.startsWith("power")) {
|
||||
@@ -7120,7 +7142,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
y = this.getNetDefense();
|
||||
} else if (property.startsWith("cmc")) {
|
||||
rhs = property.substring(5);
|
||||
if (getRules() != null && getRules().getSplitType() == CardSplitType.Split && getCurState() == CardCharacteristicName.Original) {
|
||||
y = getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC();
|
||||
y2 = getState(CardCharacteristicName.RightSplit).getManaCost().getCMC();
|
||||
} else {
|
||||
y = getCMC();
|
||||
}
|
||||
} else if (property.startsWith("totalPT")) {
|
||||
rhs = property.substring(10);
|
||||
y = this.getNetAttack() + this.getNetDefense();
|
||||
@@ -7131,9 +7158,15 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
x = CardFactoryUtil.xCount(source, source.getSVar(rhs));
|
||||
}
|
||||
|
||||
if (y2 == -1) {
|
||||
if (!Expressions.compare(y, property, x)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Expressions.compare(y, property, x) || !Expressions.compare(y2, property, x)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// syntax example: countersGE9 P1P1 or countersLT12TIME (greater number
|
||||
@@ -9110,6 +9143,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @return a int.
|
||||
*/
|
||||
public int getCMC() {
|
||||
return getCMC(SplitCMCMode.CurrentSideCMC);
|
||||
}
|
||||
|
||||
public int getCMC(SplitCMCMode mode) {
|
||||
if (isToken() && !isCopiedToken()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -9120,7 +9157,35 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (Singletons.getModel().getGame().getCardsIn(ZoneType.Stack).contains(this) && getManaCost() != null) {
|
||||
xPaid = getXManaCostPaid() * getManaCost().countX();
|
||||
}
|
||||
return getManaCost().getCMC() + xPaid;
|
||||
|
||||
int requestedCMC = 0;
|
||||
|
||||
if (getRules().getSplitType() == CardSplitType.Split) {
|
||||
switch(mode) {
|
||||
case CurrentSideCMC:
|
||||
// TODO: test if this returns combined CMC for the full face (then get rid of CombinedCMC mode?)
|
||||
requestedCMC = getManaCost().getCMC() + xPaid;
|
||||
break;
|
||||
case LeftSplitCMC:
|
||||
requestedCMC = getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC() + xPaid;
|
||||
break;
|
||||
case RightSplitCMC:
|
||||
requestedCMC = getState(CardCharacteristicName.RightSplit).getManaCost().getCMC() + xPaid;
|
||||
break;
|
||||
case CombinedCMC:
|
||||
requestedCMC += getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC();
|
||||
requestedCMC += getState(CardCharacteristicName.RightSplit).getManaCost().getCMC();
|
||||
requestedCMC += xPaid;
|
||||
break;
|
||||
default:
|
||||
System.out.println(String.format("Illegal Split Card CMC mode %s passed to getCMC!", mode.toString()));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
requestedCMC = getManaCost().getCMC() + xPaid;
|
||||
}
|
||||
|
||||
return requestedCMC;
|
||||
}
|
||||
|
||||
public final boolean canBeSacrificedBy(final SpellAbility source)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.card;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.item.CardPrinted;
|
||||
@@ -8,44 +7,15 @@ import forge.item.IPaperCard;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.storage.StorageReaderFile;
|
||||
|
||||
|
||||
/**
|
||||
* The Class BoosterData.
|
||||
*/
|
||||
public class BoosterData {
|
||||
private final String edition;
|
||||
public final String getEdition() {
|
||||
return edition;
|
||||
}
|
||||
private final String landEdition;
|
||||
public final String getLandEdition() {
|
||||
return landEdition;
|
||||
}
|
||||
|
||||
public class BoosterData extends PackData {
|
||||
private final int nCommon;
|
||||
private final int nUncommon;
|
||||
private final int nRare;
|
||||
private final int nSpecial;
|
||||
private final int nDoubleFaced;
|
||||
private final int nLand;
|
||||
private final int foilRate;
|
||||
private static final int CARDS_PER_BOOSTER = 15;
|
||||
|
||||
// private final String landCode;
|
||||
/**
|
||||
* Instantiates a new booster data.
|
||||
*
|
||||
* @param nC
|
||||
* the n c
|
||||
* @param nU
|
||||
* the n u
|
||||
* @param nR
|
||||
* the n r
|
||||
* @param nS
|
||||
* the n s
|
||||
* @param nDF
|
||||
* the n df
|
||||
*/
|
||||
public BoosterData(final String edition, final String editionLand, final int nC, final int nU, final int nR, final int nS, final int nDF) {
|
||||
// if this booster has more that 10 cards, there must be a land in
|
||||
// 15th slot unless it's already taken
|
||||
@@ -53,132 +23,116 @@ public class BoosterData {
|
||||
- nS - nDF : 0, 68);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new booster data.
|
||||
*
|
||||
* @param nC
|
||||
* the n c
|
||||
* @param nU
|
||||
* the n u
|
||||
* @param nR
|
||||
* the n r
|
||||
* @param nS
|
||||
* the n s
|
||||
* @param nDF
|
||||
* the n df
|
||||
* @param nL
|
||||
* the n l
|
||||
* @param oneFoilPer
|
||||
* the one foil per
|
||||
*/
|
||||
public BoosterData(final String edition0, final String editionLand, final int nC, final int nU, final int nR, final int nS, final int nDF, final int nL,
|
||||
final int oneFoilPer) {
|
||||
super(edition0, editionLand, nL > 0 ? nL : 0);
|
||||
this.nCommon = nC;
|
||||
this.nUncommon = nU;
|
||||
this.nRare = nR;
|
||||
this.nSpecial = nS;
|
||||
this.nDoubleFaced = nDF;
|
||||
this.nLand = nL > 0 ? nL : 0;
|
||||
this.foilRate = oneFoilPer;
|
||||
this.edition = edition0;
|
||||
this.landEdition = editionLand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the common.
|
||||
*
|
||||
* @return the common
|
||||
*/
|
||||
public final int getCommon() {
|
||||
return this.nCommon;
|
||||
}
|
||||
|
||||
public final Predicate<CardPrinted> getEditionFilter() {
|
||||
return IPaperCard.Predicates.printedInSets(edition);
|
||||
return IPaperCard.Predicates.printedInSets(getEdition());
|
||||
}
|
||||
public final Predicate<CardPrinted> getLandEditionFilter() {
|
||||
return IPaperCard.Predicates.printedInSets(landEdition);
|
||||
return IPaperCard.Predicates.printedInSets(getLandEdition());
|
||||
}
|
||||
/**
|
||||
* Gets the uncommon.
|
||||
*
|
||||
* @return the uncommon
|
||||
*/
|
||||
|
||||
public final int getUncommon() {
|
||||
return this.nUncommon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rare.
|
||||
*
|
||||
* @return the rare
|
||||
*/
|
||||
public final int getRare() {
|
||||
return this.nRare;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the special.
|
||||
*
|
||||
* @return the special
|
||||
*/
|
||||
public final int getSpecial() {
|
||||
return this.nSpecial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the double faced.
|
||||
*
|
||||
* @return the double faced
|
||||
*/
|
||||
public final int getDoubleFaced() {
|
||||
return this.nDoubleFaced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the land.
|
||||
*
|
||||
* @return the land
|
||||
*/
|
||||
public final int getLand() {
|
||||
return this.nLand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total.
|
||||
*
|
||||
* @return the total
|
||||
*/
|
||||
public final int getTotal() {
|
||||
return this.nCommon + this.nUncommon + this.nRare + this.nSpecial + this.nDoubleFaced + this.nLand;
|
||||
return this.nCommon + this.nUncommon + this.nRare + this.nSpecial + this.nDoubleFaced + getCntLands();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the foil chance.
|
||||
*
|
||||
* @return the foil chance
|
||||
*/
|
||||
public final int getFoilChance() {
|
||||
return this.foilRate;
|
||||
}
|
||||
|
||||
public static final Function<BoosterData, String> FN_GET_CODE = new Function<BoosterData, String>() {
|
||||
private void _append(StringBuilder s, int val, String name) {
|
||||
if (0 >= val) {
|
||||
return;
|
||||
}
|
||||
s.append(val).append(' ').append(name);
|
||||
if (1 < val) {
|
||||
s.append('s');
|
||||
}
|
||||
s.append(", ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(BoosterData arg1) {
|
||||
return arg1.edition;
|
||||
public String toString() {
|
||||
int total = getTotal();
|
||||
|
||||
if (0 >= total) {
|
||||
return "no cards";
|
||||
}
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
_append(s, total, "card");
|
||||
if (0 < total) {
|
||||
// remove comma
|
||||
s.deleteCharAt(s.length() - 2);
|
||||
}
|
||||
|
||||
s.append("consisting of ");
|
||||
_append(s, nSpecial, "special");
|
||||
_append(s, nDoubleFaced, "double faced card");
|
||||
_append(s, nRare, "rare");
|
||||
_append(s, nUncommon, "uncommon");
|
||||
_append(s, nCommon, "common");
|
||||
if (getEdition().equalsIgnoreCase(getLandEdition())) {
|
||||
_append(s, getCntLands(), "land");
|
||||
} else if (0 < getCntLands()) {
|
||||
s.append(getCntLands()).append("land");
|
||||
if (1 < getCntLands()) {
|
||||
s.append("s");
|
||||
}
|
||||
s.append("from edition: ").append(getLandEdition()).append(", ");
|
||||
}
|
||||
|
||||
// trim the last comma and space
|
||||
s.replace(s.length() - 2, s.length(), "");
|
||||
|
||||
// put an 'and' before the previous comma
|
||||
int lastCommaIdx = s.lastIndexOf(",");
|
||||
if (0 < lastCommaIdx) {
|
||||
s.replace(lastCommaIdx+1, lastCommaIdx+1, " and");
|
||||
}
|
||||
|
||||
if (0 < foilRate) {
|
||||
s.append(", with a foil rate of 1 in ").append(foilRate);
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
};
|
||||
|
||||
public static final class Reader extends StorageReaderFile<BoosterData> {
|
||||
|
||||
public Reader(String pathname) {
|
||||
super(pathname, BoosterData.FN_GET_CODE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.util.StorageReaderFile#read(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected BoosterData read(String line, int i) {
|
||||
final FileSection section = FileSection.parse(line, ":", "|");
|
||||
@@ -194,6 +148,7 @@ public class BoosterData {
|
||||
if (editionLand == null) {
|
||||
editionLand = edition;
|
||||
}
|
||||
|
||||
return new BoosterData(edition, editionLand, nC, nU, nR, nS, nDf, nLand, nFoilRate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class BoosterGenerator {
|
||||
*/
|
||||
public final List<CardPrinted> getBoosterPack(BoosterData booster) {
|
||||
return this.getBoosterPack(booster.getCommon(), booster.getUncommon(), booster.getRare(), 0, 0, booster.getSpecial(),
|
||||
booster.getDoubleFaced(), 0, booster.getLand());
|
||||
booster.getDoubleFaced(), 0, booster.getCntLands());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forge.card;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.util.FileSection;
|
||||
import forge.util.storage.StorageReaderFile;
|
||||
|
||||
@@ -9,53 +7,23 @@ import forge.util.storage.StorageReaderFile;
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class FatPackData {
|
||||
private final String edition;
|
||||
public final String getEdition() {
|
||||
return edition;
|
||||
}
|
||||
|
||||
private final String landsEdition;
|
||||
public final String getLandsEdition() {
|
||||
return landsEdition == null ? edition : landsEdition;
|
||||
}
|
||||
|
||||
public class FatPackData extends PackData {
|
||||
private final int cntBoosters;
|
||||
public int getCntBoosters() {
|
||||
return cntBoosters;
|
||||
}
|
||||
|
||||
public int getCntLands() {
|
||||
return cntLands;
|
||||
}
|
||||
|
||||
private final int cntBoosters;
|
||||
private final int cntLands;
|
||||
|
||||
public FatPackData(String edition0, String landsEdition0, int nBoosters, int nBasicLands)
|
||||
public FatPackData(String edition0, String landEdition0, int nBoosters, int nBasicLands)
|
||||
{
|
||||
super(edition0, landEdition0, nBasicLands);
|
||||
cntBoosters = nBoosters;
|
||||
cntLands = nBasicLands;
|
||||
edition = edition0;
|
||||
landsEdition = landsEdition0;
|
||||
}
|
||||
|
||||
public static final Function<FatPackData, String> FN_GET_CODE = new Function<FatPackData, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(FatPackData arg1) {
|
||||
return arg1.edition;
|
||||
}
|
||||
};
|
||||
|
||||
public static final class Reader extends StorageReaderFile<FatPackData> {
|
||||
|
||||
public Reader(String pathname) {
|
||||
super(pathname, FatPackData.FN_GET_CODE);
|
||||
super(pathname, PackData.FN_GET_CODE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.util.StorageReaderFile#read(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected FatPackData read(String line, int i) {
|
||||
final FileSection section = FileSection.parse(line, ":", "|");
|
||||
@@ -64,4 +32,34 @@ public class FatPackData {
|
||||
return new FatPackData(section.get("Set"), section.get("LandSet"), nBoosters, nLand);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (0 >= cntBoosters) {
|
||||
return "no cards";
|
||||
}
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
if (0 < getCntLands()) {
|
||||
s.append(getCntLands()).append(" land");
|
||||
if (1 < getCntLands()) {
|
||||
s.append("s");
|
||||
}
|
||||
|
||||
if (!getEdition().equalsIgnoreCase(getLandEdition())) {
|
||||
s.append(" from edition: ").append(getLandEdition());
|
||||
}
|
||||
|
||||
if (0 < cntBoosters) {
|
||||
s.append(" and ");
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < cntBoosters) {
|
||||
s.append(cntBoosters).append(" booster packs, each containing ");
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
}
|
||||
|
||||
52
src/main/java/forge/card/PackData.java
Normal file
52
src/main/java/forge/card/PackData.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.card;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public class PackData {
|
||||
private final String edition;
|
||||
public final String getEdition() {
|
||||
return edition;
|
||||
}
|
||||
|
||||
private final String landEdition;
|
||||
public final String getLandEdition() {
|
||||
return landEdition == null ? edition : landEdition;
|
||||
}
|
||||
|
||||
private final int cntLands;
|
||||
public int getCntLands() {
|
||||
return cntLands;
|
||||
}
|
||||
|
||||
public PackData(String edition0, String landEdition0, int nBasicLands)
|
||||
{
|
||||
edition = edition0;
|
||||
landEdition = landEdition0;
|
||||
cntLands = nBasicLands;
|
||||
}
|
||||
|
||||
public static final Function<? super PackData, String> FN_GET_CODE = new Function<PackData, String>() {
|
||||
@Override
|
||||
public String apply(PackData arg1) {
|
||||
return arg1.edition;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -31,7 +31,9 @@ import forge.Color;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ICardFace;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
@@ -313,6 +315,11 @@ public class CardFactory {
|
||||
card.addStaticAbility(stAbs.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
if ( state == CardCharacteristicName.LeftSplit || state == CardCharacteristicName.RightSplit )
|
||||
{
|
||||
card.getState(CardCharacteristicName.Original).getSpellAbility().addAll(card.getCharacteristics().getSpellAbility());
|
||||
}
|
||||
}
|
||||
|
||||
card.setState(CardCharacteristicName.Original);
|
||||
@@ -367,9 +374,30 @@ public class CardFactory {
|
||||
if (card.isInAlternateState()) {
|
||||
card.setState(CardCharacteristicName.Original);
|
||||
}
|
||||
|
||||
if ( st == CardSplitType.Split ) {
|
||||
card.setName(rules.getName());
|
||||
// BUILD COMBINED 'Original' SIDE HERE
|
||||
|
||||
// Combined mana cost
|
||||
ManaCost combinedManaCost = ManaCost.combine(rules.getMainPart().getManaCost(), rules.getOtherPart().getManaCost());
|
||||
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()));
|
||||
ArrayList<CardColor> combinedCardColorArr = new ArrayList<CardColor>();
|
||||
combinedCardColorArr.add(combinedCardColor);
|
||||
card.setColor(combinedCardColorArr);
|
||||
|
||||
// Super and 'middle' types should use enums.
|
||||
List<String> coreTypes = rules.getType().getTypesBeforeDash();
|
||||
coreTypes.addAll(rules.getType().getSubTypes());
|
||||
card.setType(coreTypes);
|
||||
|
||||
// Combined text based on Oracle text - might not be necessary, temporarily disabled.
|
||||
//String combinedText = String.format("%s: %s\n%s: %s", rules.getMainPart().getName(), rules.getMainPart().getOracleText(), rules.getOtherPart().getName(), rules.getOtherPart().getOracleText());
|
||||
//card.setText(combinedText);
|
||||
}
|
||||
|
||||
return card;
|
||||
|
||||
@@ -2796,7 +2796,6 @@ public class CardFactoryUtil {
|
||||
// **************************************************
|
||||
// AbilityFactory cards
|
||||
final ArrayList<String> ia = card.getIntrinsicAbilities();
|
||||
if (ia.size() > 0) {
|
||||
for (int i = 0; i < ia.size(); i++) {
|
||||
// System.out.println(cardName);
|
||||
final SpellAbility sa = AbilityFactory.getAbility(ia.get(i), card);
|
||||
@@ -2805,7 +2804,7 @@ public class CardFactoryUtil {
|
||||
}
|
||||
card.addSpellAbility(sa);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,9 @@ package forge.card.spellability;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cost.CostPayment;
|
||||
import forge.game.zone.Zone;
|
||||
@@ -149,6 +151,14 @@ public class SpellAbilityRequirements {
|
||||
if (this.select.isCanceled()) {
|
||||
// cancel ability during target choosing
|
||||
final Card c = this.ability.getSourceCard();
|
||||
|
||||
// split cards transform back to full form if targeting is canceled
|
||||
if (c.getRules() != null) {
|
||||
if (c.getRules().getSplitType() == CardSplitType.Split) {
|
||||
c.setState(CardCharacteristicName.Original);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
// add back to where it came from
|
||||
Singletons.getModel().getGame().getAction().moveTo(this.fromZone, c, this.zonePosition);
|
||||
@@ -203,6 +213,14 @@ public class SpellAbilityRequirements {
|
||||
Singletons.getModel().getGame().getAction().checkStateEffects();
|
||||
} else if (this.payment.isCanceled()) {
|
||||
final Card c = this.ability.getSourceCard();
|
||||
|
||||
// split cards transform back to full form if mana cost is not paid
|
||||
if (c.getRules() != null) {
|
||||
if (c.getRules().getSplitType() == CardSplitType.Split) {
|
||||
c.setState(CardCharacteristicName.Original);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
// add back to Previous Zone
|
||||
Singletons.getModel().getGame().getAction().moveTo(this.fromZone, c, this.zonePosition);
|
||||
|
||||
@@ -33,6 +33,7 @@ import forge.CardUtil;
|
||||
import forge.Command;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ability.effects.AttachEffect;
|
||||
import forge.card.cost.Cost;
|
||||
@@ -339,6 +340,13 @@ public class GameAction {
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public final Card moveTo(final Zone zoneTo, Card c) {
|
||||
// if a split card is moved, convert it back to its full form before moving (unless moving to stack)
|
||||
if (c.getRules() != null) {
|
||||
if ((c.getRules().getSplitType() == CardSplitType.Split) && (zoneTo != game.getStackZone())) {
|
||||
c.setState(CardCharacteristicName.Original);
|
||||
}
|
||||
}
|
||||
|
||||
return moveTo(zoneTo, c, null);
|
||||
}
|
||||
|
||||
@@ -704,6 +712,7 @@ public class GameAction {
|
||||
return c;
|
||||
}
|
||||
final PlayerZone removed = c.getOwner().getZone(ZoneType.Exile);
|
||||
|
||||
return moveTo(removed, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ import java.util.List;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardCharacteristicName;
|
||||
import forge.CardColor;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
@@ -363,6 +365,11 @@ public class GameActionPlay {
|
||||
public final void playSpellAbility(SpellAbility sa, Player activator) {
|
||||
sa.setActivatingPlayer(activator);
|
||||
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
// Split card support
|
||||
setSplitCardState(source, sa);
|
||||
|
||||
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
|
||||
CharmEffect.makeChoices(sa);
|
||||
}
|
||||
@@ -402,7 +409,6 @@ public class GameActionPlay {
|
||||
manaCost = this.getSpellCostChange(sa, new ManaCostBeingPaid(sa.getManaCost()));
|
||||
}
|
||||
if (manaCost.isPaid() && (sa.getBeforePayMana() == null)) {
|
||||
final Card source = sa.getSourceCard();
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setSourceCard(game.getAction().moveToStack(source));
|
||||
}
|
||||
@@ -532,4 +538,26 @@ public class GameActionPlay {
|
||||
|
||||
return usableColors;
|
||||
}
|
||||
|
||||
private void setSplitCardState(final Card source, SpellAbility sa) {
|
||||
// Split card support
|
||||
if (source.getRules() != null) {
|
||||
if (source.getRules().getSplitType() == CardSplitType.Split) {
|
||||
List<SpellAbility> leftSplitAbilities = source.getState(CardCharacteristicName.LeftSplit).getSpellAbility();
|
||||
List<SpellAbility> rightSplitAbilities = source.getState(CardCharacteristicName.RightSplit).getSpellAbility();
|
||||
for (SpellAbility a : leftSplitAbilities) {
|
||||
if (sa == a || sa.getDescription().equals(String.format("%s (without paying its mana cost)", a.getDescription()))) {
|
||||
source.setState(CardCharacteristicName.LeftSplit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (SpellAbility a : rightSplitAbilities) {
|
||||
if (sa == a || sa.getDescription().equals(String.format("%s (without paying its mana cost)", a.getDescription()))) {
|
||||
source.setState(CardCharacteristicName.RightSplit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
@@ -45,6 +47,7 @@ import forge.gui.toolbox.FPanel;
|
||||
import forge.gui.toolbox.FScrollPane;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.FTextArea;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
|
||||
/**
|
||||
* The class CardDetailPanel. Shows the details of a card.
|
||||
@@ -66,18 +69,11 @@ public class CardDetailPanel extends FPanel {
|
||||
private final FTextArea cdArea;
|
||||
private final FScrollPane scrArea;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for CardDetailPanel.
|
||||
* </p>
|
||||
*
|
||||
* @param card
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public CardDetailPanel(final Card card) {
|
||||
super();
|
||||
this.setLayout(new GridBagLayout());
|
||||
this.setBorder(new EtchedBorder());
|
||||
this.setBorderToggle(false);
|
||||
|
||||
GridBagConstraints labelConstrains = new GridBagConstraints();
|
||||
labelConstrains.fill = GridBagConstraints.BOTH;
|
||||
@@ -126,6 +122,9 @@ public class CardDetailPanel extends FPanel {
|
||||
|
||||
//4, 12
|
||||
this.cdArea = new FTextArea();
|
||||
this.cdArea.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
this.cdArea.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
this.cdArea.setOpaque(false);
|
||||
this.scrArea = new FScrollPane(this.cdArea);
|
||||
|
||||
GridBagConstraints areaConstraints = new GridBagConstraints();
|
||||
@@ -135,10 +134,6 @@ public class CardDetailPanel extends FPanel {
|
||||
areaConstraints.weightx = 1.0;
|
||||
areaConstraints.weighty = 1.0;
|
||||
this.add(scrArea, areaConstraints);
|
||||
this.cdArea.setLineWrap(true);
|
||||
this.cdArea.setWrapStyleWord(true);
|
||||
this.cdArea.setEditable(false);
|
||||
this.cdArea.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
|
||||
this.nameCostLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
this.typeLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
@@ -149,15 +144,49 @@ public class CardDetailPanel extends FPanel {
|
||||
f = f.deriveFont(java.awt.Font.BOLD);
|
||||
this.setInfoLabel.setFont(f);
|
||||
|
||||
this.cdArea.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
|
||||
this.setCard(card);
|
||||
}
|
||||
|
||||
public final void setItem(InventoryItemFromSet item) {
|
||||
nameCostLabel.setText(item.getName());
|
||||
typeLabel.setVisible(false);
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText(null);
|
||||
cdArea.setText(item.getDescription());
|
||||
setBorder(GuiDisplayUtil.getBorder(null));
|
||||
|
||||
String set = item.getEdition();
|
||||
setInfoLabel.setText(set);
|
||||
setInfoLabel.setToolTipText("");
|
||||
if (StringUtils.isEmpty(set)) {
|
||||
setInfoLabel.setOpaque(false);
|
||||
setInfoLabel.setBorder(null);
|
||||
} else {
|
||||
CardEdition edition = Singletons.getModel().getEditions().get(set);
|
||||
if (null != edition) {
|
||||
setInfoLabel.setToolTipText(edition.getName());
|
||||
}
|
||||
|
||||
this.setInfoLabel.setOpaque(true);
|
||||
this.setInfoLabel.setBackground(Color.BLACK);
|
||||
this.setInfoLabel.setForeground(Color.WHITE);
|
||||
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
scrArea.getVerticalScrollBar().setValue(scrArea.getVerticalScrollBar().getMinimum());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public final void setCard(final Card card) {
|
||||
this.nameCostLabel.setText("");
|
||||
this.typeLabel.setVisible(true);
|
||||
this.typeLabel.setText("");
|
||||
this.powerToughnessLabel.setVisible(true);
|
||||
this.powerToughnessLabel.setText("");
|
||||
this.idLabel.setText("");
|
||||
this.setInfoLabel.setText("");
|
||||
@@ -167,8 +196,9 @@ public class CardDetailPanel extends FPanel {
|
||||
this.cdArea.setText("");
|
||||
this.setBorder(GuiDisplayUtil.getBorder(card));
|
||||
|
||||
if ( null == card )
|
||||
if (null == card) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer());
|
||||
if (canShowThis) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import forge.gui.framework.ICDoc;
|
||||
import forge.gui.match.views.VDetail;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -38,7 +39,6 @@ public enum CDetail implements ICDoc {
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private VDetail view = VDetail.SINGLETON_INSTANCE;
|
||||
//private InventoryItem item = null;
|
||||
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
@@ -54,14 +54,13 @@ public enum CDetail implements ICDoc {
|
||||
public void showCard(InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
showCard(((IPaperCard)item).getMatchingForgeCard());
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO If we want to display an Items Written Text in the Detail Panel we need to add something into CardDetailPanel
|
||||
//this.item = item;
|
||||
} else if (item instanceof InventoryItemFromSet) {
|
||||
view.getLblFlipcard().setVisible(false);
|
||||
view.getPnlDetail().setCard(null);
|
||||
view.getPnlDetail().setItem((InventoryItemFromSet)item);
|
||||
view.getParentCell().repaintSelf();
|
||||
} else {
|
||||
showCard((Card)null);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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;
|
||||
|
||||
package forge.item;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
@@ -25,13 +25,7 @@ import forge.Singletons;
|
||||
import forge.card.BoosterData;
|
||||
import forge.card.CardEdition;
|
||||
|
||||
/**
|
||||
* TODO Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class BoosterPack extends OpenablePack {
|
||||
|
||||
/** The Constant fnFromSet. */
|
||||
public static final Function<CardEdition, BoosterPack> FN_FROM_SET = new Function<CardEdition, BoosterPack>() {
|
||||
@Override
|
||||
public BoosterPack apply(final CardEdition arg1) {
|
||||
@@ -40,26 +34,10 @@ public class BoosterPack extends OpenablePack {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new booster pack.
|
||||
*
|
||||
* @param set
|
||||
* the set
|
||||
*/
|
||||
public BoosterPack(final String name0, final BoosterData boosterData) {
|
||||
super(name0, boosterData);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.item.InventoryItemFromSet#getImageFilename()
|
||||
*/
|
||||
/**
|
||||
* Gets the image filename.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public final String getImageFilename() {
|
||||
return ImageCache.SEALED_PRODUCT + "booster/" + this.contents.getEdition() + ".png";
|
||||
@@ -70,20 +48,8 @@ public class BoosterPack extends OpenablePack {
|
||||
return "Booster Pack";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
/**
|
||||
* Clone.
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
@Override
|
||||
public final Object clone() {
|
||||
return new BoosterPack(name, contents);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,11 @@ public final class CardPrinted implements Comparable<IPaperCard>, InventoryItemF
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -23,6 +23,8 @@ public class CardToken implements InventoryItemFromSet, IPaperCard {
|
||||
}
|
||||
|
||||
@Override public String getName() { return name; }
|
||||
@Override public String getDescription() { return name; }
|
||||
|
||||
@Override public String getEdition() { return edition; }
|
||||
|
||||
@Override public int getArtIndex() { return 0; } // This might change however
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -27,10 +28,6 @@ import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.FatPackData;
|
||||
|
||||
/**
|
||||
* TODO Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class FatPack extends OpenablePack {
|
||||
|
||||
/** The Constant fnFromSet. */
|
||||
@@ -44,17 +41,15 @@ public class FatPack extends OpenablePack {
|
||||
|
||||
private final FatPackData fpData;
|
||||
|
||||
/**
|
||||
* Instantiates a new booster pack.
|
||||
*
|
||||
* @param set
|
||||
* the set
|
||||
*/
|
||||
public FatPack(final String name0, final FatPackData fpData0) {
|
||||
super(name0, Singletons.getModel().getBoosters().get(fpData0.getEdition()));
|
||||
fpData = fpData0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return fpData.toString() + contents.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getImageFilename() {
|
||||
@@ -73,20 +68,10 @@ public class FatPack extends OpenablePack {
|
||||
for (int i = 0; i < fpData.getCntBoosters(); i++) {
|
||||
result.addAll(super.generate());
|
||||
}
|
||||
result.addAll(getRandomBasicLands(fpData.getLandsEdition(), fpData.getCntLands()));
|
||||
result.addAll(getRandomBasicLands(fpData.getLandEdition(), fpData.getCntLands()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
/**
|
||||
* Clone.
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
@Override
|
||||
public final Object clone() {
|
||||
return new FatPack(name, fpData);
|
||||
@@ -96,6 +81,4 @@ public class FatPack extends OpenablePack {
|
||||
public int getTotalCards() {
|
||||
return super.getTotalCards() * fpData.getCntBoosters() + fpData.getCntLands();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,22 +22,10 @@ package forge.item;
|
||||
* CardPrinted, Booster, Pets, Plants... etc
|
||||
*/
|
||||
public interface InventoryItemFromSet extends InventoryItem {
|
||||
|
||||
/**
|
||||
* An inventory item has to provide a name.
|
||||
*
|
||||
* @return the name
|
||||
* The description to display for the item
|
||||
*/
|
||||
@Override
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* An inventory item has to provide a picture.
|
||||
*
|
||||
* @return the image filename
|
||||
*/
|
||||
@Override
|
||||
String getImageFilename();
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* An item belonging to a set should return its set as well.
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
@@ -28,73 +29,46 @@ import forge.card.BoosterGenerator;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*/
|
||||
public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
|
||||
/** The contents. */
|
||||
protected final BoosterData contents;
|
||||
|
||||
/** The name. */
|
||||
protected final String name;
|
||||
private List<CardPrinted> cards = null;
|
||||
|
||||
private BoosterGenerator generator = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new openable pack.
|
||||
*
|
||||
* @param name0 the name0
|
||||
* @param boosterData the booster data
|
||||
*/
|
||||
public OpenablePack(final String name0, final BoosterData boosterData) {
|
||||
this.contents = boosterData;
|
||||
this.name = name0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.item.InventoryItemFromSet#getName()
|
||||
*/
|
||||
@Override
|
||||
public final String getName() {
|
||||
return this.name + " " + this.getItemType();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.item.InventoryItemFromSet#getEdition()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return contents.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getEdition() {
|
||||
return this.contents.getEdition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cards.
|
||||
*
|
||||
* @return the cards
|
||||
*/
|
||||
public final List<CardPrinted> getCards() {
|
||||
if (null == this.cards) {
|
||||
this.cards = this.generate();
|
||||
}
|
||||
|
||||
return this.cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total cards.
|
||||
*
|
||||
* @return the total cards
|
||||
*/
|
||||
public int getTotalCards() {
|
||||
return this.contents.getTotal();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public final boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
@@ -117,16 +91,6 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
/**
|
||||
* Hash code.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -135,47 +99,27 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate.
|
||||
*
|
||||
* @return the list
|
||||
*/
|
||||
protected List<CardPrinted> generate() {
|
||||
if (null == this.generator) {
|
||||
this.generator = new BoosterGenerator(this.contents.getEditionFilter());
|
||||
}
|
||||
final List<CardPrinted> myCards = this.generator.getBoosterPack(this.contents);
|
||||
|
||||
final int cntLands = this.contents.getLand();
|
||||
final int cntLands = this.contents.getCntLands();
|
||||
if (cntLands > 0) {
|
||||
myCards.add(this.getRandomBasicLand(this.contents.getLandEdition()));
|
||||
}
|
||||
return myCards;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the random basic land.
|
||||
*
|
||||
* @param set the set
|
||||
* @return the random basic land
|
||||
*/
|
||||
protected CardPrinted getRandomBasicLand(final String setCode) {
|
||||
return this.getRandomBasicLands(setCode, 1).get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the random basic lands.
|
||||
*
|
||||
* @param set the set
|
||||
* @param count the count
|
||||
* @return the random basic lands
|
||||
*/
|
||||
protected List<CardPrinted> getRandomBasicLands(final String setCode, final int count) {
|
||||
Predicate<CardPrinted> cardsRule = Predicates.and(
|
||||
IPaperCard.Predicates.printedInSets(setCode),
|
||||
Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES));
|
||||
return Aggregates.random(Iterables.filter(CardDb.instance().getAllCards(), cardsRule), count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
@Override
|
||||
public final String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import forge.util.IItemReader;
|
||||
public abstract class StorageReaderFile<T> implements IItemReader<T> {
|
||||
|
||||
private final File file;
|
||||
private final Function<T, String> keySelector;
|
||||
private final Function<? super T, String> keySelector;
|
||||
|
||||
/**
|
||||
* Instantiates a new storage reader file.
|
||||
@@ -48,7 +48,7 @@ public abstract class StorageReaderFile<T> implements IItemReader<T> {
|
||||
* @param pathname the pathname
|
||||
* @param keySelector0 the key selector0
|
||||
*/
|
||||
public StorageReaderFile(final String pathname, final Function<T, String> keySelector0) {
|
||||
public StorageReaderFile(final String pathname, final Function<? super T, String> keySelector0) {
|
||||
this(new File(pathname), keySelector0);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class StorageReaderFile<T> implements IItemReader<T> {
|
||||
* @param file0 the file0
|
||||
* @param keySelector0 the key selector0
|
||||
*/
|
||||
public StorageReaderFile(final File file0, final Function<T, String> keySelector0) {
|
||||
public StorageReaderFile(final File file0, final Function<? super T, String> keySelector0) {
|
||||
this.file = file0;
|
||||
this.keySelector = keySelector0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user