mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 04:35:16 +00:00
WAGE: Implement getGroundItemsList()
This commit is contained in:
parent
07d11b4af6
commit
d66c3a21f1
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user