qpremake 1.5.1
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 +184 -0
- package/lib/_localizationFiles/English.d.ts +2 -0
- package/lib/_localizationFiles/English.js +307 -0
- package/lib/_mods/parserModules/addSymbol.d.ts +7 -0
- package/lib/_mods/parserModules/addSymbol.js +18 -0
- package/lib/_mods/parserModules/expression.d.ts +7 -0
- package/lib/_mods/parserModules/expression.js +45 -0
- package/lib/_mods/parserModules/expression_parser.d.ts +143 -0
- package/lib/_mods/parserModules/expression_parser.js +728 -0
- package/lib/_mods/parserModules/img.d.ts +8 -0
- package/lib/_mods/parserModules/img.js +42 -0
- package/lib/_mods/parserModules/qpOriginal.d.ts +5 -0
- package/lib/_mods/parserModules/qpOriginal.js +27 -0
- package/lib/_mods/parserModules/sectionID.d.ts +13 -0
- package/lib/_mods/parserModules/sectionID.js +56 -0
- package/lib/_mods/parserModules/tags.d.ts +9 -0
- package/lib/_mods/parserModules/tags.js +29 -0
- package/lib/_mods/parserModules/uaddminus.d.ts +9 -0
- package/lib/_mods/parserModules/uaddminus.js +42 -0
- package/lib/_mods/parserModules/variantCheck.d.ts +10 -0
- package/lib/_mods/parserModules/variantCheck.js +53 -0
- package/lib/_queenSystem/handler/actionGenrator.d.ts +994 -0
- package/lib/_queenSystem/handler/actionGenrator.js +646 -0
- package/lib/_queenSystem/handler/actionInputGenerator.d.ts +95 -0
- package/lib/_queenSystem/handler/actionInputGenerator.js +373 -0
- package/lib/_queenSystem/handler/actionInputRequesterGenerator.d.ts +92 -0
- package/lib/_queenSystem/handler/actionInputRequesterGenerator.js +341 -0
- package/lib/_queenSystem/handler/cardHandler.d.ts +20 -0
- package/lib/_queenSystem/handler/cardHandler.js +61 -0
- package/lib/_queenSystem/handler/effectGenerator.d.ts +1 -0
- package/lib/_queenSystem/handler/effectGenerator.js +127 -0
- package/lib/_queenSystem/handler/localizationHandler.d.ts +28 -0
- package/lib/_queenSystem/handler/localizationHandler.js +166 -0
- package/lib/_queenSystem/handler/modHandler.d.ts +10 -0
- package/lib/_queenSystem/handler/modHandler.js +36 -0
- package/lib/_queenSystem/handler/oldDataProcessor.d.ts +9 -0
- package/lib/_queenSystem/handler/oldDataProcessor.js +129 -0
- package/lib/_queenSystem/handler/registryHandler.d.ts +36 -0
- package/lib/_queenSystem/handler/registryHandler.js +63 -0
- package/lib/_queenSystem/handler/zoneHandler.d.ts +102 -0
- package/lib/_queenSystem/handler/zoneHandler.js +606 -0
- package/lib/_queenSystem/loader/loader_card.d.ts +20 -0
- package/lib/_queenSystem/loader/loader_card.js +124 -0
- package/lib/_queenSystem/loader/loader_effect.d.ts +27 -0
- package/lib/_queenSystem/loader/loader_effect.js +163 -0
- package/lib/_queenSystem/loader/loader_handler.d.ts +11 -0
- package/lib/_queenSystem/loader/loader_handler.js +24 -0
- package/lib/_queenSystem/loader/loader_localization.d.ts +11 -0
- package/lib/_queenSystem/loader/loader_localization.js +73 -0
- package/lib/_queenSystem/loader/loader_mod.d.ts +10 -0
- package/lib/_queenSystem/loader/loader_mod.js +72 -0
- package/lib/_queenSystem/loader/loader_subtype.d.ts +9 -0
- package/lib/_queenSystem/loader/loader_subtype.js +39 -0
- package/lib/_queenSystem/loader/loader_type.d.ts +9 -0
- package/lib/_queenSystem/loader/loader_type.js +39 -0
- package/lib/_queenSystem/loader/loader_zone.d.ts +14 -0
- package/lib/_queenSystem/loader/loader_zone.js +35 -0
- package/lib/_queenSystem/queenSystem.d.ts +127 -0
- package/lib/_queenSystem/queenSystem.js +996 -0
- package/lib/_queenSystem/renderer/rendererInterface.d.ts +9 -0
- package/lib/_queenSystem/renderer/rendererInterface.js +2 -0
- package/lib/data/actionRegistry.d.ts +56 -0
- package/lib/data/actionRegistry.js +60 -0
- package/lib/data/cardRegistry.d.ts +1162 -0
- package/lib/data/cardRegistry.js +716 -0
- package/lib/data/deckRegistry.d.ts +19 -0
- package/lib/data/deckRegistry.js +41 -0
- package/lib/data/effectRegistry.d.ts +465 -0
- package/lib/data/effectRegistry.js +151 -0
- package/lib/data/effectTypeRegistry.d.ts +14 -0
- package/lib/data/effectTypeRegistry.js +14 -0
- package/lib/data/operatorRegistry.d.ts +92 -0
- package/lib/data/operatorRegistry.js +82 -0
- package/lib/data/rarityRegistry.d.ts +28 -0
- package/lib/data/rarityRegistry.js +63 -0
- package/lib/data/registryRegistry.d.ts +10 -0
- package/lib/data/registryRegistry.js +14 -0
- package/lib/data/subtypeRegistry.d.ts +15 -0
- package/lib/data/subtypeRegistry.js +15 -0
- package/lib/data/systemRegistry.d.ts +253 -0
- package/lib/data/systemRegistry.js +56 -0
- package/lib/data/zoneRegistry.d.ts +43 -0
- package/lib/data/zoneRegistry.js +157 -0
- package/lib/effectTextParser/index.d.ts +42 -0
- package/lib/effectTextParser/index.js +316 -0
- package/lib/global/index.d.ts +8 -0
- package/lib/global/index.js +12 -0
- package/lib/index.d.ts +6344 -0
- package/lib/index.js +213 -0
- package/lib/specificEffects/e_cond.d.ts +11 -0
- package/lib/specificEffects/e_cond.js +36 -0
- package/lib/specificEffects/e_fruit.d.ts +3 -0
- package/lib/specificEffects/e_fruit.js +187 -0
- package/lib/specificEffects/e_generic.d.ts +191 -0
- package/lib/specificEffects/e_generic.js +662 -0
- package/lib/specificEffects/e_generic_cardTargetting.d.ts +38 -0
- package/lib/specificEffects/e_generic_cardTargetting.js +82 -0
- package/lib/specificEffects/e_generic_noneTargetting.d.ts +10 -0
- package/lib/specificEffects/e_generic_noneTargetting.js +26 -0
- package/lib/specificEffects/e_status.d.ts +80 -0
- package/lib/specificEffects/e_status.js +151 -0
- package/lib/specificEffects/e_test.d.ts +3 -0
- package/lib/specificEffects/e_test.js +21 -0
- package/lib/types/abstract/gameComponents/API.d.ts +19 -0
- package/lib/types/abstract/gameComponents/API.js +2 -0
- package/lib/types/abstract/gameComponents/card.d.ts +108 -0
- package/lib/types/abstract/gameComponents/card.js +771 -0
- package/lib/types/abstract/gameComponents/effect.d.ts +82 -0
- package/lib/types/abstract/gameComponents/effect.js +331 -0
- package/lib/types/abstract/gameComponents/effectSubtype.d.ts +22 -0
- package/lib/types/abstract/gameComponents/effectSubtype.js +40 -0
- package/lib/types/abstract/gameComponents/effectType.d.ts +11 -0
- package/lib/types/abstract/gameComponents/effectType.js +8 -0
- package/lib/types/abstract/gameComponents/settings.d.ts +80 -0
- package/lib/types/abstract/gameComponents/settings.js +68 -0
- package/lib/types/abstract/gameComponents/zone.d.ts +113 -0
- package/lib/types/abstract/gameComponents/zone.js +614 -0
- package/lib/types/abstract/gameComponents/zone_gridBased.d.ts +18 -0
- package/lib/types/abstract/gameComponents/zone_gridBased.js +58 -0
- package/lib/types/abstract/gameComponents/zone_stackBased.d.ts +13 -0
- package/lib/types/abstract/gameComponents/zone_stackBased.js +55 -0
- package/lib/types/abstract/generics/node.d.ts +23 -0
- package/lib/types/abstract/generics/node.js +46 -0
- package/lib/types/abstract/generics/position.d.ts +23 -0
- package/lib/types/abstract/generics/position.js +91 -0
- package/lib/types/abstract/generics/tree.d.ts +25 -0
- package/lib/types/abstract/generics/tree.js +153 -0
- package/lib/types/abstract/generics/universalResponse.d.ts +4 -0
- package/lib/types/abstract/generics/universalResponse.js +2 -0
- package/lib/types/abstract/generics/wraper.d.ts +21 -0
- package/lib/types/abstract/generics/wraper.js +56 -0
- package/lib/types/abstract/parser/component.d.ts +88 -0
- package/lib/types/abstract/parser/component.js +132 -0
- package/lib/types/abstract/parser/index.d.ts +6 -0
- package/lib/types/abstract/parser/index.js +28 -0
- package/lib/types/abstract/parser/modPack.d.ts +21 -0
- package/lib/types/abstract/parser/modPack.js +48 -0
- package/lib/types/abstract/parser/moduleInputObject.d.ts +12 -0
- package/lib/types/abstract/parser/moduleInputObject.js +21 -0
- package/lib/types/abstract/parser/options.d.ts +31 -0
- package/lib/types/abstract/parser/options.js +45 -0
- package/lib/types/abstract/serializedGameComponents/Gamestate.d.ts +46 -0
- package/lib/types/abstract/serializedGameComponents/Gamestate.js +70 -0
- package/lib/types/abstract/serializedGameComponents/Localized.d.ts +69 -0
- package/lib/types/abstract/serializedGameComponents/Localized.js +84 -0
- package/lib/types/defaultZones/ability.d.ts +10 -0
- package/lib/types/defaultZones/ability.js +22 -0
- package/lib/types/defaultZones/deck.d.ts +25 -0
- package/lib/types/defaultZones/deck.js +90 -0
- package/lib/types/defaultZones/drop.d.ts +5 -0
- package/lib/types/defaultZones/drop.js +13 -0
- package/lib/types/defaultZones/field.d.ts +11 -0
- package/lib/types/defaultZones/field.js +35 -0
- package/lib/types/defaultZones/grave.d.ts +8 -0
- package/lib/types/defaultZones/grave.js +21 -0
- package/lib/types/defaultZones/hand.d.ts +5 -0
- package/lib/types/defaultZones/hand.js +14 -0
- package/lib/types/defaultZones/storage.d.ts +9 -0
- package/lib/types/defaultZones/storage.js +21 -0
- package/lib/types/defaultZones/system.d.ts +12 -0
- package/lib/types/defaultZones/system.js +35 -0
- package/lib/types/defaultZones/void.d.ts +4 -0
- package/lib/types/defaultZones/void.js +10 -0
- package/lib/types/effects/effectSubtypes/subtype_chained.d.ts +10 -0
- package/lib/types/effects/effectSubtypes/subtype_chained.js +17 -0
- package/lib/types/effects/effectSubtypes/subtype_delayed.d.ts +9 -0
- package/lib/types/effects/effectSubtypes/subtype_delayed.js +16 -0
- package/lib/types/effects/effectSubtypes/subtype_fieldLock.d.ts +9 -0
- package/lib/types/effects/effectSubtypes/subtype_fieldLock.js +21 -0
- package/lib/types/effects/effectSubtypes/subtype_graveLock.d.ts +9 -0
- package/lib/types/effects/effectSubtypes/subtype_graveLock.js +21 -0
- package/lib/types/effects/effectSubtypes/subtype_hand_or_fieldLock.d.ts +9 -0
- package/lib/types/effects/effectSubtypes/subtype_hand_or_fieldLock.js +21 -0
- package/lib/types/effects/effectSubtypes/subtype_hardUnique.d.ts +9 -0
- package/lib/types/effects/effectSubtypes/subtype_hardUnique.js +15 -0
- package/lib/types/effects/effectSubtypes/subtype_instant.d.ts +8 -0
- package/lib/types/effects/effectSubtypes/subtype_instant.js +20 -0
- package/lib/types/effects/effectSubtypes/subtype_once.d.ts +12 -0
- package/lib/types/effects/effectSubtypes/subtype_once.js +27 -0
- package/lib/types/effects/effectSubtypes/subtype_unique.d.ts +9 -0
- package/lib/types/effects/effectSubtypes/subtype_unique.js +16 -0
- package/lib/types/effects/effectTypes/initEffect.d.ts +7 -0
- package/lib/types/effects/effectTypes/initEffect.js +23 -0
- package/lib/types/effects/effectTypes/lockEffect.d.ts +9 -0
- package/lib/types/effects/effectTypes/lockEffect.js +25 -0
- package/lib/types/effects/effectTypes/manualEffect.d.ts +9 -0
- package/lib/types/effects/effectTypes/manualEffect.js +18 -0
- package/lib/types/effects/effectTypes/passiveEffect.d.ts +9 -0
- package/lib/types/effects/effectTypes/passiveEffect.js +23 -0
- package/lib/types/effects/effectTypes/triggerEffect.d.ts +9 -0
- package/lib/types/effects/effectTypes/triggerEffect.js +28 -0
- package/lib/types/errors/cannotLoad.d.ts +5 -0
- package/lib/types/errors/cannotLoad.js +13 -0
- package/lib/types/errors/cardNotExist.d.ts +5 -0
- package/lib/types/errors/cardNotExist.js +13 -0
- package/lib/types/errors/cardNotInApplicableZone.d.ts +5 -0
- package/lib/types/errors/cardNotInApplicableZone.js +13 -0
- package/lib/types/errors/effectCondNotMet.d.ts +5 -0
- package/lib/types/errors/effectCondNotMet.js +13 -0
- package/lib/types/errors/effectNotExist.d.ts +5 -0
- package/lib/types/errors/effectNotExist.js +13 -0
- package/lib/types/errors/error.d.ts +17 -0
- package/lib/types/errors/error.js +42 -0
- package/lib/types/errors/incorrectActionType.d.ts +5 -0
- package/lib/types/errors/incorrectActionType.js +13 -0
- package/lib/types/errors/index.d.ts +16 -0
- package/lib/types/errors/index.js +36 -0
- package/lib/types/errors/invalidOrderMap.d.ts +6 -0
- package/lib/types/errors/invalidOrderMap.js +14 -0
- package/lib/types/errors/invalidPosition.d.ts +6 -0
- package/lib/types/errors/invalidPosition.js +13 -0
- package/lib/types/errors/subTypeOverrideConflict.d.ts +7 -0
- package/lib/types/errors/subTypeOverrideConflict.js +15 -0
- package/lib/types/errors/unknownError.d.ts +5 -0
- package/lib/types/errors/unknownError.js +13 -0
- package/lib/types/errors/unregisteredAction.d.ts +6 -0
- package/lib/types/errors/unregisteredAction.js +13 -0
- package/lib/types/errors/wrongEffectIdx.d.ts +5 -0
- package/lib/types/errors/wrongEffectIdx.js +14 -0
- package/lib/types/errors/zoneAttrConflict.d.ts +5 -0
- package/lib/types/errors/zoneAttrConflict.js +15 -0
- package/lib/types/errors/zoneFull.d.ts +5 -0
- package/lib/types/errors/zoneFull.js +13 -0
- package/lib/types/errors/zoneNotExist.d.ts +5 -0
- package/lib/types/errors/zoneNotExist.js +13 -0
- package/lib/types/misc.d.ts +97 -0
- package/lib/types/misc.js +8 -0
- package/lib/types/mods/effectTextParserModule.d.ts +16 -0
- package/lib/types/mods/effectTextParserModule.js +81 -0
- package/lib/types/mods/gameModule.d.ts +5 -0
- package/lib/types/mods/gameModule.js +8 -0
- package/lib/utils/index.d.ts +78 -0
- package/lib/utils/index.js +562 -0
- package/package.json +45 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//zones handler is handler of all the zones
|
|
3
|
+
//and importantly, converter from action to zone func calls
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const system_1 = __importDefault(require("../../types/defaultZones/system"));
|
|
9
|
+
const deck_1 = __importDefault(require("../../types/defaultZones/deck"));
|
|
10
|
+
const storage_1 = __importDefault(require("../../types/defaultZones/storage"));
|
|
11
|
+
const grave_1 = __importDefault(require("../../types/defaultZones/grave"));
|
|
12
|
+
const hand_1 = __importDefault(require("../../types/defaultZones/hand"));
|
|
13
|
+
const field_1 = __importDefault(require("../../types/defaultZones/field"));
|
|
14
|
+
const ability_1 = __importDefault(require("../../types/defaultZones/ability"));
|
|
15
|
+
const void_1 = __importDefault(require("../../types/defaultZones/void"));
|
|
16
|
+
const zoneRegistry_1 = __importDefault(require("../../data/zoneRegistry"));
|
|
17
|
+
const zoneRegistry_2 = require("../../data/zoneRegistry");
|
|
18
|
+
const errors_1 = require("../../types/errors");
|
|
19
|
+
const position_1 = __importDefault(require("../../types/abstract/generics/position"));
|
|
20
|
+
const actionGenrator_1 = require("./actionGenrator");
|
|
21
|
+
const actionRegistry_1 = __importDefault(require("../../data/actionRegistry"));
|
|
22
|
+
const misc_1 = require("../../types/misc");
|
|
23
|
+
const actionInputGenerator_1 = require("./actionInputGenerator");
|
|
24
|
+
const drop_1 = __importDefault(require("../../types/defaultZones/drop"));
|
|
25
|
+
// import type { Zone_T } from "../../types/abstract/gameComponents/zone";
|
|
26
|
+
class zoneHandler {
|
|
27
|
+
//old
|
|
28
|
+
// async load(zoneReg : typeof zoneDataRegistry){
|
|
29
|
+
// //every entries in zoneReg house an importURL leading to a child class extended from zone
|
|
30
|
+
// //assuming the importURL are correct, import and create a new instance of those class
|
|
31
|
+
// //stores inside this class's zoneArr
|
|
32
|
+
// //using promise.all for concurrency
|
|
33
|
+
// const zonePromises = Object.entries(zoneReg)
|
|
34
|
+
// .sort((a, b) => isNaN(a[1].priority) ? 1 : isNaN(b[1].priority) ? -1 : a[1].priority - b[1].priority)
|
|
35
|
+
// .map(async ([keyStr, zoneData], index) => {
|
|
36
|
+
// let zoneClass = (await import(zoneData.importURL)).default as typeof zone;
|
|
37
|
+
// let zoneInstance = new zoneClass(index, keyStr, zoneRegistry[keyStr as zoneName], zoneData) as zone;
|
|
38
|
+
// this.zoneArr.push(zoneInstance);
|
|
39
|
+
// });
|
|
40
|
+
// await Promise.all(zonePromises);
|
|
41
|
+
// }
|
|
42
|
+
constructor(regs) {
|
|
43
|
+
this.zoneArr = [];
|
|
44
|
+
this.loader = regs.zoneLoader;
|
|
45
|
+
}
|
|
46
|
+
loadZones(s, players) {
|
|
47
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_system], zoneRegistry_1.default.z_system, system_1.default);
|
|
48
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_drop], zoneRegistry_1.default.z_drop, drop_1.default);
|
|
49
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_void], zoneRegistry_1.default.z_void, void_1.default);
|
|
50
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_deck], zoneRegistry_1.default.z_deck, deck_1.default);
|
|
51
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_hand], zoneRegistry_1.default.z_hand, hand_1.default);
|
|
52
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_storage], zoneRegistry_1.default.z_storage, storage_1.default);
|
|
53
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_field], zoneRegistry_1.default.z_field, field_1.default);
|
|
54
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_grave], zoneRegistry_1.default.z_grave, grave_1.default);
|
|
55
|
+
this.loader.load(zoneRegistry_2.zoneRegistry[zoneRegistry_2.zoneRegistry.z_ability], zoneRegistry_1.default.z_ability, ability_1.default);
|
|
56
|
+
// this.maxPlayerIndex = s.players.length
|
|
57
|
+
Object.entries(zoneRegistry_1.default).forEach(([zkey, zdata], index) => {
|
|
58
|
+
if (!zdata.instancedFor.length) {
|
|
59
|
+
let zinstance = this.loader.getZone(zkey, s);
|
|
60
|
+
Utils.insertionSort(this.zoneArr, zinstance, this.sortFunc);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
players.forEach((p, pindex) => {
|
|
64
|
+
let zinstance = this.loader.getZone(zkey, s, p.playerType, pindex);
|
|
65
|
+
if (zdata.instancedFor.includes(p.playerType)) {
|
|
66
|
+
Utils.insertionSort(this.zoneArr, zinstance, this.sortFunc);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
this.correctID();
|
|
72
|
+
}
|
|
73
|
+
sortFunc(a, b) {
|
|
74
|
+
const x = a.priority, y = b.priority;
|
|
75
|
+
if (Object.is(x, y))
|
|
76
|
+
return 0;
|
|
77
|
+
const rank = (a) => isNaN(a) ? 0 : a === -Infinity ? 1 : a === +Infinity ? 3 : 2;
|
|
78
|
+
const ra = rank(x), rb = rank(y);
|
|
79
|
+
return (ra !== rb) ? rb - ra : y - x;
|
|
80
|
+
}
|
|
81
|
+
correctID() {
|
|
82
|
+
for (let i = 0; i < this.zoneArr.length; i++)
|
|
83
|
+
this.zoneArr[i].id = i;
|
|
84
|
+
}
|
|
85
|
+
load(key, data, c) {
|
|
86
|
+
this.loader.load(key, data, c);
|
|
87
|
+
}
|
|
88
|
+
add(zclassID, s, ptype, pid, zDataID) {
|
|
89
|
+
let instance = this.loader.getZone(zclassID, s, ptype, pid, zDataID);
|
|
90
|
+
if (!instance)
|
|
91
|
+
throw new Error(`Fail to create instance of zone ${zclassID}`);
|
|
92
|
+
Utils.insertionSort(this.zoneArr, instance, this.sortFunc);
|
|
93
|
+
this.correctID();
|
|
94
|
+
}
|
|
95
|
+
load_and_add_noPlayer(key, s, param3, param4) {
|
|
96
|
+
//case 1, add both
|
|
97
|
+
if (typeof param3 === "object" && typeof param4 === "function") {
|
|
98
|
+
this.loader.load(key, param3, param4);
|
|
99
|
+
this.add(key, s, -1, -1, key);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!param4)
|
|
103
|
+
param4 = key;
|
|
104
|
+
//case 2, add class only
|
|
105
|
+
if (typeof param3 === "function") {
|
|
106
|
+
this.loader.load(key, undefined, param3);
|
|
107
|
+
this.add(key, s, -1, -1, param4);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
//case 3, add data only
|
|
111
|
+
if (typeof param3 === "object") {
|
|
112
|
+
this.loader.load(key, param3);
|
|
113
|
+
this.add(key, s, -1, -1, param4);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
//technically unreachable code
|
|
117
|
+
throw new Error("Undefined behavior: load_and_add, zoneHandler");
|
|
118
|
+
}
|
|
119
|
+
addNewPlayerInstancedZones(s, ptype, pid = -1) {
|
|
120
|
+
let insertNew = [];
|
|
121
|
+
this.zoneArr.forEach(i => {
|
|
122
|
+
let data = this.loader.getData(i.dataID);
|
|
123
|
+
if (data && data.instancedFor.includes(ptype)) {
|
|
124
|
+
let z = this.loader.getZone(i.classID, s, ptype, pid, i.dataID);
|
|
125
|
+
if (z)
|
|
126
|
+
insertNew.push(z);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
insertNew.forEach(i => Utils.insertionSort(this.zoneArr, i, this.sortFunc));
|
|
130
|
+
this.correctID();
|
|
131
|
+
}
|
|
132
|
+
//operations
|
|
133
|
+
genericHandler_card(s, a) {
|
|
134
|
+
let target = a.targets[0];
|
|
135
|
+
let z = this.zoneArr[target.card.pos.zoneID];
|
|
136
|
+
let c = z.getCardByPosition(new position_1.default(target.card.pos));
|
|
137
|
+
if (!c) {
|
|
138
|
+
c = this.getCardWithID(target.card.id);
|
|
139
|
+
if (!c)
|
|
140
|
+
return [true, [new errors_1.cardNotExist()]];
|
|
141
|
+
}
|
|
142
|
+
if (!a.resolvable(s, z, c))
|
|
143
|
+
return [true, []];
|
|
144
|
+
return [false, c];
|
|
145
|
+
}
|
|
146
|
+
genericHandler_effect(s, a) {
|
|
147
|
+
let target = a.targets[0];
|
|
148
|
+
let z = this.zoneArr[target.card.pos.zoneID];
|
|
149
|
+
let c = z.getCardByPosition(new position_1.default(target.card.pos));
|
|
150
|
+
if (!c) {
|
|
151
|
+
c = this.getCardWithID(target.card.id);
|
|
152
|
+
if (!c)
|
|
153
|
+
return [true, [new errors_1.cardNotExist()]];
|
|
154
|
+
}
|
|
155
|
+
let eff;
|
|
156
|
+
let eindex = c.findEffectIndex(target.eff.id);
|
|
157
|
+
if (eindex < 0) {
|
|
158
|
+
eff = this.getEffectWithID(target.eff.id);
|
|
159
|
+
if (!eff)
|
|
160
|
+
return [true, [new errors_1.effectNotExist(target.eff.id, c.id)]];
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
eff = c.totalEffects[eindex];
|
|
164
|
+
}
|
|
165
|
+
if (!a.resolvable(s, z, c, eff))
|
|
166
|
+
return [true, []];
|
|
167
|
+
return [false, c, eff];
|
|
168
|
+
}
|
|
169
|
+
genericHandler_subtype(s, a) {
|
|
170
|
+
let target = a.targets[0];
|
|
171
|
+
let z = this.zoneArr[target.card.pos.zoneID];
|
|
172
|
+
let c = z.getCardByPosition(new position_1.default(target.card.pos));
|
|
173
|
+
if (!c) {
|
|
174
|
+
c = this.getCardWithID(target.card.id);
|
|
175
|
+
if (!c)
|
|
176
|
+
return [true, [new errors_1.cardNotExist()]];
|
|
177
|
+
}
|
|
178
|
+
let eff;
|
|
179
|
+
let eindex = c.findEffectIndex(target.eff.id);
|
|
180
|
+
if (eindex < 0) {
|
|
181
|
+
eff = this.getEffectWithID(target.eff.id);
|
|
182
|
+
if (!eff)
|
|
183
|
+
return [true, [new errors_1.effectNotExist(target.eff.id, c.id)]];
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
eff = c.totalEffects[eindex];
|
|
187
|
+
}
|
|
188
|
+
let st = eff.getSubtypeidx(target.subtype.dataID);
|
|
189
|
+
if (st < 0)
|
|
190
|
+
return [true, [new errors_1.effectNotExist(target.eff.id, c.id).add("zoneHandler", "handleActivateEffectSubtypeFunc", 326)]];
|
|
191
|
+
if (!a.resolvable(s, z, c, eff, eff.subTypes[st]))
|
|
192
|
+
return [true, []];
|
|
193
|
+
return [false, c, eff, st];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* @param a : a pos change action, with 2 targets, a card target and a position target in index 0 and 1
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
handlePosChange(s, a) {
|
|
201
|
+
let k1 = a.targets[0];
|
|
202
|
+
let k2 = a.targets[1];
|
|
203
|
+
let pos = new position_1.default(k2.pos);
|
|
204
|
+
let res = [];
|
|
205
|
+
let z = this.zoneArr[k1.card.pos.zoneID];
|
|
206
|
+
let c = z.getCardByPosition(new position_1.default(k1.card.pos));
|
|
207
|
+
// let idxFrom = pos.zoneID
|
|
208
|
+
// let cardIdx = utils.positionToIndex(pos.flat(), this.zoneArr[idxFrom].shape)
|
|
209
|
+
// let c = this.zoneArr[idxFrom].cardArr[cardIdx]
|
|
210
|
+
if (!c) {
|
|
211
|
+
c = this.getCardWithID(k1.card.id);
|
|
212
|
+
if (!c)
|
|
213
|
+
return [
|
|
214
|
+
new errors_1.cardNotExist().add("zoneHandler", "handlePosChange", 54)
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
if (!a.resolvable(s, z, c))
|
|
218
|
+
return [];
|
|
219
|
+
let temp;
|
|
220
|
+
if (pos && pos.valid && pos.zoneID === c.pos.zoneID) {
|
|
221
|
+
console.log("move is triggered");
|
|
222
|
+
let idxTo = pos.zoneID;
|
|
223
|
+
temp = this.zoneArr[idxTo].move(c, pos);
|
|
224
|
+
//move is prioritized
|
|
225
|
+
if (temp[0])
|
|
226
|
+
res.push(temp[0]);
|
|
227
|
+
else
|
|
228
|
+
res.push(...temp[1]);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
temp = this.zoneArr[c.pos.zoneID].remove(c);
|
|
232
|
+
if (temp[0])
|
|
233
|
+
res.push(temp[0]);
|
|
234
|
+
else
|
|
235
|
+
res.push(...temp[1]);
|
|
236
|
+
temp = this.zoneArr[pos.zoneID].add(c, pos);
|
|
237
|
+
if (temp[0])
|
|
238
|
+
res.push(temp[0]);
|
|
239
|
+
else
|
|
240
|
+
res.push(...temp[1]);
|
|
241
|
+
}
|
|
242
|
+
return res;
|
|
243
|
+
}
|
|
244
|
+
handleDraw(s, a) {
|
|
245
|
+
let zone = this.zoneArr[a.targets[0].zone.id];
|
|
246
|
+
if (!zone || !zone.draw)
|
|
247
|
+
return [
|
|
248
|
+
new errors_1.zoneNotExist(a.targets[0].zone.id).add("zoneHandler", "handleDraw", 213)
|
|
249
|
+
];
|
|
250
|
+
if (!a.resolvable(s, zone)) {
|
|
251
|
+
console.log("from handle draw: ", zone.id, a.targets[0].zone.id);
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
254
|
+
let deck = zone;
|
|
255
|
+
let playerindex = deck.playerIndex;
|
|
256
|
+
let hand = this.hands.filter(i => i.playerIndex === playerindex);
|
|
257
|
+
if (hand.length !== 1)
|
|
258
|
+
return [
|
|
259
|
+
new errors_1.zoneNotExist(-1).add("zoneHandler", "handleDraw", 222)
|
|
260
|
+
];
|
|
261
|
+
let res = deck.draw(s, a, hand[0]);
|
|
262
|
+
console.log("2", a, res);
|
|
263
|
+
if (res[0])
|
|
264
|
+
return [res[0]];
|
|
265
|
+
else
|
|
266
|
+
return res[1];
|
|
267
|
+
}
|
|
268
|
+
handleShuffle(s, a) {
|
|
269
|
+
let z = this.zoneArr[a.targets[0].zone.id];
|
|
270
|
+
if (!z || !z.draw)
|
|
271
|
+
return [
|
|
272
|
+
new errors_1.zoneNotExist(a.targets[0].zone.id).add("zoneHandler", "handleDraw", 213)
|
|
273
|
+
];
|
|
274
|
+
if (!a.resolvable(s, z))
|
|
275
|
+
return [];
|
|
276
|
+
let temp = z.shuffle(a.flatAttr().shuffleMap);
|
|
277
|
+
if (temp[0])
|
|
278
|
+
return [temp[0]];
|
|
279
|
+
return temp[1];
|
|
280
|
+
}
|
|
281
|
+
handleTurnReset(s, a) {
|
|
282
|
+
//only do field refresh
|
|
283
|
+
let res = [];
|
|
284
|
+
this.zoneArr.forEach(i => res.push(...i.turnReset(a)));
|
|
285
|
+
return res;
|
|
286
|
+
}
|
|
287
|
+
handleCardReset(s, a) {
|
|
288
|
+
let res = this.genericHandler_card(s, a);
|
|
289
|
+
if (res[0])
|
|
290
|
+
return res[1];
|
|
291
|
+
return res[1].reset();
|
|
292
|
+
}
|
|
293
|
+
handleEffectReset(s, a) {
|
|
294
|
+
let res = this.genericHandler_effect(s, a);
|
|
295
|
+
if (res[0])
|
|
296
|
+
return res[1];
|
|
297
|
+
return res[2].reset();
|
|
298
|
+
}
|
|
299
|
+
handleEffectActivation(s, a) {
|
|
300
|
+
const card = a.targets[0].card;
|
|
301
|
+
const pid = a.targets[1].pid;
|
|
302
|
+
const gen = card.getParititonInputObj(pid, s, a);
|
|
303
|
+
if (!gen)
|
|
304
|
+
return card.activatePartition(pid, s, a);
|
|
305
|
+
return [
|
|
306
|
+
actionGenrator_1.actionConstructorRegistry.a_get_input(a.cause, {
|
|
307
|
+
requester: gen,
|
|
308
|
+
applicator: new actionInputGenerator_1.inputApplicator(card.activatePartition, [pid, s, a], card)
|
|
309
|
+
})
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
handleActivateEffectSubtypeFunc(s, a) {
|
|
313
|
+
let res = this.genericHandler_subtype(s, a);
|
|
314
|
+
if (res[0])
|
|
315
|
+
return res[1];
|
|
316
|
+
return res[2].activateSubtypeSpecificFunc(res[3], res[1], s, a);
|
|
317
|
+
}
|
|
318
|
+
handleAddStatusEffect(s, a, e) {
|
|
319
|
+
let res = this.genericHandler_card(s, a);
|
|
320
|
+
if (res[0])
|
|
321
|
+
return res[1];
|
|
322
|
+
res[1].addStatusEffect(e);
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
handleClearAllStatusEffect(s, a) {
|
|
326
|
+
let res = this.genericHandler_card(s, a);
|
|
327
|
+
if (res[0])
|
|
328
|
+
return res[1];
|
|
329
|
+
res[1].clearAllStatus();
|
|
330
|
+
return [];
|
|
331
|
+
}
|
|
332
|
+
handleRemoveStatusEffect(s, a) {
|
|
333
|
+
let res = this.genericHandler_effect(s, a);
|
|
334
|
+
if (res[0])
|
|
335
|
+
return res[1];
|
|
336
|
+
res[1].removeStatusEffect(res[2].id);
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
handleCardStatus(s, a) {
|
|
340
|
+
let res = this.genericHandler_card(s, a);
|
|
341
|
+
if (res[0])
|
|
342
|
+
return res[1];
|
|
343
|
+
res[1].canAct = (a.typeID === actionRegistry_1.default.a_enable_card);
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
getWouldBeAttackTarget(s, a) {
|
|
347
|
+
//find opposite
|
|
348
|
+
if (a.cause.card === undefined)
|
|
349
|
+
return [];
|
|
350
|
+
let c = a.cause.card;
|
|
351
|
+
let oppositeZones = this.zoneArr[c.pos.zoneID];
|
|
352
|
+
if (!oppositeZones)
|
|
353
|
+
return [];
|
|
354
|
+
let targetZone = oppositeZones.getOppositeZone(this.zoneArr);
|
|
355
|
+
if (!targetZone.length)
|
|
356
|
+
return [];
|
|
357
|
+
return [oppositeZones, targetZone[0].getOppositeCards(c).sort((a, b) => a.pos.y - b.pos.y)];
|
|
358
|
+
}
|
|
359
|
+
handleAttack(s, a) {
|
|
360
|
+
var _a, _b;
|
|
361
|
+
let attr = a.flatAttr();
|
|
362
|
+
let c = a.cause.card;
|
|
363
|
+
if (!c)
|
|
364
|
+
return [];
|
|
365
|
+
let targets = this.getWouldBeAttackTarget(s, a);
|
|
366
|
+
if (!targets.length)
|
|
367
|
+
return [];
|
|
368
|
+
if (!targets[1].length) {
|
|
369
|
+
return [
|
|
370
|
+
actionGenrator_1.actionConstructorRegistry.a_deal_heart_damage(s, targets[0].playerIndex)(a.cause, {
|
|
371
|
+
dmg: (_a = c.attr.get("atk")) !== null && _a !== void 0 ? _a : 0
|
|
372
|
+
})
|
|
373
|
+
];
|
|
374
|
+
}
|
|
375
|
+
return [
|
|
376
|
+
actionGenrator_1.actionConstructorRegistry.a_deal_damage_internal(s, targets[1][0])(a.cause, {
|
|
377
|
+
dmg: (attr.dmg === undefined) ? (_b = c.attr.get("atk")) !== null && _b !== void 0 ? _b : 0 : attr.dmg,
|
|
378
|
+
dmgType: (attr.dmgType === undefined) ? misc_1.damageType.physical : attr.dmgType
|
|
379
|
+
})
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
handleDealDamage_1(s, a) {
|
|
383
|
+
let res = this.genericHandler_card(s, a);
|
|
384
|
+
if (res[0])
|
|
385
|
+
return res[1];
|
|
386
|
+
let attr = a.flatAttr();
|
|
387
|
+
res[1].hp -= attr.dmg;
|
|
388
|
+
if (res[1].hp === 0) {
|
|
389
|
+
return [
|
|
390
|
+
actionGenrator_1.actionConstructorRegistry.a_destroy(s, res[1])(actionGenrator_1.actionFormRegistry.system())
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
return [];
|
|
394
|
+
}
|
|
395
|
+
handleDealDamage_2(s, a) {
|
|
396
|
+
let pos = a.targets[0].pos;
|
|
397
|
+
let c = this.getCardWithPosition(new position_1.default(pos));
|
|
398
|
+
if (!c)
|
|
399
|
+
return [
|
|
400
|
+
new errors_1.cardNotExist()
|
|
401
|
+
];
|
|
402
|
+
let attr = a.flatAttr();
|
|
403
|
+
c.hp -= attr.dmg;
|
|
404
|
+
if (c.hp === 0) {
|
|
405
|
+
return [
|
|
406
|
+
actionGenrator_1.actionConstructorRegistry.a_destroy(s, c)(actionGenrator_1.actionFormRegistry.system())
|
|
407
|
+
];
|
|
408
|
+
}
|
|
409
|
+
return [];
|
|
410
|
+
}
|
|
411
|
+
handleExecute(s, a) {
|
|
412
|
+
let res = this.genericHandler_card(s, a);
|
|
413
|
+
if (res[0])
|
|
414
|
+
return res[1];
|
|
415
|
+
//unpacks to an attack and a send to grave
|
|
416
|
+
let zoneid = res[1].pos.zoneID;
|
|
417
|
+
let z = this.zoneArr[zoneid];
|
|
418
|
+
if (!z)
|
|
419
|
+
return [
|
|
420
|
+
new errors_1.zoneNotExist(zoneid)
|
|
421
|
+
];
|
|
422
|
+
let pid = z.playerIndex;
|
|
423
|
+
let g = this.getPlayerZone(pid, zoneRegistry_2.zoneRegistry.z_grave);
|
|
424
|
+
if (!g || !g.length)
|
|
425
|
+
return [
|
|
426
|
+
new errors_1.zoneNotExist(pid)
|
|
427
|
+
];
|
|
428
|
+
return [
|
|
429
|
+
actionGenrator_1.actionConstructorRegistry.a_attack(s, a.targets[0].card)(a.cause, {
|
|
430
|
+
dmg: res[1].atk,
|
|
431
|
+
dmgType: misc_1.damageType.physical
|
|
432
|
+
}),
|
|
433
|
+
actionGenrator_1.actionConstructorRegistry.a_pos_change_force(s, res[1])(g[0].top)(actionGenrator_1.actionFormRegistry.system()).dontchain()
|
|
434
|
+
];
|
|
435
|
+
}
|
|
436
|
+
handleSendToTop(s, a, zid) {
|
|
437
|
+
let res = this.genericHandler_card(s, a);
|
|
438
|
+
if (res[0])
|
|
439
|
+
return res[1];
|
|
440
|
+
let zoneid = res[1].pos.zoneID;
|
|
441
|
+
let z = this.zoneArr[zoneid];
|
|
442
|
+
if (!z)
|
|
443
|
+
return [
|
|
444
|
+
new errors_1.zoneNotExist(zoneid)
|
|
445
|
+
];
|
|
446
|
+
let pid = z.playerIndex;
|
|
447
|
+
let targetZone = this.getPlayerZone(pid, zid);
|
|
448
|
+
if (!targetZone)
|
|
449
|
+
return [
|
|
450
|
+
new errors_1.zoneNotExist(pid)
|
|
451
|
+
];
|
|
452
|
+
return [
|
|
453
|
+
actionGenrator_1.actionConstructorRegistry.a_pos_change_force(s, res[1])(targetZone[0].top)(actionGenrator_1.actionFormRegistry.system())
|
|
454
|
+
];
|
|
455
|
+
}
|
|
456
|
+
getZoneRespond(z, s, a) {
|
|
457
|
+
const gen = z.getInput_ZoneRespond(a, s);
|
|
458
|
+
if (gen === undefined)
|
|
459
|
+
return z.getZoneRespond(a, s, undefined);
|
|
460
|
+
return [
|
|
461
|
+
actionGenrator_1.actionConstructorRegistry.a_get_input(actionGenrator_1.actionFormRegistry.system(), {
|
|
462
|
+
requester: gen,
|
|
463
|
+
applicator: new actionInputGenerator_1.inputApplicator(z.getZoneRespond, [a, s], z)
|
|
464
|
+
})
|
|
465
|
+
];
|
|
466
|
+
}
|
|
467
|
+
handleZoneInteract(z, s, a) {
|
|
468
|
+
const gen = z.getInput_interact(s, a.cause);
|
|
469
|
+
if (gen === undefined)
|
|
470
|
+
return z.interact(s, a.cause, undefined);
|
|
471
|
+
return [
|
|
472
|
+
actionGenrator_1.actionConstructorRegistry.a_get_input(actionGenrator_1.actionFormRegistry.system(), {
|
|
473
|
+
requester: gen,
|
|
474
|
+
applicator: new actionInputGenerator_1.inputApplicator(z.interact, [s, a.cause], z)
|
|
475
|
+
})
|
|
476
|
+
];
|
|
477
|
+
}
|
|
478
|
+
respond(system, a, zoneResponsesOnly = false) {
|
|
479
|
+
let arr = [];
|
|
480
|
+
let infoLog = new Map(); //cardID, effectIDs[]
|
|
481
|
+
this.zoneArr.forEach(i => {
|
|
482
|
+
arr.push(...this.getZoneRespond(i, system, a));
|
|
483
|
+
});
|
|
484
|
+
if (zoneResponsesOnly)
|
|
485
|
+
return [arr, []];
|
|
486
|
+
this.zoneArr.forEach(i => {
|
|
487
|
+
let respondMap = i.getCanRespondMap(a, system);
|
|
488
|
+
respondMap.forEach((pidxArr, cardInfo) => {
|
|
489
|
+
pidxArr.forEach(pidx => {
|
|
490
|
+
arr.push(actionGenrator_1.actionConstructorRegistry.a_activate_effect_internal(system, cardInfo)(pidx)(a.cause));
|
|
491
|
+
if (infoLog.has(cardInfo.id)) {
|
|
492
|
+
infoLog.get(cardInfo.id).push(cardInfo.effects[pidx].id);
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
infoLog.set(cardInfo.id, [cardInfo.effects[pidx].id]);
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
return [arr, Object.entries(infoLog)];
|
|
501
|
+
}
|
|
502
|
+
forEach(depth, callback) {
|
|
503
|
+
switch (depth) {
|
|
504
|
+
case 0:
|
|
505
|
+
return this.zoneArr.forEach((z, zid) => callback(z, zid));
|
|
506
|
+
case 1:
|
|
507
|
+
return this.zoneArr.forEach((z, zid) => z.cardArr.forEach((c, cid) => {
|
|
508
|
+
if (c)
|
|
509
|
+
callback(c, zid, cid);
|
|
510
|
+
}));
|
|
511
|
+
case 2:
|
|
512
|
+
return this.zoneArr.forEach((z, zid) => z.cardArr.forEach((c, cid) => {
|
|
513
|
+
if (c)
|
|
514
|
+
c.totalEffects.forEach((e, eid) => callback(e, zid, cid, eid));
|
|
515
|
+
}));
|
|
516
|
+
case 3:
|
|
517
|
+
return this.zoneArr.forEach((z, zid) => z.cardArr.forEach((c, cid) => {
|
|
518
|
+
if (c)
|
|
519
|
+
c.totalEffects.forEach((e, eid) => e.subTypes.forEach((st, stid) => callback(st, zid, cid, eid, stid)));
|
|
520
|
+
}));
|
|
521
|
+
default: return;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
map(depth, callback) {
|
|
525
|
+
let final = [];
|
|
526
|
+
this.forEach(depth, (c, ...index) => {
|
|
527
|
+
final.push(callback(c, ...index));
|
|
528
|
+
});
|
|
529
|
+
return final;
|
|
530
|
+
}
|
|
531
|
+
filter(depth, callback) {
|
|
532
|
+
let final = [];
|
|
533
|
+
this.forEach(depth, (c, ...index) => {
|
|
534
|
+
if (callback(c, ...index))
|
|
535
|
+
final.push(c);
|
|
536
|
+
});
|
|
537
|
+
return final;
|
|
538
|
+
}
|
|
539
|
+
getEffectWithID(eid) {
|
|
540
|
+
for (let i = 0; i < this.zoneArr.length; i++) {
|
|
541
|
+
for (let j = 0; j < this.zoneArr[i].cardArr.length; j++) {
|
|
542
|
+
let c = this.zoneArr[i].cardArr[j];
|
|
543
|
+
if (!c)
|
|
544
|
+
continue;
|
|
545
|
+
let x = c.findEffectIndex(eid);
|
|
546
|
+
if (x < 0)
|
|
547
|
+
continue;
|
|
548
|
+
return c.effects[x];
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return undefined;
|
|
552
|
+
}
|
|
553
|
+
getZoneWithType(type) {
|
|
554
|
+
return this.zoneArr.filter(i => i.types.includes(type));
|
|
555
|
+
}
|
|
556
|
+
enforceCardIntoZone(zoneIdx, cardArr) {
|
|
557
|
+
this.zoneArr[zoneIdx].forceCardArrContent(cardArr);
|
|
558
|
+
}
|
|
559
|
+
getZoneWithDataID(dataID) {
|
|
560
|
+
return this.zoneArr.filter(i => i.dataID === dataID);
|
|
561
|
+
}
|
|
562
|
+
getZoneWithClassID(classID) {
|
|
563
|
+
return this.zoneArr.filter(i => i.classID === classID);
|
|
564
|
+
}
|
|
565
|
+
getZoneWithName(zoneName) {
|
|
566
|
+
return this.zoneArr.find(a => a.name == zoneName);
|
|
567
|
+
}
|
|
568
|
+
getZoneWithID(id) {
|
|
569
|
+
return this.zoneArr[id];
|
|
570
|
+
}
|
|
571
|
+
getCardWithID(cardID) {
|
|
572
|
+
for (let i = 0; i < this.zoneArr.length; i++) {
|
|
573
|
+
let index = this.zoneArr[i].cardArr.findIndex(i => i && i.id === cardID);
|
|
574
|
+
if (index < 0)
|
|
575
|
+
continue;
|
|
576
|
+
return this.zoneArr[i].cardArr[index];
|
|
577
|
+
}
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
580
|
+
getCardWithPosition(pos) {
|
|
581
|
+
let z = this.zoneArr[pos.zoneID];
|
|
582
|
+
if (!z)
|
|
583
|
+
return undefined;
|
|
584
|
+
return z.getCardByPosition(pos);
|
|
585
|
+
}
|
|
586
|
+
//get stuff
|
|
587
|
+
get system() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_system); }
|
|
588
|
+
get void() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_void); }
|
|
589
|
+
get decks() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_deck); }
|
|
590
|
+
get storages() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_storage); }
|
|
591
|
+
get hands() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_hand); }
|
|
592
|
+
get abilityZones() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_ability); }
|
|
593
|
+
get graves() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_grave); }
|
|
594
|
+
get fields() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_field); }
|
|
595
|
+
get drops() { return this.getZoneWithType(zoneRegistry_2.zoneRegistry.z_drop); }
|
|
596
|
+
getPlayerZone(pid, type) {
|
|
597
|
+
return this.zoneArr.filter(i => i.playerIndex === pid && i.types.includes(type));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
exports.default = zoneHandler;
|
|
601
|
+
/*
|
|
602
|
+
note:
|
|
603
|
+
this file isnt complete
|
|
604
|
+
i havent added the ability for zones and cards to respond to actions
|
|
605
|
+
|
|
606
|
+
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Card from "../../types/abstract/gameComponents/card";
|
|
2
|
+
import type { cardData, cardData_unified, effectData } from "../../data/cardRegistry";
|
|
3
|
+
import type effectLoader from "./loader_effect";
|
|
4
|
+
import type { Setting } from "../../types/abstract/gameComponents/settings";
|
|
5
|
+
import Effect from "../../types/abstract/gameComponents/effect";
|
|
6
|
+
export default class cardLoader {
|
|
7
|
+
private dataCache;
|
|
8
|
+
private customClassCache;
|
|
9
|
+
private countCache;
|
|
10
|
+
private effectHandler;
|
|
11
|
+
constructor(effectHandler: effectLoader);
|
|
12
|
+
get classkeys(): string[];
|
|
13
|
+
get datakeys(): string[];
|
|
14
|
+
load(key: string, data: cardData, c?: typeof Card | Record<string, typeof Card>): void;
|
|
15
|
+
getCard(cid: string, s: Setting, variantid?: string[], dataOnly?: false): Card;
|
|
16
|
+
getCard(cid: string, s: Setting, variantid: string[], dataOnly: true): Omit<cardData_unified, "effects"> & {
|
|
17
|
+
effects: effectData[];
|
|
18
|
+
};
|
|
19
|
+
getDirect(cid: string, s: Setting, ...eff: Effect<any>[]): Card | undefined;
|
|
20
|
+
}
|