aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/script.cpp34
-rw-r--r--engines/wage/script.h1
-rw-r--r--engines/wage/util.cpp12
-rw-r--r--engines/wage/wage.h1
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;