Better loading of cards

This commit is contained in:
marcin.sciesinski
2019-09-01 00:41:17 -07:00
parent d0fc13c1c0
commit 17c06c3476
12 changed files with 78 additions and 63 deletions

View File

@@ -0,0 +1,57 @@
{
"40_184": {
"title": "Black Steed",
"subtitle": "Bred to Serve",
"side": "shadow",
"culture": "wraith",
"cost": 1,
"type": "possession",
"possession": "mount",
"strength": 2,
"target": "nazgul",
"effects": {
"type": "modifyStrength",
"filter": "hasAttached(self),inSkirmishAgainst(companion,resistanceLessThan(4))",
"amount": 2
}
},
"40_211": {
"title": "*The Witch-king",
"subtitle": "Greatest of the Nine",
"side": "shadow",
"culture": "wraith",
"cost": 8,
"type": "minion",
"race": "nazgul",
"strength": 14,
"vitality": 4,
"site": 3,
"keyword": "fierce",
"effects": {
"type": "trigger",
"trigger": {
"type": "winsSkirmish",
"filter": "self"
},
"effect": {
"type": "choice",
"player": "fp",
"texts": [
"Exert the Ring-bearer",
"Add a burden"
],
"effects": [
{
"type": "exert",
"player": "fp",
"filter": "choose(ring bearer)"
},
{
"type": "addBurden",
"player": "fp"
}
]
}
}
}
}

View File

@@ -123,60 +123,5 @@
]
}
]
},
"40_184": {
"title": "Black Steed",
"subtitle": "Bred to Serve",
"side": "shadow",
"culture": "wraith",
"cost": 1,
"type": "possession",
"possession": "mount",
"strength": 2,
"target": "nazgul",
"effects": {
"type": "modifyStrength",
"filter": "hasAttached(self),inSkirmishAgainst(companion,resistanceLessThan(4))",
"amount": 2
}
},
"40_211": {
"title": "*The Witch-king",
"subtitle": "Greatest of the Nine",
"side": "shadow",
"culture": "wraith",
"cost": 8,
"type": "minion",
"race": "nazgul",
"strength": 14,
"vitality": 4,
"site": 3,
"keyword": "fierce",
"effects": {
"type": "trigger",
"trigger": {
"type": "winsSkirmish",
"filter": "self"
},
"effect": {
"type": "choice",
"player": "fp",
"texts": [
"Exert the Ring-bearer",
"Add a burden"
],
"effects": [
{
"type": "exert",
"player": "fp",
"filter": "choose(ring bearer)"
},
{
"type": "addBurden",
"player": "fp"
}
]
}
}
}
}

View File

@@ -308,4 +308,6 @@
40S308
40S309
40S310
40S311
40S311
40S312
40S313

View File

@@ -17,9 +17,17 @@ public class ValidateCards {
File path = new File(projectRoot + "/gemp-lotr-async/src/main/web/cards");
processPath(cardBlueprintBuilder, path);
}
private static void processPath(LotroCardBlueprintBuilder cardBlueprintBuilder, File path) {
for (File file : path.listFiles()) {
loadCardsFromFile(cardBlueprintBuilder, file);
System.out.println("Finished loading file: " + file.getName());
if (file.isFile()) {
loadCardsFromFile(cardBlueprintBuilder, file);
System.out.println("Finished loading file: " + file.getName());
} else {
processPath(cardBlueprintBuilder, file);
}
}
}

View File

@@ -83,9 +83,11 @@ public class LotroCardBlueprintLibrary {
}
private void loadCards(File path) {
for (File file : path.listFiles()) {
loadCardsFromFile(file);
}
if (path.isFile())
loadCardsFromFile(path);
else if (path.isDirectory())
for (File file : path.listFiles())
loadCards(file);
}
private void loadCardsFromFile(File file) {
@@ -118,7 +120,7 @@ public class LotroCardBlueprintLibrary {
() -> {
try {
WatchService watcher = FileSystems.getDefault().newWatchService();
WatchKey registrationKey = path.register(watcher,
path.register(watcher,
ENTRY_CREATE,
ENTRY_MODIFY);
@@ -153,7 +155,8 @@ public class LotroCardBlueprintLibrary {
// the resolved name is "test/foo".
Path child = path.resolve(filename);
loadCardsFromFile(child.toFile());
final File file = child.toFile();
loadCards(file);
}
// Reset the key -- this step is critical if you want to