projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement and document state-changes messages in YAML.
[open-adventure.git]
/
actions.c
diff --git
a/actions.c
b/actions.c
index d2eb46ba2320f76f449c5a3a5a60f2a52e2a9272..c79a66680da59b391e06b7967eb1a7defb15f6c1 100644
(file)
--- a/
actions.c
+++ b/
actions.c
@@
-6,6
+6,12
@@
static int fill(token_t, token_t);
static int fill(token_t, token_t);
+static void state_change(long obj, long state)
+{
+ game.prop[obj] = state;
+ pspeak(obj, change, state);
+}
+
static int attack(FILE *input, struct command_t *command)
/* Attack. Assume target if unambiguous. "Throw" also links here.
* Attackable objects fall into two categories: enemies (snake,
static int attack(FILE *input, struct command_t *command)
/* Attack. Assume target if unambiguous. "Throw" also links here.
* Attackable objects fall into two categories: enemies (snake,
@@
-14,7
+20,7
@@
static int attack(FILE *input, struct command_t *command)
{
vocab_t verb = command->verb;
vocab_t obj = command->obj;
{
vocab_t verb = command->verb;
vocab_t obj = command->obj;
-
int
spk = actions[verb].message;
+
long
spk = actions[verb].message;
if (obj == 0 || obj == INTRANSITIVE) {
if (atdwrf(game.loc) > 0)
obj = DWARF;
if (obj == 0 || obj == INTRANSITIVE) {
if (atdwrf(game.loc) > 0)
obj = DWARF;
@@
-456,8
+462,7
@@
static int extinguish(token_t verb, int obj)
game.prop[URN] = game.prop[URN] / 2;
spk = URN_DARK;
} else if (obj == LAMP) {
game.prop[URN] = game.prop[URN] / 2;
spk = URN_DARK;
} else if (obj == LAMP) {
- game.prop[LAMP] = LAMP_DARK;
- rspeak(LAMP_OFF);
+ state_change(LAMP, LAMP_DARK);
spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
} else if (obj == DRAGON || obj == VOLCANO)
spk = BEYOND_POWER;
spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
} else if (obj == DRAGON || obj == VOLCANO)
spk = BEYOND_POWER;
@@
-663,8
+668,7
@@
static int light(token_t verb, token_t obj)
rspeak(spk);
return GO_CLEAROBJ;
}
rspeak(spk);
return GO_CLEAROBJ;
}
- game.prop[LAMP] = LAMP_BRIGHT;
- rspeak(LAMP_ON);
+ state_change(LAMP, LAMP_BRIGHT);
if (game.wzdark)
return GO_TOP;
else
if (game.wzdark)
return GO_TOP;
else
@@
-737,8
+741,8
@@
static int lock(token_t verb, token_t obj)
if (!game.panic)game.clock2 = PANICTIME;
game.panic = true;
} else {
if (!game.panic)game.clock2 = PANICTIME;
game.panic = true;
} else {
-
game.prop[GRATE] = (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN
;
-
spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED
;
+
state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN)
;
+
return GO_CLEAROBJ
;
}
}
}
}
}
}
@@
-1138,7
+1142,7
@@
int action(FILE *input, struct command_t *command)
case PART:
return reservoir();
default:
case PART:
return reservoir();
default:
- BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
+ BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
// LCOV_EXCL_LINE
}
}
/* FALLTHRU */
}
}
/* FALLTHRU */
@@
-1235,13
+1239,13
@@
int action(FILE *input, struct command_t *command)
case PART:
return reservoir();
default:
case PART:
return reservoir();
default:
- BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
+ BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST);
// LCOV_EXCL_LINE
}
case unknown:
/* Unknown verb, couldn't deduce object - might need hint */
rspeak(WHAT_DO, command->wd1, command->wd1x);
return GO_CHECKHINT;
default:
}
case unknown:
/* Unknown verb, couldn't deduce object - might need hint */
rspeak(WHAT_DO, command->wd1, command->wd1x);
return GO_CHECKHINT;
default:
- BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN);
+ BUG(SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN);
// LCOV_EXCL_LINE
}
}
}
}