Minimizes magic numbers.
{verbs: [], action: [goto, LOC_Y2]},
]
+# Starting locations of dwarves.
+# Sixth dwarf is special (the pirate). He always starts at his
+# chest's eventual location inside the maze.
+dwarflocs: [
+ LOC_KINGHALL,
+ LOC_WESTBANK,
+ LOC_Y2,
+ LOC_ALIKE3,
+ LOC_COMPLEX,
+ LOC_MAZEEND12,
+]
+
arbitrary_messages: !!omap
- NO_MESSAGE: !!null
- CAVE_NEARBY: |-
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
+#include <assert.h>
#include "advent.h"
};
struct game_t game = {
- .dwarves[1].loc = LOC_KINGHALL,
- .dwarves[2].loc = LOC_WESTBANK,
- .dwarves[3].loc = LOC_Y2,
- .dwarves[4].loc = LOC_ALIKE3,
- .dwarves[5].loc = LOC_COMPLEX,
-
- /* Sixth dwarf is special (the pirate). He always starts at his
+ /* Last dwarf is special (the pirate). He always starts at his
* chest's eventual location inside the maze. This loc is saved
* in chloc for ref. The dead end in the other maze has its
* loc stored in chloc2. */
- .dwarves[6].loc = LOC_MAZEEND12,
.chloc = LOC_MAZEEND12,
.chloc2 = LOC_DEADEND13,
.abbnum = 5,
int seedval = (int)rand();
set_seed(seedval);
+ assert(NDWARVES == NDWARFLOCS);
+ for (int i = 1; i <= NDWARFLOCS; i++) {
+ game.dwarves[i].loc = dwarflocs[i-1];
+ }
+
for (int i = 1; i <= NOBJECTS; i++) {
game.objects[i].place = LOC_NOWHERE;
}
tkeys=bigdump(tkey),
travel=get_travel(travel),
ignore=ignore,
+ dwarflocs=", ".join(db["dwarflocs"]) + ",",
)
# 0-origin index of birds's last song. Bird should
motions=get_refs(db["motions"]),
actions=get_refs(db["actions"]),
state_definitions=statedefines,
+ ndwarflocs=str(len(db["dwarflocs"])),
)
with open(H_NAME, "w", encoding="ascii", errors="surrogateescape") as hf:
const char *ignore = "{ignore}";
+/* Dwarf starting locations */
+const int dwarflocs[NDWARFLOCS] = {{{dwarflocs}}};
+
/* end */
#define COND_HOGRE 20 /* Trying to deal with ogre */
#define COND_HJADE 21 /* Found all treasures except jade */
+/* Count of dwarf starting locations */
+#define NDWARFLOCS {ndwarflocs}
+extern const int dwarflocs[NDWARFLOCS];
+
typedef struct {{
const char** strs;
const int n;