Started working on solo draft
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.gempukku.lotro.draft2;
|
||||
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public class DefaultSoloDraft implements SoloDraft {
|
||||
private String _format;
|
||||
private SoloDraftStartingPool _startingPool;
|
||||
private SoloDraftPicks _picks;
|
||||
|
||||
public DefaultSoloDraft(String format, SoloDraftStartingPool startingPool, SoloDraftPicks picks) {
|
||||
_format = format;
|
||||
_startingPool = startingPool;
|
||||
_picks = picks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection initializeNewCollection(long seed) {
|
||||
return _startingPool.getCardCollection(seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection getAvailableChoices(long seed, int stage) {
|
||||
return _picks.getChoices(seed, stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNextStage(long seed, int stage) {
|
||||
return _picks.hasNextStage(seed, stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return _format;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,56 @@
|
||||
package com.gempukku.lotro.draft2;
|
||||
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SoloDraftDefinitions {
|
||||
private Map<String, SoloDraft> draftTypes = new HashMap<String, SoloDraft>();
|
||||
|
||||
public SoloDraftDefinitions(LotroCardBlueprintLibrary library) {
|
||||
try {
|
||||
final InputStreamReader reader = new InputStreamReader(LotroFormatLibrary.class.getResourceAsStream("/lotrDrafts.json"), "UTF-8");
|
||||
try {
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONArray object = (JSONArray) parser.parse(reader);
|
||||
for (Object draftDefObj : object) {
|
||||
String type = (String)((JSONObject) draftDefObj).get("type");
|
||||
String location = (String) ((JSONObject) draftDefObj).get("location");
|
||||
draftTypes.put(type, loadDraft(location));
|
||||
}
|
||||
} catch (ParseException exp) {
|
||||
throw new RuntimeException("Problem loading solo drafts", exp);
|
||||
}
|
||||
} catch (IOException exp) {
|
||||
throw new RuntimeException("Problem loading solo drafts", exp);
|
||||
}
|
||||
}
|
||||
|
||||
private SoloDraft loadDraft(String file) {
|
||||
try {
|
||||
final InputStreamReader reader = new InputStreamReader(LotroFormatLibrary.class.getResourceAsStream(file), "UTF-8");
|
||||
try {
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject object = (JSONObject) parser.parse(reader);
|
||||
String format = (String) object.get("format");
|
||||
return null;
|
||||
} catch (ParseException exp) {
|
||||
throw new RuntimeException("Problem loading solo draft "+file, exp);
|
||||
}
|
||||
} catch (IOException exp) {
|
||||
throw new RuntimeException("Problem loading solo draft "+file, exp);
|
||||
}
|
||||
}
|
||||
|
||||
public SoloDraft getSoloDraft(String draftType) {
|
||||
// TODO
|
||||
return null;
|
||||
return draftTypes.get(draftType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gempukku.lotro.draft2;
|
||||
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
|
||||
public class SoloDraftPicks {
|
||||
public CardCollection getChoices(long seed, int stage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasNextStage(long seed, int stage) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"format": "limited_hobbit",
|
||||
"startingPool": [
|
||||
{
|
||||
"type": "random",
|
||||
"data": [
|
||||
{
|
||||
"type": "cardPool",
|
||||
"data": [
|
||||
"card1", "card2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "cardPool",
|
||||
"data": [
|
||||
"card1", "card2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"picks": [
|
||||
{
|
||||
"type": "random",
|
||||
"data": [
|
||||
{
|
||||
"type": "sequence",
|
||||
"data": [
|
||||
{
|
||||
"type": "multiple",
|
||||
"data": {
|
||||
"count": 10,
|
||||
"type": "randomPick",
|
||||
"data": ["card1", "card2"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "multiple",
|
||||
"data": {
|
||||
"count": 5,
|
||||
"type": "randomPick",
|
||||
"data": ["card1", "card2"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "sequence",
|
||||
"data": [
|
||||
{
|
||||
"type": "multiple",
|
||||
"data": {
|
||||
"count": 10,
|
||||
"type": "randomPick",
|
||||
"data": ["card1", "card2"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "multiple",
|
||||
"data": {
|
||||
"count": 5,
|
||||
"type": "randomPick",
|
||||
"data": ["card1", "card2"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"type": "Hobbit Draft",
|
||||
"location": "/draft/hobbit.json"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user