aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/randomhat.cpp62
-rw-r--r--engines/wage/randomhat.h73
-rw-r--r--engines/wage/wage.cpp49
-rw-r--r--engines/wage/wage.h6
4 files changed, 177 insertions, 13 deletions
diff --git a/engines/wage/randomhat.cpp b/engines/wage/randomhat.cpp
new file mode 100644
index 0000000000..6461abf0c2
--- /dev/null
+++ b/engines/wage/randomhat.cpp
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "common/hashmap.h"
+#include "wage/randomhat.h"
+
+
+namespace Wage {
+
+void RandomHat::addTokens(int type, int count) {
+ _tokens.setVal(type, _tokens.getVal(type, 0) + count);
+}
+
+int RandomHat::drawToken() {
+ return 0;
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/randomhat.h b/engines/wage/randomhat.h
new file mode 100644
index 0000000000..f54b86bbeb
--- /dev/null
+++ b/engines/wage/randomhat.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef WAGE_RANDOMHAT_H
+#define WAGE_RANDOMHAT_H
+
+namespace Wage {
+
+enum {
+ kTokWeapons = -400,
+ kTokMagic = -300,
+ kTokRun = -200,
+ kTokOffer = -100
+};
+
+class RandomHat {
+public:
+ RandomHat() {}
+
+ void addTokens(int type, int count);
+ int drawToken();
+
+private:
+ Common::HashMap<int, int> _tokens;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 8b7f4ff212..f0690f565d 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -61,6 +61,7 @@
#include "wage/design.h"
#include "wage/entities.h"
#include "wage/gui.h"
+#include "wage/randomhat.h"
#include "wage/script.h"
#include "wage/world.h"
@@ -398,9 +399,7 @@ void WageEngine::encounter(Chr *player, Chr *chr) {
}
void WageEngine::performCombatAction(Chr *npc, Chr *player) {
- warning("STUB WageEngine::performCombatAction()");
-#if 0
- if (npc->_frozen)
+ if (npc->_context._frozen)
return;
RandomHat hat;
@@ -412,7 +411,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
// TODO: Figure out under what circumstances we need to add +1
// for the chance (e.g. only when all values were set to 0?).
if (winning) {
- if (!_world->_weaponsMenuDisabled) {
+ if (!_world->_weaponMenuDisabled) {
if (weapons->size() > 0)
hat.addTokens(kTokWeapons, npc->_winningWeapons + 1);
if (magics->size() > 0)
@@ -423,8 +422,8 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
if (npc->_inventory.size())
hat.addTokens(kTokOffer, npc->_winningOffer + 1);
} else {
- if (!_world->_weaponsMenuDisabled) {
- if (npc.getWeapons(false).length > 0)
+ if (!_world->_weaponMenuDisabled) {
+ if (weapons->size() > 0)
hat.addTokens(kTokWeapons, npc->_losingWeapons + 1);
if (magics->size() > 0)
hat.addTokens(kTokMagic, npc->_losingMagic);
@@ -435,10 +434,10 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
hat.addTokens(kTokOffer, npc->_losingOffer + 1);
}
- ObjArray *objs = npc->_currentScene->_objs;
+ Common::List<Obj *> *objs = &npc->_currentScene->_objs;
if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
int cnt = 0;
- for (ObjList::const_iterator it = objs.begin(); it != objs.end(); ++it, ++cnt) {
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt) {
if ((*it)->_type != Obj::IMMOBILE_OBJECT) {
// TODO: I'm not sure what the chance should be here.
hat.addTokens(cnt, 123);
@@ -450,11 +449,11 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
switch (token) {
case kTokWeapons:
// TODO: I think the monster should choose the "best" weapon.
- performAttack(npc, player, weapons[_rnd.getRandomNumber(weapons->size() - 1)]);
+ performAttack(npc, player, weapons->operator[](_rnd->getRandomNumber(weapons->size() - 1)));
break;
case kTokMagic:
// TODO: I think the monster should choose the "best" magic.
- performMagic(npc, player, magics[_rnd.getRandomNumber(magics->size() - 1)]);
+ performMagic(npc, player, magics->operator[](_rnd->getRandomNumber(magics->size() - 1)));
break;
case kTokRun:
performMove(npc, validMoves);
@@ -463,13 +462,37 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
performOffer(npc, player);
break;
default:
- performTake(npc, objs.get(token));
- break;
+ {
+ int cnt = 0;
+ for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt)
+ if (cnt == token)
+ performTake(npc, *it);
+ break;
+ }
}
delete weapons;
delete magics;
-#endif
+}
+
+void WageEngine::performAttack(Chr *attacker, Chr *victim, Weapon *weapon) {
+ warning("STUB: performAttack()");
+}
+
+void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) {
+ warning("STUB: performMagic()");
+}
+
+void WageEngine::performMove(Chr *chr, int validMoves) {
+ warning("STUB: performMove()");
+}
+
+void WageEngine::performOffer(Chr *attacker, Chr *victim) {
+ warning("STUB: performOffer()");
+}
+
+void WageEngine::performTake(Chr *npc, Obj *obj) {
+ warning("STUB: performTake()");
}
int WageEngine::getValidMoveDirections(Chr *npc) {
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 6fb287cad4..375425b69b 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -66,6 +66,7 @@ class Designed;
class Gui;
class Obj;
class Scene;
+class Weapon;
class World;
using Common::String;
@@ -128,6 +129,11 @@ private:
void regen();
void performCombatAction(Chr *npc, Chr *player);
int getValidMoveDirections(Chr *npc);
+ void performAttack(Chr *attacker, Chr *victim, Weapon *weapon);
+ void performMagic(Chr *attacker, Chr *victim, Obj *magicalObject);
+ void performMove(Chr *chr, int validMoves);
+ void performOffer(Chr *attacker, Chr *victim);
+ void performTake(Chr *npc, Obj *obj);
public:
Common::RandomSource *_rnd;