mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Adding some foundation for Cogwork Librarian
- It seems like Booster Drafts weren't changing directions for the middle packs?
This commit is contained in:
@@ -102,8 +102,15 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
|
|||||||
// get next booster pack
|
// get next booster pack
|
||||||
this.boosterDraft.setChoice(card);
|
this.boosterDraft.setChoice(card);
|
||||||
|
|
||||||
if (this.boosterDraft.hasNextChoice()) {
|
boolean nextChoice = this.boosterDraft.hasNextChoice();
|
||||||
this.showChoices(this.boosterDraft.nextChoice());
|
ItemPool<PaperCard> pool = null;
|
||||||
|
if (nextChoice) {
|
||||||
|
pool = this.boosterDraft.nextChoice();
|
||||||
|
nextChoice = pool != null && !pool.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextChoice) {
|
||||||
|
this.showChoices(pool);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.saveDraft();
|
this.saveDraft();
|
||||||
@@ -155,27 +162,6 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
|
|||||||
// add sideboard to deck
|
// add sideboard to deck
|
||||||
deck.getOrCreate(DeckSection.Sideboard).addAll(this.getDeckManager().getPool());
|
deck.getOrCreate(DeckSection.Sideboard).addAll(this.getDeckManager().getPool());
|
||||||
|
|
||||||
//no need to add basic lands now that Add Basic Lands button exists
|
|
||||||
/*final String landSet = IBoosterDraft.LAND_SET_CODE[0].getCode();
|
|
||||||
final boolean isZendikarSet = landSet.equals("ZEN"); // we want to generate one kind of Zendikar lands at a time only
|
|
||||||
final boolean zendikarSetMode = MyRandom.getRandom().nextBoolean();
|
|
||||||
|
|
||||||
final int landsCount = 10;
|
|
||||||
|
|
||||||
for(String landName : MagicColor.Constant.BASIC_LANDS) {
|
|
||||||
int numArt = FModel.getMagicDb().getCommonCards().getArtCount(landName, landSet);
|
|
||||||
int minArtIndex = isZendikarSet ? (zendikarSetMode ? 1 : 5) : 1;
|
|
||||||
int maxArtIndex = isZendikarSet ? minArtIndex + 3 : numArt;
|
|
||||||
|
|
||||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_RANDOM_ART_IN_POOLS)) {
|
|
||||||
for (int i = minArtIndex; i <= maxArtIndex; i++) {
|
|
||||||
deck.get(DeckSection.Sideboard).add(landName, landSet, i, numArt > 1 ? landsCount : 30);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
deck.get(DeckSection.Sideboard).add(landName, landSet, 30);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return deck;
|
return deck;
|
||||||
} // getPlayersDeck()
|
} // getPlayersDeck()
|
||||||
|
|
||||||
|
|||||||
@@ -110,11 +110,18 @@ public class CEditorQuestDraftingProcess extends ACEditorBase<PaperCard, DeckGro
|
|||||||
// get next booster pack
|
// get next booster pack
|
||||||
boosterDraft.setChoice(card);
|
boosterDraft.setChoice(card);
|
||||||
|
|
||||||
if (boosterDraft.hasNextChoice()) {
|
boolean nextChoice = this.boosterDraft.hasNextChoice();
|
||||||
showChoices(boosterDraft.nextChoice());
|
ItemPool<PaperCard> pool = null;
|
||||||
|
if (nextChoice) {
|
||||||
|
pool = this.boosterDraft.nextChoice();
|
||||||
|
nextChoice = !pool.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextChoice) {
|
||||||
|
this.showChoices(pool);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
saveDraft();
|
this.saveDraft();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ public class BoosterDraftTest implements IBoosterDraft {
|
|||||||
return this.n > 0;
|
return this.n > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRoundOver() {
|
||||||
|
return hasNextChoice();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getChosenCards.
|
* getChosenCards.
|
||||||
|
|||||||
@@ -1361,6 +1361,8 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
BoosterDraft draft = parentScreen.getDraft();
|
BoosterDraft draft = parentScreen.getDraft();
|
||||||
draft.setChoice(card);
|
draft.setChoice(card);
|
||||||
|
|
||||||
|
// TODO Implement handling of extra boosters
|
||||||
|
|
||||||
if (draft.hasNextChoice()) {
|
if (draft.hasNextChoice()) {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
protected int nextBoosterGroup = 0;
|
protected int nextBoosterGroup = 0;
|
||||||
private int currentBoosterSize = 0;
|
private int currentBoosterSize = 0;
|
||||||
private int currentBoosterPick = 0;
|
private int currentBoosterPick = 0;
|
||||||
|
private int[] draftingBooster;
|
||||||
|
|
||||||
private List<List<PaperCard>> pack; // size 8
|
private List<List<PaperCard>> pack; // size 8
|
||||||
|
|
||||||
/** The draft picks. */
|
/** The draft picks. */
|
||||||
@@ -171,14 +173,6 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
protected BoosterDraft() {
|
protected BoosterDraft() {
|
||||||
this.draftFormat = LimitedPoolType.Full;
|
this.draftFormat = LimitedPoolType.Full;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for BoosterDraft_1.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param draftType
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
*/
|
|
||||||
protected BoosterDraft(final LimitedPoolType draftType) {
|
protected BoosterDraft(final LimitedPoolType draftType) {
|
||||||
this.draftAI.setBd(this);
|
this.draftAI.setBd(this);
|
||||||
this.draftFormat = draftType;
|
this.draftFormat = draftType;
|
||||||
@@ -237,13 +231,26 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CardPool nextChoice() {
|
public CardPool nextChoice() {
|
||||||
if (this.pack.get(this.getCurrentBoosterIndex()).isEmpty()) {
|
if (this.isRoundOver()) {
|
||||||
|
// If all packs are depleted crack 8 new packs
|
||||||
this.pack = this.get8BoosterPack();
|
this.pack = this.get8BoosterPack();
|
||||||
|
if (this.pack == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.computerChoose();
|
this.computerChoose();
|
||||||
|
|
||||||
final CardPool result = new CardPool();
|
final CardPool result = new CardPool();
|
||||||
result.addAllFlat(this.pack.get(this.getCurrentBoosterIndex()));
|
result.addAllFlat(this.pack.get(this.getCurrentBoosterIndex()));
|
||||||
|
|
||||||
|
if (result.isEmpty()) {
|
||||||
|
// Can't set a card, since none are available. Just pass "empty" packs.
|
||||||
|
this.passPacks();
|
||||||
|
// Recur until we find a cardpool or finish
|
||||||
|
return nextChoice();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,55 +274,64 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
this.nextBoosterGroup++;
|
this.nextBoosterGroup++;
|
||||||
this.currentBoosterSize = list.get(0).size();
|
this.currentBoosterSize = list.get(0).size();
|
||||||
this.currentBoosterPick = 0;
|
this.currentBoosterPick = 0;
|
||||||
|
draftingBooster = new int[]{0, 1, 2, 3, 4, 5, 6, 7};
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// size 7, all the computers decks
|
public void addSingleBoosterPack(int player, boolean random) {
|
||||||
|
// TODO Cogwork Librarian
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
// size 7, all the computers decks
|
||||||
* <p>
|
|
||||||
* getDecks.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return an array of {@link forge.deck.Deck} objects.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Deck[] getDecks() {
|
public Deck[] getDecks() {
|
||||||
return this.draftAI.getDecks();
|
return this.draftAI.getDecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void passPacks() {
|
||||||
|
// Alternate direction of pack passing
|
||||||
|
int adjust = this.nextBoosterGroup % 2 == 1 ? 1 : -1;
|
||||||
|
for(int i = 0; i < N_PLAYERS; i++) {
|
||||||
|
draftingBooster[i] = (draftingBooster[i] + adjust + pack.size()) % pack.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void computerChoose() {
|
protected void computerChoose() {
|
||||||
final int iHumansBooster = this.getCurrentBoosterIndex();
|
// Loop through players 1-7 to draft their current pack
|
||||||
int iPlayer = 0;
|
for (int i = 1; i < N_PLAYERS; i++) {
|
||||||
for (int i = 1; i < this.pack.size(); i++) {
|
final List<PaperCard> booster = this.pack.get(this.draftingBooster[i]);
|
||||||
final List<PaperCard> booster = this.pack.get((iHumansBooster + i) % this.pack.size());
|
|
||||||
final PaperCard aiPick = this.draftAI.choose(booster, iPlayer++);
|
// Empty boosters can happen in a Conspiracy draft
|
||||||
booster.remove(aiPick);
|
if (!booster.isEmpty()) {
|
||||||
|
booster.remove(this.draftAI.choose(booster, i-1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // computerChoose()
|
} // computerChoose()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Get the current booster index.
|
* Get the current booster index for the Human
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public int getCurrentBoosterIndex() {
|
public int getCurrentBoosterIndex() {
|
||||||
return this.currentBoosterPick % BoosterDraft.N_PLAYERS;
|
return this.draftingBooster[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* <p>
|
public boolean isRoundOver() {
|
||||||
* hasNextChoice.
|
for(List<PaperCard> singlePack : this.pack) {
|
||||||
* </p>
|
if (!singlePack.isEmpty()) {
|
||||||
*
|
return false;
|
||||||
* @return a boolean.
|
}
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNextChoice() {
|
public boolean hasNextChoice() {
|
||||||
final boolean isLastGroup = this.nextBoosterGroup >= this.product.size();
|
return this.nextBoosterGroup < this.product.size() || !this.isRoundOver();
|
||||||
final boolean isBoosterDepleted = this.currentBoosterPick >= this.currentBoosterSize;
|
|
||||||
final boolean noMoreCards = isLastGroup && isBoosterDepleted;
|
|
||||||
return !noMoreCards;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@@ -355,6 +371,7 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
|
|
||||||
thisBooster.remove(c);
|
thisBooster.remove(c);
|
||||||
this.currentBoosterPick++;
|
this.currentBoosterPick++;
|
||||||
|
this.passPacks();
|
||||||
} // setChoice()
|
} // setChoice()
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public interface IBoosterDraft {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
boolean hasNextChoice();
|
boolean hasNextChoice();
|
||||||
|
boolean isRoundOver();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ public class WinstonDraft extends BoosterDraft {
|
|||||||
return getNextChoice(0) >= 0;
|
return getNextChoice(0) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRoundOver() {
|
||||||
|
return hasNextChoice();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLastPileAndEmptyDeck(final int pile) {
|
public boolean isLastPileAndEmptyDeck(final int pile) {
|
||||||
return this.deck.size() == 0 && getNextChoice(pile+1) >= 0;
|
return this.deck.size() == 0 && getNextChoice(pile+1) >= 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user