forked from External/mage
Adding in Jumpstart Custom
This commit is contained in:
parent
c381ea7716
commit
1e428105d5
9 changed files with 223 additions and 84 deletions
|
|
@ -1,5 +1,8 @@
|
|||
package mage.game.jumpstart;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.CharSource;
|
||||
import com.google.common.io.Resources;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.security.SecureRandom;
|
||||
|
|
@ -7,11 +10,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.CharSource;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardInfo;
|
||||
|
|
@ -20,7 +18,7 @@ import mage.game.GameException;
|
|||
|
||||
public class JumpstartPoolGenerator {
|
||||
|
||||
/**
|
||||
/**
|
||||
* "Jumpstart is a new way to play Magic that mashes together themes from throughout the history of the game and
|
||||
* lets you skip the deckbuilding part. Grab two boosters, shuffle them into a 40-card deck, and start playing.
|
||||
* The set contains almost 500 reprints but also introduces 37 new cards that were designed to help fill out some
|
||||
|
|
@ -30,7 +28,7 @@ public class JumpstartPoolGenerator {
|
|||
* symbol, while new cards and other reprints will have the Jumpstart symbol. Reprints have a Post-M15 card frame.
|
||||
* The new cards and cards with new art are numbered #1/78 to #78/78 (40 basic lands, TBA common, TBA uncommon,
|
||||
* TBA rare, and TBA mythic rare). The other reprints with the Jumpstart expansion symbol are numbered #79 to 495."
|
||||
*
|
||||
*
|
||||
* "Jumpstart is sold in 20-card boosters, and booster boxes contain 24 boosters.[9] All 20 cards in a booster fit a
|
||||
* theme, and most themes are mono-color and have multiple variations of cards included in the pack, totaling 121
|
||||
* different possible pack contents. Special "Mythic Rare" packs don't have variations at all, but just one possible
|
||||
|
|
@ -42,46 +40,64 @@ public class JumpstartPoolGenerator {
|
|||
* themed land art created for the set. The booster pack is wrapped like a regular pack, but the set of cards is
|
||||
* packed in an additional plastic wrap, with a face card (the "Pack Summary card") that indicates the theme and
|
||||
* the color of the half-deck."
|
||||
*
|
||||
* Source: https://mtg.gamepedia.com/Jumpstart
|
||||
*
|
||||
*
|
||||
* Source: https://mtg.gamepedia.com/Jumpstart
|
||||
*
|
||||
* Announcement: https://magic.wizards.com/en/articles/archive/news/introducing-jumpstart-new-way-play-magic-2020-02-20
|
||||
* Card Pool: https://magic.wizards.com/en/articles/archive/card-image-gallery/jumpstart
|
||||
* Deck Lists: https://magic.wizards.com/en/articles/archive/feature/jumpstart-decklists-2020-06-18
|
||||
*/
|
||||
*/
|
||||
private static final String RESOURCE_NAME = "jumpstart/jumpstart.txt";
|
||||
private static List<JumpstartPack> JUMPSTART_PACKS;
|
||||
|
||||
private static final String RESOURCE_NAME = "jumpstart/jumpstart.txt";
|
||||
private static final List<JumpstartPack> JUMPSTART_PACKS;
|
||||
|
||||
static {
|
||||
try {
|
||||
CharSource source = Resources.asCharSource(Resources.getResource(RESOURCE_NAME), Charsets.UTF_8);
|
||||
List<JumpstartPack> packs = new ArrayList<>();
|
||||
JumpstartPack pack = new JumpstartPack();
|
||||
packs.add(pack);
|
||||
for (String line : source.readLines()) {
|
||||
if (line.isEmpty()) {
|
||||
if (!pack.isEmpty()) {
|
||||
pack = new JumpstartPack();
|
||||
private static void setupPacks(String jumpstartPacks, boolean useDefault) {
|
||||
try {
|
||||
CharSource source;
|
||||
if (useDefault) {
|
||||
source = Resources.asCharSource(Resources.getResource(RESOURCE_NAME), Charsets.UTF_8);
|
||||
} else {
|
||||
source = CharSource.wrap(jumpstartPacks);
|
||||
}
|
||||
List<JumpstartPack> packs = new ArrayList<>();
|
||||
JumpstartPack pack = new JumpstartPack();
|
||||
packs.add(pack);
|
||||
}
|
||||
} else if (line.startsWith("#")) {
|
||||
// skip comment
|
||||
} else {
|
||||
String[] ls = line.split(" ", 4);
|
||||
int quantity = Integer.parseInt(ls[0]);
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
pack.add(new DeckCardInfo(ls[3], ls[2], ls[1]));
|
||||
}
|
||||
for (String line : source.readLines()) {
|
||||
if (line.isEmpty()) {
|
||||
if (!pack.isEmpty()) {
|
||||
pack = new JumpstartPack();
|
||||
packs.add(pack);
|
||||
}
|
||||
} else if (line.startsWith("#")) {
|
||||
// skip comment
|
||||
} else {
|
||||
String[] ls = line.split(" ", 4);
|
||||
int quantity = Integer.parseInt(ls[0]);
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
pack.add(new DeckCardInfo(ls[3], ls[2], ls[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
JUMPSTART_PACKS = Collections.unmodifiableList(packs);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
JUMPSTART_PACKS = Collections.unmodifiableList(packs);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* Notes
|
||||
private static Set<Card> doGeneratePool() {
|
||||
try {
|
||||
DeckCardLists list = new DeckCardLists();
|
||||
SecureRandom random = new SecureRandom();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int index = random.nextInt(JUMPSTART_PACKS.size());
|
||||
list.getCards().addAll(JUMPSTART_PACKS.get(index).getCards());
|
||||
}
|
||||
return Deck.load(list, false, false).getCards();
|
||||
} catch (GameException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* Notes
|
||||
*
|
||||
* 1) the pools generated by this method are for how the prerelease will be played (see https://mtg.gamepedia.com/Jumpstart#Events)
|
||||
* In order to support the 4 pack version, xmage would need to support editing multiple decks and some Duo format
|
||||
|
|
@ -93,37 +109,33 @@ public class JumpstartPoolGenerator {
|
|||
*
|
||||
* 3) this does not attempt to add an additional rare 1/3 of the time as described here:
|
||||
* https://mtg.gamepedia.com/Jumpstart#Marketing
|
||||
*/
|
||||
public static Set<Card> generatePool() {
|
||||
try {
|
||||
DeckCardLists list = new DeckCardLists();
|
||||
SecureRandom random = new SecureRandom();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int index = random.nextInt(JUMPSTART_PACKS.size());
|
||||
list.getCards().addAll(JUMPSTART_PACKS.get(index).getCards());
|
||||
}
|
||||
return Deck.load(list, false, false).getCards();
|
||||
} catch (GameException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class JumpstartPack {
|
||||
|
||||
private final List<DeckCardInfo> cards = new ArrayList<>();
|
||||
|
||||
public void add(DeckCardInfo card) {
|
||||
cards.add(card);
|
||||
*/
|
||||
public static Set<Card> generatePool() {
|
||||
setupPacks("", true);
|
||||
return doGeneratePool();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return cards.isEmpty();
|
||||
public static Set<Card> generatePool(String userJumpstartPacks) {
|
||||
setupPacks(userJumpstartPacks, false);
|
||||
return doGeneratePool();
|
||||
}
|
||||
|
||||
public List<DeckCardInfo> getCards() {
|
||||
return Collections.unmodifiableList(cards);
|
||||
}
|
||||
public static class JumpstartPack {
|
||||
|
||||
}
|
||||
private final List<DeckCardInfo> cards = new ArrayList<>();
|
||||
|
||||
public void add(DeckCardInfo card) {
|
||||
cards.add(card);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return cards.isEmpty();
|
||||
}
|
||||
|
||||
public List<DeckCardInfo> getCards() {
|
||||
return Collections.unmodifiableList(cards);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue