diff options
author | Eugene Sandulenko | 2016-01-21 20:23:02 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-02-14 17:12:51 +0100 |
commit | 42c74403760365258a4841cd139aa69be43328c7 (patch) | |
tree | c9c36b7a57c303e1a91a8f7ae3ea8e924ed81714 /engines | |
parent | 02374868f7ff8ea8bc3992aa1b6941cdccd44703 (diff) | |
download | scummvm-rg350-42c74403760365258a4841cd139aa69be43328c7.tar.gz scummvm-rg350-42c74403760365258a4841cd139aa69be43328c7.tar.bz2 scummvm-rg350-42c74403760365258a4841cd139aa69be43328c7.zip |
WAGE: Implement handleWearCommand()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/script.cpp | 44 | ||||
-rw-r--r-- | engines/wage/script.h | 2 |
2 files changed, 44 insertions, 2 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index b6a44d1340..51fb40eaa9 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -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")) { @@ -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"); } diff --git a/engines/wage/script.h b/engines/wage/script.h index 788188d506..adcff88abf 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -186,6 +186,8 @@ private: 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); |