From e71fe81d0900c8f6797386251f5ea3ad9ca5c9ed Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 22 Dec 2015 10:36:56 +0100 Subject: WAGE: stubbed attack handling --- engines/wage/entities.cpp | 8 ++++++++ engines/wage/entities.h | 33 +++++++++++++++++++-------------- engines/wage/script.cpp | 25 ++++++++++++++++++------- engines/wage/script.h | 4 ++++ engines/wage/wage.cpp | 19 +++++++++++++++++++ engines/wage/wage.h | 8 ++++---- 6 files changed, 72 insertions(+), 25 deletions(-) diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index c499283e07..75b624c4c7 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -192,4 +192,12 @@ Chr::Chr(String name, Common::SeekableReadStream *data) { _weaponSound2 = readPascalString(data); } +WeaponArray *Chr::getWeapons() { + WeaponArray *list = new WeaponArray; + + warning("STUB: getWeapons"); + + return list; +} + } // End of namespace Wage diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 43bc55f72c..edb63ef1e7 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -54,6 +54,9 @@ class Design; class Obj; class Scene; class Script; +class Weapon; + +typedef Common::Array WeaponArray; class Context { public: @@ -111,7 +114,7 @@ public: Design *_design; Common::Rect *_designBounds; - Common::Rect *getDesignBounds() { + Common::Rect *getDesignBounds() { return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds); } @@ -139,7 +142,7 @@ public: BODY_ARMOR = 1, SHIELD_ARMOR = 2 }; - + Chr(String name, Common::SeekableReadStream *data); int _index; @@ -149,7 +152,7 @@ public: bool _playerCharacter; int _maximumCarriedObjects; int _returnTo; - + int _physicalStrength; int _physicalHp; int _naturalArmor; @@ -161,7 +164,7 @@ public: int _runningSpeed; int _rejectsOffers; int _followsOpponent; - + String _initialSound; String _scoresHitSound; String _receivesHitSound; @@ -171,12 +174,12 @@ public: String _operativeVerb1; int _weaponDamage1; String _weaponSound1; - + String _nativeWeapon2; String _operativeVerb2; int _weaponDamage2; String _weaponSound2; - + int _winningWeapons; int _winningMagic; int _winningRun; @@ -185,7 +188,7 @@ public: int _losingMagic; int _losingRun; int _losingOffer; - + String _initialComment; String _scoresHitComment; String _receivesHitComment; @@ -201,6 +204,8 @@ public: Context _context; + WeaponArray *getWeapons(); + public: #if 0 Weapon[] getWeapons() { @@ -283,7 +288,7 @@ public: Weapon() : _numberOfUses(0) {} - void decrementNumberOfUses() { + void decrementNumberOfUses() { if (_numberOfUses != -1) { _numberOfUses--; } @@ -328,7 +333,7 @@ public: String _clickMessage; String _failureMessage; String _useMessage; - + Scene *_currentScene; Chr *_currentOwner; @@ -355,7 +360,7 @@ public: EAST = 2, WEST = 3 }; - + enum SceneTypes { PERIODIC = 0, RANDOM = 1 @@ -373,7 +378,7 @@ public: String _soundName; int _worldX; int _worldY; - + Common::List _objs; Common::List _chrs; @@ -385,7 +390,7 @@ public: } #if 0 - String getFontName() { + String getFontName() { String[] fonts = { "Chicago", // system font "Geneva", // application font @@ -396,7 +401,7 @@ public: "Venice", "London", "Athens", - + "San Francisco", "Toronto", "Cairo", @@ -448,5 +453,5 @@ public: }; } // End of namespace Wage - + #endif diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 60a7e95e36..e1f3c67535 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -160,18 +160,19 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i handleStatusCommand(); } else if (input.contains("rest") || input.equals("wait")) { handleRestCommand(); - /* - } else if (callbacks.getOffer() != NULL && input.contains("accept")) { + } else if (callbacks->getOffer() != NULL && input.contains("accept")) { handleAcceptCommand(); } else { - Chr player = world.getPlayer(); - for (Weapon weapon : player.getWeapons()) { - if (tryAttack(weapon, input)) { - handleAttack(weapon); + Chr *player = _world->_player; + WeaponArray *weapons = player->getWeapons(); + for (WeaponArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) { + if (tryAttack(*weapon, input)) { + handleAttack(*weapon); break; } } - */ + + delete weapons; } /* // TODO: weapons, offer, etc... @@ -492,4 +493,14 @@ void Script::handleOfferCommand(const char *target) { warning("STUB: handleOfferCommand"); } +bool Script::tryAttack(Weapon *weapon, Common::String &input) { + warning("STUB: tryAttack"); + + return false; +} + +void Script::handleAttack(Weapon *weapon) { + warning("STUB: handleAttack"); +} + } // End of namespace Wage diff --git a/engines/wage/script.h b/engines/wage/script.h index f99e6d91f0..4c8ce456c7 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -150,6 +150,10 @@ private: void handleAimCommand(const char *target); void handleWearCommand(const char *target); void handleOfferCommand(const char *target); + + bool tryAttack(Weapon *weapon, Common::String &input); + void handleAttack(Weapon *weapon); + }; } // End of namespace Wage diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index 0689d90c83..00a7aadaf0 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -134,4 +134,23 @@ void WageEngine::processEvents() { } } +void WageEngine::playSound(String soundName) { + warning("STUB: playSound"); +} + +void WageEngine::setMenu(String soundName) { + warning("STUB: setMenu"); +} + +void WageEngine::appendText(String str) { + warning("STUB: appendText"); +} + +Obj *WageEngine::getOffer() { + warning("STUB: getOffer"); + + return NULL; +} + + } // End of namespace Wage diff --git a/engines/wage/wage.h b/engines/wage/wage.h index d7c3386fe4..2ad28c9527 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -107,16 +107,16 @@ public: //PrintStream out; int _loopCount; int _turn; - //Callbacks callbacks; Chr *_monster; Obj *_offer; bool _commandWasQuick; int _aim; bool _temporarilyHidden; - void playSound(String soundName) {} - void setMenu(String soundName) {} - void appendText(String str) {} + void playSound(String soundName); + void setMenu(String soundName); + void appendText(String str); + Obj *getOffer(); void processEvents(); private: -- cgit v1.2.3