From b5d55fdf2b171ef6ff8f56d49b9f350283fde242 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 25 Jan 2016 19:49:41 +0100 Subject: WAGE: Implement decrementUses() --- engines/wage/combat.cpp | 18 +++++++++++++++++- engines/wage/entities.cpp | 4 ++++ engines/wage/entities.h | 7 ++----- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'engines/wage') diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp index 2f87119fe3..4a043311b8 100644 --- a/engines/wage/combat.cpp +++ b/engines/wage/combat.cpp @@ -232,7 +232,23 @@ void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) { } void WageEngine::decrementUses(Obj *obj) { - warning("STUB: decrementUses()"); + int numberOfUses = obj->_numberOfUses; + if (numberOfUses != -1) { + numberOfUses--; + if (numberOfUses > 0) { + obj->_numberOfUses = numberOfUses; + } else { + if (!obj->_failureMessage.empty()) { + appendText(obj->_failureMessage.c_str()); + } + if (obj->_returnToRandomScene) { + _world->move(obj, _world->getRandomScene()); + } else { + _world->move(obj, _world->_storageScene); + } + obj->resetState(obj->_currentOwner, obj->_currentScene); + } + } } bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex) { diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index 747d4861d4..5149fb3d3c 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -281,6 +281,10 @@ Designed *Obj::removeFromCharOrScene() { return from; } +void Obj::resetState(Chr *owner, Scene *scene) { + warning("STUB: Obj::resetState()"); +} + Chr::Chr(String name, Common::SeekableReadStream *data) { _name = name; _classType = CHR; diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 58cc82a894..aaaaee5928 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -288,13 +288,10 @@ public: _currentOwner = NULL; } - void decrementNumberOfUses() { - if (_numberOfUses != -1) - _numberOfUses--; - } - Chr *removeFromChr(); Designed *removeFromCharOrScene(); + + void resetState(Chr *owner, Scene *scene); }; class Scene : public Designed { -- cgit v1.2.3