make deck construction more robust
This commit is contained in:
+5
-6
@@ -35,12 +35,8 @@ Potion level: x - 21
|
||||
|
||||
/* Game stats */
|
||||
|
||||
static char deck[] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, /* monster pack 1 (clubs) */
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, /* monster pack 2 (spades) */
|
||||
14, 15, 16, 17, 18, 19, 20, 21, 22, /* weapon pack (diamonds) */
|
||||
23, 24, 25, 26, 27, 28, 29, 30, 31 /* potion pack (hearts) */
|
||||
}, room[] = {0, 0, 0, 0};
|
||||
/* main deck and room */
|
||||
static char deck[44], room[] = {0, 0, 0, 0};
|
||||
|
||||
static short deck_idx = 0, hp = 20,
|
||||
weapon = 0, durability = 0, can_run = 1,
|
||||
@@ -186,6 +182,9 @@ int game() {
|
||||
int last_room = 0, last_room_clr = 0; /* last room markers */
|
||||
char ch;
|
||||
deck_idx = 0; /* reset the deck index */
|
||||
/* Prefill the deck */
|
||||
for(i=0;i<13;i++) deck[i] = deck[i+13] = i+1;
|
||||
for(i=26;i<44;i++) deck[i] = i - 12;
|
||||
/* Shuffle the deck */
|
||||
shuffle(deck, sizeof(deck));
|
||||
/* prepare all other parameters */
|
||||
|
||||
Reference in New Issue
Block a user