add some methods to Logic for future Command class

svn-id: r10965
This commit is contained in:
Gregory Montoir 2003-10-25 20:26:50 +00:00
parent 6929b9dd7b
commit 060300339e
4 changed files with 57 additions and 6 deletions

View File

@ -116,7 +116,10 @@ enum Verb {
VERB_DIGIT_LAST = 16,
VERB_USE_JOURNAL = 20,
VERB_SKIP_TEXT = 101
VERB_SKIP_TEXT = 101,
VERB_PREP_WITH = 11,
VERB_PREP_TO = 12
};
@ -140,6 +143,12 @@ enum StateOn {
};
enum StateUse {
STATE_USE,
STATE_USE_ON
};
} // End of namespace Queen
#endif

View File

@ -116,6 +116,11 @@ Verb State::findDefaultVerb(uint16 state) {
}
StateUse State::findUse(uint16 state) {
return (state & (1 << 10)) ? STATE_USE : STATE_USE_ON;
}
void State::alterOn(uint16 *objState, StateOn state) {
switch (state) {
case STATE_ON_ON:
@ -1926,6 +1931,36 @@ Verb Logic::findVerb(int16 cursorx, int16 cursory) const {
}
uint16 Logic::findObjectFromZone(uint16 zoneNum) {
// l.316-327 select.c
uint16 noun = zoneNum;
uint16 objectMax = _objMax[_currentRoom];
if (zoneNum > objectMax) {
// this is an area box, check for associated object
uint16 obj = _area[_currentRoom][zoneNum - objectMax].object;
if (obj != 0) {
// there is an object, get its number
noun = obj - _roomData[_currentRoom];
}
}
return noun;
}
const char *Logic::verbName(Verb v) const {
if (v != VERB_NONE && v < 13) {
return _verbName[v];
}
else {
error("Logic::verbName() - Invalid verb %d", v);
return NULL;
}
}
void Logic::update() {
_graphics->update(_currentRoom);
_input->delay();

View File

@ -75,6 +75,8 @@ struct State {
//! FIND_STATE(state, "DEF");
static Verb findDefaultVerb(uint16 state);
static StateUse findUse(uint16 state);
//! ALTER_STATE(state, "ON");
static void alterOn(uint16 *objState, StateOn state);
@ -121,6 +123,7 @@ public:
uint16 currentRoomAreaMax();
uint16 walkOffCount();
WalkOffData *walkOffData(int index);
uint16 currentRoomObjMax() const { return _objMax[_currentRoom]; }
uint16 joeFacing() { return _joe.facing; }
uint16 joeX() { return _joe.x; }
@ -214,6 +217,10 @@ public:
Walk *walk() { return _walk; }
Display *display() { return _display; }
uint16 findObjectFromZone(uint16 zoneNum);
const char *verbName(Verb v) const;
void update();
protected:

View File

@ -31,13 +31,11 @@ SELECT_VERB() Command::grabSelectedVerb
ACTION,ACTION2 Command::_action*
CLEVEL Command::_commandLevel
COMMANDstr Command::_command
DEFCOMM
OLDVERB,VERB
OLDNOUN,NOUN,NOUN2
DEFCOMM Command::_defaultVerb
OLDVERB,VERB Command::_*verb*
OLDNOUN,NOUN,NOUN2 Command::_*old*
PARSE Command::_parse
SUBJ1,SUBJ2,SUBJECT Command::_subject*
TEMPstr
WORDstr
CREDIT SCRIPTING SYSTEM
@ -487,3 +485,5 @@ Pstr // not needed, FIND_STATE result
OUTLINE // not needed, textSet() Graphics::parameter
FTOT // queen.c/SETUP_FURNITURE local var
OBJMAXv // == Logic::_objMax[Logic::_currentRoom]
TEMPstr
WORDstr