@armoury/fivem-roleplay-gamemode-common 0.0.0-stage → 1.0.11

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 (68) hide show
  1. package/dist/cjs/shared/index.js +17 -0
  2. package/dist/cjs/shared/models/businesses/business.interfaces.js +2 -0
  3. package/dist/cjs/shared/models/businesses/business.model.js +12 -0
  4. package/dist/cjs/shared/models/businesses/index.js +18 -0
  5. package/dist/cjs/shared/models/index.js +18 -0
  6. package/dist/cjs/shared/models/items/clothing/clothing-item.js +60 -0
  7. package/dist/cjs/shared/models/items/clothing/index.js +17 -0
  8. package/dist/cjs/shared/models/items/errors/index.js +17 -0
  9. package/dist/cjs/shared/models/items/errors/item-error-base.js +29 -0
  10. package/dist/cjs/shared/models/items/errors/item-errors.js +35 -0
  11. package/dist/cjs/shared/models/items/errors/item-stash-error-base.js +29 -0
  12. package/dist/cjs/shared/models/items/index.js +24 -0
  13. package/dist/cjs/shared/models/items/item-stash.model.js +144 -0
  14. package/dist/cjs/shared/models/items/item-transfer.model.js +2 -0
  15. package/dist/cjs/shared/models/items/item.model.js +26 -0
  16. package/dist/cjs/shared/models/items/items-base/index.js +17 -0
  17. package/dist/cjs/shared/models/items/items-base/number-item.js +64 -0
  18. package/dist/cjs/shared/models/items/stashes-base/generic-stash.js +30 -0
  19. package/dist/cjs/shared/models/items/stashes-base/index.js +18 -0
  20. package/dist/cjs/shared/models/items/stashes-base/infinite-stash.js +37 -0
  21. package/dist/cjs/shared/models/items/weapons/index.js +17 -0
  22. package/dist/cjs/shared/models/items/weapons/weapon-item.js +74 -0
  23. package/dist/esm/shared/index.js +1 -0
  24. package/dist/esm/shared/models/businesses/business.interfaces.js +1 -0
  25. package/dist/esm/shared/models/businesses/business.model.js +9 -0
  26. package/dist/esm/shared/models/businesses/index.js +2 -0
  27. package/dist/esm/shared/models/index.js +2 -0
  28. package/dist/esm/shared/models/items/clothing/clothing-item.js +57 -0
  29. package/dist/esm/shared/models/items/clothing/index.js +1 -0
  30. package/dist/esm/shared/models/items/errors/index.js +1 -0
  31. package/dist/esm/shared/models/items/errors/item-error-base.js +26 -0
  32. package/dist/esm/shared/models/items/errors/item-errors.js +32 -0
  33. package/dist/esm/shared/models/items/errors/item-stash-error-base.js +26 -0
  34. package/dist/esm/shared/models/items/index.js +8 -0
  35. package/dist/esm/shared/models/items/item-stash.model.js +141 -0
  36. package/dist/esm/shared/models/items/item-transfer.model.js +1 -0
  37. package/dist/esm/shared/models/items/item.model.js +23 -0
  38. package/dist/esm/shared/models/items/items-base/index.js +1 -0
  39. package/dist/esm/shared/models/items/items-base/number-item.js +61 -0
  40. package/dist/esm/shared/models/items/stashes-base/generic-stash.js +27 -0
  41. package/dist/esm/shared/models/items/stashes-base/index.js +2 -0
  42. package/dist/esm/shared/models/items/stashes-base/infinite-stash.js +34 -0
  43. package/dist/esm/shared/models/items/weapons/index.js +1 -0
  44. package/dist/esm/shared/models/items/weapons/weapon-item.js +71 -0
  45. package/dist/types/shared/index.d.ts +1 -0
  46. package/dist/types/shared/models/businesses/business.interfaces.d.ts +5 -0
  47. package/dist/types/shared/models/businesses/business.model.d.ts +25 -0
  48. package/dist/types/shared/models/businesses/index.d.ts +2 -0
  49. package/dist/types/shared/models/index.d.ts +2 -0
  50. package/dist/types/shared/models/items/clothing/clothing-item.d.ts +25 -0
  51. package/dist/types/shared/models/items/clothing/index.d.ts +1 -0
  52. package/dist/types/shared/models/items/errors/index.d.ts +1 -0
  53. package/dist/types/shared/models/items/errors/item-error-base.d.ts +3 -0
  54. package/dist/types/shared/models/items/errors/item-errors.d.ts +7 -0
  55. package/dist/types/shared/models/items/errors/item-stash-error-base.d.ts +3 -0
  56. package/dist/types/shared/models/items/index.d.ts +8 -0
  57. package/dist/types/shared/models/items/item-stash.model.d.ts +53 -0
  58. package/dist/types/shared/models/items/item-transfer.model.d.ts +5 -0
  59. package/dist/types/shared/models/items/item.model.d.ts +50 -0
  60. package/dist/types/shared/models/items/items-base/index.d.ts +1 -0
  61. package/dist/types/shared/models/items/items-base/number-item.d.ts +14 -0
  62. package/dist/types/shared/models/items/stashes-base/generic-stash.d.ts +7 -0
  63. package/dist/types/shared/models/items/stashes-base/index.d.ts +2 -0
  64. package/dist/types/shared/models/items/stashes-base/infinite-stash.d.ts +10 -0
  65. package/dist/types/shared/models/items/weapons/index.d.ts +1 -0
  66. package/dist/types/shared/models/items/weapons/weapon-item.d.ts +18 -0
  67. package/package.json +24 -5
  68. package/README.md +0 -3
