diff options
author | Eugene Sandulenko | 2016-01-03 20:23:39 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-01-03 20:23:39 +0100 |
commit | d66c3a21f1b2305fe30640213ff8dba0a20595c5 (patch) | |
tree | 4b7666ed047acdaaf4130706be5dd932a6603de3 /engines/wage | |
parent | 07d11b4af695e7fdc2d3d686f3d24e60387bb749 (diff) | |
download | scummvm-rg350-d66c3a21f1b2305fe30640213ff8dba0a20595c5.tar.gz scummvm-rg350-d66c3a21f1b2305fe30640213ff8dba0a20595c5.tar.bz2 scummvm-rg350-d66c3a21f1b2305fe30640213ff8dba0a20595c5.zip |
WAGE: Implement getGroundItemsList()
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/script.cpp | 34 | ||||
-rw-r--r-- | engines/wage/script.h | 1 | ||||
-rw-r--r-- | engines/wage/util.cpp | 12 | ||||
-rw-r--r-- | engines/wage/wage.h | 1 |
4 files changed, 47 insertions, 1 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 8dde95ea55..740d8ec164 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -941,10 +941,42 @@ void Script::handleLookCommand() { } Common::String *Script::getGroundItemsList(Scene *scene) { - warning("STUB: getGroundItemsList"); + Common::Array<Obj *> objs; + + for (Common::List<Obj *>::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it) + if ((*it)->_type != Obj::IMMOBILE_OBJECT) + objs.push_back(*it); + + if (objs.size()) { + Common::String *res = new Common::String("On the ground you see "); + appendObjNames(*res, objs); + return res; + } return NULL; } +void Script::appendObjNames(Common::String &str, Common::Array<Obj *> &objs) { + for (int i = 0; i < objs.size(); i++) { + Obj *obj = objs[i]; + + if (!obj->_namePlural) + str += getIndefiniteArticle(obj->_name); + else + str += "some "; + + str += obj->_name; + + if (i == objs.size() - 1) { + str += "."; + } else if (i == objs.size() - 2) { + if (objs.size() > 2) + str += ","; + str += " and "; + } else { + str += ", "; + } + } +} void Script::handleInventoryCommand() { warning("STUB: handleInventoryCommand"); diff --git a/engines/wage/script.h b/engines/wage/script.h index 876ec0764e..bff6917fc6 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -168,6 +168,7 @@ private: void handleMoveCommand(Scene::Directions dir, const char *dirName); void handleLookCommand(); Common::String *getGroundItemsList(Scene *scene); + void appendObjNames(Common::String &str, Common::Array<Obj *> &objs); void handleInventoryCommand(); void handleStatusCommand(); void handleRestCommand(); diff --git a/engines/wage/util.cpp b/engines/wage/util.cpp index 0bed88e46f..8dac0d2935 100644 --- a/engines/wage/util.cpp +++ b/engines/wage/util.cpp @@ -87,4 +87,16 @@ Common::Rect *readRect(Common::SeekableReadStream *in) { return new Common::Rect(x1, y1, x2, y2); } +const char *getIndefiniteArticle(String &word) { + switch (word[0]) { + case 'a': case 'A': + case 'e': case 'E': + case 'i': case 'I': + case 'o': case 'O': + case 'u': case 'U': + return "an "; + } + return "a "; +} + } // End of namespace Wage diff --git a/engines/wage/wage.h b/engines/wage/wage.h index e96e298212..724f39ab91 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -98,6 +98,7 @@ enum { Common::String readPascalString(Common::SeekableReadStream *in); Common::Rect *readRect(Common::SeekableReadStream *in); +const char *getIndefiniteArticle(String &word); typedef Common::Array<byte *> Patterns; |