@armoury/fivem-roleplay-gamemode-common 1.0.54 → 1.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/shared/models/account/account.js +3 -4
  2. package/dist/cjs/shared/models/businesses/business.model.js +3 -4
  3. package/dist/cjs/shared/models/character/character.js +3 -4
  4. package/dist/cjs/shared/models/house/house.js +13 -22
  5. package/dist/cjs/shared/models/items/deprecated/clothing/clothing-item.js +23 -47
  6. package/dist/cjs/shared/models/items/deprecated/errors/item-error-base.js +5 -24
  7. package/dist/cjs/shared/models/items/deprecated/errors/item-errors.js +9 -28
  8. package/dist/cjs/shared/models/items/deprecated/errors/item-stash-error-base.js +5 -24
  9. package/dist/cjs/shared/models/items/deprecated/item-stash.model.js +45 -75
  10. package/dist/cjs/shared/models/items/deprecated/item.model.js +6 -7
  11. package/dist/cjs/shared/models/items/deprecated/items-base/number-item.js +22 -51
  12. package/dist/cjs/shared/models/items/deprecated/stashes-base/generic-stash.js +5 -25
  13. package/dist/cjs/shared/models/items/deprecated/stashes-base/infinite-stash.js +10 -30
  14. package/dist/cjs/shared/models/items/deprecated/weapons/weapon-item.js +26 -63
  15. package/dist/cjs/shared/models/persistable/persistable.js +3 -5
  16. package/dist/cjs/shared/models/stash/stash.js +4 -7
  17. package/dist/esm/shared/models/account/account.js +3 -5
  18. package/dist/esm/shared/models/businesses/business.model.js +3 -5
  19. package/dist/esm/shared/models/character/character.js +3 -5
  20. package/dist/esm/shared/models/house/house.js +13 -23
  21. package/dist/esm/shared/models/items/deprecated/clothing/clothing-item.js +22 -47
  22. package/dist/esm/shared/models/items/deprecated/errors/item-error-base.js +5 -25
  23. package/dist/esm/shared/models/items/deprecated/errors/item-errors.js +8 -29
  24. package/dist/esm/shared/models/items/deprecated/errors/item-stash-error-base.js +5 -25
  25. package/dist/esm/shared/models/items/deprecated/item-stash.model.js +44 -75
  26. package/dist/esm/shared/models/items/deprecated/item.model.js +6 -8
  27. package/dist/esm/shared/models/items/deprecated/items-base/number-item.js +21 -51
  28. package/dist/esm/shared/models/items/deprecated/stashes-base/generic-stash.js +4 -25
  29. package/dist/esm/shared/models/items/deprecated/stashes-base/infinite-stash.js +9 -30
  30. package/dist/esm/shared/models/items/deprecated/weapons/weapon-item.js +25 -63
  31. package/dist/esm/shared/models/persistable/persistable.js +3 -6
  32. package/dist/esm/shared/models/stash/stash.js +4 -8
  33. package/package.json +28 -28
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Account = void 0;
4
- var Account = /** @class */ (function () {
5
- function Account(id, lastKnownName, platformId, email) {
4
+ class Account {
5
+ constructor(id, lastKnownName, platformId, email) {
6
6
  this.id = id;
7
7
  this.lastKnownName = lastKnownName;
8
8
  this.platformId = platformId;
9
9
  this.email = email;
10
10
  }
11
- return Account;
12
- }());
11
+ }
13
12
  exports.Account = Account;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Business = void 0;
4
- var Business = /** @class */ (function () {
5
- function Business(data) {
4
+ class Business {
5
+ constructor(data) {
6
6
  if (data) {
7
7
  Object.assign(this, data);
8
8
  }
9
9
  }
10
- return Business;
11
- }());
10
+ }
12
11
  exports.Business = Business;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Character = void 0;
4
- var Character = /** @class */ (function () {
5
- function Character(id, accountId, hoursPlayed, language, firstName, lastName, lastLogoutPosition, lastLogoutRotation, lastActivity) {
4
+ class Character {
5
+ constructor(id, accountId, hoursPlayed, language, firstName, lastName, lastLogoutPosition, lastLogoutRotation, lastActivity) {
6
6
  this.id = id;
7
7
  this.accountId = accountId;
8
8
  this.hoursPlayed = hoursPlayed;
@@ -13,6 +13,5 @@ var Character = /** @class */ (function () {
13
13
  this.lastLogoutRotation = lastLogoutRotation;
14
14
  this.lastActivity = lastActivity;
15
15
  }
16
- return Character;
17
- }());
16
+ }
18
17
  exports.Character = Character;
@@ -1,22 +1,8 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.House = void 0;
15
- var House = /** @class */ (function () {
16
- function House(id, owner, entrance, exit, originalValue, address, sellingPrice, rentPrice, requiredLevel, metadata) {
17
- if (sellingPrice === void 0) { sellingPrice = 0; }
18
- if (rentPrice === void 0) { rentPrice = 0; }
19
- if (requiredLevel === void 0) { requiredLevel = 1; }
4
+ class House {
5
+ constructor(id, owner, entrance, exit, originalValue, address, sellingPrice = 0, rentPrice = 0, requiredLevel = 1, metadata) {
20
6
  this.id = id;
21
7
  this.owner = owner;
22
8
  this.entrance = entrance;
@@ -26,10 +12,16 @@ var House = /** @class */ (function () {
26
12
  this.sellingPrice = sellingPrice;
27
13
  this.rentPrice = rentPrice;
28
14
  this.requiredLevel = requiredLevel;
29
- this.metadata = __assign(__assign({}, (metadata !== null && metadata !== void 0 ? metadata : {})), { isOwned: owner != null, tenants: 0, maxTenants: 10, acceptsTenants: true, // TODO: Implement this
30
- address: address });
15
+ this.metadata = {
16
+ ...(metadata ?? {}),
17
+ isOwned: owner != null,
18
+ tenants: 0, // TODO: Implement this
19
+ maxTenants: 10, // TODO: Implement this
20
+ acceptsTenants: true, // TODO: Implement this
21
+ address,
22
+ };
31
23
  }
32
- House.toStub = function (house) {
24
+ static toStub(house) {
33
25
  return {
34
26
  id: house.id,
35
27
  sellingPrice: house.sellingPrice,
@@ -37,7 +29,6 @@ var House = /** @class */ (function () {
37
29
  requiredLevel: house.requiredLevel,
38
30
  metadata: house.metadata,
39
31
  };
40
- };
41
- return House;
42
- }());
32
+ }
33
+ }
43
34
  exports.House = House;
@@ -1,60 +1,36 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.Clothing = void 0;
19
- var item_model_1 = require("../item.model");
20
- var Clothing = /** @class */ (function (_super) {
21
- __extends(Clothing, _super);
22
- function Clothing(_name, _value) {
23
- if (_value === void 0) { _value = null; }
24
- var _this = _super.call(this, _name, 1, true, _value) || this;
25
- _this.amount = 1;
26
- return _this;
4
+ const item_model_1 = require("../item.model");
5
+ class Clothing extends item_model_1.Item {
6
+ get weight() {
7
+ return this.weightPerUnit;
27
8
  }
28
- Object.defineProperty(Clothing.prototype, "weight", {
29
- get: function () {
30
- return this.weightPerUnit;
31
- },
32
- enumerable: false,
33
- configurable: true
34
- });
35
- Clothing.prototype.add = function (_amount) {
9
+ constructor(_name, _value = null) {
10
+ super(_name, 1, true, _value);
11
+ this.amount = 1;
12
+ }
13
+ add(_amount) {
36
14
  this.amount = 1;
37
15
  return this;
38
- };
39
- Clothing.prototype.consume = function (_amount) {
16
+ }
17
+ consume(_amount) {
40
18
  this.amount = 0;
41
19
  return this;
42
- };
43
- Clothing.prototype.empty = function () {
20
+ }
21
+ empty() {
44
22
  return this.consume(this.weightPerUnit);
45
- };
46
- Clothing.prototype.serialize = function () {
47
- var _a;
48
- return (_a = {},
49
- _a[this.identifier] = this.value,
50
- _a);
51
- };
52
- Clothing.prototype.deserialize = function (serialized) {
53
- var _a = Object.entries(serialized)[0], identifier = _a[0], value = _a[1];
23
+ }
24
+ serialize() {
25
+ return ({
26
+ [this.identifier]: this.value
27
+ });
28
+ }
29
+ deserialize(serialized) {
30
+ const [identifier, value] = Object.entries(serialized)[0];
54
31
  this.identifier = identifier;
55
32
  this.value = value;
56
33
  return this;
57
- };
58
- return Clothing;
59
- }(item_model_1.Item));
34
+ }
35
+ }
60
36
  exports.Clothing = Clothing;
@@ -1,29 +1,10 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ItemError = void 0;
19
- var ItemError = /** @class */ (function (_super) {
20
- __extends(ItemError, _super);
21
- function ItemError(msg) {
22
- var _newTarget = this.constructor;
23
- var _this = _super.call(this, msg) || this;
24
- Object.setPrototypeOf(_this, _newTarget.prototype);
25
- return _this;
4
+ class ItemError extends Error {
5
+ constructor(msg) {
6
+ super(msg);
7
+ Object.setPrototypeOf(this, new.target.prototype);
26
8
  }
27
- return ItemError;
28
- }(Error));
9
+ }
29
10
  exports.ItemError = ItemError;
@@ -1,35 +1,16 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ItemStashGenericError = exports.ItemStashSlotsInsuficientError = void 0;
19
- var item_stash_error_base_1 = require("./item-stash-error-base");
20
- var ItemStashSlotsInsuficientError = /** @class */ (function (_super) {
21
- __extends(ItemStashSlotsInsuficientError, _super);
22
- function ItemStashSlotsInsuficientError(msg) {
23
- return _super.call(this, msg !== null && msg !== void 0 ? msg : 'There were insuficient slots to add to the stash.') || this;
4
+ const item_stash_error_base_1 = require("./item-stash-error-base");
5
+ class ItemStashSlotsInsuficientError extends item_stash_error_base_1.ItemStashError {
6
+ constructor(msg) {
7
+ super(msg ?? 'There were insuficient slots to add to the stash.');
24
8
  }
25
- return ItemStashSlotsInsuficientError;
26
- }(item_stash_error_base_1.ItemStashError));
9
+ }
27
10
  exports.ItemStashSlotsInsuficientError = ItemStashSlotsInsuficientError;
28
- var ItemStashGenericError = /** @class */ (function (_super) {
29
- __extends(ItemStashGenericError, _super);
30
- function ItemStashGenericError(msg) {
31
- return _super.call(this, msg !== null && msg !== void 0 ? msg : 'An unexpected runtime error occured.') || this;
11
+ class ItemStashGenericError extends item_stash_error_base_1.ItemStashError {
12
+ constructor(msg) {
13
+ super(msg ?? 'An unexpected runtime error occured.');
32
14
  }
33
- return ItemStashGenericError;
34
- }(item_stash_error_base_1.ItemStashError));
15
+ }
35
16
  exports.ItemStashGenericError = ItemStashGenericError;
@@ -1,29 +1,10 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ItemStashError = void 0;
19
- var ItemStashError = /** @class */ (function (_super) {
20
- __extends(ItemStashError, _super);
21
- function ItemStashError(msg) {
22
- var _newTarget = this.constructor;
23
- var _this = _super.call(this, msg) || this;
24
- Object.setPrototypeOf(_this, _newTarget.prototype);
25
- return _this;
4
+ class ItemStashError extends Error {
5
+ constructor(msg) {
6
+ super(msg);
7
+ Object.setPrototypeOf(this, new.target.prototype);
26
8
  }
27
- return ItemStashError;
28
- }(Error));
9
+ }
29
10
  exports.ItemStashError = ItemStashError;
@@ -1,49 +1,32 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.ItemStash = void 0;
15
- var errors_1 = require("./errors");
16
- var ItemStash = /** @class */ (function () {
17
- function ItemStash(name, slots, weightPerSlot) {
4
+ const errors_1 = require("./errors");
5
+ class ItemStash {
6
+ get items() {
7
+ return Array.from(this._items.values());
8
+ }
9
+ ;
10
+ constructor(name, slots, weightPerSlot) {
18
11
  this.name = name;
19
12
  this.slots = slots;
20
13
  this.weightPerSlot = weightPerSlot;
21
14
  this._items = new Map();
22
15
  }
23
- Object.defineProperty(ItemStash.prototype, "items", {
24
- get: function () {
25
- return Array.from(this._items.values());
26
- },
27
- enumerable: false,
28
- configurable: true
29
- });
30
- ;
31
- ItemStash.prototype.add = function (item, slot) {
32
- var _this = this;
33
- var clone = ItemStash.clone(this); // Creates a clone to operate onto, instead of altering the original map
34
- var consumedWeight = 0;
35
- var weightToConsume = item.weight;
16
+ add(item, slot) {
17
+ const clone = ItemStash.clone(this); // Creates a clone to operate onto, instead of altering the original map
18
+ let consumedWeight = 0;
19
+ const weightToConsume = item.weight;
36
20
  if (!item.fullyOccupiesSlot) {
37
21
  // If there are existing slots with this item, fill them
38
- Array.from(clone._items.entries()).forEach(function (_a) {
39
- var existingSlot = _a[0], existingItem = _a[1];
22
+ Array.from(clone._items.entries()).forEach(([existingSlot, existingItem]) => {
40
23
  if (consumedWeight < weightToConsume && existingItem.identifier === item.identifier) {
41
24
  consumedWeight += ItemStash.addToSlot(clone, item.empty().add(Math.round((weightToConsume - consumedWeight) / item.weightPerUnit)), existingSlot);
42
25
  }
43
26
  });
44
27
  }
45
28
  // If the added item is not yet fully transferred, find a new slot to put the remaining amount into
46
- var attempts = 0;
29
+ let attempts = 0;
47
30
  while (consumedWeight < weightToConsume) {
48
31
  if (consumedWeight < weightToConsume && clone._items.size >= clone.slots) {
49
32
  throw new errors_1.ItemStashSlotsInsuficientError();
@@ -55,50 +38,41 @@ var ItemStash = /** @class */ (function () {
55
38
  consumedWeight += ItemStash.addToSlot(clone, item.empty().add(Math.round((weightToConsume - consumedWeight) / item.weightPerUnit)), clone._items.size);
56
39
  }
57
40
  // If everything went well, propagate the modification into the original map
58
- Array.from(clone._items.entries()).forEach(function (_a) {
59
- var slot = _a[0], item = _a[1];
60
- _this._items.set(slot, item);
41
+ Array.from(clone._items.entries()).forEach(([slot, item]) => {
42
+ this._items.set(slot, item);
61
43
  });
62
44
  return true;
63
- };
64
- ItemStash.prototype.consume = function (item, amount) {
65
- var _this = this;
66
- var consumedAmount = 0;
45
+ }
46
+ consume(item, amount) {
47
+ let consumedAmount = 0;
67
48
  if (amount >= item.amount) {
68
- var slot = Array.from(this._items.entries()).find(function (_a) {
69
- var existingItem = _a[1];
70
- return existingItem.identifier === item.identifier;
71
- })[0];
49
+ const [slot,] = Array.from(this._items.entries()).find(([, existingItem]) => existingItem.identifier === item.identifier);
72
50
  if (slot != null) {
73
51
  this._items.delete(slot);
74
52
  }
75
53
  }
76
54
  else {
77
- Array.from(this._items.entries()).reverse().forEach(function (_a) {
78
- var existingSlot = _a[0], existingItem = _a[1];
55
+ Array.from(this._items.entries()).reverse().forEach(([existingSlot, existingItem]) => {
79
56
  if (consumedAmount < amount && item.identifier === existingItem.identifier) {
80
- var amountRemoved = ItemStash.removeFromSlot(_this, existingSlot, amount - consumedAmount);
57
+ const amountRemoved = ItemStash.removeFromSlot(this, existingSlot, amount - consumedAmount);
81
58
  consumedAmount += amountRemoved;
82
59
  }
83
60
  });
84
61
  }
85
- };
86
- ItemStash.prototype.has = function (itemIdentifier) {
87
- return Array.from(this._items.values()).some(function (item) { return item.identifier === itemIdentifier; });
88
- };
89
- ItemStash.prototype.serialize = function () {
90
- return this.items.reduce(function (prev, curr) { return (__assign(__assign({}, prev), curr.serialize())); }, {});
91
- };
92
- ItemStash.prototype.toUI = function () {
62
+ }
63
+ has(itemIdentifier) {
64
+ return Array.from(this._items.values()).some((item) => item.identifier === itemIdentifier);
65
+ }
66
+ serialize() {
67
+ return this.items.reduce((prev, curr) => ({ ...prev, ...curr.serialize() }), {});
68
+ }
69
+ toUI() {
93
70
  return ({
94
71
  title: this.name,
95
72
  items: Array.from(this._items.entries())
96
- .map(function (_a) {
97
- var slot = _a[0], item = _a[1];
98
- return item.toUI(slot);
99
- })
73
+ .map(([slot, item]) => item.toUI(slot))
100
74
  });
101
- };
75
+ }
102
76
  /**
103
77
  * Adds an item to a stash.
104
78
  * @param stash Stash to add the item to
@@ -106,14 +80,13 @@ var ItemStash = /** @class */ (function () {
106
80
  * @param slot The slot where the item should be placed into
107
81
  * @returns Weight added to the stash
108
82
  */
109
- ItemStash.addToSlot = function (stash, item, slot) {
110
- var _a;
111
- var existingWeightOfThisItem = ((_a = stash._items.get(slot)) === null || _a === void 0 ? void 0 : _a.weight) || 0;
112
- var availableWeightInThisSlot = stash.weightPerSlot - existingWeightOfThisItem;
113
- var weightToBeAdded = Math.max(1, Math.min(availableWeightInThisSlot, item.weight));
83
+ static addToSlot(stash, item, slot) {
84
+ const existingWeightOfThisItem = stash._items.get(slot)?.weight || 0;
85
+ const availableWeightInThisSlot = stash.weightPerSlot - existingWeightOfThisItem;
86
+ const weightToBeAdded = Math.max(1, Math.min(availableWeightInThisSlot, item.weight));
114
87
  stash._items.set(slot, item.empty().add(Math.round((existingWeightOfThisItem + weightToBeAdded) / item.weightPerUnit)));
115
88
  return weightToBeAdded;
116
- };
89
+ }
117
90
  /**
118
91
  * Removes an X amount of whichever item lies in the specified slot
119
92
  * @param stash Stash to remove the amount of the item from
@@ -121,24 +94,21 @@ var ItemStash = /** @class */ (function () {
121
94
  * @param amount The amount of the item to be removed
122
95
  * @returns The amount that has been removed (the amount in the slot can be lower than the provided amount-to-be-removed)
123
96
  */
124
- ItemStash.removeFromSlot = function (stash, slot, amount) {
125
- var _a;
126
- var existingAmountOfThisItem = ((_a = stash._items.get(slot)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
97
+ static removeFromSlot(stash, slot, amount) {
98
+ const existingAmountOfThisItem = stash._items.get(slot)?.amount || 0;
127
99
  if (!existingAmountOfThisItem || !stash._items.get(slot)) {
128
100
  return 0;
129
101
  }
130
- var amountToBeConsumed = Math.min(existingAmountOfThisItem, amount);
102
+ const amountToBeConsumed = Math.min(existingAmountOfThisItem, amount);
131
103
  stash._items.set(slot, stash._items.get(slot).consume(amountToBeConsumed));
132
104
  return amountToBeConsumed;
133
- };
134
- ItemStash.clone = function (stash) {
135
- var clone = new ItemStash(stash.name, stash.slots, stash.weightPerSlot);
136
- Array.from(stash._items.entries()).forEach(function (_a) {
137
- var slot = _a[0], item = _a[1];
105
+ }
106
+ static clone(stash) {
107
+ const clone = new ItemStash(stash.name, stash.slots, stash.weightPerSlot);
108
+ Array.from(stash._items.entries()).forEach(([slot, item]) => {
138
109
  clone._items.set(slot, item);
139
110
  });
140
111
  return clone;
141
- };
142
- return ItemStash;
143
- }());
112
+ }
113
+ }
144
114
  exports.ItemStash = ItemStash;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Item = void 0;
4
- var Item = /** @class */ (function () {
5
- function Item(identifier, weightPerUnit, fullyOccupiesSlot, value) {
4
+ class Item {
5
+ constructor(identifier, weightPerUnit, fullyOccupiesSlot, value) {
6
6
  this.identifier = identifier;
7
7
  this.weightPerUnit = weightPerUnit;
8
8
  this.fullyOccupiesSlot = fullyOccupiesSlot;
9
9
  this.value = value;
10
- this.fullyOccupiesSlot = fullyOccupiesSlot !== null && fullyOccupiesSlot !== void 0 ? fullyOccupiesSlot : false;
10
+ this.fullyOccupiesSlot = fullyOccupiesSlot ?? false;
11
11
  }
12
- Item.prototype.toUI = function (slot) {
12
+ toUI(slot) {
13
13
  return ({
14
14
  image: this.identifier,
15
15
  type: 'item',
@@ -20,7 +20,6 @@ var Item = /** @class */ (function () {
20
20
  outline: '#878b9f',
21
21
  width: 65,
22
22
  });
23
- };
24
- return Item;
25
- }());
23
+ }
24
+ }
26
25
  exports.Item = Item;
@@ -1,64 +1,35 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.NumberItem = void 0;
19
- var item_model_1 = require("../item.model");
20
- var NumberItem = /** @class */ (function (_super) {
21
- __extends(NumberItem, _super);
22
- function NumberItem() {
23
- return _super !== null && _super.apply(this, arguments) || this;
4
+ const item_model_1 = require("../item.model");
5
+ class NumberItem extends item_model_1.Item {
6
+ get amount() {
7
+ return this.value;
24
8
  }
25
- Object.defineProperty(NumberItem.prototype, "amount", {
26
- get: function () {
27
- return this.value;
28
- },
29
- enumerable: false,
30
- configurable: true
31
- });
32
- Object.defineProperty(NumberItem.prototype, "weight", {
33
- get: function () {
34
- return this.value * this.weightPerUnit;
35
- },
36
- enumerable: false,
37
- configurable: true
38
- });
39
- NumberItem.prototype.add = function (amount) {
9
+ get weight() {
10
+ return this.value * this.weightPerUnit;
11
+ }
12
+ add(amount) {
40
13
  this.value = Math.max(0, this.value + amount);
41
14
  return this;
42
- };
43
- NumberItem.prototype.consume = function (amount) {
15
+ }
16
+ consume(amount) {
44
17
  return this.add(-amount);
45
- };
46
- NumberItem.prototype.empty = function () {
18
+ }
19
+ empty() {
47
20
  this.value = 0;
48
21
  return this;
49
- };
50
- NumberItem.prototype.serialize = function () {
51
- var _a;
52
- return (_a = {},
53
- _a[this.identifier] = this.value,
54
- _a);
55
- };
56
- NumberItem.prototype.deserialize = function (serialized) {
57
- var _a = Object.entries(serialized)[0], identifier = _a[0], value = _a[1];
22
+ }
23
+ serialize() {
24
+ return ({
25
+ [this.identifier]: this.value
26
+ });
27
+ }
28
+ deserialize(serialized) {
29
+ const [identifier, value] = Object.entries(serialized)[0];
58
30
  this.identifier = identifier;
59
31
  this.value = value;
60
32
  return this;
61
- };
62
- return NumberItem;
63
- }(item_model_1.Item));
33
+ }
34
+ }
64
35
  exports.NumberItem = NumberItem;
@@ -1,30 +1,10 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.GenericStash = void 0;
19
- var item_stash_model_1 = require("../item-stash.model");
20
- var GenericStash = /** @class */ (function (_super) {
21
- __extends(GenericStash, _super); /* implements IItemStash<IItemBase>*/
22
- function GenericStash() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- GenericStash.prototype.deserialize = function (serialized) {
4
+ const item_stash_model_1 = require("../item-stash.model");
5
+ class GenericStash extends item_stash_model_1.ItemStash /* implements IItemStash<IItemBase>*/ {
6
+ deserialize(serialized) {
26
7
  throw new Error("Method not implemented.");
27
- };
28
- return GenericStash;
29
- }(item_stash_model_1.ItemStash));
8
+ }
9
+ }
30
10
  exports.GenericStash = GenericStash;