mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
refactored booster generation: ARN generates correctly, DGM maze land slot not coded yet.
FPs, starters not tested. known issues: guild sealed not working
This commit is contained in:
5
.gitattributes
vendored
5
.gitattributes
vendored
@@ -13553,8 +13553,8 @@ src/main/java/forge/Singletons.java svneol=native#text/plain
|
|||||||
src/main/java/forge/StaticEffect.java svneol=native#text/plain
|
src/main/java/forge/StaticEffect.java svneol=native#text/plain
|
||||||
src/main/java/forge/StaticEffects.java svneol=native#text/plain
|
src/main/java/forge/StaticEffects.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/AggregationMethod.java -text
|
src/main/java/forge/card/AggregationMethod.java -text
|
||||||
src/main/java/forge/card/BoosterData.java -text
|
|
||||||
src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plain
|
src/main/java/forge/card/BoosterGenerator.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/card/BoosterTemplate.java -text
|
||||||
src/main/java/forge/card/CardAiHints.java -text
|
src/main/java/forge/card/CardAiHints.java -text
|
||||||
src/main/java/forge/card/CardBlock.java -text
|
src/main/java/forge/card/CardBlock.java -text
|
||||||
src/main/java/forge/card/CardCharacteristics.java -text
|
src/main/java/forge/card/CardCharacteristics.java -text
|
||||||
@@ -13572,7 +13572,7 @@ src/main/java/forge/card/CardType.java -text
|
|||||||
src/main/java/forge/card/ColorSet.java -text
|
src/main/java/forge/card/ColorSet.java -text
|
||||||
src/main/java/forge/card/DeckHints.java -text
|
src/main/java/forge/card/DeckHints.java -text
|
||||||
src/main/java/forge/card/EditionCollection.java svneol=native#text/plain
|
src/main/java/forge/card/EditionCollection.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/FatPackData.java -text
|
src/main/java/forge/card/FatPackTemplate.java -text
|
||||||
src/main/java/forge/card/FormatCollection.java -text
|
src/main/java/forge/card/FormatCollection.java -text
|
||||||
src/main/java/forge/card/ICardCharacteristics.java -text
|
src/main/java/forge/card/ICardCharacteristics.java -text
|
||||||
src/main/java/forge/card/ICardFace.java -text
|
src/main/java/forge/card/ICardFace.java -text
|
||||||
@@ -14306,6 +14306,7 @@ src/main/java/forge/item/ItemPoolView.java -text
|
|||||||
src/main/java/forge/item/ItemPredicate.java -text
|
src/main/java/forge/item/ItemPredicate.java -text
|
||||||
src/main/java/forge/item/OpenablePack.java -text
|
src/main/java/forge/item/OpenablePack.java -text
|
||||||
src/main/java/forge/item/PreconDeck.java -text
|
src/main/java/forge/item/PreconDeck.java -text
|
||||||
|
src/main/java/forge/item/PrintSheet.java -text
|
||||||
src/main/java/forge/item/TournamentPack.java -text
|
src/main/java/forge/item/TournamentPack.java -text
|
||||||
src/main/java/forge/item/package-info.java -text
|
src/main/java/forge/item/package-info.java -text
|
||||||
src/main/java/forge/model/BuildInfo.java -text
|
src/main/java/forge/model/BuildInfo.java -text
|
||||||
|
|||||||
@@ -1,79 +1,80 @@
|
|||||||
Set:10E|LandSet:10E|Commons:10|Uncommons:3|Rares:1|Images:5
|
10E: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:2ED|Commons:11|Uncommons:3|Rares:1|Images:1
|
2ED: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:3ED|Commons:11|Uncommons:3|Rares:1|Images:1
|
3ED: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:4ED|Commons:11|Uncommons:3|Rares:1|Images:5
|
4ED: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:5DN|Commons:11|Uncommons:3|Rares:1|Images:3
|
5DN: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:5ED|Commons:11|Uncommons:3|Rares:1|Images:5
|
5ED: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:6ED|Commons:11|Uncommons:3|Rares:1|Images:1
|
6ED: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:7ED|Commons:10|Uncommons:3|Rares:1|Images:5
|
7ED: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:8ED|Commons:10|Uncommons:3|Rares:1|Images:5
|
8ED: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:9ED|Commons:10|Uncommons:3|Rares:1|Images:5
|
9ED: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:ALA|Commons:10|Uncommons:3|Rares:1|Images:5
|
ALA: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:ALL|Commons:8|Uncommons:3|Rares:1|Images:1
|
ALL: 1 covers, 8 Common, 3 Uncommon, 1 Rare
|
||||||
Set:APC|Commons:11|Uncommons:3|Rares:1|Images:1
|
APC: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:ARB|LandSet:ALA|Commons:10|Uncommons:3|Rares:1|Images:3
|
ARB: 3 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand ALA
|
||||||
Set:ARN|Commons:6|Uncommons:2|Images:1
|
ARN: 1 covers, 6 Common, 2 UncommonRare
|
||||||
Set:ATQ|Commons:5|Uncommons:2|Rares:1|Images:1
|
ATQ: 1 covers, 6 Common, 2 UncommonRare
|
||||||
Set:AVR|Commons:10|Uncommons:3|Rares:1|Images:5
|
AVR: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:BOK|Commons:11|Uncommons:3|Rares:1|Images:3
|
BOK: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:CFX|LandSet:ALA|Commons:10|Uncommons:3|Rares:1|Images:3
|
CFX: 3 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand ALA
|
||||||
Set:CHK|Commons:11|Uncommons:3|Rares:1|Images:5
|
CHK: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:CHR|Commons:9|Uncommons:3|Images:1
|
CHR: 1 covers, 9 Common, 3 UncommonRare
|
||||||
Set:CSP|Commons:11|Uncommons:3|Rares:1|Images:3
|
CSP: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:DIS|Commons:11|Uncommons:3|Rares:1|Images:3
|
DGM: 3 covers, 10 Common, 3 Uncommon, 1 Rare:!name("Maze's End"), 1 MazeLand
|
||||||
Set:DKA|LandSet:ISD|Commons:9|Uncommons:3|DoubleFaced:1|Rares:1|Images:3
|
DIS: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:DRK|Commons:6|Rares:2|Images:1
|
DKA: 3 covers, 9 Common:!dfc, 3 Uncommon:!dfc, 1 Rare:!dfc, 1 Any:dfc, 1 BasicLand ISD
|
||||||
Set:DST|Commons:11|Uncommons:3|Rares:1|Images:3
|
DRK: 1 covers, 6 Common, 2 UncommonRare
|
||||||
Set:EVE|Commons:11|Uncommons:3|Rares:1|Images:3
|
DST: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:EXO|Commons:11|Uncommons:3|Rares:1|Images:1
|
EVE: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:FEM|Commons:5|Uncommons:2|Rares:1|Images:1
|
EXO: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:FUT|Commons:11|Uncommons:3|Rares:1|Images:3
|
FEM: 1 covers, 5 Common, 2 Uncommon, 1 Rare
|
||||||
Set:GPT|Commons:11|Uncommons:3|Rares:1|Images:3
|
FUT: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:GTC|Commons:10|Uncommons:3|Rares:1|Images:5
|
GPT: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:HML|Commons:6|Uncommons:2|Images:1
|
GTC: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:ICE|Commons:11|Uncommons:3|Rares:1|Images:5
|
HML: 1 covers, 6 Common, 2 UncommonRare
|
||||||
Set:INV|Commons:11|Uncommons:3|Rares:1|Images:3
|
ICE: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:ISD|Commons:9|Uncommons:3|DoubleFaced:1|Rares:1|Images:5
|
INV: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:JUD|Commons:11|Uncommons:3|Rares:1|Images:1
|
ISD: 5 covers, 9 Common:!dfc, 3 Uncommon:!dfc, 1 Rare:!dfc, 1 Any:dfc, 1 BasicLand
|
||||||
Set:LEA|Commons:11|Uncommons:3|Rares:1|Images:1
|
JUD: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:LEB|Commons:11|Uncommons:3|Rares:1|Images:1
|
LEA: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:LEG|Commons:11|Uncommons:3|Rares:1|Images:1
|
LEB: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:LGN|Commons:11|Uncommons:3|Rares:1|Images:3
|
LEG: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:LRW|Commons:11|Uncommons:3|Rares:1|Images:5
|
LGN: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:M10|Commons:10|Uncommons:3|Rares:1|Images:5
|
LRW: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:M11|Commons:10|Uncommons:3|Rares:1|Images:5
|
M10: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:M12|Commons:10|Uncommons:3|Rares:1|Images:5
|
M11: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:M13|Commons:10|Uncommons:3|Rares:1|Images:5
|
M12: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:MBS|Commons:10|Uncommons:3|Rares:1|Images:3
|
M13: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:MIR|Commons:11|Uncommons:3|Rares:1|Images:5
|
MBS: 3 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:MMQ|Commons:11|Uncommons:3|Rares:1|Images:3
|
MIR: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:MOR|Commons:11|Uncommons:3|Rares:1|Images:3
|
MMQ: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:MRD|Commons:11|Uncommons:3|Rares:1|Images:5
|
MOR: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:NMS|Commons:11|Uncommons:3|Rares:1|Images:1
|
MRD: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:NPH|Commons:10|Uncommons:3|Rares:1|Images:3
|
NMS: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:ODY|Commons:11|Uncommons:3|Rares:1|Images:3
|
NPH: 3 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:ONS|Commons:11|Uncommons:3|Rares:1|Images:5
|
ODY: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:PCY|Commons:11|Uncommons:3|Rares:1|Images:1
|
ONS: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:PLC|Commons:11|Uncommons:3|Rares:1|Images:3
|
PCY: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:PLS|Commons:11|Uncommons:3|Rares:1|Images:1
|
PLC: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:PO2|Commons:11|Uncommons:3|Rares:1|Images:1
|
PLS: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:POR|Commons:11|Uncommons:3|Rares:1|Images:5
|
PO2: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:PTK|Commons:5|Uncommons:2|Rares:1|Images:1
|
POR: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:RAV|Commons:11|Uncommons:3|Rares:1|Images:5
|
PTK: 1 covers, 5 Common, 2 Uncommon, 1 Rare, 2 BasicLand
|
||||||
Set:ROE|Commons:10|Uncommons:3|Rares:1|Images:5
|
RAV: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:RTR|Commons:10|Uncommons:3|Rares:1|Images:5
|
ROE: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:SCG|Commons:11|Uncommons:3|Rares:1|Images:3
|
RTR: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:SHM|Commons:11|Uncommons:3|Rares:1|Images:5
|
SCG: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:SOK|Commons:11|Uncommons:3|Rares:1|Images:3
|
SHM: 5 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:SOM|Commons:10|Uncommons:3|Rares:1|Images:5
|
SOK: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:STH|Commons:11|Uncommons:3|Rares:1|Images:1
|
SOM: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
Set:TMP|Commons:11|Uncommons:3|Rares:1|Images:3
|
STH: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:TOR|Commons:11|Uncommons:3|Rares:1|Images:1
|
TMP: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:TSP|Commons:10|Uncommons:3|Rares:1|Special:1|Images:5
|
TOR: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:UDS|Commons:11|Uncommons:3|Rares:1|Images:1
|
TSP: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 TimeShifted
|
||||||
Set:ULG|Commons:11|Uncommons:3|Rares:1|Images:1
|
UDS: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:USG|Commons:11|Uncommons:3|Rares:1|Images:3
|
ULG: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:VIS|Commons:11|Uncommons:3|Rares:1|Images:1
|
USG: 3 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:WTH|Commons:11|Uncommons:3|Rares:1|Images:1
|
VIS: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:WWK|LandSet:ZEN|Commons:10|Uncommons:3|Rares:1|Images:3
|
WTH: 1 covers, 11 Common, 3 Uncommon, 1 Rare
|
||||||
Set:ZEN|Commons:10|Uncommons:3|Rares:1|Images:5
|
WWK: 3 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand ZEN
|
||||||
|
ZEN: 5 covers, 10 Common, 3 Uncommon, 1 Rare, 1 BasicLand
|
||||||
@@ -1,49 +1,50 @@
|
|||||||
Set:MMQ|LandSet:MMQ|Boosters:6|BasicLands:30
|
MMQ: 6 Boosters, 30 BasicLands
|
||||||
Set:NMS|LandSet:MMQ|Boosters:6|BasicLands:0
|
NMS: 6 Boosters
|
||||||
Set:PCY|LandSet:MMQ|Boosters:6|BasicLands:0
|
PCY: 6 Boosters
|
||||||
Set:INV|LandSet:INV|Boosters:6|BasicLands:0
|
INV: 6 Boosters
|
||||||
Set:PLS|LandSet:INV|Boosters:6|BasicLands:0
|
PLS: 6 Boosters
|
||||||
Set:APC|LandSet:INV|Boosters:6|BasicLands:0
|
APC: 6 Boosters
|
||||||
Set:ODY|LandSet:ODY|Boosters:6|BasicLands:0
|
ODY: 6 Boosters
|
||||||
Set:TOR|LandSet:ODY|Boosters:6|BasicLands:0
|
TOR: 6 Boosters
|
||||||
Set:JUD|LandSet:ODY|Boosters:6|BasicLands:0
|
JUD: 6 Boosters
|
||||||
Set:ONS|LandSet:ONS|Boosters:9|BasicLands:30
|
ONS: 9 Boosters, 30 BasicLands
|
||||||
Set:LGN|LandSet:ONS|Boosters:6|BasicLands:0
|
LGN: 6 Boosters
|
||||||
Set:SCG|LandSet:ONS|Boosters:6|BasicLands:0
|
SCG: 6 Boosters
|
||||||
Set:MRD|LandSet:MRD|Boosters:6|BasicLands:0
|
MRD: 6 Boosters
|
||||||
Set:DST|LandSet:MRD|Boosters:6|BasicLands:0
|
DST: 6 Boosters
|
||||||
Set:5DN|LandSet:MRD|Boosters:6|BasicLands:0
|
5DN: 6 Boosters
|
||||||
Set:CHK|LandSet:CHK|Boosters:6|BasicLands:0
|
CHK: 6 Boosters
|
||||||
Set:BOK|LandSet:CHK|Boosters:6|BasicLands:0
|
BOK: 6 Boosters
|
||||||
Set:SOK|LandSet:CHK|Boosters:6|BasicLands:0
|
SOK: 6 Boosters
|
||||||
Set:9ED|LandSet:9ED|Boosters:6|BasicLands:40
|
9ED: 6 Boosters, 40 BasicLands
|
||||||
Set:RAV|LandSet:RAV|Boosters:6|BasicLands:40
|
RAV: 6 Boosters, 40 BasicLands
|
||||||
Set:GPT|LandSet:RAV|Boosters:6|BasicLands:40
|
GPT: 6 Boosters, 40 BasicLands RAV
|
||||||
Set:DIS|LandSet:RAV|Boosters:6|BasicLands:40
|
DIS: 6 Boosters, 40 BasicLands RAV
|
||||||
Set:CSP|LandSet:CSP|Boosters:6|BasicLands:40
|
CSP: 6 Boosters, 40 BasicLands
|
||||||
Set:TSP|LandSet:TSP|Boosters:6|BasicLands:40
|
TSP: 6 Boosters, 40 BasicLands
|
||||||
Set:PLC|LandSet:TSP|Boosters:6|BasicLands:40
|
PLC: 6 Boosters, 40 BasicLands TSP
|
||||||
Set:FUT|LandSet:TSP|Boosters:6|BasicLands:40
|
FUT: 6 Boosters, 40 BasicLands TSP
|
||||||
Set:10E|LandSet:10E|Boosters:6|BasicLands:40
|
10E: 6 Boosters, 40 BasicLands
|
||||||
Set:LRW|LandSet:LRW|Boosters:6|BasicLands:40
|
LRW: 6 Boosters, 40 BasicLands
|
||||||
Set:MOR|LandSet:LRW|Boosters:6|BasicLands:40
|
MOR: 6 Boosters, 40 BasicLands LRW
|
||||||
Set:SHM|LandSet:SHM|Boosters:8|BasicLands:40
|
SHM: 8 Boosters, 40 BasicLands
|
||||||
Set:EVE|LandSet:SHM|Boosters:8|BasicLands:40
|
EVE: 8 Boosters, 40 BasicLands SHM
|
||||||
Set:ALA|LandSet:ALA|Boosters:8|BasicLands:40
|
ALA: 8 Boosters, 40 BasicLands
|
||||||
Set:CFX|LandSet:ALA|Boosters:8|BasicLands:40
|
CFX: 8 Boosters, 40 BasicLands ALA
|
||||||
Set:ARB|LandSet:ALA|Boosters:8|BasicLands:40
|
ARB: 8 Boosters, 40 BasicLands ALA
|
||||||
Set:M10|LandSet:M10|Boosters:8|BasicLands:40
|
M10: 8 Boosters, 40 BasicLands
|
||||||
Set:ZEN|LandSet:ZEN|Boosters:8|BasicLands:40
|
ZEN: 8 Boosters, 40 BasicLands
|
||||||
Set:WWK|LandSet:ZEN|Boosters:8|BasicLands:40
|
WWK: 8 Boosters, 40 BasicLands ZEN
|
||||||
Set:ROE|LandSet:ROE|Boosters:8|BasicLands:40
|
ROE: 8 Boosters, 40 BasicLands
|
||||||
Set:M11|LandSet:M11|Boosters:8|BasicLands:40
|
M11: 8 Boosters, 40 BasicLands
|
||||||
Set:SOM|LandSet:SOM|Boosters:8|BasicLands:40
|
SOM: 8 Boosters, 40 BasicLands
|
||||||
Set:MBS|LandSet:MBS|Boosters:9|BasicLands:80
|
MBS: 9 Boosters, 80 BasicLands MBS
|
||||||
Set:NPH|LandSet:NPH|Boosters:9|BasicLands:80
|
NPH: 9 Boosters, 80 BasicLands NPH
|
||||||
Set:M12|LandSet:M12|Boosters:9|BasicLands:80
|
M12: 9 Boosters, 80 BasicLands
|
||||||
Set:ISD|LandSet:ISD|Boosters:9|BasicLands:70
|
ISD: 9 Boosters, 70 BasicLands
|
||||||
Set:DKA|LandSet:ISD|Boosters:9|BasicLands:70
|
DKA: 9 Boosters, 70 BasicLands ISD
|
||||||
Set:AVR|LandSet:AVR|Boosters:9|BasicLands:80
|
AVR: 9 Boosters, 80 BasicLands
|
||||||
Set:M13|LandSet:M13|Boosters:9|BasicLands:80
|
M13: 9 Boosters, 80 BasicLands
|
||||||
Set:RTR|LandSet:RTR|Boosters:9|BasicLands:80
|
RTR: 9 Boosters, 80 BasicLands
|
||||||
Set:GTC|LandSet:RTR|Boosters:9|BasicLands:80
|
GTC: 9 Boosters, 80 BasicLands RTR
|
||||||
|
DGM: 9 Boosters, 80 BasicLands RTR
|
||||||
@@ -95,4 +95,6 @@ Code2:GTC|Code3:GTC|Type:Expansion|Name:Gatecrash
|
|||||||
|
|
||||||
Code2:VAN|Code3:VAN|Type:Other|Name:Vanguard
|
Code2:VAN|Code3:VAN|Type:Other|Name:Vanguard
|
||||||
Code2:ARC|Code3:ARC|Type:Other|Name:Archenemy
|
Code2:ARC|Code3:ARC|Type:Other|Name:Archenemy
|
||||||
|
Code2:DDC|Code3:DDC|Type:Other|Name:Divine vs. Demonic
|
||||||
|
Code2:PD2|Code3:PD2|Type:Other|Name:Fire and Lightning
|
||||||
|
Code2:EVG|Code3:EVG|Type:Other|Name:Elves vs. Goblins
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
Set:LEA|Commons:23|Uncommons:13|Rares:2|BasicLands:22
|
LEA: 23 Common, 13 Uncommon, 2 Rare, 22 BasicLand
|
||||||
Set:LEB|Commons:23|Uncommons:13|Rares:2|BasicLands:22
|
LEB: 23 Common, 13 Uncommon, 2 Rare, 22 BasicLand
|
||||||
Set:2ED|Commons:23|Uncommons:13|Rares:2|BasicLands:22
|
2ED: 23 Common, 13 Uncommon, 2 Rare, 22 BasicLand
|
||||||
Set:3ED|Commons:23|Uncommons:13|Rares:2|BasicLands:22
|
3ED: 23 Common, 13 Uncommon, 2 Rare, 22 BasicLand
|
||||||
Set:4ED|Commons:26|Uncommons:9|Rares:3|BasicLands:22
|
4ED: 26 Common, 9 Uncommon, 3 Rare, 22 BasicLand
|
||||||
Set:ICE|Commons:26|Uncommons:9|Rares:3|BasicLands:22
|
ICE: 26 Common, 9 Uncommon, 3 Rare, 22 BasicLand
|
||||||
Set:5ED|Commons:26|Uncommons:9|Rares:3|BasicLands:22
|
5ED: 26 Common, 9 Uncommon, 3 Rare, 22 BasicLand
|
||||||
Set:MIR|Commons:25|Uncommons:10|Rares:3|BasicLands:22
|
MIR: 25 Common, 10 Uncommon, 3 Rare, 22 BasicLand
|
||||||
Set:TMP|Commons:25|Uncommons:10|Rares:3|BasicLands:22
|
TMP: 25 Common, 10 Uncommon, 3 Rare, 22 BasicLand
|
||||||
Set:USG|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
USG: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:6ED|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
6ED: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:MMQ|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
MMQ: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:INV|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
INV: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:ODY|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
ODY: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:ONS|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
ONS: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:MRD|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
MRD: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:CHK|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
CHK: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:RAV|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
RAV: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:TSP|Commons:29|Uncommons:10|Rares:3|BasicLands:30|Special:3
|
TSP: 29 Common, 10 Uncommon, 3 Rare, 3 Special, 30 BasicLand
|
||||||
Set:LRW|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
LRW: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:SHM|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
SHM: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
Set:ALA|Commons:32|Uncommons:10|Rares:3|BasicLands:30
|
ALA: 32 Common, 10 Uncommon, 3 Rare, 30 BasicLand
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
package forge.card;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
|
|
||||||
import forge.item.CardPrinted;
|
|
||||||
import forge.item.IPaperCard;
|
|
||||||
import forge.util.FileSection;
|
|
||||||
import forge.util.storage.StorageReaderFile;
|
|
||||||
|
|
||||||
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 foilRate;
|
|
||||||
private final int artIndices;
|
|
||||||
private static final int CARDS_PER_BOOSTER = 15;
|
|
||||||
|
|
||||||
public BoosterData(String edition, String editionLand, int nC, int nU, int nR, int nS, int nDF, int artIndices) {
|
|
||||||
// if this booster has more that 10 cards, there must be a land in
|
|
||||||
// 15th slot unless it's already taken
|
|
||||||
this(edition, editionLand, nC, nU, nR, nS, nDF, artIndices,
|
|
||||||
(nC + nR + nU + nS + nDF) > 10 ? BoosterData.CARDS_PER_BOOSTER - nC - nR - nU - nS - nDF : 0, 68);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoosterData(String edition, String editionLand, int nC, int nU, int nR, int nS, int nDF, int artIndices0, int nL, int oneFoilPer) {
|
|
||||||
super(edition, editionLand, nL > 0 ? nL : 0);
|
|
||||||
this.nCommon = nC;
|
|
||||||
this.nUncommon = nU;
|
|
||||||
this.nRare = nR;
|
|
||||||
this.nSpecial = nS;
|
|
||||||
this.nDoubleFaced = nDF;
|
|
||||||
this.foilRate = oneFoilPer;
|
|
||||||
artIndices = artIndices0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Predicate<CardPrinted> getEditionFilter() {
|
|
||||||
return IPaperCard.Predicates.printedInSets(getEdition());
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Predicate<CardPrinted> getLandEditionFilter() {
|
|
||||||
return IPaperCard.Predicates.printedInSets(getLandEdition());
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getCommon() {
|
|
||||||
return this.nCommon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getUncommon() {
|
|
||||||
return this.nUncommon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getRare() {
|
|
||||||
return this.nRare;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getSpecial() {
|
|
||||||
return this.nSpecial;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getDoubleFaced() {
|
|
||||||
return this.nDoubleFaced;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getTotal() {
|
|
||||||
return this.nCommon + this.nUncommon + this.nRare + this.nSpecial + this.nDoubleFaced + getCntLands();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getFoilChance() {
|
|
||||||
return this.foilRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getArtIndices() {
|
|
||||||
return artIndices;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BoosterData read(String line, int i) {
|
|
||||||
final FileSection section = FileSection.parse(line, ":", "|");
|
|
||||||
int nC = section.getInt("Commons", 0);
|
|
||||||
int nU = section.getInt("Uncommons", 0);
|
|
||||||
int nR = section.getInt("Rares", 0);
|
|
||||||
int nS = section.getInt("Special", 0);
|
|
||||||
int nDf = section.getInt("DoubleFaced", 0);
|
|
||||||
int artIndices = section.getInt("Images", 1);
|
|
||||||
int nLand = section.getInt("BasicLands", 0);
|
|
||||||
int nFoilRate = section.getInt("FoilRate", 68);
|
|
||||||
String edition = section.get("Set");
|
|
||||||
String editionLand = section.get("LandSet");
|
|
||||||
if (editionLand == null) {
|
|
||||||
editionLand = edition;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BoosterData(edition, editionLand, nC, nU, nR, nS, nDf, artIndices, nLand, nFoilRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,20 +18,24 @@
|
|||||||
package forge.card;
|
package forge.card;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.HashMap;
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.IPaperCard;
|
||||||
import forge.util.MyRandom;
|
import forge.item.PrintSheet;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -42,272 +46,147 @@ import forge.util.MyRandom;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class BoosterGenerator {
|
public class BoosterGenerator {
|
||||||
private static final int BOOSTERS_TO_FIND_MYTHIC = 8;
|
private final static Map<String, PrintSheet> cachedSheets = new HashMap<String, PrintSheet>();
|
||||||
|
private static final synchronized PrintSheet getPrintSheet(String key) {
|
||||||
// Function to open a booster as it is.
|
if( !cachedSheets.containsKey(key) )
|
||||||
/** The Constant IDENTITY_PICK. */
|
cachedSheets.put(key, makeSheet(key, CardDb.instance().getAllCards()));
|
||||||
public static final Function<BoosterGenerator, List<CardPrinted>> IDENTITY_PICK = new Function<BoosterGenerator, List<CardPrinted>>() {
|
return cachedSheets.get(key);
|
||||||
@Override
|
|
||||||
public List<CardPrinted> apply(final BoosterGenerator arg1) {
|
|
||||||
return arg1.getBoosterPack(10, 3, 1, 0, 0, 0, 0, 0, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// These lists are to hold cards grouped by rarity in advance.
|
|
||||||
|
|
||||||
private final List<CardPrinted> allButLands = new ArrayList<CardPrinted>();
|
|
||||||
|
|
||||||
private final Map<CardRarity, List<CardPrinted>> cardsByRarity = new EnumMap<CardRarity, List<CardPrinted>>(CardRarity.class);
|
|
||||||
private final Map<CardRarity, List<CardPrinted>> twoFacedByRarity = new EnumMap<CardRarity, List<CardPrinted>>(CardRarity.class);
|
|
||||||
private final Map<CardRarity, List<CardPrinted>> singleFacedByRarity = new EnumMap<CardRarity, List<CardPrinted>>(CardRarity.class);
|
|
||||||
|
|
||||||
// private List<CardPrinted> commonCreatures;
|
|
||||||
// private List<CardPrinted> commonNonCreatures;
|
|
||||||
|
|
||||||
private static final List<CardPrinted> EMPTY_LIST = Collections.unmodifiableList(new ArrayList<CardPrinted>(0));
|
|
||||||
|
|
||||||
private BoosterGenerator() {
|
|
||||||
for (CardRarity v : CardRarity.values()) {
|
|
||||||
twoFacedByRarity.put(v, new ArrayList<CardPrinted>());
|
|
||||||
singleFacedByRarity.put(v, new ArrayList<CardPrinted>());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeAllFacedCards() {
|
public static final List<CardPrinted> getBoosterPack(SealedProductTemplate booster) {
|
||||||
for (CardRarity v : CardRarity.values()) {
|
List<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||||
List<CardPrinted> cp = new ArrayList<CardPrinted>(singleFacedByRarity.get(v));
|
for(Pair<String, Integer> slot : booster.getSlots()) {
|
||||||
cp.addAll(twoFacedByRarity.get(v));
|
String slotType = slot.getLeft(); // add expansion symbol here?
|
||||||
cardsByRarity.put(v, cp);
|
int numCards = slot.getRight().intValue();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
String[] sType = TextUtil.splitWithParenthesis(slotType, ' ', '(', ')');
|
||||||
* <p>
|
String sheetKey = sType.length == 1 ? slotType.trim() + " " + booster.getEdition() : slotType.trim();
|
||||||
* Constructor for BoosterGenerator.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param cards
|
|
||||||
* the cards
|
|
||||||
*/
|
|
||||||
public BoosterGenerator(final Iterable<CardPrinted> cards) {
|
|
||||||
this();
|
|
||||||
for (final CardPrinted c : cards) {
|
|
||||||
this.addToRarity(c);
|
|
||||||
}
|
|
||||||
mergeAllFacedCards();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
PrintSheet ps = getPrintSheet(sheetKey);
|
||||||
* Instantiates a new booster generator.
|
result.addAll(ps.random(numCards, true));
|
||||||
*
|
|
||||||
* @param dPool
|
|
||||||
* the d pool
|
|
||||||
*/
|
|
||||||
public BoosterGenerator(final ItemPoolView<CardPrinted> dPool) {
|
|
||||||
this();
|
|
||||||
for (final Entry<CardPrinted, Integer> e : dPool) {
|
|
||||||
this.addToRarity(e.getKey());
|
|
||||||
}
|
|
||||||
mergeAllFacedCards();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for BoosterGenerator.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param filter
|
|
||||||
* the card set
|
|
||||||
*/
|
|
||||||
public BoosterGenerator(Predicate<CardPrinted> filter) {
|
|
||||||
this();
|
|
||||||
|
|
||||||
for (final CardPrinted c : Iterables.filter(CardDb.instance().getAllCards(), filter)) {
|
|
||||||
this.addToRarity(c);
|
|
||||||
// System.out.println(c);
|
|
||||||
}
|
|
||||||
mergeAllFacedCards();
|
|
||||||
// System.out.println("done");
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<CardPrinted> pickRandomCards(final List<CardPrinted> source, final int count) {
|
|
||||||
return this.pickRandomCards(source, count, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<CardPrinted> pickRandomCards(final List<CardPrinted> source, final int count, final boolean singleton) {
|
|
||||||
int listSize = source == null ? 0 : source.size();
|
|
||||||
if ((count <= 0) || (listSize == 0)) {
|
|
||||||
return BoosterGenerator.EMPTY_LIST;
|
|
||||||
}
|
|
||||||
final List<CardPrinted> result = new ArrayList<CardPrinted>(count);
|
|
||||||
|
|
||||||
int index = Integer.MAX_VALUE;
|
|
||||||
for (int iCard = 0; iCard < count; iCard++) {
|
|
||||||
if (index >= listSize) {
|
|
||||||
Collections.shuffle(source, MyRandom.getRandom());
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
result.add(source.get(index));
|
|
||||||
|
|
||||||
if (!singleton) {
|
|
||||||
index++;
|
|
||||||
} else {
|
|
||||||
source.remove(index);
|
|
||||||
listSize--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CardPrinted> pickRandomRaresOrMythics(final List<CardPrinted> rares, final List<CardPrinted> mythics,
|
// If they request cards from an arbitrary pool, there's no use to cache printsheets.
|
||||||
final int count) {
|
public static final List<CardPrinted> getBoosterPack(SealedProductTemplate booster, Iterable<CardPrinted> sourcePool) {
|
||||||
final int raresSize = rares == null ? 0 : rares.size();
|
if(sourcePool == CardDb.instance().getAllCards())
|
||||||
final int mythicsSize = mythics == null ? 0 : mythics.size();
|
throw new IllegalArgumentException("Do not use this overload to obtain boosters based on complete cardDb");
|
||||||
if ((count <= 0) || (raresSize == 0)) {
|
|
||||||
return BoosterGenerator.EMPTY_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<CardPrinted> result = new ArrayList<CardPrinted>(count);
|
List<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||||
|
for(Pair<String, Integer> slot : booster.getSlots()) {
|
||||||
|
String slotType = slot.getLeft(); // add expansion symbol here?
|
||||||
|
int numCards = slot.getRight().intValue();
|
||||||
|
|
||||||
int indexRares = Integer.MAX_VALUE;
|
String[] sType = TextUtil.splitWithParenthesis(slotType, ' ', '(', ')');
|
||||||
int indexMythics = Integer.MAX_VALUE;
|
String sheetKey = sType.length == 1 ? slotType.trim() + " " + booster.getEdition() : slotType.trim();
|
||||||
for (int iCard = 0; iCard < count; iCard++) {
|
|
||||||
final int rollD8 = MyRandom.getRandom().nextInt(BOOSTERS_TO_FIND_MYTHIC);
|
PrintSheet ps = makeSheet(sheetKey, sourcePool);
|
||||||
final boolean takeMythic = (mythicsSize > 0) && (rollD8 < 1);
|
result.addAll(ps.random(numCards, true));
|
||||||
if (takeMythic) {
|
|
||||||
if (indexMythics >= mythicsSize) {
|
|
||||||
Collections.shuffle(mythics, MyRandom.getRandom());
|
|
||||||
indexMythics = 0;
|
|
||||||
}
|
|
||||||
result.add(mythics.get(indexMythics));
|
|
||||||
indexMythics++;
|
|
||||||
} else {
|
|
||||||
if (indexRares >= raresSize) {
|
|
||||||
Collections.shuffle(rares, MyRandom.getRandom());
|
|
||||||
indexRares = 0;
|
|
||||||
}
|
|
||||||
result.add(rares.get(indexRares));
|
|
||||||
indexRares++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@SuppressWarnings("unchecked")
|
||||||
* Gets the singleton booster pack.
|
private static final PrintSheet makeSheet(String sheetKey, Iterable<CardPrinted> src) {
|
||||||
* Singleton means that every card in every booster in whole draft is unique!
|
PrintSheet ps = new PrintSheet();
|
||||||
* First arg in pickRandomCards can't be copy, because picker must remove card from pool to ensure uniqueness.
|
String[] sKey = TextUtil.splitWithParenthesis(sheetKey, ' ', '(', ')', 2);
|
||||||
*
|
|
||||||
* @param nAnyCard
|
|
||||||
* the n any card
|
|
||||||
* @return the singleton booster pack
|
|
||||||
*/
|
|
||||||
public final List<CardPrinted> getSingletonBoosterPack(final int nAnyCard) {
|
|
||||||
return this.pickRandomCards(allButLands, nAnyCard, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
String[] operators = TextUtil.splitWithParenthesis(sKey[0], ':', '(', ')');
|
||||||
* Gets the booster pack.
|
Predicate<CardPrinted> extraPred = buildExtraPredicate(operators);
|
||||||
*
|
String mainCode = operators[0].trim();
|
||||||
* @return the booster pack
|
if(mainCode.endsWith("s"))
|
||||||
*/
|
mainCode = mainCode.substring(0, mainCode.length()-1);
|
||||||
public final List<CardPrinted> getBoosterPack(BoosterData booster) {
|
|
||||||
return this.getBoosterPack(booster.getCommon(), booster.getUncommon(), booster.getRare(), 0, 0, booster.getSpecial(),
|
|
||||||
booster.getDoubleFaced(), 0, booster.getCntLands());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
String sets = sKey[1];
|
||||||
* Gets the booster pack.
|
Predicate<CardPrinted> setPred = IPaperCard.Predicates.printedInSets(sets.split(" "));
|
||||||
*
|
|
||||||
* @param numbers the numbers
|
|
||||||
* @param nRareSlots the n rare slots
|
|
||||||
* @param nDoubls the n doubls
|
|
||||||
* @param nAnyCard the n any card
|
|
||||||
* @return the booster pack
|
|
||||||
*/
|
|
||||||
public final List<CardPrinted> getBoosterPack(final Map<CardRarity, Integer> numbers,
|
|
||||||
final int nRareSlots, final int nDoubls, final int nAnyCard) {
|
|
||||||
return getBoosterPack(numbers.get(CardRarity.Common), numbers.get(CardRarity.Uncommon), nRareSlots,
|
|
||||||
numbers.get(CardRarity.Rare), numbers.get(CardRarity.MythicRare), numbers.get(CardRarity.Special),
|
|
||||||
nDoubls, nAnyCard, numbers.get(CardRarity.BasicLand));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Pre-defined sheets:
|
||||||
|
if( mainCode.equalsIgnoreCase("any") ) {
|
||||||
|
Predicate<CardPrinted> predicate = Predicates.and(setPred, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicate));
|
||||||
|
|
||||||
/**
|
} else if( mainCode.equalsIgnoreCase("common") ) {
|
||||||
* So many parameters are needed for custom limited cardpools,.
|
Predicate<CardPrinted> predicate = Predicates.and(setPred, IPaperCard.Predicates.Presets.IS_COMMON, extraPred);
|
||||||
*
|
ps.addAll(Iterables.filter(src, predicate));
|
||||||
* @param nCom
|
|
||||||
* the n com
|
|
||||||
* @param nUnc
|
|
||||||
* the n unc
|
|
||||||
* @param nRareSlots
|
|
||||||
* the n rare slots
|
|
||||||
* @param nRares
|
|
||||||
* the n rares
|
|
||||||
* @param nMythics
|
|
||||||
* the n mythics
|
|
||||||
* @param nSpecs
|
|
||||||
* the n specs
|
|
||||||
* @param nDoubls
|
|
||||||
* the n doubls
|
|
||||||
* @param nAnyCard
|
|
||||||
* the n any card
|
|
||||||
* @param nLands
|
|
||||||
* the n lands
|
|
||||||
* @return the booster pack
|
|
||||||
*/
|
|
||||||
public final List<CardPrinted> getBoosterPack(final int nCom, final int nUnc, final int nRareSlots,
|
|
||||||
final int nRares, final int nMythics, final int nSpecs, final int nDoubls, final int nAnyCard,
|
|
||||||
final int nLands) {
|
|
||||||
|
|
||||||
final List<CardPrinted> temp = new ArrayList<CardPrinted>();
|
} else if ( mainCode.equalsIgnoreCase("uncommon") ) {
|
||||||
final Map<CardRarity, List<CardPrinted>> commonCardsMap = nDoubls != 0 ? singleFacedByRarity : cardsByRarity;
|
Predicate<CardPrinted> predicate = Predicates.and(setPred, IPaperCard.Predicates.Presets.IS_UNCOMMON, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicate));
|
||||||
|
|
||||||
temp.addAll(this.pickRandomCards(commonCardsMap.get(CardRarity.Common), nCom));
|
} else if ( mainCode.equalsIgnoreCase("uncommonrare") ) { // for sets like ARN, where U1 cards are considered rare and U3 are uncommon
|
||||||
temp.addAll(this.pickRandomCards(commonCardsMap.get(CardRarity.Uncommon), nUnc));
|
|
||||||
|
Predicate<CardPrinted> predicateRares = Predicates.and(setPred, IPaperCard.Predicates.Presets.IS_RARE, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicateRares));
|
||||||
|
|
||||||
|
Predicate<CardPrinted> predicateUncommon = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_UNCOMMON, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicateUncommon), 3);
|
||||||
|
|
||||||
|
} else if ( mainCode.equalsIgnoreCase("rare") ) {
|
||||||
|
Predicate<CardPrinted> predicateMythic = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_MYTHIC_RARE, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicateMythic));
|
||||||
|
|
||||||
|
Predicate<CardPrinted> predicateRare = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_RARE, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicateRare), 2);
|
||||||
|
|
||||||
|
} else if ( mainCode.equalsIgnoreCase("rarenotmythic") ) {
|
||||||
|
Predicate<CardPrinted> predicateRare = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_RARE, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicateRare));
|
||||||
|
|
||||||
|
} else if ( mainCode.equalsIgnoreCase("mythic") ) {
|
||||||
|
Predicate<CardPrinted> predicateMythic = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_MYTHIC_RARE, extraPred);
|
||||||
|
ps.addAll(Iterables.filter(src, predicateMythic));
|
||||||
|
|
||||||
|
} else if ( mainCode.equalsIgnoreCase("basicland") ) {
|
||||||
|
Predicate<CardPrinted> predicateLand = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_BASIC_LAND, extraPred );
|
||||||
|
ps.addAll(Iterables.filter(src, predicateLand));
|
||||||
|
|
||||||
|
} else if ( mainCode.equalsIgnoreCase("timeshifted") ) {
|
||||||
|
Predicate<CardPrinted> predicate = Predicates.and( setPred, IPaperCard.Predicates.Presets.IS_SPECIAL, extraPred );
|
||||||
|
ps.addAll(Iterables.filter(src, predicate));
|
||||||
|
|
||||||
|
} else if ( mainCode.equalsIgnoreCase("mazeland") ) {
|
||||||
|
|
||||||
if (nRareSlots > 0) {
|
|
||||||
temp.addAll(this.pickRandomRaresOrMythics(commonCardsMap.get(CardRarity.Rare),
|
|
||||||
cardsByRarity.get(CardRarity.MythicRare), nRareSlots));
|
|
||||||
}
|
}
|
||||||
if ((nRares > 0) || (nMythics > 0)) {
|
return ps;
|
||||||
if (nMythics == 0) {
|
}
|
||||||
temp.addAll(this.pickRandomRaresOrMythics(commonCardsMap.get(CardRarity.Rare),
|
|
||||||
cardsByRarity.get(CardRarity.MythicRare), nRares));
|
/**
|
||||||
} else {
|
* TODO: Write javadoc for this method.
|
||||||
temp.addAll(this.pickRandomCards(commonCardsMap.get(CardRarity.Rare), nRares));
|
* @param operators
|
||||||
temp.addAll(this.pickRandomCards(commonCardsMap.get(CardRarity.MythicRare), nMythics));
|
* @return
|
||||||
}
|
*/
|
||||||
}
|
private static Predicate<CardPrinted> buildExtraPredicate(String[] operators) {
|
||||||
if (nDoubls > 0) {
|
if ( operators.length == 0)
|
||||||
final int dblFacedRarity = MyRandom.getRandom().nextInt(nCom + nUnc + nRareSlots);
|
return Predicates.alwaysTrue();
|
||||||
CardRarity rarityInSlot = CardRarity.MythicRare;
|
|
||||||
if (dblFacedRarity < nCom) {
|
List<Predicate<CardPrinted>> conditions = new ArrayList<Predicate<CardPrinted>>();
|
||||||
rarityInSlot = CardRarity.Common;
|
for(int i = 1; i < operators.length; i++) {
|
||||||
} else if (dblFacedRarity < nCom + nUnc) {
|
String operator = operators[i];
|
||||||
rarityInSlot = CardRarity.Uncommon;
|
if(StringUtils.isEmpty(operator))
|
||||||
} else if (MyRandom.getRandom().nextInt(BOOSTERS_TO_FIND_MYTHIC) != 0) {
|
continue;
|
||||||
rarityInSlot = CardRarity.Rare;
|
|
||||||
|
boolean invert = operator.charAt(0) == '!';
|
||||||
|
if( invert ) operator = operator.substring(1);
|
||||||
|
|
||||||
|
Predicate<CardPrinted> toAdd = null;
|
||||||
|
if( operator.equals("dfc") ) {
|
||||||
|
toAdd = Predicates.compose(CardRulesPredicates.splitType(CardSplitType.Transform), CardPrinted.FN_GET_RULES);
|
||||||
|
} else if ( operator.startsWith("name(") ) {
|
||||||
|
operator = StringUtils.strip(operator.substring(4), "() ");
|
||||||
|
String[] cardNames = TextUtil.splitWithParenthesis(operator, ',', '"', '"');
|
||||||
|
toAdd = IPaperCard.Predicates.names(Lists.newArrayList(cardNames));
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.addAll(this.pickRandomCards(twoFacedByRarity.get(rarityInSlot), nDoubls));
|
if(toAdd == null)
|
||||||
|
throw new IllegalArgumentException("Booster generator: operator could not be parsed - " + operator);
|
||||||
|
|
||||||
|
if( invert )
|
||||||
|
toAdd = Predicates.not(toAdd);
|
||||||
|
conditions.add(toAdd);
|
||||||
}
|
}
|
||||||
|
return Predicates.and(conditions);
|
||||||
temp.addAll(this.pickRandomCards(commonCardsMap.get(CardRarity.Special), nSpecs));
|
|
||||||
temp.addAll(this.pickRandomCards(this.allButLands, nAnyCard));
|
|
||||||
temp.addAll(this.pickRandomCards(commonCardsMap.get(CardRarity.BasicLand), nLands));
|
|
||||||
|
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToRarity(final CardPrinted c) {
|
|
||||||
|
|
||||||
Map<CardRarity, List<CardPrinted>> targetList = c.getRules().getSplitType() == CardSplitType.Transform ? twoFacedByRarity : singleFacedByRarity;
|
|
||||||
targetList.get(c.getRarity()).add(c);
|
|
||||||
|
|
||||||
if (!c.getRules().getType().isBasicLand()) {
|
|
||||||
this.allButLands.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
101
src/main/java/forge/card/BoosterTemplate.java
Normal file
101
src/main/java/forge/card/BoosterTemplate.java
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package forge.card;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
import forge.util.storage.StorageReaderFile;
|
||||||
|
|
||||||
|
public class BoosterTemplate extends SealedProductTemplate {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public final static BoosterTemplate genericBooster = new BoosterTemplate(null, 1, Lists.newArrayList(
|
||||||
|
Pair.of("Common", 10), Pair.of("Uncommon", 3), Pair.of("Rare", 1), Pair.of("BasicLand", 1)
|
||||||
|
));
|
||||||
|
|
||||||
|
private final int foilRate = 68;
|
||||||
|
private final int artIndices;
|
||||||
|
private final String edition;
|
||||||
|
|
||||||
|
private BoosterTemplate(String edition0, int artIndices0, Iterable<Pair<String, Integer>> itrSlots) {
|
||||||
|
super(itrSlots);
|
||||||
|
this.edition = edition0;
|
||||||
|
artIndices = artIndices0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getFoilChance() {
|
||||||
|
return this.foilRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getArtIndices() {
|
||||||
|
return artIndices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String getEdition() { return edition; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
|
s.append("consisting of ");
|
||||||
|
for(Pair<String, Integer> p : slots) {
|
||||||
|
s.append(p.getRight()).append(" ").append(p.getLeft()).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 Function<? super BoosterTemplate, String> FN_GET_CODE = new Function<BoosterTemplate, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(BoosterTemplate arg1) {
|
||||||
|
return arg1.edition;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public static final class Reader extends StorageReaderFile<BoosterTemplate> {
|
||||||
|
public Reader(String pathname) {
|
||||||
|
super(pathname, BoosterTemplate.FN_GET_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BoosterTemplate read(String line, int i) {
|
||||||
|
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||||
|
final String edition = headAndData[0];
|
||||||
|
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',', '(', ')');
|
||||||
|
int nCovers = 1;
|
||||||
|
|
||||||
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
|
for(String slotDesc : data) {
|
||||||
|
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', '(', ')', 2);
|
||||||
|
if (kv[1].startsWith("cover"))
|
||||||
|
nCovers = Integer.parseInt(kv[0]);
|
||||||
|
else
|
||||||
|
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BoosterTemplate(edition, nCovers, slots);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.IPaperCard;
|
import forge.item.IPaperCard;
|
||||||
import forge.util.storage.StorageReaderFile;
|
import forge.util.storage.StorageReaderFile;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.util.List;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.util.ComparableOp;
|
import forge.util.ComparableOp;
|
||||||
import forge.util.PredicateString;
|
import forge.util.PredicateString;
|
||||||
|
|
||||||
@@ -98,6 +97,15 @@ public final class CardRulesPredicates {
|
|||||||
return new LeafString(LeafString.CardField.NAME, op, what);
|
return new LeafString(LeafString.CardField.NAME, op, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param transform
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Predicate<CardRules> splitType(CardSplitType transform) {
|
||||||
|
return new PredicateSplitType(transform);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub type.
|
* Sub type.
|
||||||
*
|
*
|
||||||
@@ -447,6 +455,19 @@ public final class CardRulesPredicates {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PredicateSplitType implements Predicate<CardRules> {
|
||||||
|
private final CardSplitType cst;
|
||||||
|
|
||||||
|
public PredicateSplitType(final CardSplitType type) {
|
||||||
|
cst = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(final CardRules subject) {
|
||||||
|
return subject.getSplitType() == cst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class Presets.
|
* The Class Presets.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
package forge.card;
|
|
||||||
|
|
||||||
import forge.util.FileSection;
|
|
||||||
import forge.util.storage.StorageReaderFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FatPackData extends PackData {
|
|
||||||
private final int cntBoosters;
|
|
||||||
public int getCntBoosters() {
|
|
||||||
return cntBoosters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FatPackData(String edition0, String landEdition0, int nBoosters, int nBasicLands)
|
|
||||||
{
|
|
||||||
super(edition0, landEdition0, nBasicLands);
|
|
||||||
cntBoosters = nBoosters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class Reader extends StorageReaderFile<FatPackData> {
|
|
||||||
public Reader(String pathname) {
|
|
||||||
super(pathname, PackData.FN_GET_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected FatPackData read(String line, int i) {
|
|
||||||
final FileSection section = FileSection.parse(line, ":", "|");
|
|
||||||
int nBoosters = section.getInt("Boosters", 0);
|
|
||||||
int nLand = section.getInt("BasicLands", 0);
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
85
src/main/java/forge/card/FatPackTemplate.java
Normal file
85
src/main/java/forge/card/FatPackTemplate.java
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
package forge.card;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
import forge.util.storage.StorageReaderFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FatPackTemplate extends SealedProductTemplate {
|
||||||
|
private final int cntBoosters;
|
||||||
|
private final String edition;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEdition() { return edition; }
|
||||||
|
public int getCntBoosters() { return cntBoosters; }
|
||||||
|
|
||||||
|
public static final Function<? super FatPackTemplate, String> FN_GET_CODE = new Function<FatPackTemplate, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(FatPackTemplate arg1) {
|
||||||
|
return arg1.edition;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private FatPackTemplate(String edition0, int boosters, Iterable<Pair<String, Integer>> itrSlots)
|
||||||
|
{
|
||||||
|
super(itrSlots);
|
||||||
|
edition = edition0;
|
||||||
|
cntBoosters = boosters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Reader extends StorageReaderFile<FatPackTemplate> {
|
||||||
|
public Reader(String pathname) {
|
||||||
|
super(pathname, FatPackTemplate.FN_GET_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected FatPackTemplate read(String line, int i) {
|
||||||
|
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||||
|
final String edition = headAndData[0];
|
||||||
|
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',', '(', ')');
|
||||||
|
int nBoosters = 6;
|
||||||
|
|
||||||
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
|
for(String slotDesc : data) {
|
||||||
|
String[] kv = TextUtil.split(slotDesc, ' ', 2);
|
||||||
|
if (kv[1].startsWith("Booster"))
|
||||||
|
nBoosters = Integer.parseInt(kv[0]);
|
||||||
|
else
|
||||||
|
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FatPackTemplate(edition, nBoosters, slots);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (0 >= cntBoosters) {
|
||||||
|
return "no cards";
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
for(Pair<String, Integer> p : slots) {
|
||||||
|
s.append(p.getRight()).append(" ").append(p.getLeft()).append(", ");
|
||||||
|
}
|
||||||
|
// trim the last comma and space
|
||||||
|
s.replace(s.length() - 2, s.length(), "");
|
||||||
|
|
||||||
|
s.append(" and ");
|
||||||
|
if (0 < cntBoosters) {
|
||||||
|
s.append(cntBoosters).append(" booster packs");
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,6 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.game.limited.CustomLimited;
|
import forge.game.limited.CustomLimited;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -189,8 +187,7 @@ public class MetaSet {
|
|||||||
final File dFolder = new File("res/sealed/");
|
final File dFolder = new File("res/sealed/");
|
||||||
|
|
||||||
if (!dFolder.exists()) {
|
if (!dFolder.exists()) {
|
||||||
throw new RuntimeException("GenerateSealed : folder not found -- folder is "
|
throw new RuntimeException("GenerateSealed : folder not found -- folder is " + dFolder.getAbsolutePath());
|
||||||
+ dFolder.getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dFolder.isDirectory()) {
|
if (!dFolder.isDirectory()) {
|
||||||
@@ -199,27 +196,12 @@ public class MetaSet {
|
|||||||
|
|
||||||
List<String> dfData = FileUtil.readFile("res/sealed/" + data + ".sealed");
|
List<String> dfData = FileUtil.readFile("res/sealed/" + data + ".sealed");
|
||||||
final CustomLimited myCube = CustomLimited.parse(dfData, Singletons.getModel().getDecks().getCubes());
|
final CustomLimited myCube = CustomLimited.parse(dfData, Singletons.getModel().getDecks().getCubes());
|
||||||
final BoosterGenerator bpCustom = new BoosterGenerator(myCube.getCardPool());
|
|
||||||
final Function<BoosterGenerator, List<CardPrinted>> fnPick = new Function<BoosterGenerator, List<CardPrinted>>() {
|
|
||||||
@Override
|
|
||||||
public List<CardPrinted> apply(final BoosterGenerator pack) {
|
|
||||||
if (myCube.getIgnoreRarity()) {
|
|
||||||
if (!myCube.getSingleton()) {
|
|
||||||
return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, myCube.getNumCards(), 0);
|
|
||||||
} else {
|
|
||||||
return pack.getSingletonBoosterPack(myCube.getNumCards());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pack.getBoosterPack(myCube.getNumbersByRarity(), 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
SealedProductTemplate fnPick = myCube.getIgnoreRarity() ? myCube.getSealedProductTemplate() : BoosterTemplate.genericBooster;
|
||||||
|
return new UnOpenedProduct(fnPick, myCube.getCardPool());
|
||||||
return new UnOpenedProduct(fnPick, bpCustom);
|
|
||||||
}
|
}
|
||||||
else if ("full".equalsIgnoreCase(type)) {
|
else if ("full".equalsIgnoreCase(type)) {
|
||||||
final BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getUniqueCards());
|
return new UnOpenedProduct(BoosterTemplate.genericBooster);
|
||||||
return new UnOpenedProduct(BoosterGenerator.IDENTITY_PICK, bpFull);
|
|
||||||
}
|
}
|
||||||
else if ("meta".equalsIgnoreCase(type)) {
|
else if ("meta".equalsIgnoreCase(type)) {
|
||||||
|
|
||||||
@@ -230,11 +212,9 @@ public class MetaSet {
|
|||||||
if (data.indexOf(aCard.getEdition()) > -1) {
|
if (data.indexOf(aCard.getEdition()) > -1) {
|
||||||
cardPool.add(aCard);
|
cardPool.add(aCard);
|
||||||
// System.out.println("Added card" + aCard.getName());
|
// System.out.println("Added card" + aCard.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new UnOpenedProduct(BoosterTemplate.genericBooster, cardPool);
|
||||||
final BoosterGenerator bpSets = new BoosterGenerator(cardPool);
|
|
||||||
return new UnOpenedProduct(BoosterGenerator.IDENTITY_PICK, bpSets);
|
|
||||||
} else if ("booster".equalsIgnoreCase(type)) {
|
} else if ("booster".equalsIgnoreCase(type)) {
|
||||||
return new UnOpenedProduct(Singletons.getModel().getBoosters().get(data));
|
return new UnOpenedProduct(Singletons.getModel().getBoosters().get(data));
|
||||||
} else if ("pack".equalsIgnoreCase(type)) {
|
} else if ("pack".equalsIgnoreCase(type)) {
|
||||||
@@ -244,8 +224,8 @@ public class MetaSet {
|
|||||||
} else if ("random1".equalsIgnoreCase(type)) {
|
} else if ("random1".equalsIgnoreCase(type)) {
|
||||||
return new UnOpenedMeta(data, false);
|
return new UnOpenedMeta(data, false);
|
||||||
} else if ("combo".equalsIgnoreCase(type)) {
|
} else if ("combo".equalsIgnoreCase(type)) {
|
||||||
final BoosterGenerator bpSets = new BoosterGenerator(buildPool(data));
|
final BoosterGenerator bpSets = new BoosterGenerator();
|
||||||
return new UnOpenedProduct(BoosterGenerator.IDENTITY_PICK, bpSets);
|
return new UnOpenedProduct(BoosterTemplate.genericBooster, buildPool(data));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new RuntimeException("Cannot initialize boosters for: " + type);
|
throw new RuntimeException("Cannot initialize boosters for: " + type);
|
||||||
|
|||||||
@@ -1,76 +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.card;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
|
|
||||||
public class PackData {
|
|
||||||
private final String edition;
|
|
||||||
private final String landEdition;
|
|
||||||
private final int cntLands;
|
|
||||||
|
|
||||||
public final String getEdition() {
|
|
||||||
return edition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getLandEdition() {
|
|
||||||
return landEdition == null ? edition : landEdition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCntLands() {
|
|
||||||
return cntLands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PackData(String edition0, String landEdition0, int nBasicLands)
|
|
||||||
{
|
|
||||||
if (null == edition0) { throw new NullArgumentException("edition0"); }
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
PackData other = (PackData)obj;
|
|
||||||
return edition.equals(other.edition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return edition.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
57
src/main/java/forge/card/SealedProductTemplate.java
Normal file
57
src/main/java/forge/card/SealedProductTemplate.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
public class SealedProductTemplate {
|
||||||
|
|
||||||
|
protected final List<Pair<String, Integer>> slots;
|
||||||
|
|
||||||
|
|
||||||
|
public String getEdition() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final List<Pair<String, Integer>> getSlots() {
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SealedProductTemplate(Iterable<Pair<String, Integer>> itrSlots)
|
||||||
|
{
|
||||||
|
slots = Lists.newArrayList(itrSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public SealedProductTemplate(int qty) {
|
||||||
|
this(Lists.newArrayList(Pair.of("any", qty)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotal() {
|
||||||
|
int sum = 0;
|
||||||
|
for(Pair<String, Integer> p : slots) {
|
||||||
|
sum += p.getRight().intValue();
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -100,7 +100,7 @@ public class UnOpenedMeta extends UnOpenedProduct {
|
|||||||
* @return List, list of cards.
|
* @return List, list of cards.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<CardPrinted> open() {
|
public List<CardPrinted> get() {
|
||||||
return this.open(true, null);
|
return this.open(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ public class UnOpenedMeta extends UnOpenedProduct {
|
|||||||
* known partialities for the AI.
|
* known partialities for the AI.
|
||||||
* @return List, list of cards.
|
* @return List, list of cards.
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public List<CardPrinted> open(final boolean isHuman, List<String> partialities) {
|
public List<CardPrinted> open(final boolean isHuman, List<String> partialities) {
|
||||||
|
|
||||||
if (metaSets.size() < 1) {
|
if (metaSets.size() < 1) {
|
||||||
@@ -132,7 +132,7 @@ public class UnOpenedMeta extends UnOpenedProduct {
|
|||||||
for (int i = 0; i < metaSets.size(); i++) {
|
for (int i = 0; i < metaSets.size(); i++) {
|
||||||
if (o.toString().equals(metaSets.get(i).getCode())) {
|
if (o.toString().equals(metaSets.get(i).getCode())) {
|
||||||
final UnOpenedProduct newBooster = metaSets.get(i).getBooster();
|
final UnOpenedProduct newBooster = metaSets.get(i).getBooster();
|
||||||
return newBooster.open();
|
return newBooster.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ public class UnOpenedMeta extends UnOpenedProduct {
|
|||||||
// System.out.println("AI chose " + metaSets.get(selected).getCode() + " because partiality not established or failed percentage test.");
|
// System.out.println("AI chose " + metaSets.get(selected).getCode() + " because partiality not established or failed percentage test.");
|
||||||
}
|
}
|
||||||
final UnOpenedProduct newBooster = metaSets.get(selected).getBooster();
|
final UnOpenedProduct newBooster = metaSets.get(selected).getBooster();
|
||||||
return newBooster.open();
|
return newBooster.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -183,7 +183,7 @@ public class UnOpenedMeta extends UnOpenedProduct {
|
|||||||
// System.out.println("AI decided to add " + metaSets.get(selected).getCode() + " to partialities.");
|
// System.out.println("AI decided to add " + metaSets.get(selected).getCode() + " to partialities.");
|
||||||
}
|
}
|
||||||
final UnOpenedProduct newBooster = metaSets.get(selected).getBooster();
|
final UnOpenedProduct newBooster = metaSets.get(selected).getBooster();
|
||||||
return newBooster.open();
|
return newBooster.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,50 +2,48 @@ package forge.card;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.item.ItemPoolView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class UnOpenedProduct {
|
public class UnOpenedProduct implements Supplier<List<CardPrinted>> {
|
||||||
|
|
||||||
private final Function<BoosterGenerator, List<CardPrinted>> openBooster;
|
|
||||||
private final BoosterGenerator generator;
|
|
||||||
private final BoosterData booster;
|
|
||||||
|
|
||||||
public UnOpenedProduct(Function<BoosterGenerator, List<CardPrinted>> identityPick, BoosterGenerator bpFull) {
|
|
||||||
openBooster = identityPick;
|
|
||||||
generator = bpFull;
|
|
||||||
booster = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private final ItemPoolView<CardPrinted> cards;
|
||||||
|
private final Iterable<CardPrinted> cardPoolFlat;
|
||||||
|
private final SealedProductTemplate tpl;
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
* @param boosterData
|
|
||||||
*/
|
*/
|
||||||
public UnOpenedProduct(BoosterData boosterData) {
|
public UnOpenedProduct(SealedProductTemplate template) {
|
||||||
booster = boosterData;
|
tpl = template;
|
||||||
openBooster = null;
|
cards = null;
|
||||||
generator = new BoosterGenerator(boosterData.getEditionFilter());
|
cardPoolFlat = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CardPrinted> open() {
|
public UnOpenedProduct(SealedProductTemplate template, ItemPoolView<CardPrinted> pool) {
|
||||||
return openBooster != null ? openBooster.apply(generator) : generator.getBoosterPack(booster);
|
cards = pool;
|
||||||
|
cardPoolFlat = null;
|
||||||
|
tpl = template;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public UnOpenedProduct(SealedProductTemplate template, Iterable<CardPrinted> pool) {
|
||||||
* Like open, can define whether is human or not.
|
cardPoolFlat = pool;
|
||||||
* @param isHuman
|
tpl = template;
|
||||||
* boolean, is human player?
|
cards = null;
|
||||||
* @param partialities
|
}
|
||||||
* known partialities for the AI.
|
|
||||||
* @return List, list of cards.
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.common.base.Supplier#get()
|
||||||
*/
|
*/
|
||||||
public List<CardPrinted> open(final boolean isHuman, List<String> partialities) {
|
@Override
|
||||||
return open();
|
public List<CardPrinted> get() {
|
||||||
|
return cards == null && cardPoolFlat == null ? BoosterGenerator.getBoosterPack(tpl)
|
||||||
|
: BoosterGenerator.getBoosterPack(tpl, cardPoolFlat == null ? cards.toFlatList() : cardPoolFlat);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ package forge.deck;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.commons.lang.math.IntRange;
|
import org.apache.commons.lang.math.IntRange;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<CardPrinted> buildFilterPrinted() {
|
private Predicate<CardPrinted> buildFilterPrinted() {
|
||||||
final Predicate<CardPrinted> banNames = IPaperCard.Predicates.namesExcept(this.bannedCardNames);
|
final Predicate<CardPrinted> banNames = Predicates.not(IPaperCard.Predicates.names(this.bannedCardNames));
|
||||||
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
||||||
return banNames;
|
return banNames;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<CardPrinted> buildFilterRules() {
|
private Predicate<CardPrinted> buildFilterRules() {
|
||||||
final Predicate<CardPrinted> banNames = IPaperCard.Predicates.namesExcept(this.bannedCardNames);
|
final Predicate<CardPrinted> banNames = Predicates.not(IPaperCard.Predicates.names(this.bannedCardNames));
|
||||||
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
|
||||||
return banNames;
|
return banNames;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,16 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.Constant.Preferences;
|
import forge.Constant.Preferences;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
|
import forge.card.SealedProductTemplate;
|
||||||
import forge.card.UnOpenedProduct;
|
import forge.card.UnOpenedProduct;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
@@ -47,6 +49,7 @@ import forge.item.ItemPoolView;
|
|||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.HttpUtil;
|
import forge.util.HttpUtil;
|
||||||
|
import forge.util.storage.IStorageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -66,7 +69,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
private final Map<String, Float> draftPicks = new TreeMap<String, Float>();
|
private final Map<String, Float> draftPicks = new TreeMap<String, Float>();
|
||||||
private final CardPoolLimitation draftFormat;
|
private final CardPoolLimitation draftFormat;
|
||||||
|
|
||||||
private final ArrayList<UnOpenedProduct> product = new ArrayList<UnOpenedProduct>();
|
private final List<Supplier<List<CardPrinted>>> product = new ArrayList<Supplier<List<CardPrinted>>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -82,11 +85,11 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
|
|
||||||
switch (draftType) {
|
switch (draftType) {
|
||||||
case Full: // Draft from all cards in Forge
|
case Full: // Draft from all cards in Forge
|
||||||
final BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getUniqueCards());
|
Supplier<List<CardPrinted>> s = new Supplier<List<CardPrinted>>() {
|
||||||
for (int i = 0; i < 3; i++) {
|
@Override public List<CardPrinted> get() { return BoosterGenerator.getBoosterPack(BoosterTemplate.genericBooster); }
|
||||||
this.product.add(new UnOpenedProduct(BoosterGenerator.IDENTITY_PICK, bpFull));
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) this.product.add(s);
|
||||||
IBoosterDraft.LAND_SET_CODE[0] = CardDb.instance().getCard("Plains").getEdition();
|
IBoosterDraft.LAND_SET_CODE[0] = CardDb.instance().getCard("Plains").getEdition();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -94,26 +97,18 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
|
|
||||||
List<CardBlock> blocks = new ArrayList<CardBlock>();
|
List<CardBlock> blocks = new ArrayList<CardBlock>();
|
||||||
|
|
||||||
if (draftType == CardPoolLimitation.Block) {
|
IStorageView<CardBlock> storage = draftType == CardPoolLimitation.Block
|
||||||
for (CardBlock b : Singletons.getModel().getBlocks()) {
|
? Singletons.getModel().getBlocks() : Singletons.getModel().getFantasyBlocks();
|
||||||
if (b.hasMetaSetType("choose1") || b.hasMetaSetType("random1")) {
|
|
||||||
System.out.println("Ignoring block " + b.getName() + " because its MetaSet types are not supported in Draft.");
|
|
||||||
} else {
|
|
||||||
blocks.add(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
for (CardBlock b : storage) {
|
||||||
else {
|
if (b.hasMetaSetType("choose1") || b.hasMetaSetType("random1")) {
|
||||||
for (CardBlock b : Singletons.getModel().getFantasyBlocks()) {
|
System.out.println("Ignoring block " + b.getName() + " because its MetaSet types are not supported in Draft.");
|
||||||
if (b.hasMetaSetType("choose1") || b.hasMetaSetType("random1")) {
|
} else {
|
||||||
System.out.println("Ignoring block " + b.getName() + " because its MetaSet types are not supported in Draft.");
|
blocks.add(b);
|
||||||
} else {
|
|
||||||
blocks.add(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final CardBlock block = GuiChoose.one("Choose Block", blocks);
|
final CardBlock block = GuiChoose.one("Choose Block", blocks);
|
||||||
|
|
||||||
final CardEdition[] cardSets = block.getSets();
|
final CardEdition[] cardSets = block.getSets();
|
||||||
@@ -146,7 +141,8 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
this.product.add(block.getBooster(pp[i]));
|
this.product.add(block.getBooster(pp[i]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.product.add(new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i])));
|
this.product.add(
|
||||||
|
new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -190,22 +186,10 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
throw new RuntimeException("BoosterGenerator : deck not found");
|
throw new RuntimeException("BoosterGenerator : deck not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
final BoosterGenerator bpCustom = new BoosterGenerator(dPool);
|
final SealedProductTemplate tpl = draft.getSealedProductTemplate();
|
||||||
final Function<BoosterGenerator, List<CardPrinted>> fnPick = new Function<BoosterGenerator, List<CardPrinted>>() {
|
|
||||||
@Override
|
|
||||||
public List<CardPrinted> apply(final BoosterGenerator pack) {
|
|
||||||
if (draft.getIgnoreRarity()) {
|
|
||||||
if (!draft.getSingleton()) {
|
|
||||||
return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, draft.getNumCards(), 0);
|
|
||||||
}
|
|
||||||
return pack.getSingletonBoosterPack(draft.getNumCards());
|
|
||||||
}
|
|
||||||
return pack.getBoosterPack(draft.getNumbersByRarity(), 0, 0, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < draft.getNumPacks(); i++) {
|
for (int i = 0; i < draft.getNumPacks(); i++) {
|
||||||
this.product.add(new UnOpenedProduct(fnPick, bpCustom));
|
this.product.add(new UnOpenedProduct(tpl, dPool));
|
||||||
}
|
}
|
||||||
|
|
||||||
IBoosterDraft.LAND_SET_CODE[0] = draft.getLandSetCode();
|
IBoosterDraft.LAND_SET_CODE[0] = draft.getLandSetCode();
|
||||||
@@ -268,7 +252,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
|
|
||||||
final List<List<CardPrinted>> list = new ArrayList<List<CardPrinted>>();
|
final List<List<CardPrinted>> list = new ArrayList<List<CardPrinted>>();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
list.add(this.product.get(this.nextBoosterGroup).open());
|
list.add(this.product.get(this.nextBoosterGroup).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nextBoosterGroup++;
|
this.nextBoosterGroup++;
|
||||||
|
|||||||
@@ -17,11 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.limited;
|
package forge.game.limited;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import forge.card.CardRarity;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import forge.card.BoosterTemplate;
|
||||||
|
import forge.card.SealedProductTemplate;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckBase;
|
import forge.deck.DeckBase;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -29,6 +33,7 @@ import forge.item.CardPrinted;
|
|||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.storage.IStorageView;
|
import forge.util.storage.IStorageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,14 +45,17 @@ import forge.util.storage.IStorageView;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class CustomLimited extends DeckBase {
|
public class CustomLimited extends DeckBase {
|
||||||
|
private final SealedProductTemplate tpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for Constructor.
|
* TODO: Write javadoc for Constructor.
|
||||||
*
|
*
|
||||||
* @param name0 the name0
|
* @param name0 the name0
|
||||||
|
* @param slots
|
||||||
*/
|
*/
|
||||||
public CustomLimited(final String name0) {
|
public CustomLimited(final String name0, List<Pair<String, Integer>> slots) {
|
||||||
super(name0);
|
super(name0);
|
||||||
|
tpl = new SealedProductTemplate(slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 7435640939026612173L;
|
private static final long serialVersionUID = 7435640939026612173L;
|
||||||
@@ -58,10 +66,6 @@ public class CustomLimited extends DeckBase {
|
|||||||
/** The Singleton. */
|
/** The Singleton. */
|
||||||
private boolean singleton = false;
|
private boolean singleton = false;
|
||||||
|
|
||||||
/** The Num cards. */
|
|
||||||
private int numCards = 15;
|
|
||||||
|
|
||||||
private final Map<CardRarity, Integer> numRarity = new EnumMap<CardRarity, Integer>(CardRarity.class);
|
|
||||||
|
|
||||||
/** The Num packs. */
|
/** The Num packs. */
|
||||||
private int numPacks = 3;
|
private int numPacks = 3;
|
||||||
@@ -71,6 +75,7 @@ public class CustomLimited extends DeckBase {
|
|||||||
/** The Land set code. */
|
/** The Land set code. */
|
||||||
private String landSetCode = CardDb.instance().getCard("Plains", true).getEdition();
|
private String landSetCode = CardDb.instance().getCard("Plains", true).getEdition();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -92,48 +97,29 @@ public class CustomLimited extends DeckBase {
|
|||||||
|
|
||||||
final FileSection data = FileSection.parse(dfData, ":");
|
final FileSection data = FileSection.parse(dfData, ":");
|
||||||
|
|
||||||
final CustomLimited cd = new CustomLimited(data.get("Name"));
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
|
String boosterData = data.get("Booster");
|
||||||
|
if(StringUtils.isNotEmpty(boosterData)){
|
||||||
|
final String[] booster = TextUtil.splitWithParenthesis(boosterData, ',', '(', ')');
|
||||||
|
for(String slotDesc : booster) {
|
||||||
|
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', '(', ')', 2);
|
||||||
|
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
slots = BoosterTemplate.genericBooster.getSlots();
|
||||||
|
|
||||||
|
final CustomLimited cd = new CustomLimited(data.get("Name"), slots);
|
||||||
cd.setIgnoreRarity(data.getBoolean("IgnoreRarity"));
|
cd.setIgnoreRarity(data.getBoolean("IgnoreRarity"));
|
||||||
cd.setSingleton(data.getBoolean("Singleton"));
|
cd.setSingleton(data.getBoolean("Singleton"));
|
||||||
cd.setLandSetCode(data.get("LandSetCode"));
|
cd.landSetCode = data.get("LandSetCode");
|
||||||
cd.numCards = data.getInt("NumCards", 15);
|
|
||||||
|
|
||||||
cd.numRarity.put(CardRarity.BasicLand, data.getInt("NumBasicLands", 1));
|
|
||||||
cd.numRarity.put(CardRarity.Special, data.getInt("NumSpecials"));
|
|
||||||
cd.numRarity.put(CardRarity.Rare, data.getInt("NumRares", 1));
|
|
||||||
cd.numRarity.put(CardRarity.MythicRare, data.getInt("NumMythics"));
|
|
||||||
cd.numRarity.put(CardRarity.Uncommon, data.getInt("NumUncommons", 3));
|
|
||||||
cd.numRarity.put(CardRarity.Common, data.getInt("NumCommons", 10));
|
|
||||||
|
|
||||||
cd.numPacks = data.getInt("NumPacks");
|
cd.numPacks = data.getInt("NumPacks");
|
||||||
|
final Deck deckCube = cubes.get(data.get("DeckFile"));
|
||||||
final String deckName = data.get("DeckFile");
|
cd.cardPool = deckCube == null ? ItemPool.createFrom(CardDb.instance().getUniqueCards(), CardPrinted.class) : deckCube.getMain();
|
||||||
final Deck deckCube = cubes.get(deckName);
|
|
||||||
cd.cardPool = deckCube == null ? ItemPool.createFrom(
|
|
||||||
CardDb.instance().getUniqueCards(), CardPrinted.class)
|
|
||||||
: deckCube.getMain();
|
|
||||||
|
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the num cards.
|
|
||||||
*
|
|
||||||
* @return the numCards
|
|
||||||
*/
|
|
||||||
public int getNumCards() {
|
|
||||||
return this.numCards;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the num cards.
|
|
||||||
*
|
|
||||||
* @param numCardsIn
|
|
||||||
* the numCards to set
|
|
||||||
*/
|
|
||||||
public void setNumCards(final int numCardsIn) {
|
|
||||||
this.numCards = numCardsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the num packs.
|
* Gets the num packs.
|
||||||
@@ -201,16 +187,6 @@ public class CustomLimited extends DeckBase {
|
|||||||
return this.landSetCode;
|
return this.landSetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the land set code.
|
|
||||||
*
|
|
||||||
* @param landSetCodeIn
|
|
||||||
* the landSetCode to set
|
|
||||||
*/
|
|
||||||
public void setLandSetCode(final String landSetCodeIn) {
|
|
||||||
this.landSetCode = landSetCodeIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -227,16 +203,14 @@ public class CustomLimited extends DeckBase {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected DeckBase newInstance(final String name0) {
|
protected DeckBase newInstance(final String name0) {
|
||||||
return new CustomLimited(name0);
|
return new CustomLimited(name0, tpl.getSlots());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
*
|
* @return
|
||||||
* @return the numbers by rarity
|
|
||||||
*/
|
*/
|
||||||
public Map<CardRarity, Integer> getNumbersByRarity() {
|
public SealedProductTemplate getSealedProductTemplate() {
|
||||||
return this.numRarity;
|
return tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,11 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
|
import forge.card.UnOpenedMeta;
|
||||||
import forge.card.UnOpenedProduct;
|
import forge.card.UnOpenedProduct;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -65,9 +64,6 @@ public class SealedDeckFormat {
|
|||||||
partiality = new ArrayList<String>();
|
partiality = new ArrayList<String>();
|
||||||
|
|
||||||
if (sealedType.equals("Full")) {
|
if (sealedType.equals("Full")) {
|
||||||
|
|
||||||
final BoosterGenerator bpFull = new BoosterGenerator(CardDb.instance().getUniqueCards());
|
|
||||||
|
|
||||||
// Choose number of boosters
|
// Choose number of boosters
|
||||||
final Integer[] integers = new Integer[10];
|
final Integer[] integers = new Integer[10];
|
||||||
|
|
||||||
@@ -78,7 +74,7 @@ public class SealedDeckFormat {
|
|||||||
Integer nrBoosters = GuiChoose.one("How many booster packs?", integers);
|
Integer nrBoosters = GuiChoose.one("How many booster packs?", integers);
|
||||||
|
|
||||||
for (int i = 0; i < nrBoosters; i++) {
|
for (int i = 0; i < nrBoosters; i++) {
|
||||||
this.product.add(new UnOpenedProduct(BoosterGenerator.IDENTITY_PICK, bpFull));
|
this.product.add(new UnOpenedProduct(BoosterTemplate.genericBooster));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getLandSetCode()[0] = CardDb.instance().getCard("Plains").getEdition();
|
this.getLandSetCode()[0] = CardDb.instance().getCard("Plains").getEdition();
|
||||||
@@ -259,7 +255,7 @@ public class SealedDeckFormat {
|
|||||||
if (element.endsWith(".sealed")) {
|
if (element.endsWith(".sealed")) {
|
||||||
final List<String> dfData = FileUtil.readFile("res/sealed/" + element);
|
final List<String> dfData = FileUtil.readFile("res/sealed/" + element);
|
||||||
final CustomLimited cs = CustomLimited.parse(dfData, Singletons.getModel().getDecks().getCubes());
|
final CustomLimited cs = CustomLimited.parse(dfData, Singletons.getModel().getDecks().getCubes());
|
||||||
if (cs.getNumCards() > 5) { // Do not allow too small cubes to be played as 'stand-alone'!
|
if (cs.getSealedProductTemplate().getTotal() > 5) { // Do not allow too small cubes to be played as 'stand-alone'!
|
||||||
customs.add(cs);
|
customs.add(cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,20 +269,6 @@ public class SealedDeckFormat {
|
|||||||
final CustomLimited draft = GuiChoose.one("Choose Custom Sealed Pool",
|
final CustomLimited draft = GuiChoose.one("Choose Custom Sealed Pool",
|
||||||
customs);
|
customs);
|
||||||
|
|
||||||
final BoosterGenerator bpCustom = new BoosterGenerator(draft.getCardPool());
|
|
||||||
final Function<BoosterGenerator, List<CardPrinted>> fnPick = new Function<BoosterGenerator, List<CardPrinted>>() {
|
|
||||||
@Override
|
|
||||||
public List<CardPrinted> apply(final BoosterGenerator pack) {
|
|
||||||
if (draft.getIgnoreRarity()) {
|
|
||||||
if (!draft.getSingleton()) {
|
|
||||||
return pack.getBoosterPack(0, 0, 0, 0, 0, 0, 0, draft.getNumCards(), 0);
|
|
||||||
} else {
|
|
||||||
return pack.getSingletonBoosterPack(draft.getNumCards());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pack.getBoosterPack(draft.getNumbersByRarity(), 0, 0, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Choose number of boosters
|
// Choose number of boosters
|
||||||
final Integer[] integers = new Integer[10];
|
final Integer[] integers = new Integer[10];
|
||||||
@@ -298,7 +280,7 @@ public class SealedDeckFormat {
|
|||||||
Integer nrBoosters = GuiChoose.one("How many booster packs?", integers);
|
Integer nrBoosters = GuiChoose.one("How many booster packs?", integers);
|
||||||
|
|
||||||
for (int i = 0; i < nrBoosters; i++) {
|
for (int i = 0; i < nrBoosters; i++) {
|
||||||
this.product.add(new UnOpenedProduct(fnPick, bpCustom));
|
this.product.add(new UnOpenedProduct(draft.getSealedProductTemplate(), draft.getCardPool()));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getLandSetCode()[0] = draft.getLandSetCode();
|
this.getLandSetCode()[0] = draft.getLandSetCode();
|
||||||
@@ -468,10 +450,12 @@ public class SealedDeckFormat {
|
|||||||
}
|
}
|
||||||
final ItemPool<CardPrinted> pool = new ItemPool<CardPrinted>(CardPrinted.class);
|
final ItemPool<CardPrinted> pool = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||||
|
|
||||||
for (int i = 0; i < this.product.size(); i++) {
|
for (UnOpenedProduct prod : product) {
|
||||||
pool.addAllFlat(this.product.get(i).open(isHuman, partiality));
|
if( prod instanceof UnOpenedMeta )
|
||||||
|
pool.addAllFlat(((UnOpenedMeta) prod).open(isHuman, partiality));
|
||||||
|
else
|
||||||
|
pool.addAllFlat(prod.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ public class ImportSourceAnalyzer {
|
|||||||
_cardFileNamesBySet = new TreeMap<String, Map<String, String>>(String.CASE_INSENSITIVE_ORDER);
|
_cardFileNamesBySet = new TreeMap<String, Map<String, String>>(String.CASE_INSENSITIVE_ORDER);
|
||||||
for (CardEdition ce : Singletons.getModel().getEditions()) {
|
for (CardEdition ce : Singletons.getModel().getEditions()) {
|
||||||
Map<String, String> cardFileNames = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, String> cardFileNames = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
||||||
Predicate<CardPrinted> filter = IPaperCard.Predicates.printedInSets(ce.getCode());
|
Predicate<CardPrinted> filter = IPaperCard.Predicates.printedInSet(ce.getCode());
|
||||||
_addSetCards(cardFileNames, CardDb.instance().getAllCards(), filter);
|
_addSetCards(cardFileNames, CardDb.instance().getAllCards(), filter);
|
||||||
_addSetCards(cardFileNames, CardDb.variants().getAllCards(), filter);
|
_addSetCards(cardFileNames, CardDb.variants().getAllCards(), filter);
|
||||||
_cardFileNamesBySet.put(ce.getCode2(), cardFileNames);
|
_cardFileNamesBySet.put(ce.getCode2(), cardFileNames);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class InputProxy implements Observer {
|
|||||||
private AtomicReference<Input> input = new AtomicReference<Input>();
|
private AtomicReference<Input> input = new AtomicReference<Input>();
|
||||||
private MatchController match = null;
|
private MatchController match = null;
|
||||||
|
|
||||||
private static final boolean INPUT_DEBUG = false;
|
private static final boolean INPUT_DEBUG = true;
|
||||||
|
|
||||||
public void setMatch(MatchController matchController) {
|
public void setMatch(MatchController matchController) {
|
||||||
match = matchController;
|
match = matchController;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import javax.swing.SwingConstants;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.UnOpenedProduct;
|
import forge.card.UnOpenedProduct;
|
||||||
import forge.control.FControl;
|
import forge.control.FControl;
|
||||||
@@ -571,7 +571,7 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
} else {
|
} else {
|
||||||
final List<String> sets = new ArrayList<String>();
|
final List<String> sets = new ArrayList<String>();
|
||||||
|
|
||||||
for (BoosterData bd : Singletons.getModel().getBoosters()) {
|
for (BoosterTemplate bd : Singletons.getModel().getBoosters()) {
|
||||||
if (qData.getFormat().isSetLegal(bd.getEdition())) {
|
if (qData.getFormat().isSetLegal(bd.getEdition())) {
|
||||||
sets.add(bd.getEdition());
|
sets.add(bd.getEdition());
|
||||||
}
|
}
|
||||||
@@ -626,7 +626,7 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
}
|
}
|
||||||
final CardEdition chooseEd = GuiChoose.one(setPrompt, chooseEditions);
|
final CardEdition chooseEd = GuiChoose.one(setPrompt, chooseEditions);
|
||||||
|
|
||||||
cardsWon = (new UnOpenedProduct(Singletons.getModel().getBoosters().get(chooseEd.getCode()))).open();
|
cardsWon = (new UnOpenedProduct(Singletons.getModel().getBoosters().get(chooseEd.getCode()))).get();
|
||||||
qData.getCards().addAllCards(cardsWon);
|
qData.getCards().addAllCards(cardsWon);
|
||||||
this.lblTemp1 = new TitleLabel("Bonus " + chooseEd.getName() + " booster pack!");
|
this.lblTemp1 = new TitleLabel("Bonus " + chooseEd.getName() + " booster pack!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ package forge.item;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
@@ -32,12 +32,12 @@ public class BoosterPack extends OpenablePack {
|
|||||||
public static final Function<CardEdition, BoosterPack> FN_FROM_SET = new Function<CardEdition, BoosterPack>() {
|
public static final Function<CardEdition, BoosterPack> FN_FROM_SET = new Function<CardEdition, BoosterPack>() {
|
||||||
@Override
|
@Override
|
||||||
public BoosterPack apply(final CardEdition arg1) {
|
public BoosterPack apply(final CardEdition arg1) {
|
||||||
BoosterData d = Singletons.getModel().getBoosters().get(arg1.getCode());
|
BoosterTemplate d = Singletons.getModel().getBoosters().get(arg1.getCode());
|
||||||
return new BoosterPack(arg1.getName(), d);
|
return new BoosterPack(arg1.getName(), d);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public BoosterPack(final String name0, final BoosterData boosterData) {
|
public BoosterPack(final String name0, final BoosterTemplate boosterData) {
|
||||||
super(name0, boosterData);
|
super(name0, boosterData);
|
||||||
artIndex = MyRandom.getRandom().nextInt(boosterData.getArtIndices()) + 1;
|
artIndex = MyRandom.getRandom().nextInt(boosterData.getArtIndices()) + 1;
|
||||||
hash = super.hashCode() ^ artIndex;
|
hash = super.hashCode() ^ artIndex;
|
||||||
@@ -57,7 +57,7 @@ public class BoosterPack extends OpenablePack {
|
|||||||
return new BoosterPack(name, contents);
|
return new BoosterPack(name, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoosterData getBoosterData() {
|
public BoosterTemplate getBoosterData() {
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,6 @@ public final class CardDb {
|
|||||||
if (null == result) {
|
if (null == result) {
|
||||||
throw new NoSuchElementException(String.format("Card '%s' not found in our database.", name));
|
throw new NoSuchElementException(String.format("Card '%s' not found in our database.", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFoil) {
|
if (isFoil) {
|
||||||
|
|||||||
@@ -24,21 +24,22 @@ import java.util.List;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.FatPackData;
|
import forge.card.FatPackTemplate;
|
||||||
|
|
||||||
public class FatPack extends OpenablePack {
|
public class FatPack extends OpenablePack {
|
||||||
public static final Function<CardEdition, FatPack> FN_FROM_SET = new Function<CardEdition, FatPack>() {
|
public static final Function<CardEdition, FatPack> FN_FROM_SET = new Function<CardEdition, FatPack>() {
|
||||||
@Override
|
@Override
|
||||||
public FatPack apply(final CardEdition arg1) {
|
public FatPack apply(final CardEdition arg1) {
|
||||||
FatPackData d = Singletons.getModel().getFatPacks().get(arg1.getCode());
|
FatPackTemplate d = Singletons.getModel().getFatPacks().get(arg1.getCode());
|
||||||
return new FatPack(arg1.getName(), d);
|
return new FatPack(arg1.getName(), d);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final FatPackData fpData;
|
private final FatPackTemplate fpData;
|
||||||
|
|
||||||
public FatPack(final String name0, final FatPackData fpData0) {
|
public FatPack(final String name0, final FatPackTemplate fpData0) {
|
||||||
super(name0, Singletons.getModel().getBoosters().get(fpData0.getEdition()));
|
super(name0, Singletons.getModel().getBoosters().get(fpData0.getEdition()));
|
||||||
fpData = fpData0;
|
fpData = fpData0;
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,7 @@ public class FatPack extends OpenablePack {
|
|||||||
for (int i = 0; i < fpData.getCntBoosters(); i++) {
|
for (int i = 0; i < fpData.getCntBoosters(); i++) {
|
||||||
result.addAll(super.generate());
|
result.addAll(super.generate());
|
||||||
}
|
}
|
||||||
result.addAll(getRandomBasicLands(fpData.getLandEdition(), fpData.getCntLands()));
|
result.addAll(BoosterGenerator.getBoosterPack(contents));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +71,6 @@ public class FatPack extends OpenablePack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTotalCards() {
|
public int getTotalCards() {
|
||||||
return super.getTotalCards() * fpData.getCntBoosters() + fpData.getCntLands();
|
return super.getTotalCards() * fpData.getCntBoosters() + fpData.getTotal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package forge.item;
|
package forge.item;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -8,6 +7,7 @@ import java.util.Set;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
@@ -25,6 +25,9 @@ public interface IPaperCard extends InventoryItem {
|
|||||||
public static Predicate<CardPrinted> rarity(final boolean isEqual, final CardRarity value) {
|
public static Predicate<CardPrinted> rarity(final boolean isEqual, final CardRarity value) {
|
||||||
return new PredicateRarity(value, isEqual);
|
return new PredicateRarity(value, isEqual);
|
||||||
}
|
}
|
||||||
|
public static Predicate<CardPrinted> printedInSets(final String[] sets) {
|
||||||
|
return printedInSets(Lists.newArrayList(sets), true);
|
||||||
|
}
|
||||||
|
|
||||||
public static Predicate<CardPrinted> printedInSets(final List<String> value, final boolean shouldContain) {
|
public static Predicate<CardPrinted> printedInSets(final List<String> value, final boolean shouldContain) {
|
||||||
if ((value == null) || value.isEmpty()) {
|
if ((value == null) || value.isEmpty()) {
|
||||||
@@ -33,11 +36,11 @@ public interface IPaperCard extends InventoryItem {
|
|||||||
return new PredicateSets(value, shouldContain);
|
return new PredicateSets(value, shouldContain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<CardPrinted> printedInSets(final String value) {
|
public static Predicate<CardPrinted> printedInSet(final String value) {
|
||||||
if (StringUtils.isEmpty(value)) {
|
if (StringUtils.isEmpty(value)) {
|
||||||
return com.google.common.base.Predicates.alwaysTrue();
|
return com.google.common.base.Predicates.alwaysTrue();
|
||||||
}
|
}
|
||||||
return new PredicateSets(Arrays.asList(new String[] { value }), true);
|
return new PredicateSets(Lists.newArrayList(value), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<CardPrinted> name(final String what) {
|
public static Predicate<CardPrinted> name(final String what) {
|
||||||
@@ -48,8 +51,8 @@ public interface IPaperCard extends InventoryItem {
|
|||||||
return new PredicateName(op, what);
|
return new PredicateName(op, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<CardPrinted> namesExcept(final List<String> what) {
|
public static Predicate<CardPrinted> names(final List<String> what) {
|
||||||
return new PredicateNamesExcept(what);
|
return new PredicateNames(what);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PredicateRarity implements Predicate<CardPrinted> {
|
private static class PredicateRarity implements Predicate<CardPrinted> {
|
||||||
@@ -96,7 +99,7 @@ public interface IPaperCard extends InventoryItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PredicateNamesExcept extends PredicateString<CardPrinted> {
|
private static class PredicateNames extends PredicateString<CardPrinted> {
|
||||||
private final List<String> operand;
|
private final List<String> operand;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -104,13 +107,13 @@ public interface IPaperCard extends InventoryItem {
|
|||||||
final String cardName = card.getName();
|
final String cardName = card.getName();
|
||||||
for (final String element : this.operand) {
|
for (final String element : this.operand) {
|
||||||
if (this.op(cardName, element)) {
|
if (this.op(cardName, element)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PredicateNamesExcept(final List<String> operand) {
|
public PredicateNames(final List<String> operand) {
|
||||||
super(StringOp.EQUALS);
|
super(StringOp.EQUALS);
|
||||||
this.operand = operand;
|
this.operand = operand;
|
||||||
}
|
}
|
||||||
@@ -143,7 +146,7 @@ public interface IPaperCard extends InventoryItem {
|
|||||||
public static final Predicate<CardPrinted> IS_SPECIAL = Predicates.rarity(true, CardRarity.Special);
|
public static final Predicate<CardPrinted> IS_SPECIAL = Predicates.rarity(true, CardRarity.Special);
|
||||||
|
|
||||||
/** The Constant exceptLands. */
|
/** The Constant exceptLands. */
|
||||||
public static final Predicate<CardPrinted> EXCEPT_LANDS = Predicates.rarity(false, CardRarity.BasicLand);
|
public static final Predicate<CardPrinted> IS_BASIC_LAND = Predicates.rarity(true, CardRarity.BasicLand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,19 +26,18 @@ import com.google.common.base.Predicate;
|
|||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardRulesPredicates;
|
import forge.card.CardRulesPredicates;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
|
|
||||||
public abstract class OpenablePack implements InventoryItemFromSet {
|
public abstract class OpenablePack implements InventoryItemFromSet {
|
||||||
protected final BoosterData contents;
|
protected final BoosterTemplate contents;
|
||||||
protected final String name;
|
protected final String name;
|
||||||
private final int hash;
|
private final int hash;
|
||||||
private List<CardPrinted> cards = null;
|
private List<CardPrinted> cards = null;
|
||||||
private BoosterGenerator generator = null;
|
|
||||||
|
|
||||||
public OpenablePack(String name0, BoosterData boosterData) {
|
public OpenablePack(String name0, BoosterTemplate boosterData) {
|
||||||
if (null == name0) { throw new NullArgumentException("name0"); }
|
if (null == name0) { throw new NullArgumentException("name0"); }
|
||||||
if (null == boosterData) { throw new NullArgumentException("boosterData"); }
|
if (null == boosterData) { throw new NullArgumentException("boosterData"); }
|
||||||
contents = boosterData;
|
contents = boosterData;
|
||||||
@@ -93,16 +92,7 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected List<CardPrinted> generate() {
|
protected List<CardPrinted> generate() {
|
||||||
if (null == generator) {
|
return BoosterGenerator.getBoosterPack(contents);
|
||||||
generator = new BoosterGenerator(contents.getEditionFilter());
|
|
||||||
}
|
|
||||||
final List<CardPrinted> myCards = generator.getBoosterPack(contents);
|
|
||||||
|
|
||||||
final int cntLands = contents.getCntLands();
|
|
||||||
if (cntLands > 0) {
|
|
||||||
myCards.add(getRandomBasicLand(contents.getLandEdition()));
|
|
||||||
}
|
|
||||||
return myCards;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CardPrinted getRandomBasicLand(final String setCode) {
|
protected CardPrinted getRandomBasicLand(final String setCode) {
|
||||||
@@ -111,7 +101,7 @@ public abstract class OpenablePack implements InventoryItemFromSet {
|
|||||||
|
|
||||||
protected List<CardPrinted> getRandomBasicLands(final String setCode, final int count) {
|
protected List<CardPrinted> getRandomBasicLands(final String setCode, final int count) {
|
||||||
Predicate<CardPrinted> cardsRule = Predicates.and(
|
Predicate<CardPrinted> cardsRule = Predicates.and(
|
||||||
IPaperCard.Predicates.printedInSets(setCode),
|
IPaperCard.Predicates.printedInSet(setCode),
|
||||||
Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES));
|
Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES));
|
||||||
return Aggregates.random(Iterables.filter(CardDb.instance().getAllCards(), cardsRule), count);
|
return Aggregates.random(Iterables.filter(CardDb.instance().getAllCards(), cardsRule), count);
|
||||||
}
|
}
|
||||||
|
|||||||
71
src/main/java/forge/item/PrintSheet.java
Normal file
71
src/main/java/forge/item/PrintSheet.java
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package forge.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PrintSheet {
|
||||||
|
private final ItemPool<CardPrinted> cardsWithWeights = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||||
|
|
||||||
|
|
||||||
|
public void add(CardPrinted card) {
|
||||||
|
add(card,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(CardPrinted card, int weight) {
|
||||||
|
cardsWithWeights.add(card, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAll(Iterable<CardPrinted> cards) {
|
||||||
|
addAll(cards, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAll(Iterable<CardPrinted> cards, int weight) {
|
||||||
|
for(CardPrinted card : cards)
|
||||||
|
cardsWithWeights.add(card, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CardPrinted fetchRoulette(int start, int roulette, Collection<CardPrinted> toSkip) {
|
||||||
|
int sum = start;
|
||||||
|
boolean isSecondRun = start > 0;
|
||||||
|
for(Entry<CardPrinted, Integer> cc : cardsWithWeights ) {
|
||||||
|
sum += cc.getValue().intValue();
|
||||||
|
if( sum > roulette ) {
|
||||||
|
if( toSkip != null && toSkip.contains(cc.getKey()))
|
||||||
|
continue;
|
||||||
|
return cc.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( isSecondRun )
|
||||||
|
throw new IllegalStateException("Print sheet does not have enough unique cards");
|
||||||
|
|
||||||
|
return fetchRoulette(sum + 1, roulette, toSkip); // start over from beginning, in case last cards were to skip
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardPrinted random() {
|
||||||
|
int totalWeight = cardsWithWeights.countAll();
|
||||||
|
int index = MyRandom.getRandom().nextInt(totalWeight);
|
||||||
|
return fetchRoulette(0, index, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CardPrinted> random(int number, boolean wantUnique) {
|
||||||
|
List<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||||
|
|
||||||
|
int totalWeight = cardsWithWeights.countAll();
|
||||||
|
for(int iC = 0; iC < number; iC++) {
|
||||||
|
int index = MyRandom.getRandom().nextInt(totalWeight);
|
||||||
|
CardPrinted toAdd = fetchRoulette(0, index, wantUnique ? result : null);
|
||||||
|
result.add(toAdd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
|
|
||||||
@@ -32,17 +32,17 @@ public class TournamentPack extends OpenablePack {
|
|||||||
public static final Function<CardEdition, TournamentPack> FN_FROM_SET = new Function<CardEdition, TournamentPack>() {
|
public static final Function<CardEdition, TournamentPack> FN_FROM_SET = new Function<CardEdition, TournamentPack>() {
|
||||||
@Override
|
@Override
|
||||||
public TournamentPack apply(final CardEdition arg1) {
|
public TournamentPack apply(final CardEdition arg1) {
|
||||||
BoosterData d = Singletons.getModel().getTournamentPacks().get(arg1.getCode());
|
BoosterTemplate d = Singletons.getModel().getTournamentPacks().get(arg1.getCode());
|
||||||
return new TournamentPack(arg1.getName(), d);
|
return new TournamentPack(arg1.getName(), d);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public TournamentPack(final String name0, final BoosterData boosterData) {
|
public TournamentPack(final String name0, final BoosterTemplate boosterData) {
|
||||||
super(name0, boosterData);
|
super(name0, boosterData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isStarterDeck() {
|
public final boolean isStarterDeck() {
|
||||||
return contents.getCommon() < 30;
|
return contents.getSlots().get(0).getRight() < 30; // hack - getting number of commons, they are first in list
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,8 +52,7 @@ public class TournamentPack extends OpenablePack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CardPrinted> generate() {
|
protected List<CardPrinted> generate() {
|
||||||
final BoosterGenerator gen = new BoosterGenerator(this.contents.getEditionFilter());
|
return BoosterGenerator.getBoosterPack(this.contents);
|
||||||
return gen.getBoosterPack(this.contents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ import java.util.List;
|
|||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Constant.Preferences;
|
import forge.Constant.Preferences;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.CardBlock;
|
import forge.card.CardBlock;
|
||||||
import forge.card.CardRulesReader;
|
import forge.card.CardRulesReader;
|
||||||
import forge.card.EditionCollection;
|
import forge.card.EditionCollection;
|
||||||
import forge.card.FatPackData;
|
import forge.card.FatPackTemplate;
|
||||||
import forge.card.FormatCollection;
|
import forge.card.FormatCollection;
|
||||||
import forge.card.cardfactory.CardStorageReader;
|
import forge.card.cardfactory.CardStorageReader;
|
||||||
import forge.deck.CardCollections;
|
import forge.deck.CardCollections;
|
||||||
@@ -83,9 +83,9 @@ public enum FModel {
|
|||||||
|
|
||||||
private final EditionCollection editions;
|
private final EditionCollection editions;
|
||||||
private final FormatCollection formats;
|
private final FormatCollection formats;
|
||||||
private final IStorageView<BoosterData> boosters;
|
private final IStorageView<BoosterTemplate> boosters;
|
||||||
private final IStorageView<BoosterData> tournaments;
|
private final IStorageView<BoosterTemplate> tournaments;
|
||||||
private final IStorageView<FatPackData> fatPacks;
|
private final IStorageView<FatPackTemplate> fatPacks;
|
||||||
private final IStorageView<CardBlock> blocks;
|
private final IStorageView<CardBlock> blocks;
|
||||||
private final IStorageView<CardBlock> fantasyBlocks;
|
private final IStorageView<CardBlock> fantasyBlocks;
|
||||||
private final IStorageView<QuestWorld> worlds;
|
private final IStorageView<QuestWorld> worlds;
|
||||||
@@ -144,9 +144,9 @@ public enum FModel {
|
|||||||
|
|
||||||
this.editions = CardRulesReader.editions; // CardRules ctor cannot refer to FModel, since it is not yet build by that moment
|
this.editions = CardRulesReader.editions; // CardRules ctor cannot refer to FModel, since it is not yet build by that moment
|
||||||
this.formats = new FormatCollection("res/blockdata/formats.txt");
|
this.formats = new FormatCollection("res/blockdata/formats.txt");
|
||||||
this.boosters = new StorageView<BoosterData>(new BoosterData.Reader("res/blockdata/boosters.txt"));
|
this.boosters = new StorageView<BoosterTemplate>(new BoosterTemplate.Reader("res/blockdata/boosters.txt"));
|
||||||
this.tournaments = new StorageView<BoosterData>(new BoosterData.Reader("res/blockdata/starters.txt"));
|
this.tournaments = new StorageView<BoosterTemplate>(new BoosterTemplate.Reader("res/blockdata/starters.txt"));
|
||||||
this.fatPacks = new StorageView<FatPackData>(new FatPackData.Reader("res/blockdata/fatpacks.txt"));
|
this.fatPacks = new StorageView<FatPackTemplate>(new FatPackTemplate.Reader("res/blockdata/fatpacks.txt"));
|
||||||
this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions));
|
this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions));
|
||||||
this.fantasyBlocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/fantasyblocks.txt", editions));
|
this.fantasyBlocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/fantasyblocks.txt", editions));
|
||||||
this.worlds = new StorageView<QuestWorld>(new QuestWorld.Reader("res/quest/world/worlds.txt"));
|
this.worlds = new StorageView<QuestWorld>(new QuestWorld.Reader("res/quest/world/worlds.txt"));
|
||||||
@@ -358,18 +358,18 @@ public enum FModel {
|
|||||||
return fantasyBlocks;
|
return fantasyBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.FatPackData}> */
|
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.FatPackTemplate}> */
|
||||||
public IStorageView<FatPackData> getFatPacks() {
|
public IStorageView<FatPackTemplate> getFatPacks() {
|
||||||
return fatPacks;
|
return fatPacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterData}> */
|
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
|
||||||
public final IStorageView<BoosterData> getTournamentPacks() {
|
public final IStorageView<BoosterTemplate> getTournamentPacks() {
|
||||||
return tournaments;
|
return tournaments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterData}> */
|
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
|
||||||
public final IStorageView<BoosterData> getBoosters() {
|
public final IStorageView<BoosterTemplate> getBoosters() {
|
||||||
return boosters;
|
return boosters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,16 +23,15 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterGenerator;
|
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.card.CardRulesPredicates;
|
import forge.card.CardRulesPredicates;
|
||||||
|
import forge.card.SealedProductTemplate;
|
||||||
import forge.card.UnOpenedProduct;
|
import forge.card.UnOpenedProduct;
|
||||||
import forge.item.BoosterPack;
|
import forge.item.BoosterPack;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
@@ -228,9 +227,9 @@ public final class BoosterUtils {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static Predicate<CardRules> parseRulesLimitation(final String input) {
|
public static Predicate<CardRules> parseRulesLimitation(final String input) {
|
||||||
if (null == input) {
|
if (null == input)
|
||||||
return null;
|
return Predicates.alwaysTrue();
|
||||||
}
|
|
||||||
if (input.equalsIgnoreCase("black")) {
|
if (input.equalsIgnoreCase("black")) {
|
||||||
return CardRulesPredicates.Presets.IS_BLACK;
|
return CardRulesPredicates.Presets.IS_BLACK;
|
||||||
} else if (input.equalsIgnoreCase("blue")) {
|
} else if (input.equalsIgnoreCase("blue")) {
|
||||||
@@ -260,8 +259,8 @@ public final class BoosterUtils {
|
|||||||
} else if (input.equalsIgnoreCase("enchantment")) {
|
} else if (input.equalsIgnoreCase("enchantment")) {
|
||||||
return CardRulesPredicates.Presets.IS_ENCHANTMENT;
|
return CardRulesPredicates.Presets.IS_ENCHANTMENT;
|
||||||
}
|
}
|
||||||
// No CardRules limitations could be parsed
|
|
||||||
return null;
|
throw new IllegalArgumentException("No CardRules limitations could be parsed from: " + input);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* parseReward - used internally to parse individual items in a challenge reward definition.
|
* parseReward - used internally to parse individual items in a challenge reward definition.
|
||||||
@@ -282,25 +281,16 @@ public final class BoosterUtils {
|
|||||||
final Predicate<CardPrinted> rar = IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC;
|
final Predicate<CardPrinted> rar = IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC;
|
||||||
|
|
||||||
// Determine color ("random" defaults to null color)
|
// Determine color ("random" defaults to null color)
|
||||||
Predicate<CardRules> col = Predicates.alwaysTrue();
|
Predicate<CardRules> col = parseRulesLimitation(temp[1]);
|
||||||
final Predicate<CardRules> colorRules = parseRulesLimitation(temp[1]);
|
|
||||||
|
|
||||||
if (colorRules != null) {
|
|
||||||
col = colorRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
Function<BoosterGenerator, List<CardPrinted>> openWay = new Function<BoosterGenerator, List<CardPrinted>>() {
|
|
||||||
@Override
|
|
||||||
public List<CardPrinted> apply(BoosterGenerator arg1) {
|
|
||||||
return arg1.getSingletonBoosterPack(qty);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Predicate<CardPrinted> colorPred = Predicates.compose(col, CardPrinted.FN_GET_RULES);
|
Predicate<CardPrinted> colorPred = Predicates.compose(col, CardPrinted.FN_GET_RULES);
|
||||||
Predicate<CardPrinted> rarAndColor = Predicates.and(rar, colorPred);
|
Predicate<CardPrinted> rarAndColor = Predicates.and(rar, colorPred);
|
||||||
if (Singletons.getModel().getQuest().getFormat() != null) {
|
if (Singletons.getModel().getQuest().getFormat() != null) {
|
||||||
rarAndColor = Predicates.and(Singletons.getModel().getQuest().getFormat().getFilterPrinted(), rarAndColor);
|
rarAndColor = Predicates.and(Singletons.getModel().getQuest().getFormat().getFilterPrinted(), rarAndColor);
|
||||||
}
|
}
|
||||||
rewards.addAll(new UnOpenedProduct(openWay, new BoosterGenerator(rarAndColor)).open());
|
Iterable<CardPrinted> cardPool = Iterables.filter(CardDb.instance().getAllCards(), rarAndColor);
|
||||||
|
UnOpenedProduct product = new UnOpenedProduct(new SealedProductTemplate(qty), cardPool);
|
||||||
|
rewards.addAll(product.get());
|
||||||
} else if (temp.length == 2 && temp[0].equalsIgnoreCase("duplicate") && temp[1].equalsIgnoreCase("card")) {
|
} else if (temp.length == 2 && temp[0].equalsIgnoreCase("duplicate") && temp[1].equalsIgnoreCase("card")) {
|
||||||
// Type 2: a duplicate card of the players choice
|
// Type 2: a duplicate card of the players choice
|
||||||
rewards.add(new QuestRewardCardDuplicate());
|
rewards.add(new QuestRewardCardDuplicate());
|
||||||
|
|||||||
@@ -21,16 +21,20 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
import forge.card.FormatCollection;
|
import forge.card.FormatCollection;
|
||||||
|
import forge.card.SealedProductTemplate;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.item.BoosterPack;
|
import forge.item.BoosterPack;
|
||||||
@@ -521,8 +525,6 @@ public final class QuestUtilCards {
|
|||||||
qc.getFormat().getFilterPrinted());
|
qc.getFormat().getFilterPrinted());
|
||||||
}
|
}
|
||||||
|
|
||||||
final BoosterGenerator pack = new BoosterGenerator(cardList);
|
|
||||||
|
|
||||||
int nLevel = this.qc.getAchievements().getLevel();
|
int nLevel = this.qc.getAchievements().getLevel();
|
||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
@@ -537,8 +539,13 @@ public final class QuestUtilCards {
|
|||||||
final int winPacks = this.qc.getAchievements().getWin() / winsForPack;
|
final int winPacks = this.qc.getAchievements().getWin() / winsForPack;
|
||||||
final int totalPacks = Math.min(levelPacks + winPacks, maxPacks);
|
final int totalPacks = Math.min(levelPacks + winPacks, maxPacks);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
SealedProductTemplate template = new SealedProductTemplate(Lists.newArrayList(
|
||||||
|
Pair.of("Commmon", common), Pair.of("uncommmon", uncommon), Pair.of("Rare", rare)
|
||||||
|
));
|
||||||
|
|
||||||
for (int i = 0; i < totalPacks; i++) {
|
for (int i = 0; i < totalPacks; i++) {
|
||||||
this.qa.getShopList().addAllFlat(pack.getBoosterPack(common, uncommon, rare, 0, 0, 0, 0, 0, 0));
|
this.qa.getShopList().addAllFlat(BoosterGenerator.getBoosterPack(template, cardList));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.generateBoostersInShop(totalPacks);
|
this.generateBoostersInShop(totalPacks);
|
||||||
@@ -631,7 +638,7 @@ public final class QuestUtilCards {
|
|||||||
|
|
||||||
public int getCompletionPercent(String edition) {
|
public int getCompletionPercent(String edition) {
|
||||||
// get all cards in the specified edition
|
// get all cards in the specified edition
|
||||||
Predicate<CardPrinted> filter = IPaperCard.Predicates.printedInSets(edition);
|
Predicate<CardPrinted> filter = IPaperCard.Predicates.printedInSet(edition);
|
||||||
Iterable<CardPrinted> editionCards = Iterables.filter(CardDb.instance().getAllCards(), filter);
|
Iterable<CardPrinted> editionCards = Iterables.filter(CardDb.instance().getAllCards(), filter);
|
||||||
|
|
||||||
ItemPool<CardPrinted> ownedCards = qa.getCardPool();
|
ItemPool<CardPrinted> ownedCards = qa.getCardPool();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.google.common.collect.Iterables;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.UnOpenedProduct;
|
import forge.card.UnOpenedProduct;
|
||||||
import forge.gui.CardListViewer;
|
import forge.gui.CardListViewer;
|
||||||
@@ -184,21 +184,21 @@ public class QuestUtilUnlockSets {
|
|||||||
*/
|
*/
|
||||||
public static void doUnlock(QuestController qData, final CardEdition unlockedSet) {
|
public static void doUnlock(QuestController qData, final CardEdition unlockedSet) {
|
||||||
|
|
||||||
IStorageView<BoosterData> starters = Singletons.getModel().getTournamentPacks();
|
IStorageView<BoosterTemplate> starters = Singletons.getModel().getTournamentPacks();
|
||||||
IStorageView<BoosterData> boosters = Singletons.getModel().getBoosters();
|
IStorageView<BoosterTemplate> boosters = Singletons.getModel().getBoosters();
|
||||||
qData.getFormat().unlockSet(unlockedSet.getCode());
|
qData.getFormat().unlockSet(unlockedSet.getCode());
|
||||||
|
|
||||||
List<CardPrinted> cardsWon = new ArrayList<CardPrinted>();
|
List<CardPrinted> cardsWon = new ArrayList<CardPrinted>();
|
||||||
|
|
||||||
if (starters.contains(unlockedSet.getCode())) {
|
if (starters.contains(unlockedSet.getCode())) {
|
||||||
UnOpenedProduct starter = new UnOpenedProduct(starters.get(unlockedSet.getCode()));
|
UnOpenedProduct starter = new UnOpenedProduct(starters.get(unlockedSet.getCode()));
|
||||||
cardsWon.addAll(starter.open());
|
cardsWon.addAll(starter.get());
|
||||||
}
|
}
|
||||||
else if (boosters.contains(unlockedSet.getCode())) {
|
else if (boosters.contains(unlockedSet.getCode())) {
|
||||||
UnOpenedProduct booster = new UnOpenedProduct(boosters.get(unlockedSet.getCode()));
|
UnOpenedProduct booster = new UnOpenedProduct(boosters.get(unlockedSet.getCode()));
|
||||||
cardsWon.addAll(booster.open());
|
cardsWon.addAll(booster.get());
|
||||||
cardsWon.addAll(booster.open());
|
cardsWon.addAll(booster.get());
|
||||||
cardsWon.addAll(booster.open());
|
cardsWon.addAll(booster.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
qData.getCards().addAllCards(cardsWon);
|
qData.getCards().addAllCards(cardsWon);
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ public class TextUtil {
|
|||||||
return splitWithParenthesis(input, delimiter, Integer.MAX_VALUE, openPar, closePar, true);
|
return splitWithParenthesis(input, delimiter, Integer.MAX_VALUE, openPar, closePar, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] splitWithParenthesis(CharSequence input, char delimiter, char openPar, char closePar, int limit) {
|
||||||
|
return splitWithParenthesis(input, delimiter, limit, openPar, closePar, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split string separated by a single char delimiter, can take parenthesis in account
|
* Split string separated by a single char delimiter, can take parenthesis in account
|
||||||
* It's faster than String.split, and allows parenthesis
|
* It's faster than String.split, and allows parenthesis
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import forge.card.BoosterData;
|
import forge.card.BoosterTemplate;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.limited.IBoosterDraft;
|
import forge.game.limited.IBoosterDraft;
|
||||||
@@ -49,9 +49,8 @@ public class BoosterDraftTest implements IBoosterDraft {
|
|||||||
@Override
|
@Override
|
||||||
public ItemPoolView<CardPrinted> nextChoice() {
|
public ItemPoolView<CardPrinted> nextChoice() {
|
||||||
this.n--;
|
this.n--;
|
||||||
BoosterData booster = Singletons.getModel().getBoosters().get("M11");
|
BoosterTemplate booster = Singletons.getModel().getBoosters().get("M11");
|
||||||
final BoosterGenerator pack = new BoosterGenerator(booster.getEditionFilter());
|
return ItemPool.createFrom(BoosterGenerator.getBoosterPack(booster), CardPrinted.class);
|
||||||
return ItemPool.createFrom(pack.getBoosterPack(booster), CardPrinted.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|||||||
Reference in New Issue
Block a user