}
}
+static int seed(verb_t verb, const char *arg)
+/* Set seed */
+{
+ long seed = atol(arg);
+ speak(actions[verb].message, arg);
+ set_seed(seed);
+ --game.turns;
+ return GO_TOP;
+}
+
+static int waste(verb_t verb, turn_t turns)
+/* Burn turns */
+{
+ game.limit -= turns;
+ char newlim[1024];
+ sprintf(newlim, "%ld", (long)game.limit);
+ speak(actions[verb].message, newlim);
+ return GO_TOP;
+}
+
static int wave(verb_t verb, obj_t obj)
/* Wave. No effect unless waving rod at fissure or at bird. */
{
return listen();
case PART:
return reservoir();
+ case SEED:
+ case WASTE:
+ rspeak(NUMERIC_REQUIRED);
+ return GO_TOP;
default: // LCOV_EXCL_LINE
BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
}
}
case PART:
return reservoir();
+ case SEED:
+ return seed(command->verb, command->raw2);
+ case WASTE:
+ return waste(command->verb, (turn_t)atol(command->raw2));
default: // LCOV_EXCL_LINE
BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
}
enum speechpart {unknown, intransitive, transitive};
-enum wordtype {NO_WORD_TYPE, MOTION, OBJECT, ACTION, SPECIAL};
+enum wordtype {NO_WORD_TYPE, MOTION, OBJECT, ACTION, SPECIAL, NUMERIC};
typedef enum scorebonus {none, splatter, defeat, victory} score_t;
- GO_UNNEEDED: |-
You don't have to say "go" every time; just specify a direction or, if
it's nearby, name the place to which you wish to move.
+- NUMERIC_REQUIRED:
+ This command requires a numeric argument.
classes:
- threshold: 0
- PART:
message: *nothing_happens
words: ['z''zzz']
+- SEED:
+ message: 'Seed set to %s'
+ words: ['seed']
+- WASTE:
+ message: 'Game limit is now %s'
+ words: ['waste']
- ACT_UNKNOWN:
message: *huh_man
words: !!null
terminate(quitgame);
}
-static bool fallback_handler(struct command_t command)
-/* fallback handler for commands not handled by FORTRANish parser */
-{
- long sv;
- turn_t turnlimit;
- char buf[DIM(command.raw1) + DIM(command.raw2) + 1];
- sprintf(buf, "%s %s", command.raw1, command.raw2);
-
- if (sscanf(buf, "seed %ld", &sv) == 1) {
- set_seed(sv);
- printf("Seed set to %ld\n", sv);
- // autogenerated, so don't charge user time for it.
- --game.turns;
- return true;
- } else if (sscanf(buf, "waste %ld", &turnlimit) == 1) {
- game.limit -= turnlimit;
- printf("Game limit is now %ld\n", game.limit);
- return true;
- }
- return false;
-}
-
/* Check if this loc is eligible for any hints. If been here long
* enough, display. Ignore "HINTS" < 4 (special stuff, see database
* notes). */
rspeak(GO_UNNEEDED);
}
if (command.id1 == WORD_NOT_FOUND) {
- if (fallback_handler(command))
- continue;
/* Gee, I don't understand. */
sspeak(DONT_KNOW, command.raw1);
goto Lclearobj;
command.obj = command.id1;
break;
case ACTION:
- command.part = intransitive;
+ if(command.type2 == NUMERIC)
+ command.part = transitive;
+ else
+ command.part = intransitive;
command.verb = command.id1;
break;
case SPECIAL:
speak(specials[command.id1].message);
goto Lclearobj;
+ case NUMERIC:
default: // LCOV_EXCL_LINE
BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
}
return (WORD_NOT_FOUND);
}
+static bool is_valid_int(const char *str)
+/* Returns true if the string passed in is represents a valid integer,
+ * that could then be parsed by atoi() */
+{
+ // Handle negative number
+ if (*str == '-')
+ ++str;
+
+ // Handle empty string or just "-"
+ if (!*str)
+ return false;
+
+ // Check for non-digit chars in the rest of the stirng.
+ while (*str)
+ {
+ if (!isdigit(*str))
+ return false;
+ else
+ ++str;
+ }
+
+ return true;
+}
+
static void get_vocab_metadata(const char* word, vocab_t* id, enum wordtype* type)
{
/* Check for an empty string */
return;
}
+ // Check words that are actually numbers.
+ if (is_valid_int(word)) {
+ *id = WORD_EMPTY;
+ *type = NUMERIC;
+ return;
+ }
+
*id = WORD_NOT_FOUND;
*type = NO_WORD_TYPE;
return;
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
Dwarf's axe
> waste 2443
+
Game limit is now 30
You're in Hall of Mists.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1071883378
+
Seed set to 1071883378
You're in front of building.
down a gully.
> seed 1495951709
+
Seed set to 1495951709
You're in front of building.
down a gully.
> seed 1495774850
+
Seed set to 1495774850
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 18084731
+
Seed set to 18084731
You're in front of building.
down a gully.
> seed 1495951709
+
Seed set to 1495951709
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1494912171
+
Seed set to 1494912171
You're in front of building.
down a gully.
> seed 383847
+
Seed set to 383847
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 25508795
+
Seed set to 25508795
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 25508795
+
Seed set to 25508795
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 1495951709
+
Seed set to 1495951709
You're in front of building.
down a gully.
> seed 1495774850
+
Seed set to 1495774850
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1951269982
+
Seed set to 1951269982
You're in front of building.
down a gully.
> seed 1495951709
+
Seed set to 1495951709
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
You're in front of building.
+> seed
+
+This command requires a numeric argument.
+
+You're in front of building.
+
+> waste
+
+This command requires a numeric argument.
+
+You are standing at the end of a road before a small brick building.
+Around you is a forest. A small stream flows out of the building and
+down a gully.
+
> eat grate
I see no grate here.
> building
-You are standing at the end of a road before a small brick building.
-Around you is a forest. A small stream flows out of the building and
-down a gully.
+You're in front of building.
> cave
> score
-You have garnered 27 out of a possible 430 points, using 113 turns.
+You have garnered 27 out of a possible 430 points, using 115 turns.
> z
> score
-You have garnered 27 out of a possible 430 points, using 115 turns.
+You have garnered 27 out of a possible 430 points, using 117 turns.
> quit keys
OK
-You scored 27 out of a possible 430, using 123 turns.
+You scored 27 out of a possible 430, using 125 turns.
You are obviously a rank amateur. Better luck next time.
say grate
_
back
+seed
+waste
eat grate
eat building
in
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1495951709
+
Seed set to 1495951709
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1071883378
+
Seed set to 1071883378
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 25508795
+
Seed set to 25508795
You're in front of building.
down a gully.
> seed 437547289
+
Seed set to 437547289
You're in front of building.
> seed 1071883378
+
Seed set to 1071883378
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1837473132
+
Seed set to 1837473132
You're in front of building.
down a gully.
> seed 1830473132
+
Seed set to 1830473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 780351908
+
Seed set to 780351908
You're in front of building.
down a gully.
> seed 1495951709
+
Seed set to 1495951709
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1495774850
+
Seed set to 1495774850
You're in front of building.
down a gully.
> seed 1240742801
+
Seed set to 1240742801
You're in front of building.
down a gully.
> seed 1240742801
+
Seed set to 1240742801
You're in front of building.
down a gully.
> seed 1240742801
+
Seed set to 1240742801
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
There is an enormous clam here with its shell tightly closed.
> seed 1635997320
+
Seed set to 1635997320
You're in Shell Room.
down a gully.
> seed 1951269982
+
Seed set to 1951269982
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1071883378
+
Seed set to 1071883378
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1951269982
+
Seed set to 1951269982
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 1838473132
+
Seed set to 1838473132
You're in front of building.
down a gully.
> seed 183847312
+
Seed set to 183847312
You're in front of building.
down a gully.
> seed 694608006
+
Seed set to 694608006
You're in front of building.
down a gully.
> seed 1071883378
+
Seed set to 1071883378
You're in front of building.
down a gully.
> seed 1635997320
+
Seed set to 1635997320
You're in front of building.
down a gully.
> seed 2099333241
+
Seed set to 2099333241
You're in front of building.