@@ -0,0 +1,74 @@
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
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.WeaponItem = void 0;
30
+ var item_model_1 = require("../item.model");
31
+ var WeaponItem = /** @class */ (function (_super) {
32
+ __extends(WeaponItem, _super);
33
+ function WeaponItem() {
34
+ return _super !== null && _super.apply(this, arguments) || this;
35
+ }
36
+ Object.defineProperty(WeaponItem.prototype, "amount", {
37
+ get: function () {
38
+ return this.value.ammo;
39
+ },
40
+ enumerable: false,
41
+ configurable: true
42
+ });
43
+ Object.defineProperty(WeaponItem.prototype, "weight", {
44
+ get: function () {
45
+ return this.amount * this.weightPerUnit;
46
+ },
47
+ enumerable: false,
48
+ configurable: true
49
+ });
50
+ WeaponItem.prototype.add = function (amount) {
51
+ this.value = __assign(__assign({}, this.value), { ammo: Math.max(0, this.value.ammo + amount) });
52
+ return this;
53
+ };
54
+ WeaponItem.prototype.consume = function (amount) {
55
+ return this.add(-amount);
56
+ };
57
+ WeaponItem.prototype.empty = function () {
58
+ return this.add(-this.value.ammo);
59
+ };
60
+ WeaponItem.prototype.serialize = function () {
61
+ var _a;
62
+ return (_a = {},
63
+ _a[this.identifier] = this.value,
64
+ _a);
65
+ };
66
+ WeaponItem.prototype.deserialize = function (serialized) {
67
+ var _a = Object.entries(serialized)[0], identifier = _a[0], value = _a[1];
68
+ this.identifier = identifier;
69
+ this.value = value;
70
+ return this;
71
+ };
72
+ return WeaponItem;
73
+ }(item_model_1.Item));
74
+ exports.WeaponItem = WeaponItem;
@@ -0,0 +1 @@
1
+ export * from './models';
@@ -0,0 +1,9 @@
1
+ var Business = /** @class */ (function () {
2
+ function Business(data) {
3
+ if (data) {
4
+ Object.assign(this, data);
5
+ }
6
+ }
7
+ return Business;
8
+ }());
9
+ export { Business };
@@ -0,0 +1,2 @@
1
+ export * from './business.model';
2
+ export * from './business.interfaces';
@@ -0,0 +1,2 @@
1
+ export * from './businesses';
2
+ export * from './items';
@@ -0,0 +1,57 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { Item } from "../item.model";
17
+ var Clothing = /** @class */ (function (_super) {
18
+ __extends(Clothing, _super);
19
+ function Clothing(_name, _value) {
20
+ if (_value === void 0) { _value = null; }
21
+ var _this = _super.call(this, _name, 1, true, _value) || this;
22
+ _this.amount = 1;
23
+ return _this;
24
+ }
25
+ Object.defineProperty(Clothing.prototype, "weight", {
26
+ get: function () {
27
+ return this.weightPerUnit;
28
+ },
29
+ enumerable: false,
30
+ configurable: true
31
+ });
32
+ Clothing.prototype.add = function (_amount) {
33
+ this.amount = 1;
34
+ return this;
35
+ };
36
+ Clothing.prototype.consume = function (_amount) {
37
+ this.amount = 0;
38
+ return this;
39
+ };
40
+ Clothing.prototype.empty = function () {
41
+ return this.consume(this.weightPerUnit);
42
+ };
43
+ Clothing.prototype.serialize = function () {
44
+ var _a;
45
+ return (_a = {},
46
+ _a[this.identifier] = this.value,
47
+ _a);
48
+ };
49
+ Clothing.prototype.deserialize = function (serialized) {
50
+ var _a = Object.entries(serialized)[0], identifier = _a[0], value = _a[1];
51
+ this.identifier = identifier;
52
+ this.value = value;
53
+ return this;
54
+ };
55
+ return Clothing;
56
+ }(Item));
57
+ export { Clothing };
@@ -0,0 +1 @@
1
+ export * from './clothing-item';
@@ -0,0 +1 @@
1
+ export * from './item-errors';
@@ -0,0 +1,26 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var ItemError = /** @class */ (function (_super) {
17
+ __extends(ItemError, _super);
18
+ function ItemError(msg) {
19
+ var _newTarget = this.constructor;
20
+ var _this = _super.call(this, msg) || this;
21
+ Object.setPrototypeOf(_this, _newTarget.prototype);
22
+ return _this;
23
+ }
24
+ return ItemError;
25
+ }(Error));
26
+ export { ItemError };
@@ -0,0 +1,32 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { ItemStashError } from "./item-stash-error-base";
17
+ var ItemStashSlotsInsuficientError = /** @class */ (function (_super) {
18
+ __extends(ItemStashSlotsInsuficientError, _super);
19
+ function ItemStashSlotsInsuficientError(msg) {
20
+ return _super.call(this, msg !== null && msg !== void 0 ? msg : 'There were insuficient slots to add to the stash.') || this;
21
+ }
22
+ return ItemStashSlotsInsuficientError;
23
+ }(ItemStashError));
24
+ export { ItemStashSlotsInsuficientError };
25
+ var ItemStashGenericError = /** @class */ (function (_super) {
26
+ __extends(ItemStashGenericError, _super);
27
+ function ItemStashGenericError(msg) {
28
+ return _super.call(this, msg !== null && msg !== void 0 ? msg : 'An unexpected runtime error occured.') || this;
29
+ }
30
+ return ItemStashGenericError;
31
+ }(ItemStashError));
32
+ export { ItemStashGenericError };
@@ -0,0 +1,26 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var ItemStashError = /** @class */ (function (_super) {
17
+ __extends(ItemStashError, _super);
18
+ function ItemStashError(msg) {
19
+ var _newTarget = this.constructor;
20
+ var _this = _super.call(this, msg) || this;
21
+ Object.setPrototypeOf(_this, _newTarget.prototype);
22
+ return _this;
23
+ }
24
+ return ItemStashError;
25
+ }(Error));
26
+ export { ItemStashError };
@@ -0,0 +1,8 @@
1
+ export * from './item-stash.model';
2
+ export * from './item.model';
3
+ export * from './item-transfer.model';
4
+ export * from './items-base';
5
+ export * from './stashes-base';
6
+ export * from './errors';
7
+ export * from './clothing';
8
+ export * from './weapons';
@@ -0,0 +1,141 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { ItemStashGenericError, ItemStashSlotsInsuficientError } from "./errors";
13
+ var ItemStash = /** @class */ (function () {
14
+ function ItemStash(name, slots, weightPerSlot) {
15
+ this.name = name;
16
+ this.slots = slots;
17
+ this.weightPerSlot = weightPerSlot;
18
+ this._items = new Map();
19
+ }
20
+ Object.defineProperty(ItemStash.prototype, "items", {
21
+ get: function () {
22
+ return Array.from(this._items.values());
23
+ },
24
+ enumerable: false,
25
+ configurable: true
26
+ });
27
+ ;
28
+ ItemStash.prototype.add = function (item, slot) {
29
+ var _this = this;
30
+ var clone = ItemStash.clone(this); // Creates a clone to operate onto, instead of altering the original map
31
+ var consumedWeight = 0;
32
+ var weightToConsume = item.weight;
33
+ if (!item.fullyOccupiesSlot) {
34
+ // If there are existing slots with this item, fill them
35
+ Array.from(clone._items.entries()).forEach(function (_a) {
36
+ var existingSlot = _a[0], existingItem = _a[1];
37
+ if (consumedWeight < weightToConsume && existingItem.identifier === item.identifier) {
38
+ consumedWeight += ItemStash.addToSlot(clone, item.empty().add(Math.round((weightToConsume - consumedWeight) / item.weightPerUnit)), existingSlot);
39
+ }
40
+ });
41
+ }
42
+ // If the added item is not yet fully transferred, find a new slot to put the remaining amount into
43
+ var attempts = 0;
44
+ while (consumedWeight < weightToConsume) {
45
+ if (consumedWeight < weightToConsume && clone._items.size >= clone.slots) {
46
+ throw new ItemStashSlotsInsuficientError();
47
+ }
48
+ attempts++;
49
+ if (attempts >= this.slots) {
50
+ throw new ItemStashGenericError();
51
+ }
52
+ consumedWeight += ItemStash.addToSlot(clone, item.empty().add(Math.round((weightToConsume - consumedWeight) / item.weightPerUnit)), clone._items.size);
53
+ }
54
+ // If everything went well, propagate the modification into the original map
55
+ Array.from(clone._items.entries()).forEach(function (_a) {
56
+ var slot = _a[0], item = _a[1];
57
+ _this._items.set(slot, item);
58
+ });
59
+ return true;
60
+ };
61
+ ItemStash.prototype.consume = function (item, amount) {
62
+ var _this = this;
63
+ var consumedAmount = 0;
64
+ if (amount >= item.amount) {
65
+ var slot = Array.from(this._items.entries()).find(function (_a) {
66
+ var existingItem = _a[1];
67
+ return existingItem.identifier === item.identifier;
68
+ })[0];
69
+ if (slot != null) {
70
+ this._items.delete(slot);
71
+ }
72
+ }
73
+ else {
74
+ Array.from(this._items.entries()).reverse().forEach(function (_a) {
75
+ var existingSlot = _a[0], existingItem = _a[1];
76
+ if (consumedAmount < amount && item.identifier === existingItem.identifier) {
77
+ var amountRemoved = ItemStash.removeFromSlot(_this, existingSlot, amount - consumedAmount);
78
+ consumedAmount += amountRemoved;
79
+ }
80
+ });
81
+ }
82
+ };
83
+ ItemStash.prototype.has = function (itemIdentifier) {
84
+ return Array.from(this._items.values()).some(function (item) { return item.identifier === itemIdentifier; });
85
+ };
86
+ ItemStash.prototype.serialize = function () {
87
+ return this.items.reduce(function (prev, curr) { return (__assign(__assign({}, prev), curr.serialize())); }, {});
88
+ };
89
+ ItemStash.prototype.toUI = function () {
90
+ return ({
91
+ title: this.name,
92
+ items: Array.from(this._items.entries())
93
+ .map(function (_a) {
94
+ var slot = _a[0], item = _a[1];
95
+ return item.toUI(slot);
96
+ })
97
+ });
98
+ };
99
+ /**
100
+ * Adds an item to a stash.
101
+ * @param stash Stash to add the item to
102
+ * @param item Item to add to the stash
103
+ * @param slot The slot where the item should be placed into
104
+ * @returns Weight added to the stash
105
+ */
106
+ ItemStash.addToSlot = function (stash, item, slot) {
107
+ var _a;
108
+ var existingWeightOfThisItem = ((_a = stash._items.get(slot)) === null || _a === void 0 ? void 0 : _a.weight) || 0;
109
+ var availableWeightInThisSlot = stash.weightPerSlot - existingWeightOfThisItem;
110
+ var weightToBeAdded = Math.max(1, Math.min(availableWeightInThisSlot, item.weight));
111
+ stash._items.set(slot, item.empty().add(Math.round((existingWeightOfThisItem + weightToBeAdded) / item.weightPerUnit)));
112
+ return weightToBeAdded;
113
+ };
114
+ /**
115
+ * Removes an X amount of whichever item lies in the specified slot
116
+ * @param stash Stash to remove the amount of the item from
117
+ * @param slot Slot of the stash which will have this amount of the item removed
118
+ * @param amount The amount of the item to be removed
119
+ * @returns The amount that has been removed (the amount in the slot can be lower than the provided amount-to-be-removed)
120
+ */
121
+ ItemStash.removeFromSlot = function (stash, slot, amount) {
122
+ var _a;
123
+ var existingAmountOfThisItem = ((_a = stash._items.get(slot)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
124
+ if (!existingAmountOfThisItem || !stash._items.get(slot)) {
125
+ return 0;
126
+ }
127
+ var amountToBeConsumed = Math.min(existingAmountOfThisItem, amount);
128
+ stash._items.set(slot, stash._items.get(slot).consume(amountToBeConsumed));
129
+ return amountToBeConsumed;
130
+ };
131
+ ItemStash.clone = function (stash) {
132
+ var clone = new ItemStash(stash.name, stash.slots, stash.weightPerSlot);
133
+ Array.from(stash._items.entries()).forEach(function (_a) {
134
+ var slot = _a[0], item = _a[1];
135
+ clone._items.set(slot, item);
136
+ });
137
+ return clone;
138
+ };
139
+ return ItemStash;
140
+ }());
141
+ export { ItemStash };
@@ -0,0 +1,23 @@
1
+ var Item = /** @class */ (function () {
2
+ function Item(identifier, weightPerUnit, fullyOccupiesSlot, value) {
3
+ this.identifier = identifier;
4
+ this.weightPerUnit = weightPerUnit;
5
+ this.fullyOccupiesSlot = fullyOccupiesSlot;
6
+ this.value = value;
7
+ this.fullyOccupiesSlot = fullyOccupiesSlot !== null && fullyOccupiesSlot !== void 0 ? fullyOccupiesSlot : false;
8
+ }
9
+ Item.prototype.toUI = function (slot) {
10
+ return ({
11
+ image: this.identifier,
12
+ type: 'item',
13
+ description: 'Just an inventory item.',
14
+ topLeft: '',
15
+ bottomRight: JSON.stringify(this.value),
16
+ _piKey: '', // TODO: Can we remove this?
17
+ outline: '#878b9f',
18
+ width: 65,
19
+ });
20
+ };
21
+ return Item;
22
+ }());
23
+ export { Item };
@@ -0,0 +1 @@
1
+ export * from './number-item';
@@ -0,0 +1,61 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { Item } from "../item.model";
17
+ var NumberItem = /** @class */ (function (_super) {
18
+ __extends(NumberItem, _super);
19
+ function NumberItem() {
20
+ return _super !== null && _super.apply(this, arguments) || this;
21
+ }
22
+ Object.defineProperty(NumberItem.prototype, "amount", {
23
+ get: function () {
24
+ return this.value;
25
+ },
26
+ enumerable: false,
27
+ configurable: true
28
+ });
29
+ Object.defineProperty(NumberItem.prototype, "weight", {
30
+ get: function () {
31
+ return this.value * this.weightPerUnit;
32
+ },
33
+ enumerable: false,
34
+ configurable: true
35
+ });
36
+ NumberItem.prototype.add = function (amount) {
37
+ this.value = Math.max(0, this.value + amount);
38
+ return this;
39
+ };
40
+ NumberItem.prototype.consume = function (amount) {
41
+ return this.add(-amount);
42
+ };
43
+ NumberItem.prototype.empty = function () {
44
+ this.value = 0;
45
+ return this;
46
+ };
47
+ NumberItem.prototype.serialize = function () {
48
+ var _a;
49
+ return (_a = {},
50
+ _a[this.identifier] = this.value,
51
+ _a);
52
+ };
53
+ NumberItem.prototype.deserialize = function (serialized) {
54
+ var _a = Object.entries(serialized)[0], identifier = _a[0], value = _a[1];
55
+ this.identifier = identifier;
56
+ this.value = value;
57
+ return this;
58
+ };
59
+ return NumberItem;
60
+ }(Item));
61
+ export { NumberItem };
@@ -0,0 +1,27 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { ItemStash } from "../item-stash.model";
17
+ var GenericStash = /** @class */ (function (_super) {
18
+ __extends(GenericStash, _super); /* implements IItemStash<IItemBase>*/
19
+ function GenericStash() {
20
+ return _super !== null && _super.apply(this, arguments) || this;
21
+ }
22
+ GenericStash.prototype.deserialize = function (serialized) {
23
+ throw new Error("Method not implemented.");
24
+ };
25
+ return GenericStash;
26
+ }(ItemStash));
27
+ export { GenericStash };
@@ -0,0 +1,2 @@
1
+ export * from './generic-stash';
2
+ export * from './infinite-stash';
@@ -0,0 +1,34 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { ItemStash } from "../item-stash.model";
17
+ var InfiniteStash = /** @class */ (function (_super) {
18
+ __extends(InfiniteStash, _super); /* implements IItemStash<IItemBase>*/
19
+ function InfiniteStash() {
20
+ return _super !== null && _super.apply(this, arguments) || this;
21
+ }
22
+ InfiniteStash.prototype.add = function (_item, slot) {
23
+ return true;
24
+ };
25
+ InfiniteStash.prototype.consume = function (_item, _amount) { };
26
+ InfiniteStash.prototype.has = function (_itemIdentifier) {
27
+ return true;
28
+ };
29
+ InfiniteStash.prototype.deserialize = function (serialized) {
30
+ throw new Error("Method not implemented.");
31
+ };
32
+ return InfiniteStash;
33
+ }(ItemStash));
34
+ export { InfiniteStash };
@@ -0,0 +1 @@
1
+ export * from './weapon-item';
@@ -0,0 +1,71 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ import { Item } from "../item.model";
28
+ var WeaponItem = /** @class */ (function (_super) {
29
+ __extends(WeaponItem, _super);
30
+ function WeaponItem() {
31
+ return _super !== null && _super.apply(this, arguments) || this;
32
+ }
33
+ Object.defineProperty(WeaponItem.prototype, "amount", {
34
+ get: function () {
35
+ return this.value.ammo;
36
+ },
37
+ enumerable: false,
38
+ configurable: true
39
+ });
40
+ Object.defineProperty(WeaponItem.prototype, "weight", {
41
+ get: function () {
42
+ return this.amount * this.weightPerUnit;
43
+ },
44
+ enumerable: false,
45
+ configurable: true
46
+ });
47
+ WeaponItem.prototype.add = function (amount) {
48
+ this.value = __assign(__assign({}, this.value), { ammo: Math.max(0, this.value.ammo + amount) });
49
+ return this;
50
+ };
51
+ WeaponItem.prototype.consume = function (amount) {
52
+ return this.add(-amount);
53
+ };
54
+ WeaponItem.prototype.empty = function () {
55
+ return this.add(-this.value.ammo);
56
+ };
57
+ WeaponItem.prototype.serialize = function () {
58
+ var _a;
59
+ return (_a = {},
60
+ _a[this.identifier] = this.value,
61
+ _a);
62
+ };
63
+ WeaponItem.prototype.deserialize = function (serialized) {
64
+ var _a = Object.entries(serialized)[0], identifier = _a[0], value = _a[1];
65
+ this.identifier = identifier;
66
+ this.value = value;
67
+ return this;
68
+ };
69
+ return WeaponItem;
70
+ }(Item));
71
+ export { WeaponItem };
@@ -0,0 +1 @@
1
+ export * from './models';
@@ -0,0 +1,5 @@
1
+ import { Business } from "./business.model";
2
+ export interface IBusinessInteractRequest {
3
+ by: number;
4
+ business: Business;
5
+ }