aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-11-13 20:37:29 -0500
committerPaul Gilbert2017-11-13 20:37:29 -0500
commit13a53f3731dcf3509a71b139d7755ebf9ab508f3 (patch)
tree3ac9ed16320f83f60357ebe07aba7489301eb92f
parent6412dc5f0e4b88cde6664f2a81ca094137cb98f6 (diff)
downloadscummvm-rg350-13a53f3731dcf3509a71b139d7755ebf9ab508f3.tar.gz
scummvm-rg350-13a53f3731dcf3509a71b139d7755ebf9ab508f3.tar.bz2
scummvm-rg350-13a53f3731dcf3509a71b139d7755ebf9ab508f3.zip
XEEN: Added resetBlacksmithWares method
-rw-r--r--engines/xeen/dialogs_input.cpp1
-rw-r--r--engines/xeen/party.cpp133
-rw-r--r--engines/xeen/party.h8
3 files changed, 139 insertions, 3 deletions
diff --git a/engines/xeen/dialogs_input.cpp b/engines/xeen/dialogs_input.cpp
index 75654f62bf..f66bd242f5 100644
--- a/engines/xeen/dialogs_input.cpp
+++ b/engines/xeen/dialogs_input.cpp
@@ -283,7 +283,6 @@ int HowMuch::show(XeenEngine *vm) {
}
int HowMuch::execute() {
- Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
Window &w = screen._windows[6];
Common::String num;
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 3d2f13dd0a..92b7dff6f1 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -33,6 +33,8 @@
namespace Xeen {
+/*------------------------------------------------------------------------*/
+
Roster::Roster() {
resize(TOTAL_CHARACTERS);
@@ -392,7 +394,8 @@ void Party::addTime(int numMinutes) {
if ((_day % 10) == 1 || numMinutes > (24 * 60)) {
if (_day != day) {
- warning("TODO: resetBlacksmith? and giveInterest?");
+ resetBlacksmithWares();
+ giveInterest();
}
}
@@ -1248,7 +1251,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
break;
case 66: {
warning("TODO: Verify case 66");
- Character c;
+ Character &c = _itemsCharacter;
int idx = -1;
if (scripts._itemType != 0) {
for (idx = 0; idx < 10 && _treasure._misc[idx]._material; ++idx);
@@ -1400,4 +1403,130 @@ void Party::resetYearlyBits() {
_gameFlags[0][231] = false;
}
+const int BLACKSMITH_DATA1[4][4] = {
+ { 15, 5, 5, 5 },{ 5, 10, 5, 5 },{ 0, 5, 10, 5 },{ 0, 0, 0, 5 }
+};
+const int BLACKSMITH_DATA2[4][4] = {
+ { 10, 5, 0, 5 },{ 10, 5, 5, 5 },{ 0, 5, 5, 10 },{ 0, 5, 10, 0 }
+};
+
+void Party::resetBlacksmithWares() {
+ Character &c = _itemsCharacter;
+ int catCount[4];
+
+ // Clear existing blacksmith wares
+ for (int i = 0; i < 2; ++i) {
+ for (int j = 0; j < ITEMS_COUNT; ++j) {
+ _blacksmithWeapons[i][j].clear();
+ _blacksmithArmor[i][j].clear();
+ _blacksmithAccessories[i][j].clear();
+ _blacksmithWeapons[i][j].clear();
+ }
+ }
+
+ for (int idx1 = 0; idx1 < 4; ++idx1) {
+ Common::fill(&catCount[0], &catCount[4], 0);
+
+ for (int idx2 = 0; idx2 < 4; ++idx2) {
+ for (int idx3 = 0; idx3 < BLACKSMITH_DATA1[idx2][idx1]; ++idx3) {
+ int itemCat = c.makeItem(idx2, 0, 0);
+ if (catCount[itemCat] < 8) {
+ switch (itemCat) {
+ case 0: {
+ XeenItem &item = _blacksmithWeapons[0][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ case 1: {
+ XeenItem &item = _blacksmithArmor[0][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ case 2: {
+ XeenItem &item = _blacksmithAccessories[0][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ case 3: {
+ XeenItem &item = _blacksmithMisc[0][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ ++catCount[itemCat];
+ }
+ }
+ }
+ }
+
+ for (int idx1 = 0; idx1 < 4; ++idx1) {
+ Common::fill(&catCount[0], &catCount[4], 0);
+
+ for (int idx2 = 0; idx2 < 4; ++idx2) {
+ for (int idx3 = 0; idx3 < BLACKSMITH_DATA2[idx2][idx1]; ++idx3) {
+ int itemCat = c.makeItem(idx2 + (idx1 >= 2 ? 3 : 1), 0, 0);
+ if (catCount[itemCat] < 8) {
+ switch (itemCat) {
+ case 0: {
+ XeenItem &item = _blacksmithWeapons[1][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ case 1: {
+ XeenItem &item = _blacksmithArmor[1][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ case 2: {
+ XeenItem &item = _blacksmithAccessories[1][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ case 3: {
+ XeenItem &item = _blacksmithMisc[1][idx2 * 4 + catCount[itemCat]];
+ item._id = c._weapons[0]._id;
+ item._material = c._weapons[0]._material;
+ item._bonusFlags = c._weapons[0]._bonusFlags;
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ ++catCount[itemCat];
+ }
+ }
+ }
+ }
+}
+
+void Party::giveInterest() {
+
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 790540bb48..adf0ad760d 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -77,6 +77,7 @@ class Party {
friend class InventoryItems;
private:
static XeenEngine *_vm;
+ Character _itemsCharacter;
/**
* Give a treasure item to the given character's inventory
@@ -94,6 +95,13 @@ private:
void subPartyTime(int time);
void resetYearlyBits();
+
+ /**
+ * Resets the inventory that Blacksmiths sell
+ */
+ void resetBlacksmithWares();
+
+ void giveInterest();
public:
// Dynamic data that's saved
Direction _mazeDirection;