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.
Files changed (234) hide show
  1. package/README.md +5 -3
  2. package/package.json +2 -7
  3. package/lib/_localizationFiles/English.d.ts +0 -2
  4. package/lib/_localizationFiles/English.js +0 -307
  5. package/lib/_mods/parserModules/addSymbol.d.ts +0 -7
  6. package/lib/_mods/parserModules/addSymbol.js +0 -18
  7. package/lib/_mods/parserModules/expression.d.ts +0 -7
  8. package/lib/_mods/parserModules/expression.js +0 -45
  9. package/lib/_mods/parserModules/expression_parser.d.ts +0 -143
  10. package/lib/_mods/parserModules/expression_parser.js +0 -728
  11. package/lib/_mods/parserModules/img.d.ts +0 -8
  12. package/lib/_mods/parserModules/img.js +0 -42
  13. package/lib/_mods/parserModules/qpOriginal.d.ts +0 -5
  14. package/lib/_mods/parserModules/qpOriginal.js +0 -27
  15. package/lib/_mods/parserModules/sectionID.d.ts +0 -13
  16. package/lib/_mods/parserModules/sectionID.js +0 -56
  17. package/lib/_mods/parserModules/tags.d.ts +0 -9
  18. package/lib/_mods/parserModules/tags.js +0 -29
  19. package/lib/_mods/parserModules/uaddminus.d.ts +0 -9
  20. package/lib/_mods/parserModules/uaddminus.js +0 -42
  21. package/lib/_mods/parserModules/variantCheck.d.ts +0 -10
  22. package/lib/_mods/parserModules/variantCheck.js +0 -53
  23. package/lib/_queenSystem/handler/actionGenrator.d.ts +0 -994
  24. package/lib/_queenSystem/handler/actionGenrator.js +0 -646
  25. package/lib/_queenSystem/handler/actionInputGenerator.d.ts +0 -95
  26. package/lib/_queenSystem/handler/actionInputGenerator.js +0 -373
  27. package/lib/_queenSystem/handler/actionInputRequesterGenerator.d.ts +0 -92
  28. package/lib/_queenSystem/handler/actionInputRequesterGenerator.js +0 -341
  29. package/lib/_queenSystem/handler/cardHandler.d.ts +0 -20
  30. package/lib/_queenSystem/handler/cardHandler.js +0 -61
  31. package/lib/_queenSystem/handler/effectGenerator.d.ts +0 -1
  32. package/lib/_queenSystem/handler/effectGenerator.js +0 -127
  33. package/lib/_queenSystem/handler/localizationHandler.d.ts +0 -28
  34. package/lib/_queenSystem/handler/localizationHandler.js +0 -166
  35. package/lib/_queenSystem/handler/modHandler.d.ts +0 -10
  36. package/lib/_queenSystem/handler/modHandler.js +0 -36
  37. package/lib/_queenSystem/handler/oldDataProcessor.d.ts +0 -9
  38. package/lib/_queenSystem/handler/oldDataProcessor.js +0 -129
  39. package/lib/_queenSystem/handler/registryHandler.d.ts +0 -36
  40. package/lib/_queenSystem/handler/registryHandler.js +0 -63
  41. package/lib/_queenSystem/handler/zoneHandler.d.ts +0 -102
  42. package/lib/_queenSystem/handler/zoneHandler.js +0 -606
  43. package/lib/_queenSystem/loader/loader_card.d.ts +0 -20
  44. package/lib/_queenSystem/loader/loader_card.js +0 -124
  45. package/lib/_queenSystem/loader/loader_effect.d.ts +0 -27
  46. package/lib/_queenSystem/loader/loader_effect.js +0 -163
  47. package/lib/_queenSystem/loader/loader_handler.d.ts +0 -11
  48. package/lib/_queenSystem/loader/loader_handler.js +0 -24
  49. package/lib/_queenSystem/loader/loader_localization.d.ts +0 -11
  50. package/lib/_queenSystem/loader/loader_localization.js +0 -73
  51. package/lib/_queenSystem/loader/loader_mod.d.ts +0 -10
  52. package/lib/_queenSystem/loader/loader_mod.js +0 -72
  53. package/lib/_queenSystem/loader/loader_subtype.d.ts +0 -9
  54. package/lib/_queenSystem/loader/loader_subtype.js +0 -39
  55. package/lib/_queenSystem/loader/loader_type.d.ts +0 -9
  56. package/lib/_queenSystem/loader/loader_type.js +0 -39
  57. package/lib/_queenSystem/loader/loader_zone.d.ts +0 -14
  58. package/lib/_queenSystem/loader/loader_zone.js +0 -35
  59. package/lib/_queenSystem/queenSystem.d.ts +0 -127
  60. package/lib/_queenSystem/queenSystem.js +0 -996
  61. package/lib/_queenSystem/renderer/rendererInterface.d.ts +0 -27
  62. package/lib/_queenSystem/renderer/rendererInterface.js +0 -25
  63. package/lib/data/actionRegistry.d.ts +0 -56
  64. package/lib/data/actionRegistry.js +0 -60
  65. package/lib/data/cardRegistry.d.ts +0 -1162
  66. package/lib/data/cardRegistry.js +0 -716
  67. package/lib/data/deckRegistry.d.ts +0 -19
  68. package/lib/data/deckRegistry.js +0 -41
  69. package/lib/data/effectRegistry.d.ts +0 -465
  70. package/lib/data/effectRegistry.js +0 -151
  71. package/lib/data/effectTypeRegistry.d.ts +0 -14
  72. package/lib/data/effectTypeRegistry.js +0 -14
  73. package/lib/data/operatorRegistry.d.ts +0 -92
  74. package/lib/data/operatorRegistry.js +0 -82
  75. package/lib/data/rarityRegistry.d.ts +0 -28
  76. package/lib/data/rarityRegistry.js +0 -63
  77. package/lib/data/registryRegistry.d.ts +0 -10
  78. package/lib/data/registryRegistry.js +0 -14
  79. package/lib/data/subtypeRegistry.d.ts +0 -15
  80. package/lib/data/subtypeRegistry.js +0 -15
  81. package/lib/data/systemRegistry.d.ts +0 -253
  82. package/lib/data/systemRegistry.js +0 -56
  83. package/lib/data/zoneRegistry.d.ts +0 -43
  84. package/lib/data/zoneRegistry.js +0 -157
  85. package/lib/effectTextParser/index.d.ts +0 -42
  86. package/lib/effectTextParser/index.js +0 -316
  87. package/lib/global/index.d.ts +0 -8
  88. package/lib/global/index.js +0 -12
  89. package/lib/index.d.ts +0 -6335
  90. package/lib/index.js +0 -205
  91. package/lib/specificEffects/e_cond.d.ts +0 -11
  92. package/lib/specificEffects/e_cond.js +0 -36
  93. package/lib/specificEffects/e_fruit.d.ts +0 -3
  94. package/lib/specificEffects/e_fruit.js +0 -187
  95. package/lib/specificEffects/e_generic.d.ts +0 -191
  96. package/lib/specificEffects/e_generic.js +0 -662
  97. package/lib/specificEffects/e_generic_cardTargetting.d.ts +0 -38
  98. package/lib/specificEffects/e_generic_cardTargetting.js +0 -82
  99. package/lib/specificEffects/e_generic_noneTargetting.d.ts +0 -10
  100. package/lib/specificEffects/e_generic_noneTargetting.js +0 -26
  101. package/lib/specificEffects/e_status.d.ts +0 -80
  102. package/lib/specificEffects/e_status.js +0 -151
  103. package/lib/specificEffects/e_test.d.ts +0 -3
  104. package/lib/specificEffects/e_test.js +0 -21
  105. package/lib/types/abstract/gameComponents/API.d.ts +0 -19
  106. package/lib/types/abstract/gameComponents/API.js +0 -2
  107. package/lib/types/abstract/gameComponents/card.d.ts +0 -108
  108. package/lib/types/abstract/gameComponents/card.js +0 -771
  109. package/lib/types/abstract/gameComponents/effect.d.ts +0 -82
  110. package/lib/types/abstract/gameComponents/effect.js +0 -331
  111. package/lib/types/abstract/gameComponents/effectSubtype.d.ts +0 -22
  112. package/lib/types/abstract/gameComponents/effectSubtype.js +0 -40
  113. package/lib/types/abstract/gameComponents/effectType.d.ts +0 -11
  114. package/lib/types/abstract/gameComponents/effectType.js +0 -8
  115. package/lib/types/abstract/gameComponents/settings.d.ts +0 -80
  116. package/lib/types/abstract/gameComponents/settings.js +0 -72
  117. package/lib/types/abstract/gameComponents/zone.d.ts +0 -113
  118. package/lib/types/abstract/gameComponents/zone.js +0 -614
  119. package/lib/types/abstract/gameComponents/zone_gridBased.d.ts +0 -18
  120. package/lib/types/abstract/gameComponents/zone_gridBased.js +0 -58
  121. package/lib/types/abstract/gameComponents/zone_stackBased.d.ts +0 -13
  122. package/lib/types/abstract/gameComponents/zone_stackBased.js +0 -55
  123. package/lib/types/abstract/generics/node.d.ts +0 -23
  124. package/lib/types/abstract/generics/node.js +0 -46
  125. package/lib/types/abstract/generics/position.d.ts +0 -23
  126. package/lib/types/abstract/generics/position.js +0 -91
  127. package/lib/types/abstract/generics/tree.d.ts +0 -25
  128. package/lib/types/abstract/generics/tree.js +0 -153
  129. package/lib/types/abstract/generics/universalResponse.d.ts +0 -4
  130. package/lib/types/abstract/generics/universalResponse.js +0 -2
  131. package/lib/types/abstract/generics/wraper.d.ts +0 -21
  132. package/lib/types/abstract/generics/wraper.js +0 -56
  133. package/lib/types/abstract/parser/component.d.ts +0 -88
  134. package/lib/types/abstract/parser/component.js +0 -132
  135. package/lib/types/abstract/parser/index.d.ts +0 -6
  136. package/lib/types/abstract/parser/index.js +0 -28
  137. package/lib/types/abstract/parser/modPack.d.ts +0 -21
  138. package/lib/types/abstract/parser/modPack.js +0 -48
  139. package/lib/types/abstract/parser/moduleInputObject.d.ts +0 -12
  140. package/lib/types/abstract/parser/moduleInputObject.js +0 -21
  141. package/lib/types/abstract/parser/options.d.ts +0 -31
  142. package/lib/types/abstract/parser/options.js +0 -45
  143. package/lib/types/abstract/serializedGameComponents/Gamestate.d.ts +0 -46
  144. package/lib/types/abstract/serializedGameComponents/Gamestate.js +0 -70
  145. package/lib/types/abstract/serializedGameComponents/Localized.d.ts +0 -69
  146. package/lib/types/abstract/serializedGameComponents/Localized.js +0 -84
  147. package/lib/types/defaultZones/ability.d.ts +0 -10
  148. package/lib/types/defaultZones/ability.js +0 -22
  149. package/lib/types/defaultZones/deck.d.ts +0 -25
  150. package/lib/types/defaultZones/deck.js +0 -90
  151. package/lib/types/defaultZones/drop.d.ts +0 -5
  152. package/lib/types/defaultZones/drop.js +0 -13
  153. package/lib/types/defaultZones/field.d.ts +0 -11
  154. package/lib/types/defaultZones/field.js +0 -35
  155. package/lib/types/defaultZones/grave.d.ts +0 -8
  156. package/lib/types/defaultZones/grave.js +0 -21
  157. package/lib/types/defaultZones/hand.d.ts +0 -5
  158. package/lib/types/defaultZones/hand.js +0 -14
  159. package/lib/types/defaultZones/storage.d.ts +0 -9
  160. package/lib/types/defaultZones/storage.js +0 -21
  161. package/lib/types/defaultZones/system.d.ts +0 -12
  162. package/lib/types/defaultZones/system.js +0 -35
  163. package/lib/types/defaultZones/void.d.ts +0 -4
  164. package/lib/types/defaultZones/void.js +0 -10
  165. package/lib/types/effects/effectSubtypes/subtype_chained.d.ts +0 -10
  166. package/lib/types/effects/effectSubtypes/subtype_chained.js +0 -17
  167. package/lib/types/effects/effectSubtypes/subtype_delayed.d.ts +0 -9
  168. package/lib/types/effects/effectSubtypes/subtype_delayed.js +0 -16
  169. package/lib/types/effects/effectSubtypes/subtype_fieldLock.d.ts +0 -9
  170. package/lib/types/effects/effectSubtypes/subtype_fieldLock.js +0 -21
  171. package/lib/types/effects/effectSubtypes/subtype_graveLock.d.ts +0 -9
  172. package/lib/types/effects/effectSubtypes/subtype_graveLock.js +0 -21
  173. package/lib/types/effects/effectSubtypes/subtype_hand_or_fieldLock.d.ts +0 -9
  174. package/lib/types/effects/effectSubtypes/subtype_hand_or_fieldLock.js +0 -21
  175. package/lib/types/effects/effectSubtypes/subtype_hardUnique.d.ts +0 -9
  176. package/lib/types/effects/effectSubtypes/subtype_hardUnique.js +0 -15
  177. package/lib/types/effects/effectSubtypes/subtype_instant.d.ts +0 -8
  178. package/lib/types/effects/effectSubtypes/subtype_instant.js +0 -20
  179. package/lib/types/effects/effectSubtypes/subtype_once.d.ts +0 -12
  180. package/lib/types/effects/effectSubtypes/subtype_once.js +0 -27
  181. package/lib/types/effects/effectSubtypes/subtype_unique.d.ts +0 -9
  182. package/lib/types/effects/effectSubtypes/subtype_unique.js +0 -16
  183. package/lib/types/effects/effectTypes/initEffect.d.ts +0 -7
  184. package/lib/types/effects/effectTypes/initEffect.js +0 -23
  185. package/lib/types/effects/effectTypes/lockEffect.d.ts +0 -9
  186. package/lib/types/effects/effectTypes/lockEffect.js +0 -25
  187. package/lib/types/effects/effectTypes/manualEffect.d.ts +0 -9
  188. package/lib/types/effects/effectTypes/manualEffect.js +0 -18
  189. package/lib/types/effects/effectTypes/passiveEffect.d.ts +0 -9
  190. package/lib/types/effects/effectTypes/passiveEffect.js +0 -23
  191. package/lib/types/effects/effectTypes/triggerEffect.d.ts +0 -9
  192. package/lib/types/effects/effectTypes/triggerEffect.js +0 -28
  193. package/lib/types/errors/cannotLoad.d.ts +0 -5
  194. package/lib/types/errors/cannotLoad.js +0 -13
  195. package/lib/types/errors/cardNotExist.d.ts +0 -5
  196. package/lib/types/errors/cardNotExist.js +0 -13
  197. package/lib/types/errors/cardNotInApplicableZone.d.ts +0 -5
  198. package/lib/types/errors/cardNotInApplicableZone.js +0 -13
  199. package/lib/types/errors/effectCondNotMet.d.ts +0 -5
  200. package/lib/types/errors/effectCondNotMet.js +0 -13
  201. package/lib/types/errors/effectNotExist.d.ts +0 -5
  202. package/lib/types/errors/effectNotExist.js +0 -13
  203. package/lib/types/errors/error.d.ts +0 -17
  204. package/lib/types/errors/error.js +0 -42
  205. package/lib/types/errors/incorrectActionType.d.ts +0 -5
  206. package/lib/types/errors/incorrectActionType.js +0 -13
  207. package/lib/types/errors/index.d.ts +0 -16
  208. package/lib/types/errors/index.js +0 -36
  209. package/lib/types/errors/invalidOrderMap.d.ts +0 -6
  210. package/lib/types/errors/invalidOrderMap.js +0 -14
  211. package/lib/types/errors/invalidPosition.d.ts +0 -6
  212. package/lib/types/errors/invalidPosition.js +0 -13
  213. package/lib/types/errors/subTypeOverrideConflict.d.ts +0 -7
  214. package/lib/types/errors/subTypeOverrideConflict.js +0 -15
  215. package/lib/types/errors/unknownError.d.ts +0 -5
  216. package/lib/types/errors/unknownError.js +0 -13
  217. package/lib/types/errors/unregisteredAction.d.ts +0 -6
  218. package/lib/types/errors/unregisteredAction.js +0 -13
  219. package/lib/types/errors/wrongEffectIdx.d.ts +0 -5
  220. package/lib/types/errors/wrongEffectIdx.js +0 -14
  221. package/lib/types/errors/zoneAttrConflict.d.ts +0 -5
  222. package/lib/types/errors/zoneAttrConflict.js +0 -15
  223. package/lib/types/errors/zoneFull.d.ts +0 -5
  224. package/lib/types/errors/zoneFull.js +0 -13
  225. package/lib/types/errors/zoneNotExist.d.ts +0 -5
  226. package/lib/types/errors/zoneNotExist.js +0 -13
  227. package/lib/types/misc.d.ts +0 -97
  228. package/lib/types/misc.js +0 -8
  229. package/lib/types/mods/effectTextParserModule.d.ts +0 -16
  230. package/lib/types/mods/effectTextParserModule.js +0 -81
  231. package/lib/types/mods/gameModule.d.ts +0 -5
  232. package/lib/types/mods/gameModule.js +0 -8
  233. package/lib/utils/index.d.ts +0 -78
  234. package/lib/utils/index.js +0 -562
@@ -1,771 +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.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;