aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/entities.cpp10
-rw-r--r--engines/wage/entities.h1
-rw-r--r--engines/wage/gui.cpp4
-rw-r--r--engines/wage/gui.h1
-rw-r--r--engines/wage/wage.cpp109
-rw-r--r--engines/wage/wage.h8
6 files changed, 131 insertions, 2 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index f9a68d652a..614b831f53 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -390,5 +390,15 @@ int Chr::wearObjIfPossible(Obj *obj) {
return -1;
}
+String &Chr::getNameWithDefiniteArticle(bool capitalize) {
+ Common::String *res = new Common::String;
+
+ if (!_nameProperNoun)
+ *res += capitalize ? "The " : "the ";
+ *res += _name;
+
+ return *res;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 5c1a902bd2..f6cb525f43 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -215,6 +215,7 @@ public:
Context _context;
WeaponArray *getWeapons();
+ String &getNameWithDefiniteArticle(bool capitalize);
public:
#if 0
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 789c350353..8ec904eb90 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -153,6 +153,10 @@ void Gui::setScene(Scene *scene) {
_scene = scene;
}
+void Gui::clearOutput() {
+ _out.clear();
+}
+
void Gui::appendText(String &str) {
if (!str.contains('\n')) {
_out.push_back(str);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index f5e1ef5c9b..25629f64b9 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -67,6 +67,7 @@ public:
void draw();
void setScene(Scene *scene);
void appendText(Common::String &str);
+ void clearOutput();
void mouseMove(int x, int y);
Designed *getClickTarget(int x, int y);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index bc0aff734a..e492bdb8c9 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -73,8 +73,11 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_temporarilyHidden = false;
_isGameOver = false;
_monster = NULL;
+ _running = NULL;
_lastScene = NULL;
+ _commandWasQuick = false;
+
debug("WageEngine::WageEngine()");
}
@@ -150,7 +153,7 @@ void WageEngine::processEvents() {
{
Designed *obj = _gui->getClickTarget(event.mouse.x, event.mouse.y);
if (obj != NULL)
- debug(0, "Clicked: %s", obj->_name.c_str());
+ processTurn(NULL, obj);
}
default:
break;
@@ -305,6 +308,10 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
warning("STUB WageEngine::encounter()");
}
+void WageEngine::performCombatAction(Chr *npc, Chr *player) {
+ warning("STUB WageEngine::performCombatAction()");
+}
+
void WageEngine::redrawScene() {
Scene *currentScene = _world->_player->_currentScene;
if (currentScene != NULL) {
@@ -323,4 +330,104 @@ void WageEngine::redrawScene() {
}
}
+void WageEngine::regen() {
+ warning("STUB WageEngine::regen()");
+}
+
+void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickInput) {
+ Scene *playerScene = _world->_player->_currentScene;
+ if (playerScene == _world->_storageScene)
+ return;
+
+ bool shouldEncounter = false;
+
+ if (playerScene != _lastScene) {
+ _loopCount = 0;
+ _lastScene = playerScene;
+ _monster = NULL;
+ _running = NULL;
+ _offer = NULL;
+
+ for (Common::List<Chr *>::const_iterator it = playerScene->_chrs.begin(); it != playerScene->_chrs.end(); ++it) {
+ if (!(*it)->_playerCharacter) {
+ _monster = *it;
+ shouldEncounter = true;
+ break;
+ }
+ }
+ }
+
+ bool monsterWasNull = (_monster == NULL);
+ bool handled = playerScene->_script->execute(_world, _loopCount++, textInput, clickInput, this);
+
+ playerScene = _world->_player->_currentScene;
+
+ if (playerScene == _world->_storageScene)
+ return;
+
+ if (playerScene != _lastScene) {
+ _temporarilyHidden = true;
+ _gui->clearOutput();
+ regen();
+ Common::String input("look");
+ processTurnInternal(&input, NULL);
+ redrawScene();
+ _temporarilyHidden = false;
+ } else if (_loopCount == 1) {
+ redrawScene();
+ if (shouldEncounter && _monster != NULL) {
+ encounter(_world->_player, _monster);
+ }
+ } else if (textInput != NULL && !handled) {
+ if (monsterWasNull && _monster != NULL)
+ return;
+
+ Common::String rant(_rnd->getRandomNumber(1) ? "What?" : "Huh?");
+
+ appendText(rant);
+ _commandWasQuick = true;
+ }
+}
+
+void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
+ _commandWasQuick = false;
+ Scene *prevScene = _world->_player->_currentScene;
+ Chr *prevMonster = _monster;
+ processTurnInternal(textInput, clickInput);
+ Scene *playerScene = _world->_player->_currentScene;
+
+ if (prevScene != playerScene && playerScene != _world->_storageScene) {
+ if (prevMonster != NULL) {
+ bool followed = false;
+ if (_monster == NULL) {
+ warning("STUB: processTurn(), monster");
+ //Set<Scene> scenes = world.getAdjacentScenes(prevMonster.getState().getCurrentScene());
+ // TODO: adjacent scenes doesn't contain up/down etc... verify that monsters can't follow these...
+ //if (scenes.contains(playerScene)) {
+ // int chance = (int) (Math.random() * 255);
+ // followed = (chance < prevMonster.getFollowsOpponent());
+ //}
+ }
+
+ Common::String msg;
+
+ if (followed) {
+ msg = prevMonster->getNameWithDefiniteArticle(true);
+ msg += " follows you.";
+ appendText(msg);
+ _world->move(prevMonster, playerScene);
+ } else {
+ msg = "You escape ";
+ msg += prevMonster->getNameWithDefiniteArticle(false);
+ msg += ".";
+ appendText(msg);
+ }
+ }
+ }
+ if (!_commandWasQuick && _monster != NULL) {
+ performCombatAction(_monster, _world->_player);
+ }
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 3e29471246..e96e298212 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -119,6 +119,10 @@ private:
bool loadWorld(Common::MacResManager *resMan);
void performInitialSetup();
void wearObjs(Chr *chr);
+ void processTurn(Common::String *textInput, Designed *clickInput);
+ void processTurnInternal(Common::String *textInput, Designed *clickInput);
+ void regen();
+ void performCombatAction(Chr *npc, Chr *player);
public:
Common::RandomSource *_rnd;
@@ -131,8 +135,8 @@ public:
int _loopCount;
int _turn;
Chr *_monster;
+ Chr *_running;
Obj *_offer;
- bool _commandWasQuick;
int _aim;
bool _temporarilyHidden;
bool _isGameOver;
@@ -156,6 +160,8 @@ private:
Common::MacResManager *_resManager;
+ bool _commandWasQuick;
+
};
// Example console class