Added test
This commit is contained in:
@@ -72,8 +72,9 @@ public class DraftChoiceBuilder {
|
||||
public CardCollection getCardsForChoiceId(String choiceId, long seed, int stage) {
|
||||
List<String> cardIds = cardsMap.get(choiceId);
|
||||
DefaultCardCollection cardCollection = new DefaultCardCollection();
|
||||
for (String cardId : cardIds)
|
||||
cardCollection.addItem(cardId, 1);
|
||||
if (cardIds != null)
|
||||
for (String cardId : cardIds)
|
||||
cardCollection.addItem(cardId, 1);
|
||||
|
||||
return cardCollection;
|
||||
}
|
||||
@@ -95,7 +96,7 @@ public class DraftChoiceBuilder {
|
||||
final List<String> shuffledCards = getShuffledCards(seed, stage);
|
||||
|
||||
List<SoloDraft.DraftChoice> draftableCards = new ArrayList<SoloDraft.DraftChoice>(count);
|
||||
for (int i=0; i<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final int finalI = i;
|
||||
draftableCards.add(
|
||||
new SoloDraft.DraftChoice() {
|
||||
@@ -122,10 +123,11 @@ public class DraftChoiceBuilder {
|
||||
public CardCollection getCardsForChoiceId(String choiceId, long seed, int stage) {
|
||||
List<String> shuffledCards = getShuffledCards(seed, stage);
|
||||
|
||||
for (int i=0; i<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (shuffledCards.get(i).equals(choiceId)) {
|
||||
DefaultCardCollection result = new DefaultCardCollection();
|
||||
result.addItem(choiceId, 1);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gempukku.lotro.draft2;
|
||||
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SoloDraftDefinitionsTest {
|
||||
@Test
|
||||
public void loadSoloDraftDefinitions() {
|
||||
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void playerDrafting() {
|
||||
SoloDraftDefinitions soloDraftDefinitions = new SoloDraftDefinitions();
|
||||
SoloDraft soloDraft = soloDraftDefinitions.getSoloDraft("hobbit_draft");
|
||||
assertTrue(soloDraft.hasNextStage(0, 0));
|
||||
Iterable<SoloDraft.DraftChoice> availableChoices = soloDraft.getAvailableChoices(0, 0);
|
||||
String choiceId = availableChoices.iterator().next().getChoiceId();
|
||||
|
||||
CardCollection firstPickCards = soloDraft.getCardsForChoiceId(choiceId, 0, 0);
|
||||
assertFalse(firstPickCards.getAll().isEmpty());
|
||||
|
||||
assertTrue(soloDraft.getCardsForChoiceId("madeUpChoiceId", 0, 0).getAll().isEmpty());
|
||||
|
||||
assertTrue(soloDraft.hasNextStage(0, 1));
|
||||
Iterable<SoloDraft.DraftChoice> secondChoices = soloDraft.getAvailableChoices(0, 1);
|
||||
String secondChoiceId = secondChoices.iterator().next().getChoiceId();
|
||||
|
||||
assertFalse(soloDraft.getCardsForChoiceId(secondChoiceId, 0, 1).getAll().isEmpty());
|
||||
assertTrue(soloDraft.getCardsForChoiceId("madeUpChoiceId", 0, 1).getAll().isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user