Skip to content

Commit

Permalink
WAGE: Implement handleInventoryCommand()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 14, 2016
1 parent b066a59 commit 2dc5841
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions engines/wage/entities.cpp
Expand Up @@ -483,4 +483,12 @@ const char *Chr::getDefiniteArticle(bool capitalize) {
return "";
}

bool Chr::isWearing(Obj *obj) {
for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
if (_armor[i] == obj)
return true;

return false;
}

} // End of namespace Wage
2 changes: 2 additions & 0 deletions engines/wage/entities.h
Expand Up @@ -229,6 +229,8 @@ class Chr : public Designed {
void wearObjs();

void resetState();

bool isWearing(Obj *obj);
};

class Obj : public Designed {
Expand Down
15 changes: 14 additions & 1 deletion engines/wage/script.cpp
Expand Up @@ -1026,7 +1026,20 @@ void Script::appendObjNames(Common::String &str, ObjArray &objs) {
}

void Script::handleInventoryCommand() {
warning("STUB: handleInventoryCommand");
Chr *player = _world->_player;
ObjArray objs;

for (ObjArray::const_iterator it = player->_inventory.begin(); it != player->_inventory.end(); ++it)
if (!player->isWearing(*it))
objs.push_back(*it);

if (!objs.size()) {
appendText("Your pack is empty.");
} else {
Common::String res("Your pack contains ");
appendObjNames(res, objs);
appendText(res);
}
}

static const char *armorMessages[] = {
Expand Down

0 comments on commit 2dc5841

Please sign in to comment.