qpremake 1.5.3 → 1.6.3
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/README.md +5 -3
- package/package.json +2 -7
- package/lib/_localizationFiles/English.d.ts +0 -2
- package/lib/_localizationFiles/English.js +0 -307
- package/lib/_mods/parserModules/addSymbol.d.ts +0 -7
- package/lib/_mods/parserModules/addSymbol.js +0 -18
- package/lib/_mods/parserModules/expression.d.ts +0 -7
- package/lib/_mods/parserModules/expression.js +0 -45
- package/lib/_mods/parserModules/expression_parser.d.ts +0 -143
- package/lib/_mods/parserModules/expression_parser.js +0 -728
- package/lib/_mods/parserModules/img.d.ts +0 -8
- package/lib/_mods/parserModules/img.js +0 -42
- package/lib/_mods/parserModules/qpOriginal.d.ts +0 -5
- package/lib/_mods/parserModules/qpOriginal.js +0 -27
- package/lib/_mods/parserModules/sectionID.d.ts +0 -13
- package/lib/_mods/parserModules/sectionID.js +0 -56
- package/lib/_mods/parserModules/tags.d.ts +0 -9
- package/lib/_mods/parserModules/tags.js +0 -29
- package/lib/_mods/parserModules/uaddminus.d.ts +0 -9
- package/lib/_mods/parserModules/uaddminus.js +0 -42
- package/lib/_mods/parserModules/variantCheck.d.ts +0 -10
- package/lib/_mods/parserModules/variantCheck.js +0 -53
- package/lib/_queenSystem/handler/actionGenrator.d.ts +0 -994
- package/lib/_queenSystem/handler/actionGenrator.js +0 -646
- package/lib/_queenSystem/handler/actionInputGenerator.d.ts +0 -95
- package/lib/_queenSystem/handler/actionInputGenerator.js +0 -373
- package/lib/_queenSystem/handler/actionInputRequesterGenerator.d.ts +0 -92
- package/lib/_queenSystem/handler/actionInputRequesterGenerator.js +0 -341
- package/lib/_queenSystem/handler/cardHandler.d.ts +0 -20
- package/lib/_queenSystem/handler/cardHandler.js +0 -61
- package/lib/_queenSystem/handler/effectGenerator.d.ts +0 -1
- package/lib/_queenSystem/handler/effectGenerator.js +0 -127
- package/lib/_queenSystem/handler/localizationHandler.d.ts +0 -28
- package/lib/_queenSystem/handler/localizationHandler.js +0 -166
- package/lib/_queenSystem/handler/modHandler.d.ts +0 -10
- package/lib/_queenSystem/handler/modHandler.js +0 -36
- package/lib/_queenSystem/handler/oldDataProcessor.d.ts +0 -9
- package/lib/_queenSystem/handler/oldDataProcessor.js +0 -129
- package/lib/_queenSystem/handler/registryHandler.d.ts +0 -36
- package/lib/_queenSystem/handler/registryHandler.js +0 -63
- package/lib/_queenSystem/handler/zoneHandler.d.ts +0 -102
- package/lib/_queenSystem/handler/zoneHandler.js +0 -606
- package/lib/_queenSystem/loader/loader_card.d.ts +0 -20
- package/lib/_queenSystem/loader/loader_card.js +0 -124
- package/lib/_queenSystem/loader/loader_effect.d.ts +0 -27
- package/lib/_queenSystem/loader/loader_effect.js +0 -163
- package/lib/_queenSystem/loader/loader_handler.d.ts +0 -11
- package/lib/_queenSystem/loader/loader_handler.js +0 -24
- package/lib/_queenSystem/loader/loader_localization.d.ts +0 -11
- package/lib/_queenSystem/loader/loader_localization.js +0 -73
- package/lib/_queenSystem/loader/loader_mod.d.ts +0 -10
- package/lib/_queenSystem/loader/loader_mod.js +0 -72
- package/lib/_queenSystem/loader/loader_subtype.d.ts +0 -9
- package/lib/_queenSystem/loader/loader_subtype.js +0 -39
- package/lib/_queenSystem/loader/loader_type.d.ts +0 -9
- package/lib/_queenSystem/loader/loader_type.js +0 -39
- package/lib/_queenSystem/loader/loader_zone.d.ts +0 -14
- package/lib/_queenSystem/loader/loader_zone.js +0 -35
- package/lib/_queenSystem/queenSystem.d.ts +0 -127
- package/lib/_queenSystem/queenSystem.js +0 -996
- package/lib/_queenSystem/renderer/rendererInterface.d.ts +0 -27
- package/lib/_queenSystem/renderer/rendererInterface.js +0 -25
- package/lib/data/actionRegistry.d.ts +0 -56
- package/lib/data/actionRegistry.js +0 -60
- package/lib/data/cardRegistry.d.ts +0 -1162
- package/lib/data/cardRegistry.js +0 -716
- package/lib/data/deckRegistry.d.ts +0 -19
- package/lib/data/deckRegistry.js +0 -41
- package/lib/data/effectRegistry.d.ts +0 -465
- package/lib/data/effectRegistry.js +0 -151
- package/lib/data/effectTypeRegistry.d.ts +0 -14
- package/lib/data/effectTypeRegistry.js +0 -14
- package/lib/data/operatorRegistry.d.ts +0 -92
- package/lib/data/operatorRegistry.js +0 -82
- package/lib/data/rarityRegistry.d.ts +0 -28
- package/lib/data/rarityRegistry.js +0 -63
- package/lib/data/registryRegistry.d.ts +0 -10
- package/lib/data/registryRegistry.js +0 -14
- package/lib/data/subtypeRegistry.d.ts +0 -15
- package/lib/data/subtypeRegistry.js +0 -15
- package/lib/data/systemRegistry.d.ts +0 -253
- package/lib/data/systemRegistry.js +0 -56
- package/lib/data/zoneRegistry.d.ts +0 -43
- package/lib/data/zoneRegistry.js +0 -157
- package/lib/effectTextParser/index.d.ts +0 -42
- package/lib/effectTextParser/index.js +0 -316
- package/lib/global/index.d.ts +0 -8
- package/lib/global/index.js +0 -12
- package/lib/index.d.ts +0 -6335
- package/lib/index.js +0 -205
- package/lib/specificEffects/e_cond.d.ts +0 -11
- package/lib/specificEffects/e_cond.js +0 -36
- package/lib/specificEffects/e_fruit.d.ts +0 -3
- package/lib/specificEffects/e_fruit.js +0 -187
- package/lib/specificEffects/e_generic.d.ts +0 -191
- package/lib/specificEffects/e_generic.js +0 -662
- package/lib/specificEffects/e_generic_cardTargetting.d.ts +0 -38
- package/lib/specificEffects/e_generic_cardTargetting.js +0 -82
- package/lib/specificEffects/e_generic_noneTargetting.d.ts +0 -10
- package/lib/specificEffects/e_generic_noneTargetting.js +0 -26
- package/lib/specificEffects/e_status.d.ts +0 -80
- package/lib/specificEffects/e_status.js +0 -151
- package/lib/specificEffects/e_test.d.ts +0 -3
- package/lib/specificEffects/e_test.js +0 -21
- package/lib/types/abstract/gameComponents/API.d.ts +0 -19
- package/lib/types/abstract/gameComponents/API.js +0 -2
- package/lib/types/abstract/gameComponents/card.d.ts +0 -108
- package/lib/types/abstract/gameComponents/card.js +0 -771
- package/lib/types/abstract/gameComponents/effect.d.ts +0 -82
- package/lib/types/abstract/gameComponents/effect.js +0 -331
- package/lib/types/abstract/gameComponents/effectSubtype.d.ts +0 -22
- package/lib/types/abstract/gameComponents/effectSubtype.js +0 -40
- package/lib/types/abstract/gameComponents/effectType.d.ts +0 -11
- package/lib/types/abstract/gameComponents/effectType.js +0 -8
- package/lib/types/abstract/gameComponents/settings.d.ts +0 -80
- package/lib/types/abstract/gameComponents/settings.js +0 -72
- package/lib/types/abstract/gameComponents/zone.d.ts +0 -113
- package/lib/types/abstract/gameComponents/zone.js +0 -614
- package/lib/types/abstract/gameComponents/zone_gridBased.d.ts +0 -18
- package/lib/types/abstract/gameComponents/zone_gridBased.js +0 -58
- package/lib/types/abstract/gameComponents/zone_stackBased.d.ts +0 -13
- package/lib/types/abstract/gameComponents/zone_stackBased.js +0 -55
- package/lib/types/abstract/generics/node.d.ts +0 -23
- package/lib/types/abstract/generics/node.js +0 -46
- package/lib/types/abstract/generics/position.d.ts +0 -23
- package/lib/types/abstract/generics/position.js +0 -91
- package/lib/types/abstract/generics/tree.d.ts +0 -25
- package/lib/types/abstract/generics/tree.js +0 -153
- package/lib/types/abstract/generics/universalResponse.d.ts +0 -4
- package/lib/types/abstract/generics/universalResponse.js +0 -2
- package/lib/types/abstract/generics/wraper.d.ts +0 -21
- package/lib/types/abstract/generics/wraper.js +0 -56
- package/lib/types/abstract/parser/component.d.ts +0 -88
- package/lib/types/abstract/parser/component.js +0 -132
- package/lib/types/abstract/parser/index.d.ts +0 -6
- package/lib/types/abstract/parser/index.js +0 -28
- package/lib/types/abstract/parser/modPack.d.ts +0 -21
- package/lib/types/abstract/parser/modPack.js +0 -48
- package/lib/types/abstract/parser/moduleInputObject.d.ts +0 -12
- package/lib/types/abstract/parser/moduleInputObject.js +0 -21
- package/lib/types/abstract/parser/options.d.ts +0 -31
- package/lib/types/abstract/parser/options.js +0 -45
- package/lib/types/abstract/serializedGameComponents/Gamestate.d.ts +0 -46
- package/lib/types/abstract/serializedGameComponents/Gamestate.js +0 -70
- package/lib/types/abstract/serializedGameComponents/Localized.d.ts +0 -69
- package/lib/types/abstract/serializedGameComponents/Localized.js +0 -84
- package/lib/types/defaultZones/ability.d.ts +0 -10
- package/lib/types/defaultZones/ability.js +0 -22
- package/lib/types/defaultZones/deck.d.ts +0 -25
- package/lib/types/defaultZones/deck.js +0 -90
- package/lib/types/defaultZones/drop.d.ts +0 -5
- package/lib/types/defaultZones/drop.js +0 -13
- package/lib/types/defaultZones/field.d.ts +0 -11
- package/lib/types/defaultZones/field.js +0 -35
- package/lib/types/defaultZones/grave.d.ts +0 -8
- package/lib/types/defaultZones/grave.js +0 -21
- package/lib/types/defaultZones/hand.d.ts +0 -5
- package/lib/types/defaultZones/hand.js +0 -14
- package/lib/types/defaultZones/storage.d.ts +0 -9
- package/lib/types/defaultZones/storage.js +0 -21
- package/lib/types/defaultZones/system.d.ts +0 -12
- package/lib/types/defaultZones/system.js +0 -35
- package/lib/types/defaultZones/void.d.ts +0 -4
- package/lib/types/defaultZones/void.js +0 -10
- package/lib/types/effects/effectSubtypes/subtype_chained.d.ts +0 -10
- package/lib/types/effects/effectSubtypes/subtype_chained.js +0 -17
- package/lib/types/effects/effectSubtypes/subtype_delayed.d.ts +0 -9
- package/lib/types/effects/effectSubtypes/subtype_delayed.js +0 -16
- package/lib/types/effects/effectSubtypes/subtype_fieldLock.d.ts +0 -9
- package/lib/types/effects/effectSubtypes/subtype_fieldLock.js +0 -21
- package/lib/types/effects/effectSubtypes/subtype_graveLock.d.ts +0 -9
- package/lib/types/effects/effectSubtypes/subtype_graveLock.js +0 -21
- package/lib/types/effects/effectSubtypes/subtype_hand_or_fieldLock.d.ts +0 -9
- package/lib/types/effects/effectSubtypes/subtype_hand_or_fieldLock.js +0 -21
- package/lib/types/effects/effectSubtypes/subtype_hardUnique.d.ts +0 -9
- package/lib/types/effects/effectSubtypes/subtype_hardUnique.js +0 -15
- package/lib/types/effects/effectSubtypes/subtype_instant.d.ts +0 -8
- package/lib/types/effects/effectSubtypes/subtype_instant.js +0 -20
- package/lib/types/effects/effectSubtypes/subtype_once.d.ts +0 -12
- package/lib/types/effects/effectSubtypes/subtype_once.js +0 -27
- package/lib/types/effects/effectSubtypes/subtype_unique.d.ts +0 -9
- package/lib/types/effects/effectSubtypes/subtype_unique.js +0 -16
- package/lib/types/effects/effectTypes/initEffect.d.ts +0 -7
- package/lib/types/effects/effectTypes/initEffect.js +0 -23
- package/lib/types/effects/effectTypes/lockEffect.d.ts +0 -9
- package/lib/types/effects/effectTypes/lockEffect.js +0 -25
- package/lib/types/effects/effectTypes/manualEffect.d.ts +0 -9
- package/lib/types/effects/effectTypes/manualEffect.js +0 -18
- package/lib/types/effects/effectTypes/passiveEffect.d.ts +0 -9
- package/lib/types/effects/effectTypes/passiveEffect.js +0 -23
- package/lib/types/effects/effectTypes/triggerEffect.d.ts +0 -9
- package/lib/types/effects/effectTypes/triggerEffect.js +0 -28
- package/lib/types/errors/cannotLoad.d.ts +0 -5
- package/lib/types/errors/cannotLoad.js +0 -13
- package/lib/types/errors/cardNotExist.d.ts +0 -5
- package/lib/types/errors/cardNotExist.js +0 -13
- package/lib/types/errors/cardNotInApplicableZone.d.ts +0 -5
- package/lib/types/errors/cardNotInApplicableZone.js +0 -13
- package/lib/types/errors/effectCondNotMet.d.ts +0 -5
- package/lib/types/errors/effectCondNotMet.js +0 -13
- package/lib/types/errors/effectNotExist.d.ts +0 -5
- package/lib/types/errors/effectNotExist.js +0 -13
- package/lib/types/errors/error.d.ts +0 -17
- package/lib/types/errors/error.js +0 -42
- package/lib/types/errors/incorrectActionType.d.ts +0 -5
- package/lib/types/errors/incorrectActionType.js +0 -13
- package/lib/types/errors/index.d.ts +0 -16
- package/lib/types/errors/index.js +0 -36
- package/lib/types/errors/invalidOrderMap.d.ts +0 -6
- package/lib/types/errors/invalidOrderMap.js +0 -14
- package/lib/types/errors/invalidPosition.d.ts +0 -6
- package/lib/types/errors/invalidPosition.js +0 -13
- package/lib/types/errors/subTypeOverrideConflict.d.ts +0 -7
- package/lib/types/errors/subTypeOverrideConflict.js +0 -15
- package/lib/types/errors/unknownError.d.ts +0 -5
- package/lib/types/errors/unknownError.js +0 -13
- package/lib/types/errors/unregisteredAction.d.ts +0 -6
- package/lib/types/errors/unregisteredAction.js +0 -13
- package/lib/types/errors/wrongEffectIdx.d.ts +0 -5
- package/lib/types/errors/wrongEffectIdx.js +0 -14
- package/lib/types/errors/zoneAttrConflict.d.ts +0 -5
- package/lib/types/errors/zoneAttrConflict.js +0 -15
- package/lib/types/errors/zoneFull.d.ts +0 -5
- package/lib/types/errors/zoneFull.js +0 -13
- package/lib/types/errors/zoneNotExist.d.ts +0 -5
- package/lib/types/errors/zoneNotExist.js +0 -13
- package/lib/types/misc.d.ts +0 -97
- package/lib/types/misc.js +0 -8
- package/lib/types/mods/effectTextParserModule.d.ts +0 -16
- package/lib/types/mods/effectTextParserModule.js +0 -81
- package/lib/types/mods/gameModule.d.ts +0 -5
- package/lib/types/mods/gameModule.js +0 -8
- package/lib/utils/index.d.ts +0 -78
- package/lib/utils/index.js +0 -562
|
@@ -1,614 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Zone = void 0;
|
|
7
|
-
const position_1 = __importDefault(require("../generics/position"));
|
|
8
|
-
const zoneRegistry_1 = require("../../../data/zoneRegistry");
|
|
9
|
-
const actionGenrator_1 = require("../../../_queenSystem/handler/actionGenrator");
|
|
10
|
-
const errors_1 = require("../../errors");
|
|
11
|
-
class Zone {
|
|
12
|
-
constructor(id, //changes on insert
|
|
13
|
-
name, //fixxed identifier
|
|
14
|
-
dataID, classID, playerType = -1, playerIndex = -1, data) {
|
|
15
|
-
this.cardArr = [];
|
|
16
|
-
this.name = name;
|
|
17
|
-
this.dataID = dataID;
|
|
18
|
-
let t = undefined;
|
|
19
|
-
if (data) {
|
|
20
|
-
this.attr = new Map(Object.entries(data));
|
|
21
|
-
t = data.types;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.attr = new Map();
|
|
25
|
-
}
|
|
26
|
-
if (t) {
|
|
27
|
-
this.types = t;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
let t = zoneRegistry_1.zoneRegistry[dataID];
|
|
31
|
-
if (typeof t === "number")
|
|
32
|
-
this.types = [t];
|
|
33
|
-
else
|
|
34
|
-
this.types = [];
|
|
35
|
-
}
|
|
36
|
-
this.attr.set("index", id);
|
|
37
|
-
this.attr.set("playerIndex", playerIndex);
|
|
38
|
-
this.attr.set("playerType", playerType);
|
|
39
|
-
if (classID && classID !== dataID)
|
|
40
|
-
this.attr.set("classID", classID);
|
|
41
|
-
}
|
|
42
|
-
get attrArr() { var _a; return (_a = this.attr.get("attriutesArr")) !== null && _a !== void 0 ? _a : []; }
|
|
43
|
-
get playerIndex() { var _a; return (_a = this.attr.get("playerIndex")) !== null && _a !== void 0 ? _a : -1; }
|
|
44
|
-
get playerType() { var _a; return (_a = this.attr.get("playerType")) !== null && _a !== void 0 ? _a : -1; }
|
|
45
|
-
get classID() { var _a; return (_a = this.attr.get("classID")) !== null && _a !== void 0 ? _a : this.dataID; }
|
|
46
|
-
//helper properties
|
|
47
|
-
get isFull() {
|
|
48
|
-
return this.cardArr.length >= this.capacity;
|
|
49
|
-
}
|
|
50
|
-
get valid() {
|
|
51
|
-
return this.id >= 0;
|
|
52
|
-
}
|
|
53
|
-
//helper properties - quick attr access
|
|
54
|
-
get posBound() {
|
|
55
|
-
var _a;
|
|
56
|
-
return (_a = this.attr.get("posBound")) !== null && _a !== void 0 ? _a : [];
|
|
57
|
-
}
|
|
58
|
-
set posBound(bound) {
|
|
59
|
-
this.attr.set("posBound", bound);
|
|
60
|
-
}
|
|
61
|
-
get priority() {
|
|
62
|
-
var _a;
|
|
63
|
-
return (_a = this.attr.get("priority")) !== null && _a !== void 0 ? _a : -1;
|
|
64
|
-
}
|
|
65
|
-
get id() {
|
|
66
|
-
var _a;
|
|
67
|
-
return (_a = this.attr.get("index")) !== null && _a !== void 0 ? _a : -1;
|
|
68
|
-
}
|
|
69
|
-
set id(newVal) {
|
|
70
|
-
this.attr.set("index", newVal);
|
|
71
|
-
}
|
|
72
|
-
get posLength() {
|
|
73
|
-
return this.posBound.length;
|
|
74
|
-
}
|
|
75
|
-
get shape() {
|
|
76
|
-
return this.posBound;
|
|
77
|
-
}
|
|
78
|
-
get lastPos() {
|
|
79
|
-
return new position_1.default(this.id, this.name, ...Utils.indexToPosition(this.isFull ? this.capacity - 1 : this.cardArr.length, this.shape));
|
|
80
|
-
}
|
|
81
|
-
get firstPos() {
|
|
82
|
-
return new position_1.default(this.id, this.name, ...Utils.indexToPosition(0, this.shape));
|
|
83
|
-
}
|
|
84
|
-
get top() { return this.lastPos; }
|
|
85
|
-
get bottom() { return this.firstPos; }
|
|
86
|
-
getCardByPosition(p) {
|
|
87
|
-
if (!this.validatePosition(p))
|
|
88
|
-
return undefined;
|
|
89
|
-
let index = Utils.positionToIndex(p.flat(), this.shape);
|
|
90
|
-
return this.cardArr[index];
|
|
91
|
-
}
|
|
92
|
-
isOpposite(p1, p2) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
getOppositeZone(zoneArr) {
|
|
96
|
-
return zoneArr.filter(z => this.isOpposite(z));
|
|
97
|
-
}
|
|
98
|
-
getOppositeCards(c) {
|
|
99
|
-
//default implementation
|
|
100
|
-
return this.cardArr.filter(i => i !== undefined && this.isOpposite(c, i));
|
|
101
|
-
}
|
|
102
|
-
//helper properties - initialized attributes
|
|
103
|
-
get canReorderSelf() {
|
|
104
|
-
return this.attrArr.includes(zoneRegistry_1.zoneAttributes.canReorderSelf);
|
|
105
|
-
}
|
|
106
|
-
get canMoveTo() {
|
|
107
|
-
return this.attrArr.includes(zoneRegistry_1.zoneAttributes.canMoveTo);
|
|
108
|
-
}
|
|
109
|
-
get canMoveFrom() {
|
|
110
|
-
return this.attrArr.includes(zoneRegistry_1.zoneAttributes.canMoveFrom);
|
|
111
|
-
}
|
|
112
|
-
get moveToNeedPosition() {
|
|
113
|
-
return this.attrArr.includes(zoneRegistry_1.zoneAttributes.moveToNeedPosition);
|
|
114
|
-
}
|
|
115
|
-
get isField() {
|
|
116
|
-
return this.types.includes(zoneRegistry_1.zoneRegistry.z_field);
|
|
117
|
-
}
|
|
118
|
-
get isGrave() {
|
|
119
|
-
return this.types.includes(zoneRegistry_1.zoneRegistry.z_grave);
|
|
120
|
-
}
|
|
121
|
-
get minCapacity() {
|
|
122
|
-
var _a;
|
|
123
|
-
return (_a = this.attr.get("minCapacity")) !== null && _a !== void 0 ? _a : 0;
|
|
124
|
-
}
|
|
125
|
-
set canReorderSelf(value) {
|
|
126
|
-
if (value)
|
|
127
|
-
this.attr.set("attriutesArr", this.attrArr.concat([zoneRegistry_1.zoneAttributes.canReorderSelf]));
|
|
128
|
-
}
|
|
129
|
-
set canMoveTo(value) {
|
|
130
|
-
if (value)
|
|
131
|
-
this.attr.set("attriutesArr", this.attrArr.concat([zoneRegistry_1.zoneAttributes.canMoveTo]));
|
|
132
|
-
}
|
|
133
|
-
set canMoveFrom(value) {
|
|
134
|
-
if (value)
|
|
135
|
-
this.attr.set("attriutesArr", this.attrArr.concat([zoneRegistry_1.zoneAttributes.canMoveFrom]));
|
|
136
|
-
}
|
|
137
|
-
set moveToNeedPosition(value) {
|
|
138
|
-
if (value)
|
|
139
|
-
this.attr.set("attriutesArr", this.attrArr.concat([zoneRegistry_1.zoneAttributes.moveToNeedPosition]));
|
|
140
|
-
}
|
|
141
|
-
set minCapacity(value) {
|
|
142
|
-
this.attr.set("minCapacity", value);
|
|
143
|
-
}
|
|
144
|
-
get capacity() {
|
|
145
|
-
return this.posLength ? this.posBound.reduce((a, b) => a * b) : 0;
|
|
146
|
-
}
|
|
147
|
-
set capacity(newCap) { } //override if zone allow for overriding capacity
|
|
148
|
-
setArbitraryAttribute(value) {
|
|
149
|
-
this.attr.set("attriutesArr", this.attrArr.concat([value]));
|
|
150
|
-
}
|
|
151
|
-
hasArbitraryAttribute(valueToCheck) {
|
|
152
|
-
return this.attrArr.includes(valueToCheck);
|
|
153
|
-
}
|
|
154
|
-
//helper functions
|
|
155
|
-
// forEach = this.cardArr.forEach.bind(this.cardArr)
|
|
156
|
-
// map = this.cardArr.map.bind(this.cardArr)
|
|
157
|
-
// filter = this.cardArr.filter.bind(this.cardArr)
|
|
158
|
-
findIndex(cid) {
|
|
159
|
-
if (!cid)
|
|
160
|
-
return -1;
|
|
161
|
-
for (let index = 0; index < this.cardArr.length; index++) {
|
|
162
|
-
if (this.cardArr[index] && this.cardArr[index].id === cid)
|
|
163
|
-
return index;
|
|
164
|
-
}
|
|
165
|
-
return -1;
|
|
166
|
-
}
|
|
167
|
-
applyFuncToID(func, cid) {
|
|
168
|
-
//maybe obsolete
|
|
169
|
-
if (!cid)
|
|
170
|
-
return undefined;
|
|
171
|
-
this.cardArr.forEach((i, index) => {
|
|
172
|
-
if (i && i.id == cid)
|
|
173
|
-
return func(i);
|
|
174
|
-
});
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
isPositionInBounds(p) {
|
|
178
|
-
if (this.capacity <= 0)
|
|
179
|
-
return false;
|
|
180
|
-
if (p.zoneID != this.id)
|
|
181
|
-
return false;
|
|
182
|
-
let res = true;
|
|
183
|
-
p.forEach((i, index) => {
|
|
184
|
-
if (i >= this.posBound[index])
|
|
185
|
-
res = false;
|
|
186
|
-
});
|
|
187
|
-
return res;
|
|
188
|
-
}
|
|
189
|
-
validatePosition(p) {
|
|
190
|
-
return p && p.valid && this.valid && this.isPositionInBounds(p);
|
|
191
|
-
}
|
|
192
|
-
positionToIndex(p) {
|
|
193
|
-
if (!this.validatePosition(p))
|
|
194
|
-
return -1;
|
|
195
|
-
p = p;
|
|
196
|
-
if (this.posLength == 1)
|
|
197
|
-
return p.x;
|
|
198
|
-
return Utils.positionToIndex(p.flat(), this.shape);
|
|
199
|
-
}
|
|
200
|
-
isPositionOccupied(p) {
|
|
201
|
-
if (!this.validatePosition(p))
|
|
202
|
-
return [-1, false];
|
|
203
|
-
let i = this.positionToIndex(p);
|
|
204
|
-
if (i < 0)
|
|
205
|
-
return [i, false];
|
|
206
|
-
if (this.cardArr[i])
|
|
207
|
-
return [i, false];
|
|
208
|
-
else
|
|
209
|
-
return [i, true];
|
|
210
|
-
} //[index, result], index -1 is error code,
|
|
211
|
-
// distinguising the false from error with the false from actual result
|
|
212
|
-
//zone functionality functions
|
|
213
|
-
//zone has 2 jobs
|
|
214
|
-
//1. provides an action if the player wanna do something
|
|
215
|
-
//2. perform an action using API/func calls, not action (not enough info)
|
|
216
|
-
//functions for step 1
|
|
217
|
-
//get actions only checks for wrong params
|
|
218
|
-
getAction_add(s, c, p, cause = actionGenrator_1.actionFormRegistry.none()) {
|
|
219
|
-
if (!this.canMoveTo) {
|
|
220
|
-
return new errors_1.zoneAttrConflict(this.id, "moveTo", c.id).add("zone.ts", "getAction_add", 130);
|
|
221
|
-
}
|
|
222
|
-
if (!p && this.moveToNeedPosition) {
|
|
223
|
-
return new errors_1.zoneAttrConflict(this.id, "moveTo", c.id).add("zone.ts", "getAction_add", 133);
|
|
224
|
-
}
|
|
225
|
-
if (!p)
|
|
226
|
-
p = this.lastPos;
|
|
227
|
-
let idx = Utils.positionToIndex(p.flat(), this.shape);
|
|
228
|
-
if (idx < 0 || !this.validatePosition(p)) {
|
|
229
|
-
return new errors_1.invalidPosition(c.id, p).add("zone.Dts", "getAction_add", 138);
|
|
230
|
-
}
|
|
231
|
-
// let swapTargetID: undefined | string = undefined;
|
|
232
|
-
// if (this.cardArr[idx]) swapTargetID = (this.cardArr[idx] as card).id;
|
|
233
|
-
//return new posChange(c.id, isChain, c.pos, p, swapTargetID);
|
|
234
|
-
return actionGenrator_1.actionConstructorRegistry.a_pos_change(s, c)(p)(cause);
|
|
235
|
-
}
|
|
236
|
-
getAction_remove(s, c, newPos, cause = actionGenrator_1.actionFormRegistry.none()) {
|
|
237
|
-
//probably not gonna be used
|
|
238
|
-
if (this.cardArr.length <= this.minCapacity) {
|
|
239
|
-
return new errors_1.zoneAttrConflict(this.id, "moveFrom", c.id).add("zone.ts", "getAction_remove", 223);
|
|
240
|
-
}
|
|
241
|
-
if (!this.canMoveFrom) {
|
|
242
|
-
return new errors_1.zoneAttrConflict(this.id, "moveFrom", c.id).add("zone.ts", "getAction_remove", 147);
|
|
243
|
-
}
|
|
244
|
-
// return new posChange(c.id, isChain, c.pos, newPos);
|
|
245
|
-
return actionGenrator_1.actionConstructorRegistry.a_pos_change(s, c)(newPos)(cause);
|
|
246
|
-
}
|
|
247
|
-
//move within zone
|
|
248
|
-
getAction_move(s, c, newPos, cause = actionGenrator_1.actionFormRegistry.none()) {
|
|
249
|
-
if (!this.canReorderSelf) {
|
|
250
|
-
return new errors_1.zoneAttrConflict(this.id, "moveFrom", c.id).add("zone.ts", "getAction_move", 154);
|
|
251
|
-
}
|
|
252
|
-
let index = this.findIndex(c.id);
|
|
253
|
-
if (index < 0 || !this.cardArr[index] || !this.validatePosition(c.pos))
|
|
254
|
-
return new errors_1.cardNotInApplicableZone(this.id, c.id).add("zone.ts", "getAction_move", 158);
|
|
255
|
-
let toIndex = Utils.positionToIndex(newPos.flat(), this.shape);
|
|
256
|
-
if (toIndex < 0 || !this.validatePosition(newPos))
|
|
257
|
-
return new errors_1.invalidPosition(c.id, newPos).add("zone.ts", "getAction_move", 162);
|
|
258
|
-
// let swapTargetID: undefined | string = undefined;
|
|
259
|
-
// if (this.cardArr[toIndex])
|
|
260
|
-
// swapTargetID = (this.cardArr[toIndex] as card).id;
|
|
261
|
-
// return new posChange(c.id, isChain, c.pos, newPos, swapTargetID);
|
|
262
|
-
return actionGenrator_1.actionConstructorRegistry.a_pos_change(s, c)(newPos)(cause);
|
|
263
|
-
}
|
|
264
|
-
generateShuffleMap() {
|
|
265
|
-
let a = [];
|
|
266
|
-
for (let i = 0; i < this.capacity; i++)
|
|
267
|
-
a.push(i);
|
|
268
|
-
a = a.sort((a, b) => Utils.rng(1, 0, false) - 0.5);
|
|
269
|
-
let k = new Map();
|
|
270
|
-
a.forEach((i, index) => k.set(index, i));
|
|
271
|
-
return k;
|
|
272
|
-
}
|
|
273
|
-
getAction_shuffle(s, cause = actionGenrator_1.actionFormRegistry.none()) {
|
|
274
|
-
if (!this.canReorderSelf || !this.capacity) {
|
|
275
|
-
return new errors_1.zoneAttrConflict(this.id, "shuffle").add("zone.ts", "getAction_shuffle", 181);
|
|
276
|
-
}
|
|
277
|
-
let map = this.generateShuffleMap();
|
|
278
|
-
return actionGenrator_1.actionConstructorRegistry.a_shuffle(s, this)(cause, {
|
|
279
|
-
shuffleMap: map
|
|
280
|
-
});
|
|
281
|
-
// return new shuffle(this.id, isChain);
|
|
282
|
-
}
|
|
283
|
-
//functions for step 2
|
|
284
|
-
addToIndex(c, toIndex) {
|
|
285
|
-
//assumes index is correct
|
|
286
|
-
if (!c)
|
|
287
|
-
return this.handleCardNotExist("addToIndex", 189);
|
|
288
|
-
if (!this.canMoveTo)
|
|
289
|
-
return this.handleNoMoveTo(c, "addToIndex", 190);
|
|
290
|
-
if (this.isFull)
|
|
291
|
-
return this.handleFull(c, "addToIndex", 111);
|
|
292
|
-
if (this.cardArr[toIndex])
|
|
293
|
-
return this.handleOccupied(c, toIndex, "addToIndex", 192);
|
|
294
|
-
//let oldPos = c.pos;
|
|
295
|
-
c.pos = new position_1.default(this.id, this.name, ...Utils.indexToPosition(toIndex, this.shape));
|
|
296
|
-
this.cardArr[toIndex] = c;
|
|
297
|
-
return [undefined, []];
|
|
298
|
-
}
|
|
299
|
-
add(c, p1) {
|
|
300
|
-
if (this.moveToNeedPosition) {
|
|
301
|
-
let toIndex = Utils.positionToIndex(p1.flat(), this.shape);
|
|
302
|
-
if (toIndex < 0 || !this.validatePosition(p1))
|
|
303
|
-
return this.handleInvalidPos(c ? c.id : undefined, p1, "add", 204);
|
|
304
|
-
let res = this.addToIndex(c, toIndex);
|
|
305
|
-
if (res[0])
|
|
306
|
-
res[0].add(this.name, "add", 133);
|
|
307
|
-
return res;
|
|
308
|
-
}
|
|
309
|
-
let res = this.addToIndex(c, this.cardArr.length);
|
|
310
|
-
if (res[0])
|
|
311
|
-
res[0].add(this.name, "add", 210);
|
|
312
|
-
return res;
|
|
313
|
-
}
|
|
314
|
-
remove(c) {
|
|
315
|
-
if (!this.canMoveFrom)
|
|
316
|
-
return this.handleNoMoveFrom(c, "remove", 215);
|
|
317
|
-
if (this.cardArr.length <= this.minCapacity)
|
|
318
|
-
return this.handleBelowMinimum(c, "remove", 323);
|
|
319
|
-
let index = this.findIndex(c.id);
|
|
320
|
-
if (index < 0 || !this.cardArr[index] || !this.validatePosition(c.pos))
|
|
321
|
-
return this.handleCardNotInApplicableZone(c, "remove", 219);
|
|
322
|
-
//let oldPos = c.pos;
|
|
323
|
-
this.cardArr[index] = undefined;
|
|
324
|
-
if (c.pos.zoneID == this.id)
|
|
325
|
-
c.pos.invalidate();
|
|
326
|
-
return [undefined, []];
|
|
327
|
-
}
|
|
328
|
-
move(c, p) {
|
|
329
|
-
if (!this.canReorderSelf)
|
|
330
|
-
return this.handleNoReorder("move", 229);
|
|
331
|
-
let index = this.findIndex(c.id);
|
|
332
|
-
if (index < 0 || !this.cardArr[index] || !this.validatePosition(c.pos))
|
|
333
|
-
return this.handleCardNotInApplicableZone(c, "remove", 233);
|
|
334
|
-
let toIndex = Utils.positionToIndex(p.flat(), this.shape);
|
|
335
|
-
if (toIndex < 0 || !this.validatePosition(p))
|
|
336
|
-
return this.handleInvalidPos(c.id, p, "move", 237);
|
|
337
|
-
if (this.cardArr[toIndex])
|
|
338
|
-
return this.handleOccupied(c, toIndex, "move", 239);
|
|
339
|
-
//let oldPos = c.pos;
|
|
340
|
-
c.pos = p;
|
|
341
|
-
this.cardArr[toIndex] = c;
|
|
342
|
-
return [undefined, []];
|
|
343
|
-
}
|
|
344
|
-
reorder(orderMap) {
|
|
345
|
-
if (!this.isValidOrderMap(orderMap, this.cardArr.length))
|
|
346
|
-
return false;
|
|
347
|
-
const visited = new Array(orderMap.size).fill(false);
|
|
348
|
-
// Iterate through the map to process each cycle
|
|
349
|
-
orderMap.forEach((newIndex, oldIndex) => {
|
|
350
|
-
if (visited[oldIndex])
|
|
351
|
-
return; // Skip if already processed
|
|
352
|
-
let current = oldIndex;
|
|
353
|
-
let temp = this.cardArr[current];
|
|
354
|
-
do {
|
|
355
|
-
visited[current] = true;
|
|
356
|
-
const next = orderMap.get(current);
|
|
357
|
-
const nextTemp = this.cardArr[next];
|
|
358
|
-
this.cardArr[next] = temp;
|
|
359
|
-
temp = nextTemp;
|
|
360
|
-
current = next;
|
|
361
|
-
} while (current !== oldIndex);
|
|
362
|
-
});
|
|
363
|
-
return true;
|
|
364
|
-
}
|
|
365
|
-
isValidOrderMap(orderMap, arrayLength) {
|
|
366
|
-
const visited = new Array(arrayLength).fill(false);
|
|
367
|
-
let c = 0;
|
|
368
|
-
// Check each entry in the map
|
|
369
|
-
for (const [oldIndex, newIndex] of orderMap.entries()) {
|
|
370
|
-
// Ensure indices are within bounds
|
|
371
|
-
if (oldIndex < 0 ||
|
|
372
|
-
oldIndex >= arrayLength ||
|
|
373
|
-
newIndex < 0 ||
|
|
374
|
-
newIndex >= arrayLength) {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
// Ensure newIndex is unique
|
|
378
|
-
if (visited[newIndex]) {
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
visited[newIndex] = true;
|
|
382
|
-
c++;
|
|
383
|
-
}
|
|
384
|
-
// Ensure the map is complete (contains exactly arrayLength entries)
|
|
385
|
-
return c === arrayLength;
|
|
386
|
-
}
|
|
387
|
-
shuffle(orderMap) {
|
|
388
|
-
if (!this.canReorderSelf || !this.capacity)
|
|
389
|
-
return this.handleNoReorder("shuffle", 298);
|
|
390
|
-
let a = this.reorder(orderMap);
|
|
391
|
-
if (!a)
|
|
392
|
-
return this.handleInvalidOrderMap(orderMap, "shuffle", 300);
|
|
393
|
-
return [undefined, []];
|
|
394
|
-
}
|
|
395
|
-
turnReset(a) {
|
|
396
|
-
let res = [];
|
|
397
|
-
this.cardArr.forEach((i) => {
|
|
398
|
-
if (i)
|
|
399
|
-
res.push(...i.reset());
|
|
400
|
-
});
|
|
401
|
-
return res;
|
|
402
|
-
}
|
|
403
|
-
//should override
|
|
404
|
-
getInput_ZoneRespond(a, s) { return undefined; }
|
|
405
|
-
getZoneRespond(a, system, input) {
|
|
406
|
-
//zone responses bypasses cannot chain
|
|
407
|
-
//only calls in chain phase
|
|
408
|
-
return [];
|
|
409
|
-
}
|
|
410
|
-
//should override
|
|
411
|
-
getInput_interact(s, cause) { return undefined; }
|
|
412
|
-
interact(s, cause, input) {
|
|
413
|
-
return [];
|
|
414
|
-
}
|
|
415
|
-
getCanRespondMap(a, system) {
|
|
416
|
-
let res = new Map();
|
|
417
|
-
this.cardArr.forEach((i, idx) => {
|
|
418
|
-
if (i) {
|
|
419
|
-
res.set(i, i.getResponseIndexArr(system, a));
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
return res;
|
|
423
|
-
}
|
|
424
|
-
//can override section
|
|
425
|
-
handleCardNotExist(func, line) {
|
|
426
|
-
return [new errors_1.cardNotExist().add(this.name, func, line), undefined];
|
|
427
|
-
}
|
|
428
|
-
handleInvalidPos(cid, p, func, line) {
|
|
429
|
-
if (!cid)
|
|
430
|
-
return this.handleCardNotExist(func, line);
|
|
431
|
-
return [new errors_1.invalidPosition(cid, p).add(this.name, func, line), undefined];
|
|
432
|
-
}
|
|
433
|
-
handleNoMoveTo(c, func, line) {
|
|
434
|
-
return [
|
|
435
|
-
new errors_1.zoneAttrConflict(this.id, "move card to this zone").add(this.name, func, line),
|
|
436
|
-
undefined,
|
|
437
|
-
];
|
|
438
|
-
}
|
|
439
|
-
handleNoMoveFrom(c, func, line) {
|
|
440
|
-
return [
|
|
441
|
-
new errors_1.zoneAttrConflict(this.id, "move card away from this zone").add(this.name, func, line),
|
|
442
|
-
undefined,
|
|
443
|
-
];
|
|
444
|
-
}
|
|
445
|
-
handleNoReorder(func, line) {
|
|
446
|
-
return [
|
|
447
|
-
new errors_1.zoneAttrConflict(this.id, "move card within this zone").add(this.name, func, line),
|
|
448
|
-
undefined,
|
|
449
|
-
];
|
|
450
|
-
}
|
|
451
|
-
handleFull(c, func, line) {
|
|
452
|
-
return [new errors_1.zoneFull(this.id, c.id).add(this.name, func, line), undefined];
|
|
453
|
-
}
|
|
454
|
-
handleCardNotInApplicableZone(c, func, line) {
|
|
455
|
-
return [
|
|
456
|
-
new errors_1.cardNotInApplicableZone(this.id, c.id).add(this.name, func, line),
|
|
457
|
-
undefined,
|
|
458
|
-
];
|
|
459
|
-
}
|
|
460
|
-
handleInvalidOrderMap(orderMap, func, line) {
|
|
461
|
-
return [
|
|
462
|
-
new errors_1.invalidOrderMap(orderMap).add(this.name, func, line),
|
|
463
|
-
undefined,
|
|
464
|
-
];
|
|
465
|
-
}
|
|
466
|
-
handleBelowMinimum(c, func, line) {
|
|
467
|
-
return [
|
|
468
|
-
new errors_1.zoneAttrConflict(this.id, "move card away from this zone").add(this.name, func, line),
|
|
469
|
-
undefined,
|
|
470
|
-
];
|
|
471
|
-
}
|
|
472
|
-
handleOccupiedSwap(c, index, func, line) {
|
|
473
|
-
//default behavior: if
|
|
474
|
-
// + can rearrange self and
|
|
475
|
-
// + card has same zoneID with this one
|
|
476
|
-
// --> swap
|
|
477
|
-
// else throw error
|
|
478
|
-
if (!this.canReorderSelf)
|
|
479
|
-
return this.handleNoReorder(func, line);
|
|
480
|
-
if (c.pos.zoneID != this.id)
|
|
481
|
-
return this.handleCardNotInApplicableZone(c, func, line);
|
|
482
|
-
if (!this.cardArr[index]) {
|
|
483
|
-
//technically not happenable but better be safe than sorry
|
|
484
|
-
let err = new errors_1.unknownError();
|
|
485
|
-
err.add(this.name, func, line);
|
|
486
|
-
return [err, undefined];
|
|
487
|
-
}
|
|
488
|
-
//swap the two indexes
|
|
489
|
-
let cIndex = Utils.positionToIndex(c.pos.flat(), this.shape);
|
|
490
|
-
//let swapTargetID = this.cardArr[index].id
|
|
491
|
-
let oldPos = c.pos;
|
|
492
|
-
let newPos = this.cardArr[index].pos;
|
|
493
|
-
//swap the position
|
|
494
|
-
this.cardArr[index].pos = oldPos;
|
|
495
|
-
c.pos = newPos;
|
|
496
|
-
//swap the data
|
|
497
|
-
let temp = this.cardArr[cIndex];
|
|
498
|
-
this.cardArr[cIndex] = this.cardArr[index];
|
|
499
|
-
this.cardArr[index] = temp;
|
|
500
|
-
return [undefined, []];
|
|
501
|
-
}
|
|
502
|
-
handleOccupiedPush(c, index, func, line) {
|
|
503
|
-
if (!this.canReorderSelf)
|
|
504
|
-
return this.handleNoReorder(func, line);
|
|
505
|
-
if (!this.cardArr[index]) {
|
|
506
|
-
//technically not happenable but better be safe than sorry
|
|
507
|
-
let err = new errors_1.unknownError();
|
|
508
|
-
err.add(this.name, func, line);
|
|
509
|
-
return [err, undefined];
|
|
510
|
-
}
|
|
511
|
-
let temp = this.cardArr.slice(0, index);
|
|
512
|
-
let temp2 = this.cardArr.slice(index);
|
|
513
|
-
this.cardArr = [...temp, c, ...temp2];
|
|
514
|
-
this.cardArr.forEach((i, index) => {
|
|
515
|
-
if (i) {
|
|
516
|
-
i.pos.arr = Utils.indexToPosition(index, this.shape);
|
|
517
|
-
i.pos.zoneID = this.id;
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
return [undefined, []];
|
|
521
|
-
}
|
|
522
|
-
handleOccupied(c, index, func, line) {
|
|
523
|
-
return this.handleOccupiedSwap(c, index, func, line);
|
|
524
|
-
}
|
|
525
|
-
forceCardArrContent(newCardArr, shuffle = false) {
|
|
526
|
-
this.cardArr = newCardArr;
|
|
527
|
-
if (shuffle)
|
|
528
|
-
this.cardArr = this.cardArr.sort((_, __) => Math.random() - 0.5);
|
|
529
|
-
this.cardArr.forEach((i, index) => {
|
|
530
|
-
let p = new position_1.default(this.id, this.name, ...Utils.indexToPosition(index, this.shape));
|
|
531
|
-
i.pos = p;
|
|
532
|
-
// console.log(
|
|
533
|
-
// `forcing ${(i as Card).dataID} in index ` +
|
|
534
|
-
// index +
|
|
535
|
-
// " to pos " +
|
|
536
|
-
// p.toString() +
|
|
537
|
-
// " whose validity is " +
|
|
538
|
-
// p.valid
|
|
539
|
-
// );
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
toString(spaces = 2, simplify = false) {
|
|
543
|
-
let c = {};
|
|
544
|
-
this.cardArr.forEach((value, key) => {
|
|
545
|
-
c[key.toString()] = (value === undefined) ? "undefined" : value.toString(spaces, simplify);
|
|
546
|
-
});
|
|
547
|
-
return JSON.stringify({
|
|
548
|
-
id: this.id,
|
|
549
|
-
name: this.name,
|
|
550
|
-
priority: this.priority,
|
|
551
|
-
cardMap: c
|
|
552
|
-
}, null, spaces);
|
|
553
|
-
}
|
|
554
|
-
count(callback) {
|
|
555
|
-
let a = 0;
|
|
556
|
-
this.cardArr.forEach(c => { if (c)
|
|
557
|
-
a += callback(c) ? 1 : 0; });
|
|
558
|
-
return a;
|
|
559
|
-
}
|
|
560
|
-
has(obj) {
|
|
561
|
-
return this.id === obj.pos.zoneID;
|
|
562
|
-
}
|
|
563
|
-
is(p) {
|
|
564
|
-
if (p === undefined)
|
|
565
|
-
return false;
|
|
566
|
-
if (typeof p === "number") {
|
|
567
|
-
return this.types.includes(p);
|
|
568
|
-
}
|
|
569
|
-
return p.id === this.id;
|
|
570
|
-
}
|
|
571
|
-
of(p) {
|
|
572
|
-
if (typeof p === "number") {
|
|
573
|
-
return this.playerIndex === p;
|
|
574
|
-
}
|
|
575
|
-
if (!p)
|
|
576
|
-
return false;
|
|
577
|
-
return p.playerIndex === this.playerIndex;
|
|
578
|
-
}
|
|
579
|
-
get cardArr_filtered() { return this.cardArr.filter(i => i !== undefined); }
|
|
580
|
-
getAllPos() {
|
|
581
|
-
return this.cardArr.map((_, index) => new position_1.default(this.id, this.name, ...Utils.indexToPosition(index, this.shape)));
|
|
582
|
-
}
|
|
583
|
-
//Position check API
|
|
584
|
-
isC2Behind(c1, c2) {
|
|
585
|
-
if (c1.pos.zoneID !== this.id || c2.pos.zoneID !== this.id)
|
|
586
|
-
return false;
|
|
587
|
-
const p = this.getFrontPos(c1);
|
|
588
|
-
return c2.pos.x === p.x && c2.pos.y === p.y;
|
|
589
|
-
}
|
|
590
|
-
isC2Infront(c1, c2) {
|
|
591
|
-
if (c1.pos.zoneID !== this.id || c2.pos.zoneID !== this.id)
|
|
592
|
-
return false;
|
|
593
|
-
const p = this.getBackPos(c1);
|
|
594
|
-
return c2.pos.x === p.x && c2.pos.y === p.y;
|
|
595
|
-
}
|
|
596
|
-
getFrontPos(c) {
|
|
597
|
-
return new position_1.default(this.id, this.name, c.pos.x + 1, c.pos.y);
|
|
598
|
-
}
|
|
599
|
-
getBackPos(c) {
|
|
600
|
-
return new position_1.default(this.id, this.name, c.pos.x - 1, c.pos.y);
|
|
601
|
-
}
|
|
602
|
-
isOccupied(pos) {
|
|
603
|
-
const n = Utils.positionToIndex(pos.flat(), this.shape);
|
|
604
|
-
if (isNaN(n) || n < 0)
|
|
605
|
-
return false;
|
|
606
|
-
return this.cardArr[n] !== undefined;
|
|
607
|
-
}
|
|
608
|
-
isExposed(c1) {
|
|
609
|
-
//exposed = no card is infront of this
|
|
610
|
-
return !this.isOccupied(this.getFrontPos(c1));
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
exports.Zone = Zone;
|
|
614
|
-
exports.default = Zone;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Position from "../generics/position";
|
|
2
|
-
import { Zone } from "./zone";
|
|
3
|
-
import type Card from "./card";
|
|
4
|
-
import type { Positionable, Player_specific, HasTypesArr } from "../../misc";
|
|
5
|
-
import type { inputData } from "../../../data/systemRegistry";
|
|
6
|
-
declare class Zone_grid<T_cull_zone_res extends inputData[] | undefined = undefined, T_cull_interact extends inputData[] | undefined = undefined> extends Zone<T_cull_zone_res, T_cull_interact> {
|
|
7
|
-
cardArr: any[];
|
|
8
|
-
private get firstEmptyIndex();
|
|
9
|
-
private get lastEmptyIndex();
|
|
10
|
-
get isFull(): boolean;
|
|
11
|
-
get valid(): boolean;
|
|
12
|
-
get lastPos(): Position;
|
|
13
|
-
get firstPos(): Position;
|
|
14
|
-
forceCardArrContent(newCardArr: Card[]): void;
|
|
15
|
-
isOpposite(c1: Positionable, c2: Positionable): boolean;
|
|
16
|
-
isOpposite(z: Player_specific & HasTypesArr): boolean;
|
|
17
|
-
}
|
|
18
|
-
export default Zone_grid;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
//hand, grave, field, deck, etc extends from this, reserve index 0 for system
|
|
7
|
-
const position_1 = __importDefault(require("../generics/position"));
|
|
8
|
-
const zone_1 = require("./zone");
|
|
9
|
-
const zoneRegistry_1 = require("../../../data/zoneRegistry");
|
|
10
|
-
class Zone_grid extends zone_1.Zone {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
this.cardArr = (isFinite(this.capacity) && !isNaN(this.capacity)) ? new Array(this.capacity).fill(undefined) : [];
|
|
14
|
-
}
|
|
15
|
-
get firstEmptyIndex() { return this.cardArr.indexOf(undefined); }
|
|
16
|
-
get lastEmptyIndex() { return this.cardArr.lastIndexOf(undefined); }
|
|
17
|
-
get isFull() {
|
|
18
|
-
return (this.firstEmptyIndex === -1);
|
|
19
|
-
}
|
|
20
|
-
get valid() {
|
|
21
|
-
return this.id >= 0 && this.capacity !== Infinity;
|
|
22
|
-
}
|
|
23
|
-
get lastPos() {
|
|
24
|
-
return new position_1.default(this.id, this.name, ...Utils.indexToPosition((this.isFull) ? this.capacity - 1 : this.lastEmptyIndex, this.shape));
|
|
25
|
-
}
|
|
26
|
-
get firstPos() {
|
|
27
|
-
return new position_1.default(this.id, this.name, ...Utils.indexToPosition(this.firstEmptyIndex, this.shape));
|
|
28
|
-
}
|
|
29
|
-
forceCardArrContent(newCardArr) {
|
|
30
|
-
const oldLen = this.cardArr.length;
|
|
31
|
-
this.cardArr = newCardArr;
|
|
32
|
-
if (isNaN(this.capacity) || !isFinite(this.capacity))
|
|
33
|
-
return;
|
|
34
|
-
if (this.cardArr.length < oldLen)
|
|
35
|
-
this.cardArr = this.cardArr.concat(...(new Array(oldLen - this.cardArr.length).fill(undefined)));
|
|
36
|
-
while (this.cardArr.length > oldLen)
|
|
37
|
-
this.cardArr.pop();
|
|
38
|
-
}
|
|
39
|
-
isOpposite(p1, p2) {
|
|
40
|
-
if (p2 === undefined) {
|
|
41
|
-
const z = p1;
|
|
42
|
-
const flag1 = zoneRegistry_1.playerOppositeMap[zoneRegistry_1.playerTypeID[this.playerType]].some(i => i === z.playerType);
|
|
43
|
-
const flag2 = this.types.join() === z.types.join();
|
|
44
|
-
return flag1 && flag2;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const c1 = p1;
|
|
48
|
-
const c2 = p2;
|
|
49
|
-
return c1.pos.valid &&
|
|
50
|
-
c2.pos.valid &&
|
|
51
|
-
c1.pos.flat().length === 2 &&
|
|
52
|
-
c2.pos.flat().length === 2 &&
|
|
53
|
-
c1.pos.x === c2.pos.x &&
|
|
54
|
-
c1.pos.y !== c2.pos.y;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.default = Zone_grid;
|