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,771 @@
|
|
|
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.partitionData_class = void 0;
|
|
7
|
+
const e_status_1 = require("../../../specificEffects/e_status");
|
|
8
|
+
const position_1 = __importDefault(require("../generics/position"));
|
|
9
|
+
const cardRegistry_1 = require("../../../data/cardRegistry");
|
|
10
|
+
const errors_1 = require("../../errors");
|
|
11
|
+
const settings_1 = require("./settings");
|
|
12
|
+
// import error from "../../errors/error";
|
|
13
|
+
class partitionData_class {
|
|
14
|
+
constructor(pdata, ...mapping) {
|
|
15
|
+
if (typeof pdata === "object") {
|
|
16
|
+
this.mapping = pdata.mapping;
|
|
17
|
+
this.behaviorID = pdata.behaviorID;
|
|
18
|
+
this.displayID = pdata.displayID;
|
|
19
|
+
this.typeID = pdata.typeID;
|
|
20
|
+
this.subTypeID = pdata.subTypeID;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.mapping = mapping;
|
|
24
|
+
this.behaviorID = pdata;
|
|
25
|
+
this.displayID = "default";
|
|
26
|
+
this.typeID = cardRegistry_1.type_and_or_subtype_inference_method.first;
|
|
27
|
+
this.subTypeID = cardRegistry_1.type_and_or_subtype_inference_method.all;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.partitionData_class = partitionData_class;
|
|
32
|
+
class Card {
|
|
33
|
+
constructor(s, cardData, effectArr) {
|
|
34
|
+
this.pos = new position_1.default();
|
|
35
|
+
this.canAct = true;
|
|
36
|
+
//effects section
|
|
37
|
+
this.effects = [];
|
|
38
|
+
//maps partition index -> array of effects indexes, Record instead of array since it may have gaps
|
|
39
|
+
//update : changed back into array cause why we shrink/compact to be an array
|
|
40
|
+
this.partitionInfo = [];
|
|
41
|
+
//status effects are temporary effects
|
|
42
|
+
this.statusEffects = [];
|
|
43
|
+
this.attr = new Map();
|
|
44
|
+
this.pInputMap = new Map;
|
|
45
|
+
this.pShareMemory = new Map;
|
|
46
|
+
this.originalData = cardData;
|
|
47
|
+
this.loadStat(true);
|
|
48
|
+
this.repartitioning(s);
|
|
49
|
+
this.setting = s;
|
|
50
|
+
this.effects = effectArr;
|
|
51
|
+
}
|
|
52
|
+
//load functions
|
|
53
|
+
loadSetting(s) {
|
|
54
|
+
if (s.global_partition_setting !== this.setting.global_partition_setting) {
|
|
55
|
+
this.repartitioning(s);
|
|
56
|
+
}
|
|
57
|
+
this.setting = s;
|
|
58
|
+
}
|
|
59
|
+
repartitioning(newSetting) {
|
|
60
|
+
switch (newSetting.global_partition_setting) {
|
|
61
|
+
case settings_1.partitionSetting.auto_mapping_one_to_one: {
|
|
62
|
+
this.partitionInfo = this.effects.map((_, index) => new partitionData_class(newSetting.default_partition_behavior, index));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
case settings_1.partitionSetting.auto_mapping_types: {
|
|
66
|
+
let mmap = new Map();
|
|
67
|
+
this.effects.forEach((i, index) => {
|
|
68
|
+
let key = i.signature_type;
|
|
69
|
+
if (mmap.has(key))
|
|
70
|
+
mmap.get(key).push(index);
|
|
71
|
+
else
|
|
72
|
+
mmap.set(key, [index]);
|
|
73
|
+
});
|
|
74
|
+
this.partitionInfo = [];
|
|
75
|
+
mmap.forEach(i => {
|
|
76
|
+
this.partitionInfo.push(new partitionData_class(newSetting.default_partition_behavior, ...i));
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
case settings_1.partitionSetting.auto_mapping_subtypes: {
|
|
81
|
+
let mmap = new Map();
|
|
82
|
+
this.effects.forEach((i, index) => {
|
|
83
|
+
let key = i.signature_type;
|
|
84
|
+
if (mmap.has(key))
|
|
85
|
+
mmap.get(key).push(index);
|
|
86
|
+
else
|
|
87
|
+
mmap.set(key, [index]);
|
|
88
|
+
});
|
|
89
|
+
this.partitionInfo = [];
|
|
90
|
+
mmap.forEach(i => {
|
|
91
|
+
this.partitionInfo.push(new partitionData_class(newSetting.default_partition_behavior, ...i));
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
case settings_1.partitionSetting.auto_mapping_ygo: {
|
|
96
|
+
this.partitionInfo = [
|
|
97
|
+
new partitionData_class(newSetting.default_partition_behavior, ...Utils.range(this.effects.length))
|
|
98
|
+
];
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
case settings_1.partitionSetting.manual_mapping_no_ghost: {
|
|
102
|
+
//I have no authroity to load effects here
|
|
103
|
+
//ahhh ?
|
|
104
|
+
//oh welp
|
|
105
|
+
this.partitionInfo = this.originalData.partition.map(val => new partitionData_class(val));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
case settings_1.partitionSetting.manual_mapping_with_ghost: {
|
|
109
|
+
let presence = new Set();
|
|
110
|
+
this.partitionInfo = this.originalData.partition.map(val => {
|
|
111
|
+
val.mapping.forEach(i => presence.add(i));
|
|
112
|
+
return new partitionData_class(val);
|
|
113
|
+
});
|
|
114
|
+
let t = [];
|
|
115
|
+
for (let i = 0; i < this.effects.length; i++) {
|
|
116
|
+
if (presence.has(i))
|
|
117
|
+
continue;
|
|
118
|
+
t.push(i);
|
|
119
|
+
}
|
|
120
|
+
this.partitionInfo.push(new partitionData_class(newSetting.default_partition_behavior, ...t));
|
|
121
|
+
}
|
|
122
|
+
case settings_1.partitionSetting.manual_mapping_with_ghost_spread: {
|
|
123
|
+
let presence = new Set();
|
|
124
|
+
this.partitionInfo = this.originalData.partition.map(val => {
|
|
125
|
+
val.mapping.forEach(i => presence.add(i));
|
|
126
|
+
return new partitionData_class(val.behaviorID, ...val.mapping);
|
|
127
|
+
});
|
|
128
|
+
for (let i = 0; i < this.effects.length; i++) {
|
|
129
|
+
if (presence.has(i))
|
|
130
|
+
continue;
|
|
131
|
+
this.partitionInfo.push(new partitionData_class(newSetting.default_partition_behavior, i));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
loadStat(fromStart = true) {
|
|
137
|
+
let statObj = {
|
|
138
|
+
maxAtk: this.originalData.atk,
|
|
139
|
+
maxHp: this.originalData.hp,
|
|
140
|
+
level: this.originalData.level,
|
|
141
|
+
extensionArr: this.originalData.extensionArr.map(i => String(i)),
|
|
142
|
+
rarityID: this.originalData.rarityID
|
|
143
|
+
};
|
|
144
|
+
this.statusEffects.forEach(i => i.parseStat(statObj));
|
|
145
|
+
if (fromStart) {
|
|
146
|
+
this.attr.set("atk", this.originalData.atk);
|
|
147
|
+
this.attr.set("hp", this.originalData.hp);
|
|
148
|
+
this.attr.set("maxAtk", statObj.maxAtk);
|
|
149
|
+
this.attr.set("maxHp", statObj.maxHp);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.maxAtk = statObj.maxAtk;
|
|
153
|
+
this.maxHp = statObj.maxHp;
|
|
154
|
+
}
|
|
155
|
+
this.level = statObj.level;
|
|
156
|
+
this.extensionArr = statObj.extensionArr;
|
|
157
|
+
this.rarityID = statObj.rarityID;
|
|
158
|
+
}
|
|
159
|
+
//shorthand access
|
|
160
|
+
get level() { return this.attr.get("level"); }
|
|
161
|
+
set level(newLevel) { this.attr.set("level", newLevel); }
|
|
162
|
+
get rarityID() { return this.attr.get("rarityID"); }
|
|
163
|
+
set rarityID(newRarityID) { this.attr.set("rarityID", newRarityID); }
|
|
164
|
+
get atk() { return this.attr.get("atk"); }
|
|
165
|
+
set atk(n) {
|
|
166
|
+
this.attr.set("atk", n);
|
|
167
|
+
if (n > this.maxAtk)
|
|
168
|
+
this.attr.set("maxAtk", n);
|
|
169
|
+
}
|
|
170
|
+
get hp() { return this.attr.get("hp"); }
|
|
171
|
+
set hp(n) {
|
|
172
|
+
this.attr.set("hp", n);
|
|
173
|
+
if (n > this.maxHp)
|
|
174
|
+
this.attr.set("maxHp", n);
|
|
175
|
+
}
|
|
176
|
+
get maxAtk() { return this.attr.get("maxAtk"); }
|
|
177
|
+
set maxAtk(n) {
|
|
178
|
+
//maintains the diff between
|
|
179
|
+
const diff = this.maxAtk - this.atk;
|
|
180
|
+
this.attr.set("maxAtk", n);
|
|
181
|
+
this.hp = n - diff;
|
|
182
|
+
}
|
|
183
|
+
get maxHp() { return this.attr.get("maxHp"); }
|
|
184
|
+
set maxHp(n) {
|
|
185
|
+
//maintains the diff between maxHp and hp
|
|
186
|
+
const diff = this.maxHp - this.hp;
|
|
187
|
+
this.attr.set("maxHp", n);
|
|
188
|
+
this.hp = n - diff;
|
|
189
|
+
}
|
|
190
|
+
get extensionArr() {
|
|
191
|
+
var _a;
|
|
192
|
+
let res = ((_a = this.attr.get("extensionArr")) !== null && _a !== void 0 ? _a : []);
|
|
193
|
+
return res.includes("*") ? ["*"] : res;
|
|
194
|
+
}
|
|
195
|
+
set extensionArr(val) { this.attr.set("extensionArr", val); }
|
|
196
|
+
//read only shorthand access
|
|
197
|
+
get effectIDs() { return this.effects.map(i => i.id); }
|
|
198
|
+
get imgUrl() { return this.originalData.imgURL; }
|
|
199
|
+
//belongTo should only be used for reference only? most cards check using extension, not this
|
|
200
|
+
get belongTo() { return this.originalData.belongTo; }
|
|
201
|
+
get id() { return this.originalData.id; }
|
|
202
|
+
get dataID() { return this.originalData.dataID; }
|
|
203
|
+
;
|
|
204
|
+
get variants() { return this.originalData.variants; }
|
|
205
|
+
;
|
|
206
|
+
//easier attributes to work with
|
|
207
|
+
get real_effectCount() { return this.effects.length; }
|
|
208
|
+
get display_effectCount() { return this.partitionInfo.length; }
|
|
209
|
+
get totalEffects() { return [...this.effects, ...this.statusEffects]; }
|
|
210
|
+
get hasStatusEffect() { return this.statusEffects.length !== 0; }
|
|
211
|
+
get isDead() { return this.hp <= 0; }
|
|
212
|
+
get display_atk() { return (this.setting.show_negative_stat) ? this.atk : Math.max(this.atk, 0); }
|
|
213
|
+
get display_hp() { return (this.setting.show_negative_stat) ? this.hp : Math.max(this.atk, 0); }
|
|
214
|
+
// pushNewExtension(nExtension : string){
|
|
215
|
+
// let a = this.extensionArr
|
|
216
|
+
// a.push(nExtension)
|
|
217
|
+
// this.attr.set("extensionArr", a)
|
|
218
|
+
// }
|
|
219
|
+
// removeExtension(whatToRemove : string){
|
|
220
|
+
// let a = this.extensionArr
|
|
221
|
+
// a = a.filter(n => n !== whatToRemove)
|
|
222
|
+
// this.attr.set("extensionArr", a)
|
|
223
|
+
// }
|
|
224
|
+
//effect manipulation
|
|
225
|
+
//partition API:
|
|
226
|
+
getAllGhostEffects() {
|
|
227
|
+
let presenceMap = new Array(this.effects.length).fill(false);
|
|
228
|
+
this.partitionInfo.forEach(i => {
|
|
229
|
+
i.mapping.forEach(k => { presenceMap[k] = true; });
|
|
230
|
+
});
|
|
231
|
+
return presenceMap.map((i, index) => !i ? index : undefined).filter(i => i !== undefined);
|
|
232
|
+
}
|
|
233
|
+
throwPartitionConflict(cid, pid, parr) {
|
|
234
|
+
throw new Error(`Partition mapping invalid on card data with key ${cid}, invalid mapping on partition ${pid} : ${parr.toString()}`);
|
|
235
|
+
}
|
|
236
|
+
//those id are display id, aka partition index
|
|
237
|
+
replacePartition(from_eidx, to_eidx, cardToCopyFrom) {
|
|
238
|
+
if (to_eidx < 0 || to_eidx >= this.display_effectCount)
|
|
239
|
+
return [new errors_1.effectNotExist(`<partition_id>_${to_eidx}`, this.id), undefined];
|
|
240
|
+
if (from_eidx < 0 || from_eidx >= cardToCopyFrom.display_effectCount)
|
|
241
|
+
return [new errors_1.effectNotExist(`<partition_id>_${from_eidx}`, this.id), undefined];
|
|
242
|
+
let dataFrom = this.partitionInfo[from_eidx];
|
|
243
|
+
let dataTo = cardToCopyFrom.partitionInfo[to_eidx];
|
|
244
|
+
//1st step : delete the indexes from this card
|
|
245
|
+
let res = [];
|
|
246
|
+
let indexMap = new Map();
|
|
247
|
+
this.partitionInfo.forEach((val, key) => {
|
|
248
|
+
if (key !== to_eidx) {
|
|
249
|
+
val.mapping.forEach((i, index) => {
|
|
250
|
+
if (indexMap.has(i)) {
|
|
251
|
+
let newIndex = indexMap.get(i);
|
|
252
|
+
this.partitionInfo[key].mapping[index] = newIndex;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
indexMap.set(i, res.length);
|
|
256
|
+
res.push(this.effects[i]);
|
|
257
|
+
this.partitionInfo[key].mapping[index] = res.length - 1;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
// delete this.partitionInfo[to_eidx]
|
|
263
|
+
//push back the data not referenced but still not deleted
|
|
264
|
+
//allowing ghost effects
|
|
265
|
+
if (res.length !== this.effects.length) {
|
|
266
|
+
for (let i = 0; i < this.effects.length; i++) {
|
|
267
|
+
if (dataTo.mapping.includes(i))
|
|
268
|
+
continue;
|
|
269
|
+
if (indexMap.has(i))
|
|
270
|
+
continue;
|
|
271
|
+
res.push(this.effects[i]);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
this.effects = res;
|
|
275
|
+
let newPartitionInfo = new partitionData_class(dataFrom);
|
|
276
|
+
//2nd step : add the new effects in
|
|
277
|
+
dataFrom.mapping.forEach(i => {
|
|
278
|
+
newPartitionInfo.mapping.push(this.effects.length);
|
|
279
|
+
this.effects.push(cardToCopyFrom.effects[i]);
|
|
280
|
+
});
|
|
281
|
+
this.partitionInfo[to_eidx] = newPartitionInfo;
|
|
282
|
+
return [undefined, []];
|
|
283
|
+
}
|
|
284
|
+
removePartition(pid) {
|
|
285
|
+
//delete the indexes from this card
|
|
286
|
+
let res = [];
|
|
287
|
+
let indexMap = new Map();
|
|
288
|
+
this.partitionInfo.forEach((val, key) => {
|
|
289
|
+
if (key !== pid) {
|
|
290
|
+
val.mapping.forEach((i, index) => {
|
|
291
|
+
if (indexMap.has(i)) {
|
|
292
|
+
let newIndex = indexMap.get(i);
|
|
293
|
+
this.partitionInfo[key].mapping[index] = newIndex;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
indexMap.set(i, res.length);
|
|
297
|
+
res.push(this.effects[i]);
|
|
298
|
+
this.partitionInfo[key].mapping[index] = res.length - 1;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
//push back the data not referenced but still not deleted
|
|
304
|
+
//allowing ghost effects
|
|
305
|
+
if (res.length !== this.effects.length) {
|
|
306
|
+
for (let i = 0; i < this.effects.length; i++) {
|
|
307
|
+
if (this.partitionInfo[pid].mapping.includes(i))
|
|
308
|
+
continue;
|
|
309
|
+
if (indexMap.has(i))
|
|
310
|
+
continue;
|
|
311
|
+
res.push(this.effects[i]);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
this.effects = res;
|
|
315
|
+
delete this.partitionInfo[pid];
|
|
316
|
+
return [undefined, []];
|
|
317
|
+
}
|
|
318
|
+
sanitizePartitionMapping(mapping) {
|
|
319
|
+
return mapping.filter(i => {
|
|
320
|
+
i >= 0 && i < this.effects.length;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
insertPartition(partition, newEffects = []) {
|
|
324
|
+
this.effects.push(...newEffects);
|
|
325
|
+
let newRes = this.sanitizePartitionMapping(partition.mapping);
|
|
326
|
+
if (newRes.length !== partition.mapping.length && !this.setting.ignore_invalid_partition_mapping) {
|
|
327
|
+
this.throwPartitionConflict(this.id, this.partitionInfo.length, partition.mapping);
|
|
328
|
+
}
|
|
329
|
+
partition.mapping = newRes;
|
|
330
|
+
this.partitionInfo.push(new partitionData_class(partition));
|
|
331
|
+
return [undefined, []];
|
|
332
|
+
}
|
|
333
|
+
remapPartition(targetPartitionID, newMapping) {
|
|
334
|
+
let k = this.sanitizePartitionMapping(newMapping);
|
|
335
|
+
if (k.length !== newMapping.length && !this.setting.ignore_invalid_partition_mapping ||
|
|
336
|
+
targetPartitionID < 0 || targetPartitionID >= this.partitionInfo.length) {
|
|
337
|
+
this.throwPartitionConflict(this.id, targetPartitionID, newMapping);
|
|
338
|
+
}
|
|
339
|
+
this.partitionInfo[targetPartitionID].mapping = k;
|
|
340
|
+
}
|
|
341
|
+
updatePartitionInfo(targetPartitionID, patchData) {
|
|
342
|
+
if (targetPartitionID < 0 || targetPartitionID >= this.partitionInfo.length) {
|
|
343
|
+
this.throwPartitionConflict(this.id, targetPartitionID, []);
|
|
344
|
+
}
|
|
345
|
+
if (patchData.mapping) {
|
|
346
|
+
let k = this.sanitizePartitionMapping(patchData.mapping);
|
|
347
|
+
if (k.length !== patchData.mapping.length && !this.setting.ignore_invalid_partition_mapping) {
|
|
348
|
+
this.throwPartitionConflict(this.id, targetPartitionID, patchData.mapping);
|
|
349
|
+
}
|
|
350
|
+
patchData.mapping = k;
|
|
351
|
+
}
|
|
352
|
+
Utils.patchGeneric(this.partitionInfo[targetPartitionID], patchData);
|
|
353
|
+
}
|
|
354
|
+
getPartitionDisplayInputs(sys, pid = -1) {
|
|
355
|
+
//default implementation
|
|
356
|
+
if (pid < 0) {
|
|
357
|
+
//get all
|
|
358
|
+
return this.getAllDisplayEffects().map(p => this.getPartitionDisplayInputs(sys, p.pid));
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
if (pid >= this.partitionInfo.length) {
|
|
362
|
+
pid -= this.partitionInfo.length;
|
|
363
|
+
if (pid >= this.statusEffects.length) {
|
|
364
|
+
//ghost effects
|
|
365
|
+
pid -= this.statusEffects.length;
|
|
366
|
+
const res = this.effects[pid];
|
|
367
|
+
if (res)
|
|
368
|
+
return res.getDisplayInput(this, sys);
|
|
369
|
+
return [];
|
|
370
|
+
}
|
|
371
|
+
//status effects
|
|
372
|
+
const res = this.statusEffects[pid];
|
|
373
|
+
if (res)
|
|
374
|
+
return res.getDisplayInput(this, sys);
|
|
375
|
+
return [];
|
|
376
|
+
}
|
|
377
|
+
const partition = this.partitionInfo[pid];
|
|
378
|
+
if (!partition)
|
|
379
|
+
return [];
|
|
380
|
+
return partition.mapping.map(i => this.effects[i]).flatMap(e => e.getDisplayInput(this, sys));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
isInSamePartition(eindex1, eindex2) {
|
|
384
|
+
const e1 = this.effects[eindex1];
|
|
385
|
+
const e2 = this.effects[eindex2];
|
|
386
|
+
if (!e1 || !e2)
|
|
387
|
+
return false;
|
|
388
|
+
return this.partitionInfo.some(p => {
|
|
389
|
+
p.mapping.length >= 2 && p.mapping.includes(eindex1) && p.mapping.includes(eindex2);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
getAllPartitionsIDs(eindex) {
|
|
393
|
+
let res = [];
|
|
394
|
+
this.partitionInfo.forEach((p, i) => {
|
|
395
|
+
if (p.mapping.length >= 2 && p.mapping.includes(eindex))
|
|
396
|
+
res.push(i);
|
|
397
|
+
});
|
|
398
|
+
if (res.length === 0) {
|
|
399
|
+
//eff is ghost or status
|
|
400
|
+
if (eindex < this.effects.length) {
|
|
401
|
+
//ghost
|
|
402
|
+
return [eindex + this.partitionInfo.length + this.statusEffects.length];
|
|
403
|
+
}
|
|
404
|
+
//status
|
|
405
|
+
return [eindex + this.partitionInfo.length];
|
|
406
|
+
}
|
|
407
|
+
return res;
|
|
408
|
+
}
|
|
409
|
+
inferPdata(pdata) {
|
|
410
|
+
var _a, _b, _c;
|
|
411
|
+
const res = {};
|
|
412
|
+
const effs = pdata.mapping.map(i => this.effects[i]);
|
|
413
|
+
switch (pdata.typeID) {
|
|
414
|
+
case cardRegistry_1.type_and_or_subtype_inference_method.first: {
|
|
415
|
+
res.type = effs[0] ? effs[0].type.dataID : "e_t_null";
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
case cardRegistry_1.type_and_or_subtype_inference_method.most: {
|
|
419
|
+
res.type = (_a = Utils.most(effs.map(e => e.type.dataID))) !== null && _a !== void 0 ? _a : "e_t_null";
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
default: {
|
|
423
|
+
res.type = (_b = pdata.typeID) !== null && _b !== void 0 ? _b : "e_t_null";
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
switch (pdata.subTypeID) {
|
|
428
|
+
case cardRegistry_1.type_and_or_subtype_inference_method.first: {
|
|
429
|
+
res.subtype = effs[0] ? effs[0].subTypes.map(st => st.dataID) : [];
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
case cardRegistry_1.type_and_or_subtype_inference_method.most: {
|
|
433
|
+
res.subtype = [(_c = Utils.most(effs.flatMap(e => e.subTypes.map(st => st.dataID)))) !== null && _c !== void 0 ? _c : ""];
|
|
434
|
+
if (res.subtype[0].length === 0)
|
|
435
|
+
res.subtype = [];
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
case cardRegistry_1.type_and_or_subtype_inference_method.all: {
|
|
439
|
+
res.subtype = effs.flatMap(e => e.subTypes.map(st => st.dataID));
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
default: {
|
|
443
|
+
res.subtype = pdata.subTypeID;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (pdata.displayID)
|
|
448
|
+
res.key = pdata.displayID;
|
|
449
|
+
else if (effs[0])
|
|
450
|
+
res.key = effs[0].displayID;
|
|
451
|
+
return (res.key) ? res : undefined;
|
|
452
|
+
}
|
|
453
|
+
getAllDisplayEffects() {
|
|
454
|
+
return this.partitionInfo.map((p, index) => {
|
|
455
|
+
const obj = this.inferPdata(p);
|
|
456
|
+
if (!obj)
|
|
457
|
+
return undefined;
|
|
458
|
+
return {
|
|
459
|
+
pid: index,
|
|
460
|
+
key: obj.key,
|
|
461
|
+
type: obj.type,
|
|
462
|
+
subtypes: obj.subtype
|
|
463
|
+
};
|
|
464
|
+
}).filter(c => c !== undefined);
|
|
465
|
+
}
|
|
466
|
+
isStatusPartition(pid) {
|
|
467
|
+
return (pid >= this.partitionInfo.length && pid - this.partitionInfo.length < this.statusEffects.length);
|
|
468
|
+
}
|
|
469
|
+
getParititonInputObj(pid, s, a) {
|
|
470
|
+
if (pid >= this.partitionInfo.length) {
|
|
471
|
+
pid -= this.partitionInfo.length;
|
|
472
|
+
if (pid >= this.statusEffects.length) {
|
|
473
|
+
//ghost effects
|
|
474
|
+
pid -= this.statusEffects.length;
|
|
475
|
+
const res = this.effects[pid];
|
|
476
|
+
if (res)
|
|
477
|
+
return res.getInputObj(this, s, a);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
//status effects
|
|
481
|
+
const res = this.statusEffects[pid];
|
|
482
|
+
if (res)
|
|
483
|
+
return res.getInputObj(this, s, a);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const pdata = this.partitionInfo[pid];
|
|
487
|
+
if (!pdata)
|
|
488
|
+
return;
|
|
489
|
+
const iarr = pdata.mapping.map(i => {
|
|
490
|
+
const res = this.effects[i].getInputObj(this, s, a);
|
|
491
|
+
if (res)
|
|
492
|
+
this.pInputMap.set(i, res);
|
|
493
|
+
return res;
|
|
494
|
+
}).filter(e => e !== undefined);
|
|
495
|
+
if (iarr.length === 0)
|
|
496
|
+
return;
|
|
497
|
+
return iarr.reduce((prev, curr) => prev.merge_with_signature(curr));
|
|
498
|
+
}
|
|
499
|
+
getFirstActualPartitionIndex() {
|
|
500
|
+
if (this.partitionInfo.length)
|
|
501
|
+
return 0;
|
|
502
|
+
if (this.effects.length)
|
|
503
|
+
return this.getAllGhostEffects()[0] + this.partitionInfo.length + this.statusEffects.length;
|
|
504
|
+
return -1;
|
|
505
|
+
}
|
|
506
|
+
activatePartition(pid, s, a, input) {
|
|
507
|
+
if (pid >= this.partitionInfo.length) {
|
|
508
|
+
pid -= this.partitionInfo.length;
|
|
509
|
+
if (pid >= this.statusEffects.length) {
|
|
510
|
+
//ghost effects
|
|
511
|
+
pid -= this.statusEffects.length;
|
|
512
|
+
const res = this.effects[pid];
|
|
513
|
+
if (res)
|
|
514
|
+
return res.activate(this, s, a, input);
|
|
515
|
+
return [];
|
|
516
|
+
}
|
|
517
|
+
//status effects
|
|
518
|
+
const res = this.statusEffects[pid];
|
|
519
|
+
if (res)
|
|
520
|
+
return res.activate(this, s, a, input);
|
|
521
|
+
return [];
|
|
522
|
+
}
|
|
523
|
+
const pdata = this.partitionInfo[pid];
|
|
524
|
+
if (!pdata)
|
|
525
|
+
return [];
|
|
526
|
+
const iarr = pdata.mapping.map(i => {
|
|
527
|
+
const k = this.pInputMap.get(i);
|
|
528
|
+
if (k)
|
|
529
|
+
k.emplaceReserve();
|
|
530
|
+
return k;
|
|
531
|
+
});
|
|
532
|
+
const mem = this.pShareMemory.get(pid);
|
|
533
|
+
const res = pdata.mapping.flatMap((i, idx) => {
|
|
534
|
+
//transplant memory
|
|
535
|
+
if (mem)
|
|
536
|
+
mem.forEach((val, key) => this.effects[i].attr.set(key, val));
|
|
537
|
+
return this.effects[i].activate(this, s, a, iarr[idx]);
|
|
538
|
+
});
|
|
539
|
+
//clear saved inputs
|
|
540
|
+
this.pInputMap.clear();
|
|
541
|
+
this.pShareMemory.delete(pid);
|
|
542
|
+
return res;
|
|
543
|
+
}
|
|
544
|
+
addShareMemory(e, key, val) {
|
|
545
|
+
const eindex = this.findEffectIndex(e.id);
|
|
546
|
+
const pid = this.getAllPartitionsIDs(eindex);
|
|
547
|
+
if (pid.length <= 0)
|
|
548
|
+
return;
|
|
549
|
+
pid.forEach(p => {
|
|
550
|
+
let k = this.pShareMemory.get(p);
|
|
551
|
+
if (!k) {
|
|
552
|
+
k = new Map();
|
|
553
|
+
this.pShareMemory.set(p, k);
|
|
554
|
+
}
|
|
555
|
+
k.set(key, val);
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
//end partition API
|
|
559
|
+
/** @final */
|
|
560
|
+
toDry() {
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
563
|
+
// Effects API (mostl internal but not private due to the upper system may use this)
|
|
564
|
+
disableEffect(eid) {
|
|
565
|
+
let index = this.findEffectIndex(eid);
|
|
566
|
+
if (index < 0)
|
|
567
|
+
return;
|
|
568
|
+
this.effects[index].disable();
|
|
569
|
+
}
|
|
570
|
+
disable() {
|
|
571
|
+
this.effects.forEach(e => e.disable());
|
|
572
|
+
}
|
|
573
|
+
enable() {
|
|
574
|
+
this.effects.forEach(e => e.enable());
|
|
575
|
+
}
|
|
576
|
+
findEffectIndex(eid) {
|
|
577
|
+
if (!eid)
|
|
578
|
+
return -1;
|
|
579
|
+
for (let i = 0; i < this.totalEffects.length; i++) {
|
|
580
|
+
if (this.totalEffects[i].id === eid)
|
|
581
|
+
return i;
|
|
582
|
+
}
|
|
583
|
+
return -1;
|
|
584
|
+
}
|
|
585
|
+
getEffect(eid) {
|
|
586
|
+
let index = this.findEffectIndex(eid);
|
|
587
|
+
if (index < 0)
|
|
588
|
+
return undefined;
|
|
589
|
+
return this.totalEffects[index];
|
|
590
|
+
}
|
|
591
|
+
getResponseIndexArr(system, a) {
|
|
592
|
+
//returns the effect indexes that respond
|
|
593
|
+
let res = [];
|
|
594
|
+
//update 1.2.6
|
|
595
|
+
//assume map is all 1s
|
|
596
|
+
let map = this.effects.map(i => i.canRespondAndActivate_prelim(this, system, a));
|
|
597
|
+
this.partitionInfo.forEach((i, index) => {
|
|
598
|
+
switch (i.behaviorID) {
|
|
599
|
+
case cardRegistry_1.partitionActivationBehavior.first: {
|
|
600
|
+
if (i.mapping.length && map[i.mapping[0]]) {
|
|
601
|
+
res.push(index);
|
|
602
|
+
}
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
case cardRegistry_1.partitionActivationBehavior.last: {
|
|
606
|
+
//only allow the last to activate
|
|
607
|
+
if (i.mapping.length && map[i.mapping.at(-1)]) {
|
|
608
|
+
res.push(index);
|
|
609
|
+
}
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
case cardRegistry_1.partitionActivationBehavior.strict: {
|
|
613
|
+
if (i.mapping.some(t => map[t] === false))
|
|
614
|
+
return;
|
|
615
|
+
res.push(index);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
//pid mapping
|
|
621
|
+
//0 -> pinfo's len - 1 : normal map, 1 to 1
|
|
622
|
+
//pinfo's len -> pinfo's len + status's len -1 (x): map to status eff id x - pinfo's len
|
|
623
|
+
//pinfo's len + status's len -> pinfo's len + status's len + efflen's len (x): map to eff id
|
|
624
|
+
let l = this.partitionInfo.length;
|
|
625
|
+
this.statusEffects.forEach((i, index) => {
|
|
626
|
+
if (i.canRespondAndActivate_prelim(this, system, a))
|
|
627
|
+
res.push(index + l);
|
|
628
|
+
});
|
|
629
|
+
l = l + this.statusEffects.length;
|
|
630
|
+
this.getAllGhostEffects().forEach(i => {
|
|
631
|
+
if (map[i])
|
|
632
|
+
res.push(l + i);
|
|
633
|
+
});
|
|
634
|
+
return res;
|
|
635
|
+
}
|
|
636
|
+
;
|
|
637
|
+
// activateEffect(idx : number, system : dry_system, a : Action) : [error, undefined] | [undefined, ReturnType<Effect["activate"]>]
|
|
638
|
+
// activateEffect(eid : string, system : dry_system, a : Action) : [error, undefined] | [undefined, ReturnType<Effect["activate"]>]
|
|
639
|
+
// activateEffect(id : number | string, system : dry_system, a : Action) : [error, undefined] | [undefined, ReturnType<Effect["activate"]>]{
|
|
640
|
+
// let idx : number
|
|
641
|
+
// if(typeof id === "number"){
|
|
642
|
+
// idx = id;
|
|
643
|
+
// } else {
|
|
644
|
+
// idx = this.findEffectIndex(id);
|
|
645
|
+
// if(idx < 0) return [new effectNotExist(id, this.id), undefined]
|
|
646
|
+
// }
|
|
647
|
+
// if(!this.totalEffects[idx]){
|
|
648
|
+
// let err = new wrongEffectIdx(idx, this.id)
|
|
649
|
+
// err.add("card.ts", "activateEffect", 25)
|
|
650
|
+
// return [err, undefined]
|
|
651
|
+
// }
|
|
652
|
+
// //assumes can activate
|
|
653
|
+
// //fix later
|
|
654
|
+
// return [undefined, this.totalEffects[idx].activate(this, system, a)]
|
|
655
|
+
// }
|
|
656
|
+
// activateEffectSubtypeSpecificFunc(eidx : number, subTypeidx : number, system : dry_system, a : Action) : res;
|
|
657
|
+
// activateEffectSubtypeSpecificFunc(eidx : number, subTypeID : string, system : dry_system, a : Action) : res;
|
|
658
|
+
// activateEffectSubtypeSpecificFunc(eID : string, subTypeID : string, system : dry_system, a : Action) : res;
|
|
659
|
+
// activateEffectSubtypeSpecificFunc(eID : string, subTypeidx : number, system : dry_system, a : Action) : res;
|
|
660
|
+
// activateEffectSubtypeSpecificFunc(effectIdentifier : string | number, subtypeIdentifier : string | number, system : dry_system, a : Action) : res{
|
|
661
|
+
// let idx : number
|
|
662
|
+
// if(typeof effectIdentifier === "string"){
|
|
663
|
+
// idx = this.findEffectIndex(effectIdentifier)
|
|
664
|
+
// if(idx < 0) return [new effectNotExist(effectIdentifier, this.id), undefined]
|
|
665
|
+
// } else idx = effectIdentifier;
|
|
666
|
+
// if(!this.totalEffects[idx]){
|
|
667
|
+
// let err = new wrongEffectIdx(idx, this.id)
|
|
668
|
+
// err.add("card.ts", "activateEffect", 25)
|
|
669
|
+
// return [err, undefined]
|
|
670
|
+
// }
|
|
671
|
+
// return [undefined, this.totalEffects[idx].activateSubtypeSpecificFunc(subtypeIdentifier, this, system, a)];
|
|
672
|
+
// }
|
|
673
|
+
//misc APIs
|
|
674
|
+
//this is specicfically for step2 - resolution of effects
|
|
675
|
+
reset() {
|
|
676
|
+
this.canAct = true;
|
|
677
|
+
let res = [];
|
|
678
|
+
this.totalEffects.forEach(i => res.push(...i.reset()));
|
|
679
|
+
return res;
|
|
680
|
+
}
|
|
681
|
+
//status effects stuff
|
|
682
|
+
clearAllStatus() {
|
|
683
|
+
//i hereby declare, status effect do not do shit when they are cleared forcefully
|
|
684
|
+
//i.e via this function
|
|
685
|
+
//should this declaration fails in the future, modify this bad boi
|
|
686
|
+
//Note that things that activate when a timer ran out can still be done
|
|
687
|
+
//it can emit activate effect - self in respond to the "turn start" action
|
|
688
|
+
// if timer <= 0, [do effect, remove status effect from self]
|
|
689
|
+
// else timer - 1, []
|
|
690
|
+
//for status that activate just once, repond to turn start as normal,
|
|
691
|
+
// but decrease an internal counter too
|
|
692
|
+
//reset stats, keep the effect
|
|
693
|
+
this.statusEffects = [];
|
|
694
|
+
this.loadStat(true);
|
|
695
|
+
}
|
|
696
|
+
addStatusEffect(s) {
|
|
697
|
+
//preferably also input the id into this thing, but to get the actual thing from the id
|
|
698
|
+
//we need the handler
|
|
699
|
+
//maybe we handle this outside or s.th
|
|
700
|
+
this.statusEffects.push(s);
|
|
701
|
+
this.loadStat(false);
|
|
702
|
+
}
|
|
703
|
+
removeStatusEffect(id) {
|
|
704
|
+
this.statusEffects = this.statusEffects.filter(i => i.id !== id);
|
|
705
|
+
this.loadStat(true);
|
|
706
|
+
}
|
|
707
|
+
mergeStatusEffect() {
|
|
708
|
+
let map = new Map();
|
|
709
|
+
map.set(0, []);
|
|
710
|
+
this.statusEffects.forEach(i => {
|
|
711
|
+
let sig = i.mergeSignature;
|
|
712
|
+
if (sig) {
|
|
713
|
+
let k = map.get(sig);
|
|
714
|
+
if (k)
|
|
715
|
+
k.push(i);
|
|
716
|
+
else
|
|
717
|
+
map.set(sig, [i]);
|
|
718
|
+
}
|
|
719
|
+
else
|
|
720
|
+
map.get(0).push(i);
|
|
721
|
+
});
|
|
722
|
+
let final = [];
|
|
723
|
+
map.forEach((val, key) => {
|
|
724
|
+
if (val.length <= 1 || key === 0)
|
|
725
|
+
final.push(...val);
|
|
726
|
+
else
|
|
727
|
+
final.push(...val[0].merge(val.slice(1)));
|
|
728
|
+
});
|
|
729
|
+
this.statusEffects = final;
|
|
730
|
+
this.loadStat(true);
|
|
731
|
+
}
|
|
732
|
+
toString(spaces = 4, simplify = false) {
|
|
733
|
+
if (simplify)
|
|
734
|
+
return this.id;
|
|
735
|
+
return JSON.stringify({
|
|
736
|
+
id: this.id,
|
|
737
|
+
effects: this.effects.map(i => i.toString(spaces)),
|
|
738
|
+
statusEffects: this.statusEffects,
|
|
739
|
+
pos: this.pos.toString(),
|
|
740
|
+
canAct: this.canAct,
|
|
741
|
+
attr: Array.from(Object.entries(this.attr)),
|
|
742
|
+
extensionArr: this.extensionArr,
|
|
743
|
+
variants: this.variants,
|
|
744
|
+
belongTo: this.belongTo,
|
|
745
|
+
dataID: this.dataID,
|
|
746
|
+
imgUrl: this.imgUrl,
|
|
747
|
+
}, null, spaces);
|
|
748
|
+
}
|
|
749
|
+
get numCounters() {
|
|
750
|
+
return this.statusEffects.filter(s => s.is(e_status_1.genericCounter)).reduce((prev, cur) => prev + cur.count, 0);
|
|
751
|
+
}
|
|
752
|
+
get hasCounter() {
|
|
753
|
+
return this.statusEffects.some(s => s.is(e_status_1.genericCounter));
|
|
754
|
+
}
|
|
755
|
+
is(p) {
|
|
756
|
+
if (Array.isArray(p)) {
|
|
757
|
+
return p.some(ex => this.is(ex));
|
|
758
|
+
}
|
|
759
|
+
if (typeof p === "object") {
|
|
760
|
+
return p.id === this.id;
|
|
761
|
+
}
|
|
762
|
+
return this.extensionArr.includes("*") || this.extensionArr.includes(p);
|
|
763
|
+
}
|
|
764
|
+
isFrom(s, z) {
|
|
765
|
+
const zone = s.getZoneOf(this);
|
|
766
|
+
if (!zone)
|
|
767
|
+
return false;
|
|
768
|
+
return zone.is(z);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
exports.default = Card;
|