Skip to content

Commit

Permalink
WAGE: Implement handleWearCommand()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 14, 2016
1 parent 0237486 commit 42c7440
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
44 changes: 42 additions & 2 deletions engines/wage/script.cpp
Expand Up @@ -1149,6 +1149,8 @@ void Script::handleAimCommand(const char *t) {
bool wasHandled = true;
Common::String target(t);

target.toLowercase();

if (target.contains("head")) {
_callbacks->_aim = Chr::HEAD;
} else if (target.contains("chest")) {
Expand All @@ -1166,10 +1168,48 @@ void Script::handleAimCommand(const char *t) {
_callbacks->_commandWasQuick = true;
}

void Script::handleWearCommand(const char *target) {
warning("STUB: handleWearCommand");
void Script::handleWearCommand(const char *t) {
Chr *player = _world->_player;
char buf[512];
Common::String target(t);

target.toLowercase();

for (ObjArray::const_iterator it = _world->_player->_inventory.begin(); it != _world->_player->_inventory.end(); ++it) {
Common::String n((*it)->_name);

if (target.contains(n)) {
if ((*it)->_type == Obj::HELMET) {
wearObj(*it, Chr::HEAD_ARMOR);
} else if ((*it)->_type == Obj::CHEST_ARMOR) {
wearObj(*it, Chr::BODY_ARMOR);
} else if ((*it)->_type == Obj::SHIELD) {
wearObj(*it, Chr::SHIELD_ARMOR);
} else if ((*it)->_type == Obj::SPIRITUAL_ARMOR) {
wearObj(*it, Chr::MAGIC_ARMOR);
} else {
appendText((char *)"You cannot wear that object.");
}
break;
}
}

for (ObjList::const_iterator it = player->_currentScene->_objs.begin(); it != player->_currentScene->_objs.end(); ++it) {
Common::String n((*it)->_name);
n.toLowercase();
if (target.contains(n)) {
snprintf(buf, 512, "First you must get the %s.", (*it)->_name.c_str());
appendText(buf);
break;
}
}
}

void Script::wearObj(Obj *o, int pos) {
warning("STUB: wearObj()");
}


void Script::handleOfferCommand(const char *target) {
warning("STUB: handleOfferCommand");
}
Expand Down
2 changes: 2 additions & 0 deletions engines/wage/script.h
Expand Up @@ -186,6 +186,8 @@ class Script {
void handleWearCommand(const char *target);
void handleOfferCommand(const char *target);

void wearObj(Obj *o, int pos);

bool tryAttack(Obj *weapon, Common::String &input);
void handleAttack(Obj *weapon);

Expand Down

0 comments on commit 42c7440

Please sign in to comment.