@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.
- package/dist/cjs/shared/index.js +17 -0
- package/dist/cjs/shared/models/businesses/business.interfaces.js +2 -0
- package/dist/cjs/shared/models/businesses/business.model.js +12 -0
- package/dist/cjs/shared/models/businesses/index.js +18 -0
- package/dist/cjs/shared/models/index.js +18 -0
- package/dist/cjs/shared/models/items/clothing/clothing-item.js +60 -0
- package/dist/cjs/shared/models/items/clothing/index.js +17 -0
- package/dist/cjs/shared/models/items/errors/index.js +17 -0
- package/dist/cjs/shared/models/items/errors/item-error-base.js +29 -0
- package/dist/cjs/shared/models/items/errors/item-errors.js +35 -0
- package/dist/cjs/shared/models/items/errors/item-stash-error-base.js +29 -0
- package/dist/cjs/shared/models/items/index.js +24 -0
- package/dist/cjs/shared/models/items/item-stash.model.js +144 -0
- package/dist/cjs/shared/models/items/item-transfer.model.js +2 -0
- package/dist/cjs/shared/models/items/item.model.js +26 -0
- package/dist/cjs/shared/models/items/items-base/index.js +17 -0
- package/dist/cjs/shared/models/items/items-base/number-item.js +64 -0
- package/dist/cjs/shared/models/items/stashes-base/generic-stash.js +30 -0
- package/dist/cjs/shared/models/items/stashes-base/index.js +18 -0
- package/dist/cjs/shared/models/items/stashes-base/infinite-stash.js +37 -0
- package/dist/cjs/shared/models/items/weapons/index.js +17 -0
- package/dist/cjs/shared/models/items/weapons/weapon-item.js +74 -0
- package/dist/esm/shared/index.js +1 -0
- package/dist/esm/shared/models/businesses/business.interfaces.js +1 -0
- package/dist/esm/shared/models/businesses/business.model.js +9 -0
- package/dist/esm/shared/models/businesses/index.js +2 -0
- package/dist/esm/shared/models/index.js +2 -0
- package/dist/esm/shared/models/items/clothing/clothing-item.js +57 -0
- package/dist/esm/shared/models/items/clothing/index.js +1 -0
- package/dist/esm/shared/models/items/errors/index.js +1 -0
- package/dist/esm/shared/models/items/errors/item-error-base.js +26 -0
- package/dist/esm/shared/models/items/errors/item-errors.js +32 -0
- package/dist/esm/shared/models/items/errors/item-stash-error-base.js +26 -0
- package/dist/esm/shared/models/items/index.js +8 -0
- package/dist/esm/shared/models/items/item-stash.model.js +141 -0
- package/dist/esm/shared/models/items/item-transfer.model.js +1 -0
- package/dist/esm/shared/models/items/item.model.js +23 -0
- package/dist/esm/shared/models/items/items-base/index.js +1 -0
- package/dist/esm/shared/models/items/items-base/number-item.js +61 -0
- package/dist/esm/shared/models/items/stashes-base/generic-stash.js +27 -0
- package/dist/esm/shared/models/items/stashes-base/index.js +2 -0
- package/dist/esm/shared/models/items/stashes-base/infinite-stash.js +34 -0
- package/dist/esm/shared/models/items/weapons/index.js +1 -0
- package/dist/esm/shared/models/items/weapons/weapon-item.js +71 -0
- package/dist/types/shared/index.d.ts +1 -0
- package/dist/types/shared/models/businesses/business.interfaces.d.ts +5 -0
- package/dist/types/shared/models/businesses/business.model.d.ts +25 -0
- package/dist/types/shared/models/businesses/index.d.ts +2 -0
- package/dist/types/shared/models/index.d.ts +2 -0
- package/dist/types/shared/models/items/clothing/clothing-item.d.ts +25 -0
- package/dist/types/shared/models/items/clothing/index.d.ts +1 -0
- package/dist/types/shared/models/items/errors/index.d.ts +1 -0
- package/dist/types/shared/models/items/errors/item-error-base.d.ts +3 -0
- package/dist/types/shared/models/items/errors/item-errors.d.ts +7 -0
- package/dist/types/shared/models/items/errors/item-stash-error-base.d.ts +3 -0
- package/dist/types/shared/models/items/index.d.ts +8 -0
- package/dist/types/shared/models/items/item-stash.model.d.ts +53 -0
- package/dist/types/shared/models/items/item-transfer.model.d.ts +5 -0
- package/dist/types/shared/models/items/item.model.d.ts +50 -0
- package/dist/types/shared/models/items/items-base/index.d.ts +1 -0
- package/dist/types/shared/models/items/items-base/number-item.d.ts +14 -0
- package/dist/types/shared/models/items/stashes-base/generic-stash.d.ts +7 -0
- package/dist/types/shared/models/items/stashes-base/index.d.ts +2 -0
- package/dist/types/shared/models/items/stashes-base/infinite-stash.d.ts +10 -0
- package/dist/types/shared/models/items/weapons/index.d.ts +1 -0
- package/dist/types/shared/models/items/weapons/weapon-item.d.ts +18 -0
- package/package.json +24 -5
- package/README.md +0 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./models"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Business = void 0;
|
|
4
|
+
var Business = /** @class */ (function () {
|
|
5
|
+
function Business(data) {
|
|
6
|
+
if (data) {
|
|
7
|
+
Object.assign(this, data);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return Business;
|
|
11
|
+
}());
|
|
12
|
+
exports.Business = Business;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./business.model"), exports);
|
|
18
|
+
__exportStar(require("./business.interfaces"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./businesses"), exports);
|
|
18
|
+
__exportStar(require("./items"), exports);
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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;
|
|
27
|
+
}
|
|
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) {
|
|
36
|
+
this.amount = 1;
|
|
37
|
+
return this;
|
|
38
|
+
};
|
|
39
|
+
Clothing.prototype.consume = function (_amount) {
|
|
40
|
+
this.amount = 0;
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
Clothing.prototype.empty = function () {
|
|
44
|
+
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];
|
|
54
|
+
this.identifier = identifier;
|
|
55
|
+
this.value = value;
|
|
56
|
+
return this;
|
|
57
|
+
};
|
|
58
|
+
return Clothing;
|
|
59
|
+
}(item_model_1.Item));
|
|
60
|
+
exports.Clothing = Clothing;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./clothing-item"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./item-errors"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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;
|
|
26
|
+
}
|
|
27
|
+
return ItemError;
|
|
28
|
+
}(Error));
|
|
29
|
+
exports.ItemError = ItemError;
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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;
|
|
24
|
+
}
|
|
25
|
+
return ItemStashSlotsInsuficientError;
|
|
26
|
+
}(item_stash_error_base_1.ItemStashError));
|
|
27
|
+
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;
|
|
32
|
+
}
|
|
33
|
+
return ItemStashGenericError;
|
|
34
|
+
}(item_stash_error_base_1.ItemStashError));
|
|
35
|
+
exports.ItemStashGenericError = ItemStashGenericError;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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;
|
|
26
|
+
}
|
|
27
|
+
return ItemStashError;
|
|
28
|
+
}(Error));
|
|
29
|
+
exports.ItemStashError = ItemStashError;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./item-stash.model"), exports);
|
|
18
|
+
__exportStar(require("./item.model"), exports);
|
|
19
|
+
__exportStar(require("./item-transfer.model"), exports);
|
|
20
|
+
__exportStar(require("./items-base"), exports);
|
|
21
|
+
__exportStar(require("./stashes-base"), exports);
|
|
22
|
+
__exportStar(require("./errors"), exports);
|
|
23
|
+
__exportStar(require("./clothing"), exports);
|
|
24
|
+
__exportStar(require("./weapons"), exports);
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ItemStash = void 0;
|
|
15
|
+
var errors_1 = require("./errors");
|
|
16
|
+
var ItemStash = /** @class */ (function () {
|
|
17
|
+
function ItemStash(name, slots, weightPerSlot) {
|
|
18
|
+
this.name = name;
|
|
19
|
+
this.slots = slots;
|
|
20
|
+
this.weightPerSlot = weightPerSlot;
|
|
21
|
+
this._items = new Map();
|
|
22
|
+
}
|
|
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;
|
|
36
|
+
if (!item.fullyOccupiesSlot) {
|
|
37
|
+
// 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];
|
|
40
|
+
if (consumedWeight < weightToConsume && existingItem.identifier === item.identifier) {
|
|
41
|
+
consumedWeight += ItemStash.addToSlot(clone, item.empty().add(Math.round((weightToConsume - consumedWeight) / item.weightPerUnit)), existingSlot);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// If the added item is not yet fully transferred, find a new slot to put the remaining amount into
|
|
46
|
+
var attempts = 0;
|
|
47
|
+
while (consumedWeight < weightToConsume) {
|
|
48
|
+
if (consumedWeight < weightToConsume && clone._items.size >= clone.slots) {
|
|
49
|
+
throw new errors_1.ItemStashSlotsInsuficientError();
|
|
50
|
+
}
|
|
51
|
+
attempts++;
|
|
52
|
+
if (attempts >= this.slots) {
|
|
53
|
+
throw new errors_1.ItemStashGenericError();
|
|
54
|
+
}
|
|
55
|
+
consumedWeight += ItemStash.addToSlot(clone, item.empty().add(Math.round((weightToConsume - consumedWeight) / item.weightPerUnit)), clone._items.size);
|
|
56
|
+
}
|
|
57
|
+
// 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);
|
|
61
|
+
});
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
ItemStash.prototype.consume = function (item, amount) {
|
|
65
|
+
var _this = this;
|
|
66
|
+
var consumedAmount = 0;
|
|
67
|
+
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];
|
|
72
|
+
if (slot != null) {
|
|
73
|
+
this._items.delete(slot);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
Array.from(this._items.entries()).reverse().forEach(function (_a) {
|
|
78
|
+
var existingSlot = _a[0], existingItem = _a[1];
|
|
79
|
+
if (consumedAmount < amount && item.identifier === existingItem.identifier) {
|
|
80
|
+
var amountRemoved = ItemStash.removeFromSlot(_this, existingSlot, amount - consumedAmount);
|
|
81
|
+
consumedAmount += amountRemoved;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
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 () {
|
|
93
|
+
return ({
|
|
94
|
+
title: this.name,
|
|
95
|
+
items: Array.from(this._items.entries())
|
|
96
|
+
.map(function (_a) {
|
|
97
|
+
var slot = _a[0], item = _a[1];
|
|
98
|
+
return item.toUI(slot);
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Adds an item to a stash.
|
|
104
|
+
* @param stash Stash to add the item to
|
|
105
|
+
* @param item Item to add to the stash
|
|
106
|
+
* @param slot The slot where the item should be placed into
|
|
107
|
+
* @returns Weight added to the stash
|
|
108
|
+
*/
|
|
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));
|
|
114
|
+
stash._items.set(slot, item.empty().add(Math.round((existingWeightOfThisItem + weightToBeAdded) / item.weightPerUnit)));
|
|
115
|
+
return weightToBeAdded;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Removes an X amount of whichever item lies in the specified slot
|
|
119
|
+
* @param stash Stash to remove the amount of the item from
|
|
120
|
+
* @param slot Slot of the stash which will have this amount of the item removed
|
|
121
|
+
* @param amount The amount of the item to be removed
|
|
122
|
+
* @returns The amount that has been removed (the amount in the slot can be lower than the provided amount-to-be-removed)
|
|
123
|
+
*/
|
|
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;
|
|
127
|
+
if (!existingAmountOfThisItem || !stash._items.get(slot)) {
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
var amountToBeConsumed = Math.min(existingAmountOfThisItem, amount);
|
|
131
|
+
stash._items.set(slot, stash._items.get(slot).consume(amountToBeConsumed));
|
|
132
|
+
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];
|
|
138
|
+
clone._items.set(slot, item);
|
|
139
|
+
});
|
|
140
|
+
return clone;
|
|
141
|
+
};
|
|
142
|
+
return ItemStash;
|
|
143
|
+
}());
|
|
144
|
+
exports.ItemStash = ItemStash;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Item = void 0;
|
|
4
|
+
var Item = /** @class */ (function () {
|
|
5
|
+
function Item(identifier, weightPerUnit, fullyOccupiesSlot, value) {
|
|
6
|
+
this.identifier = identifier;
|
|
7
|
+
this.weightPerUnit = weightPerUnit;
|
|
8
|
+
this.fullyOccupiesSlot = fullyOccupiesSlot;
|
|
9
|
+
this.value = value;
|
|
10
|
+
this.fullyOccupiesSlot = fullyOccupiesSlot !== null && fullyOccupiesSlot !== void 0 ? fullyOccupiesSlot : false;
|
|
11
|
+
}
|
|
12
|
+
Item.prototype.toUI = function (slot) {
|
|
13
|
+
return ({
|
|
14
|
+
image: this.identifier,
|
|
15
|
+
type: 'item',
|
|
16
|
+
description: 'Just an inventory item.',
|
|
17
|
+
topLeft: '',
|
|
18
|
+
bottomRight: JSON.stringify(this.value),
|
|
19
|
+
_piKey: '', // TODO: Can we remove this?
|
|
20
|
+
outline: '#878b9f',
|
|
21
|
+
width: 65,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
return Item;
|
|
25
|
+
}());
|
|
26
|
+
exports.Item = Item;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./number-item"), exports);
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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;
|
|
24
|
+
}
|
|
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) {
|
|
40
|
+
this.value = Math.max(0, this.value + amount);
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
NumberItem.prototype.consume = function (amount) {
|
|
44
|
+
return this.add(-amount);
|
|
45
|
+
};
|
|
46
|
+
NumberItem.prototype.empty = function () {
|
|
47
|
+
this.value = 0;
|
|
48
|
+
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];
|
|
58
|
+
this.identifier = identifier;
|
|
59
|
+
this.value = value;
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
return NumberItem;
|
|
63
|
+
}(item_model_1.Item));
|
|
64
|
+
exports.NumberItem = NumberItem;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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) {
|
|
26
|
+
throw new Error("Method not implemented.");
|
|
27
|
+
};
|
|
28
|
+
return GenericStash;
|
|
29
|
+
}(item_stash_model_1.ItemStash));
|
|
30
|
+
exports.GenericStash = GenericStash;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generic-stash"), exports);
|
|
18
|
+
__exportStar(require("./infinite-stash"), exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.InfiniteStash = void 0;
|
|
19
|
+
var item_stash_model_1 = require("../item-stash.model");
|
|
20
|
+
var InfiniteStash = /** @class */ (function (_super) {
|
|
21
|
+
__extends(InfiniteStash, _super); /* implements IItemStash<IItemBase>*/
|
|
22
|
+
function InfiniteStash() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
InfiniteStash.prototype.add = function (_item, slot) {
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
InfiniteStash.prototype.consume = function (_item, _amount) { };
|
|
29
|
+
InfiniteStash.prototype.has = function (_itemIdentifier) {
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
InfiniteStash.prototype.deserialize = function (serialized) {
|
|
33
|
+
throw new Error("Method not implemented.");
|
|
34
|
+
};
|
|
35
|
+
return InfiniteStash;
|
|
36
|
+
}(item_stash_model_1.ItemStash));
|
|
37
|
+
exports.InfiniteStash = InfiniteStash;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./weapon-item"), exports);
|