@gamepark/mythologies 0.10.0 → 0.11.0

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 (319) hide show
  1. package/dist/CustomMoveType.d.ts +14 -14
  2. package/dist/CustomMoveType.js +11 -14
  3. package/dist/Memory.d.ts +14 -14
  4. package/dist/Memory.js +15 -18
  5. package/dist/MythologiesOptions.d.ts +12 -12
  6. package/dist/MythologiesOptions.js +22 -25
  7. package/dist/MythologiesRules.d.ts +158 -158
  8. package/dist/MythologiesRules.js +216 -244
  9. package/dist/MythologiesSetup.d.ts +17 -17
  10. package/dist/MythologiesSetup.js +84 -161
  11. package/dist/PlayerColor.d.ts +10 -10
  12. package/dist/PlayerColor.js +7 -10
  13. package/dist/index.d.ts +3 -3
  14. package/dist/index.js +3 -9
  15. package/dist/material/Destiny.d.ts +15 -15
  16. package/dist/material/Destiny.js +91 -130
  17. package/dist/material/Entity.d.ts +102 -102
  18. package/dist/material/Entity.js +92 -99
  19. package/dist/material/LocationType.d.ts +28 -28
  20. package/dist/material/LocationType.js +29 -33
  21. package/dist/material/MaterialType.d.ts +13 -13
  22. package/dist/material/MaterialType.js +14 -17
  23. package/dist/material/Mythology.d.ts +18 -18
  24. package/dist/material/Mythology.js +16 -19
  25. package/dist/material/Pantheon.d.ts +50 -50
  26. package/dist/material/Pantheon.js +294 -484
  27. package/dist/material/Trial.d.ts +22 -22
  28. package/dist/material/Trial.js +139 -183
  29. package/dist/material/entity/AutoEffectRule.d.ts +11 -11
  30. package/dist/material/entity/AutoEffectRule.js +16 -49
  31. package/dist/material/entity/Effect.d.ts +106 -106
  32. package/dist/material/entity/Effect.js +26 -46
  33. package/dist/material/entity/EntityDescription.d.ts +13 -13
  34. package/dist/material/entity/EntityDescription.js +165 -170
  35. package/dist/material/entity/MoveEffectRule.d.ts +18 -18
  36. package/dist/material/entity/MoveEffectRule.js +73 -129
  37. package/dist/material/entity/PlaceCardEffectRule.d.ts +15 -15
  38. package/dist/material/entity/PlaceCardEffectRule.js +43 -78
  39. package/dist/material/entity/PlayerEffectRule.d.ts +14 -14
  40. package/dist/material/entity/PlayerEffectRule.js +36 -63
  41. package/dist/material/entity/SacrificeEffectRule.d.ts +11 -11
  42. package/dist/material/entity/SacrificeEffectRule.js +40 -64
  43. package/dist/material/entity/SimultaneousEffectRule.d.ts +18 -18
  44. package/dist/material/entity/SimultaneousEffectRule.js +64 -149
  45. package/dist/material/entity/SimultaneousMoveEffectRule.d.ts +17 -17
  46. package/dist/material/entity/SimultaneousMoveEffectRule.js +65 -141
  47. package/dist/material/entity/SimultaneousSacrificeEffectRule.d.ts +10 -10
  48. package/dist/material/entity/SimultaneousSacrificeEffectRule.js +31 -55
  49. package/dist/material/entity/celtic/Banshee.d.ts +2 -2
  50. package/dist/material/entity/celtic/Banshee.js +23 -46
  51. package/dist/material/entity/celtic/Brigid.d.ts +2 -2
  52. package/dist/material/entity/celtic/Brigid.js +17 -40
  53. package/dist/material/entity/celtic/Cernunnos.d.ts +2 -2
  54. package/dist/material/entity/celtic/Cernunnos.js +19 -43
  55. package/dist/material/entity/celtic/Dagda.d.ts +2 -2
  56. package/dist/material/entity/celtic/Dagda.js +26 -50
  57. package/dist/material/entity/celtic/Dullahan.d.ts +2 -2
  58. package/dist/material/entity/celtic/Dullahan.js +9 -12
  59. package/dist/material/entity/celtic/Fairy.d.ts +2 -2
  60. package/dist/material/entity/celtic/Fairy.js +9 -12
  61. package/dist/material/entity/celtic/Kelpie.d.ts +2 -2
  62. package/dist/material/entity/celtic/Kelpie.js +16 -39
  63. package/dist/material/entity/celtic/Leprechaun.d.ts +2 -2
  64. package/dist/material/entity/celtic/Leprechaun.js +9 -12
  65. package/dist/material/entity/celtic/Morrigan.d.ts +2 -2
  66. package/dist/material/entity/celtic/Morrigan.js +8 -11
  67. package/dist/material/entity/celtic/Selkie.d.ts +2 -2
  68. package/dist/material/entity/celtic/Selkie.js +14 -17
  69. package/dist/material/entity/chinese/ChangE.d.ts +2 -2
  70. package/dist/material/entity/chinese/ChangE.js +6 -9
  71. package/dist/material/entity/chinese/Fenghuang.d.ts +2 -2
  72. package/dist/material/entity/chinese/Fenghuang.js +10 -15
  73. package/dist/material/entity/chinese/Jiangshi.d.ts +2 -2
  74. package/dist/material/entity/chinese/Jiangshi.js +9 -12
  75. package/dist/material/entity/chinese/Mogwai.d.ts +2 -2
  76. package/dist/material/entity/chinese/Mogwai.js +18 -44
  77. package/dist/material/entity/chinese/Nian.d.ts +2 -2
  78. package/dist/material/entity/chinese/Nian.js +19 -42
  79. package/dist/material/entity/chinese/Nuwa.d.ts +2 -2
  80. package/dist/material/entity/chinese/Nuwa.js +9 -12
  81. package/dist/material/entity/chinese/Qilin.d.ts +2 -2
  82. package/dist/material/entity/chinese/Qilin.js +9 -12
  83. package/dist/material/entity/chinese/SunWukong.d.ts +2 -2
  84. package/dist/material/entity/chinese/SunWukong.js +17 -43
  85. package/dist/material/entity/chinese/Tianlong.d.ts +2 -2
  86. package/dist/material/entity/chinese/Tianlong.js +9 -12
  87. package/dist/material/entity/chinese/YanluoWang.d.ts +2 -2
  88. package/dist/material/entity/chinese/YanluoWang.js +9 -12
  89. package/dist/material/entity/egyptian/Ammit.d.ts +2 -2
  90. package/dist/material/entity/egyptian/Ammit.js +9 -12
  91. package/dist/material/entity/egyptian/Anubis.d.ts +2 -2
  92. package/dist/material/entity/egyptian/Anubis.js +9 -12
  93. package/dist/material/entity/egyptian/Beetle.d.ts +2 -2
  94. package/dist/material/entity/egyptian/Beetle.js +20 -43
  95. package/dist/material/entity/egyptian/Bennu.d.ts +2 -2
  96. package/dist/material/entity/egyptian/Bennu.js +9 -12
  97. package/dist/material/entity/egyptian/Cobra.d.ts +2 -2
  98. package/dist/material/entity/egyptian/Cobra.js +9 -12
  99. package/dist/material/entity/egyptian/Isis.d.ts +2 -2
  100. package/dist/material/entity/egyptian/Isis.js +15 -41
  101. package/dist/material/entity/egyptian/Mummy.d.ts +2 -2
  102. package/dist/material/entity/egyptian/Mummy.js +17 -40
  103. package/dist/material/entity/egyptian/Osiris.d.ts +2 -2
  104. package/dist/material/entity/egyptian/Osiris.js +24 -72
  105. package/dist/material/entity/egyptian/Ra.d.ts +2 -2
  106. package/dist/material/entity/egyptian/Ra.js +9 -12
  107. package/dist/material/entity/egyptian/Sphinx.d.ts +2 -2
  108. package/dist/material/entity/egyptian/Sphinx.js +9 -12
  109. package/dist/material/entity/greek/Athena.d.ts +2 -2
  110. package/dist/material/entity/greek/Athena.js +9 -12
  111. package/dist/material/entity/greek/Centaur.d.ts +2 -2
  112. package/dist/material/entity/greek/Centaur.js +9 -12
  113. package/dist/material/entity/greek/Chimera.d.ts +2 -2
  114. package/dist/material/entity/greek/Chimera.js +9 -12
  115. package/dist/material/entity/greek/Cyclops.d.ts +2 -2
  116. package/dist/material/entity/greek/Cyclops.js +15 -19
  117. package/dist/material/entity/greek/Gorgon.d.ts +2 -2
  118. package/dist/material/entity/greek/Gorgon.js +9 -12
  119. package/dist/material/entity/greek/Griffin.d.ts +2 -2
  120. package/dist/material/entity/greek/Griffin.js +9 -12
  121. package/dist/material/entity/greek/Hades.d.ts +2 -2
  122. package/dist/material/entity/greek/Hades.js +9 -12
  123. package/dist/material/entity/greek/Minotaur.d.ts +2 -2
  124. package/dist/material/entity/greek/Minotaur.js +9 -12
  125. package/dist/material/entity/greek/Poseidon.d.ts +2 -2
  126. package/dist/material/entity/greek/Poseidon.js +20 -46
  127. package/dist/material/entity/greek/Zeus.d.ts +2 -2
  128. package/dist/material/entity/greek/Zeus.js +17 -40
  129. package/dist/material/entity/hindu/Asura.d.ts +2 -2
  130. package/dist/material/entity/hindu/Asura.js +19 -67
  131. package/dist/material/entity/hindu/Brahma.d.ts +2 -2
  132. package/dist/material/entity/hindu/Brahma.js +14 -37
  133. package/dist/material/entity/hindu/Ganesh.d.ts +2 -2
  134. package/dist/material/entity/hindu/Ganesh.js +18 -41
  135. package/dist/material/entity/hindu/Garuda.d.ts +2 -2
  136. package/dist/material/entity/hindu/Garuda.js +9 -12
  137. package/dist/material/entity/hindu/Kinnara.d.ts +2 -2
  138. package/dist/material/entity/hindu/Kinnara.js +9 -12
  139. package/dist/material/entity/hindu/Naga.d.ts +2 -2
  140. package/dist/material/entity/hindu/Naga.js +29 -75
  141. package/dist/material/entity/hindu/Rakshasa.d.ts +2 -2
  142. package/dist/material/entity/hindu/Rakshasa.js +9 -12
  143. package/dist/material/entity/hindu/Shiva.d.ts +2 -2
  144. package/dist/material/entity/hindu/Shiva.js +9 -12
  145. package/dist/material/entity/hindu/Vetala.d.ts +2 -2
  146. package/dist/material/entity/hindu/Vetala.js +9 -12
  147. package/dist/material/entity/hindu/Vishnu.d.ts +2 -2
  148. package/dist/material/entity/hindu/Vishnu.js +20 -68
  149. package/dist/material/entity/inca/Amaru.d.ts +2 -2
  150. package/dist/material/entity/inca/Amaru.js +15 -38
  151. package/dist/material/entity/inca/Caiman.d.ts +2 -2
  152. package/dist/material/entity/inca/Caiman.js +9 -12
  153. package/dist/material/entity/inca/Condor.d.ts +2 -2
  154. package/dist/material/entity/inca/Condor.js +9 -12
  155. package/dist/material/entity/inca/Illapa.d.ts +2 -2
  156. package/dist/material/entity/inca/Illapa.js +9 -12
  157. package/dist/material/entity/inca/Inti.d.ts +2 -2
  158. package/dist/material/entity/inca/Inti.js +16 -39
  159. package/dist/material/entity/inca/MamaQucha.d.ts +2 -2
  160. package/dist/material/entity/inca/MamaQucha.js +20 -43
  161. package/dist/material/entity/inca/Puma.d.ts +2 -2
  162. package/dist/material/entity/inca/Puma.js +14 -40
  163. package/dist/material/entity/inca/Supay.d.ts +2 -2
  164. package/dist/material/entity/inca/Supay.js +9 -12
  165. package/dist/material/entity/inca/Ukuku.d.ts +2 -2
  166. package/dist/material/entity/inca/Ukuku.js +14 -18
  167. package/dist/material/entity/inca/Viracocha.d.ts +2 -2
  168. package/dist/material/entity/inca/Viracocha.js +9 -12
  169. package/dist/material/entity/norse/Alf.d.ts +2 -2
  170. package/dist/material/entity/norse/Alf.js +9 -12
  171. package/dist/material/entity/norse/Draugr.d.ts +2 -2
  172. package/dist/material/entity/norse/Draugr.js +9 -12
  173. package/dist/material/entity/norse/Fenrir.d.ts +2 -2
  174. package/dist/material/entity/norse/Fenrir.js +9 -12
  175. package/dist/material/entity/norse/Freya.d.ts +2 -2
  176. package/dist/material/entity/norse/Freya.js +17 -40
  177. package/dist/material/entity/norse/Jotunn.d.ts +2 -2
  178. package/dist/material/entity/norse/Jotunn.js +15 -38
  179. package/dist/material/entity/norse/Loki.d.ts +2 -2
  180. package/dist/material/entity/norse/Loki.js +14 -37
  181. package/dist/material/entity/norse/Odin.d.ts +2 -2
  182. package/dist/material/entity/norse/Odin.js +3 -6
  183. package/dist/material/entity/norse/Thor.d.ts +2 -2
  184. package/dist/material/entity/norse/Thor.js +9 -12
  185. package/dist/material/entity/norse/Troll.d.ts +2 -2
  186. package/dist/material/entity/norse/Troll.js +6 -9
  187. package/dist/material/entity/norse/Valkyrie.d.ts +2 -2
  188. package/dist/material/entity/norse/Valkyrie.js +27 -73
  189. package/dist/material/entity/zulu/Idlozi.d.ts +2 -2
  190. package/dist/material/entity/zulu/Idlozi.js +9 -12
  191. package/dist/material/entity/zulu/Impundulu.d.ts +2 -2
  192. package/dist/material/entity/zulu/Impundulu.js +9 -12
  193. package/dist/material/entity/zulu/Inkanyamba.d.ts +2 -2
  194. package/dist/material/entity/zulu/Inkanyamba.js +16 -42
  195. package/dist/material/entity/zulu/Inkosazana.d.ts +2 -2
  196. package/dist/material/entity/zulu/Inkosazana.js +9 -12
  197. package/dist/material/entity/zulu/Shembe.d.ts +2 -2
  198. package/dist/material/entity/zulu/Shembe.js +19 -44
  199. package/dist/material/entity/zulu/Tokoloshe.d.ts +2 -2
  200. package/dist/material/entity/zulu/Tokoloshe.js +24 -47
  201. package/dist/material/entity/zulu/Umvelinqangi.d.ts +2 -2
  202. package/dist/material/entity/zulu/Umvelinqangi.js +22 -45
  203. package/dist/material/entity/zulu/Unkulunkulu.d.ts +2 -2
  204. package/dist/material/entity/zulu/Unkulunkulu.js +20 -43
  205. package/dist/material/entity/zulu/Unwabu.d.ts +2 -2
  206. package/dist/material/entity/zulu/Unwabu.js +25 -49
  207. package/dist/material/entity/zulu/Werehyena.d.ts +2 -2
  208. package/dist/material/entity/zulu/Werehyena.js +9 -12
  209. package/dist/rules/ChooseDraftTokenRule.d.ts +15 -15
  210. package/dist/rules/ChooseDraftTokenRule.js +54 -103
  211. package/dist/rules/DrawDestinyCardRule.d.ts +7 -7
  212. package/dist/rules/DrawDestinyCardRule.js +44 -115
  213. package/dist/rules/EndGameRule.d.ts +5 -5
  214. package/dist/rules/EndGameRule.js +34 -105
  215. package/dist/rules/PlaceCardsRule.d.ts +14 -14
  216. package/dist/rules/PlaceCardsRule.js +107 -206
  217. package/dist/rules/PlaceTokenRule.d.ts +12 -12
  218. package/dist/rules/PlaceTokenRule.js +75 -151
  219. package/dist/rules/RuleId.d.ts +65 -65
  220. package/dist/rules/RuleId.js +66 -69
  221. package/dist/rules/UpkeepRule.d.ts +9 -9
  222. package/dist/rules/UpkeepRule.js +56 -154
  223. package/dist/rules/effects/AlfEffectRule.d.ts +10 -10
  224. package/dist/rules/effects/AlfEffectRule.js +33 -59
  225. package/dist/rules/effects/AmmitEffectRule.d.ts +6 -6
  226. package/dist/rules/effects/AmmitEffectRule.js +15 -40
  227. package/dist/rules/effects/AnubisEffectRule.d.ts +9 -9
  228. package/dist/rules/effects/AnubisEffectRule.js +24 -49
  229. package/dist/rules/effects/AthenaEffectRule.d.ts +10 -10
  230. package/dist/rules/effects/AthenaEffectRule.js +48 -150
  231. package/dist/rules/effects/BennuEffectRule.d.ts +6 -6
  232. package/dist/rules/effects/BennuEffectRule.js +10 -35
  233. package/dist/rules/effects/CaimanEffectRule.d.ts +7 -7
  234. package/dist/rules/effects/CaimanEffectRule.js +23 -72
  235. package/dist/rules/effects/CentaurEffectRule.d.ts +15 -15
  236. package/dist/rules/effects/CentaurEffectRule.js +36 -95
  237. package/dist/rules/effects/ChimeraEffectRule.d.ts +8 -8
  238. package/dist/rules/effects/ChimeraEffectRule.js +15 -40
  239. package/dist/rules/effects/CobraEffectRule.d.ts +13 -13
  240. package/dist/rules/effects/CobraEffectRule.js +30 -61
  241. package/dist/rules/effects/CondorEffectRule.d.ts +8 -8
  242. package/dist/rules/effects/CondorEffectRule.js +20 -45
  243. package/dist/rules/effects/CyclopsEffectRule.d.ts +11 -11
  244. package/dist/rules/effects/CyclopsEffectRule.js +50 -106
  245. package/dist/rules/effects/DraugrEffectRule.d.ts +11 -11
  246. package/dist/rules/effects/DraugrEffectRule.js +32 -58
  247. package/dist/rules/effects/DullahanEffectRule.d.ts +11 -11
  248. package/dist/rules/effects/DullahanEffectRule.js +48 -73
  249. package/dist/rules/effects/FairyEffectRule.d.ts +10 -10
  250. package/dist/rules/effects/FairyEffectRule.js +33 -55
  251. package/dist/rules/effects/FenghuangEffectRule.d.ts +8 -8
  252. package/dist/rules/effects/FenghuangEffectRule.js +18 -48
  253. package/dist/rules/effects/FenrirEffectRule.d.ts +16 -16
  254. package/dist/rules/effects/FenrirEffectRule.js +85 -139
  255. package/dist/rules/effects/GarudaEffectRule.d.ts +16 -16
  256. package/dist/rules/effects/GarudaEffectRule.js +55 -113
  257. package/dist/rules/effects/GorgonEffectRule.d.ts +7 -7
  258. package/dist/rules/effects/GorgonEffectRule.js +15 -40
  259. package/dist/rules/effects/GriffinEffectRule.d.ts +9 -9
  260. package/dist/rules/effects/GriffinEffectRule.js +16 -41
  261. package/dist/rules/effects/HadesEffectRule.d.ts +9 -9
  262. package/dist/rules/effects/HadesEffectRule.js +14 -39
  263. package/dist/rules/effects/IdloziEffectRule.d.ts +9 -9
  264. package/dist/rules/effects/IdloziEffectRule.js +21 -46
  265. package/dist/rules/effects/IllapaEffectRule.d.ts +16 -16
  266. package/dist/rules/effects/IllapaEffectRule.js +43 -76
  267. package/dist/rules/effects/ImpunduluEffectRule.d.ts +10 -10
  268. package/dist/rules/effects/ImpunduluEffectRule.js +39 -77
  269. package/dist/rules/effects/InkosazanaEffectRule.d.ts +7 -7
  270. package/dist/rules/effects/InkosazanaEffectRule.js +21 -46
  271. package/dist/rules/effects/JiangshiEffectRule.d.ts +8 -8
  272. package/dist/rules/effects/JiangshiEffectRule.js +25 -51
  273. package/dist/rules/effects/KinnaraEffectRule.d.ts +13 -13
  274. package/dist/rules/effects/KinnaraEffectRule.js +42 -95
  275. package/dist/rules/effects/LeprechaunEffectRule.d.ts +9 -9
  276. package/dist/rules/effects/LeprechaunEffectRule.js +23 -49
  277. package/dist/rules/effects/MinotaurEffectRule.d.ts +11 -11
  278. package/dist/rules/effects/MinotaurEffectRule.js +23 -49
  279. package/dist/rules/effects/MultipleSimultaneousMoveEffectRule.d.ts +14 -14
  280. package/dist/rules/effects/MultipleSimultaneousMoveEffectRule.js +71 -144
  281. package/dist/rules/effects/NuwaEffectRule.d.ts +14 -14
  282. package/dist/rules/effects/NuwaEffectRule.js +57 -106
  283. package/dist/rules/effects/OdinEffectRule.d.ts +11 -11
  284. package/dist/rules/effects/OdinEffectRule.js +27 -52
  285. package/dist/rules/effects/PermanentEffectsRule.d.ts +7 -7
  286. package/dist/rules/effects/PermanentEffectsRule.js +21 -54
  287. package/dist/rules/effects/QilinEffectRule.d.ts +8 -8
  288. package/dist/rules/effects/QilinEffectRule.js +40 -115
  289. package/dist/rules/effects/RaEffectRule.d.ts +9 -9
  290. package/dist/rules/effects/RaEffectRule.js +14 -39
  291. package/dist/rules/effects/RakshasaEffectRule.d.ts +13 -13
  292. package/dist/rules/effects/RakshasaEffectRule.js +23 -48
  293. package/dist/rules/effects/ResolveEffectsRule.d.ts +12 -12
  294. package/dist/rules/effects/ResolveEffectsRule.js +87 -141
  295. package/dist/rules/effects/SelkieEffectRule.d.ts +8 -8
  296. package/dist/rules/effects/SelkieEffectRule.js +19 -44
  297. package/dist/rules/effects/ShivaEffectRule.d.ts +10 -10
  298. package/dist/rules/effects/ShivaEffectRule.js +35 -61
  299. package/dist/rules/effects/SphinxEffectRule.d.ts +10 -10
  300. package/dist/rules/effects/SphinxEffectRule.js +33 -58
  301. package/dist/rules/effects/SupayEffectRule.d.ts +20 -20
  302. package/dist/rules/effects/SupayEffectRule.js +44 -81
  303. package/dist/rules/effects/ThorEffectRule.d.ts +11 -11
  304. package/dist/rules/effects/ThorEffectRule.js +32 -58
  305. package/dist/rules/effects/TianlongEffectRule.d.ts +17 -17
  306. package/dist/rules/effects/TianlongEffectRule.js +47 -105
  307. package/dist/rules/effects/TriggerEffectsRule.d.ts +11 -11
  308. package/dist/rules/effects/TriggerEffectsRule.js +65 -183
  309. package/dist/rules/effects/UkukuEffectRule.d.ts +14 -14
  310. package/dist/rules/effects/UkukuEffectRule.js +35 -66
  311. package/dist/rules/effects/VetalaEffectRule.d.ts +12 -12
  312. package/dist/rules/effects/VetalaEffectRule.js +37 -62
  313. package/dist/rules/effects/ViracochaEffectRule.d.ts +7 -7
  314. package/dist/rules/effects/ViracochaEffectRule.js +15 -40
  315. package/dist/rules/effects/WerehyenaEffectRule.d.ts +8 -8
  316. package/dist/rules/effects/WerehyenaEffectRule.js +37 -98
  317. package/dist/rules/effects/YanluoWangEffectRule.d.ts +9 -9
  318. package/dist/rules/effects/YanluoWangEffectRule.js +46 -104
  319. package/package.json +7 -8
@@ -1,484 +1,294 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __read = (this && this.__read) || function (o, n) {
18
- var m = typeof Symbol === "function" && o[Symbol.iterator];
19
- if (!m) return o;
20
- var i = m.call(o), r, ar = [], e;
21
- try {
22
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
23
- }
24
- catch (error) { e = { error: error }; }
25
- finally {
26
- try {
27
- if (r && !r.done && (m = i["return"])) m.call(i);
28
- }
29
- finally { if (e) throw e.error; }
30
- }
31
- return ar;
32
- };
33
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
34
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
35
- if (ar || !(i in from)) {
36
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
37
- ar[i] = from[i];
38
- }
39
- }
40
- return to.concat(ar || Array.prototype.slice.call(from));
41
- };
42
- var __values = (this && this.__values) || function(o) {
43
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
44
- if (m) return m.call(o);
45
- if (o && typeof o.length === "number") return {
46
- next: function () {
47
- if (o && i >= o.length) o = void 0;
48
- return { value: o && o[i++], done: !o };
49
- }
50
- };
51
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.Pantheon = void 0;
55
- var rules_api_1 = require("@gamepark/rules-api");
56
- var lodash_1 = require("lodash");
57
- var Memory_1 = require("../Memory");
58
- var MythologiesRules_1 = require("../MythologiesRules");
59
- var PermanentEffectsRule_1 = require("../rules/effects/PermanentEffectsRule");
60
- var TriggerEffectsRule_1 = require("../rules/effects/TriggerEffectsRule");
61
- var Destiny_1 = require("./Destiny");
62
- var Entity_1 = require("./Entity");
63
- var Effect_1 = require("./entity/Effect");
64
- var EntityDescription_1 = require("./entity/EntityDescription");
65
- var LocationType_1 = require("./LocationType");
66
- var MaterialType_1 = require("./MaterialType");
67
- var Pantheon = (function (_super) {
68
- __extends(Pantheon, _super);
69
- function Pantheon(game, player) {
70
- var _this = _super.call(this, game) || this;
71
- _this.player = player;
72
- return _this;
73
- }
74
- Object.defineProperty(Pantheon.prototype, "allCards", {
75
- get: function () {
76
- return this.material(MaterialType_1.MaterialType.EntityCard).location(LocationType_1.LocationType.Pantheon).player(this.player);
77
- },
78
- enumerable: false,
79
- configurable: true
80
- });
81
- Object.defineProperty(Pantheon.prototype, "visibleEntities", {
82
- get: function () {
83
- var allCards = this.allCards;
84
- return allCards.location(function (_a) {
85
- var x = _a.x, y = _a.y, z = _a.z;
86
- return z === allCards.location(function (l) { return l.x === x && l.y === y; }).length - 1;
87
- });
88
- },
89
- enumerable: false,
90
- configurable: true
91
- });
92
- Object.defineProperty(Pantheon.prototype, "coveredEntities", {
93
- get: function () {
94
- var allCards = this.material(MaterialType_1.MaterialType.EntityCard).location(LocationType_1.LocationType.Pantheon).player(this.player);
95
- return allCards.location(function (_a) {
96
- var x = _a.x, y = _a.y, z = _a.z;
97
- return z < allCards.location(function (l) { return l.x === x && l.y === y; }).length - 1;
98
- });
99
- },
100
- enumerable: false,
101
- configurable: true
102
- });
103
- Object.defineProperty(Pantheon.prototype, "grid", {
104
- get: function () {
105
- var visibleEntities = this.visibleEntities;
106
- return (0, lodash_1.range)(0, 3).map(function (y) { return (0, lodash_1.range)(0, 3).map(function (x) { var _a; return (_a = visibleEntities.location(function (l) { return l.x === x && l.y === y; }).getItem()) === null || _a === void 0 ? void 0 : _a.id.front; }); });
107
- },
108
- enumerable: false,
109
- configurable: true
110
- });
111
- Object.defineProperty(Pantheon.prototype, "indexGrid", {
112
- get: function () {
113
- var visibleEntities = this.visibleEntities;
114
- return (0, lodash_1.range)(0, 3).map(function (y) {
115
- return (0, lodash_1.range)(0, 3).map(function (x) {
116
- var entity = visibleEntities.location(function (l) { return l.x === x && l.y === y; });
117
- return entity.length > 0 ? entity.getIndex() : null;
118
- });
119
- });
120
- },
121
- enumerable: false,
122
- configurable: true
123
- });
124
- Object.defineProperty(Pantheon.prototype, "legalSpacesToInvoke", {
125
- get: function () {
126
- var _this = this;
127
- return this.legalSpaces.filter(function (space) { return _this.isLegalSpaceToInvoke(space); });
128
- },
129
- enumerable: false,
130
- configurable: true
131
- });
132
- Pantheon.prototype.isLegalSpaceToInvoke = function (space) {
133
- var _this = this;
134
- var opponents = this.game.players.filter(function (player) { return player !== _this.player; });
135
- var favorTax = (0, lodash_1.sumBy)(opponents, function (opponent) { return new Pantheon(_this.game, opponent).getFavorTax(space); });
136
- var gemTax = (0, lodash_1.sumBy)(opponents, function (opponent) { return new Pantheon(_this.game, opponent).getGemTax(space); });
137
- return (!favorTax || this.favor >= favorTax) && (!gemTax || this.gems >= gemTax);
138
- };
139
- Pantheon.prototype.getFavorTax = function (space) {
140
- return (0, lodash_1.sumBy)(this.visibleEntities.getItems(), function (card) {
141
- return (0, lodash_1.sumBy)((0, EntityDescription_1.getEffects)(card.id.front), function (effect) { var _a, _b, _c; return (_c = (_b = (_a = effect).favorTax) === null || _b === void 0 ? void 0 : _b.call(_a, space, card)) !== null && _c !== void 0 ? _c : 0; });
142
- });
143
- };
144
- Pantheon.prototype.getGemTax = function (space) {
145
- return (0, lodash_1.sumBy)(this.visibleEntities.getItems(), function (card) {
146
- return (0, lodash_1.sumBy)((0, EntityDescription_1.getEffects)(card.id.front), function (effect) { var _a, _b, _c; return (_c = (_b = (_a = effect).gemTax) === null || _b === void 0 ? void 0 : _b.call(_a, space, card)) !== null && _c !== void 0 ? _c : 0; });
147
- });
148
- };
149
- Object.defineProperty(Pantheon.prototype, "legalSpaces", {
150
- get: function () {
151
- var _this = this;
152
- var grid = this.grid;
153
- return (0, lodash_1.range)(0, 3)
154
- .flatMap(function (y) { return (0, lodash_1.range)(0, 3).map(function (x) { return ({ x: x, y: y }); }); })
155
- .filter(function (space) { return _this.isLegalSpace(space, grid); });
156
- },
157
- enumerable: false,
158
- configurable: true
159
- });
160
- Pantheon.prototype.isLegalSpace = function (_a, grid) {
161
- var x = _a.x, y = _a.y;
162
- if (grid === void 0) { grid = this.grid; }
163
- var card = this.visibleEntities.location(function (l) { return l.x === x && l.y === y; }).getItem();
164
- return !card || (!(0, Entity_1.isGod)(grid[y][x]) && new PermanentEffectsRule_1.PermanentEffectsRule(this.game).canCrush(card));
165
- };
166
- Pantheon.prototype.isFreeSpace = function (_a) {
167
- var x = _a.x, y = _a.y;
168
- return this.allCards.location(function (l) { return l.x === x && l.y === y; }).length === 0;
169
- };
170
- Pantheon.prototype.gainGems = function (quantity) {
171
- return this.material(MaterialType_1.MaterialType.GemToken).createItem({ location: { type: LocationType_1.LocationType.PlayerGems, player: this.player }, quantity: quantity });
172
- };
173
- Object.defineProperty(Pantheon.prototype, "gemMaterial", {
174
- get: function () {
175
- return this.material(MaterialType_1.MaterialType.GemToken).location(LocationType_1.LocationType.PlayerGems).player(this.player);
176
- },
177
- enumerable: false,
178
- configurable: true
179
- });
180
- Object.defineProperty(Pantheon.prototype, "gems", {
181
- get: function () {
182
- return this.gemMaterial.getQuantity();
183
- },
184
- enumerable: false,
185
- configurable: true
186
- });
187
- Pantheon.prototype.spendGems = function (quantity) {
188
- return this.gemMaterial.deleteItem(quantity);
189
- };
190
- Pantheon.prototype.gainFavor = function (quantity) {
191
- return this.material(MaterialType_1.MaterialType.FavorToken).createItem({ location: { type: LocationType_1.LocationType.PlayerFavor, player: this.player }, quantity: quantity });
192
- };
193
- Object.defineProperty(Pantheon.prototype, "favor", {
194
- get: function () {
195
- return this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(this.player).getQuantity();
196
- },
197
- enumerable: false,
198
- configurable: true
199
- });
200
- Pantheon.prototype.loseFavor = function (quantity) {
201
- if (quantity === void 0) { quantity = 1; }
202
- return this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(this.player).deleteItem(quantity);
203
- };
204
- Pantheon.prototype.onCardPlaced = function (move) {
205
- var _a, _b;
206
- var moves = [];
207
- var location = move.location;
208
- var card = this.material(MaterialType_1.MaterialType.EntityCard).index(move.itemIndex);
209
- var cardItem = card.getItem();
210
- var entity = (_a = cardItem.id.front) !== null && _a !== void 0 ? _a : ((_b = move.reveal) === null || _b === void 0 ? void 0 : _b.id).front;
211
- if ((0, Entity_1.isGod)(entity)) {
212
- moves.push(this.spendGems(4));
213
- }
214
- var grid = this.indexGrid;
215
- var crush = grid[move.location.y][move.location.x] !== null;
216
- grid[move.location.y][move.location.x] = move.itemIndex;
217
- moves.push.apply(moves, __spreadArray([], __read(this.gainBonus(grid)), false));
218
- var triggerEffectsRule = new TriggerEffectsRule_1.TriggerEffectsRule(this.game);
219
- triggerEffectsRule.triggerCardEffect(move.itemIndex, location, { type: Effect_1.TriggerEventType.SelfPlaced, crush: crush });
220
- var triggerEvents = this.updateGrid(grid);
221
- var invoked = this.isInvoke;
222
- if (invoked) {
223
- moves.push.apply(moves, __spreadArray([], __read(this.onInvoke(move)), false));
224
- }
225
- triggerEvents.push({ type: Effect_1.TriggerEventType.EntityPlaced, cardIndex: move.itemIndex, entity: entity, location: location, invoked: invoked });
226
- if (triggerEvents.length) {
227
- triggerEffectsRule.triggerEffects.apply(triggerEffectsRule, __spreadArray([], __read(triggerEvents), false));
228
- }
229
- return moves;
230
- };
231
- Object.defineProperty(Pantheon.prototype, "isInvoke", {
232
- get: function () {
233
- return new MythologiesRules_1.MythologiesRules(this.game).delegate().isInvoke;
234
- },
235
- enumerable: false,
236
- configurable: true
237
- });
238
- Pantheon.prototype.updateGrid = function (gridAfter) {
239
- var e_1, _a;
240
- var _b;
241
- if (gridAfter === void 0) { gridAfter = this.indexGrid; }
242
- var gridBefore = (_b = this.remind(Memory_1.Memory.PlayerGrid, this.player)) !== null && _b !== void 0 ? _b : this.indexGrid;
243
- this.memorize(Memory_1.Memory.PlayerGrid, gridAfter, this.player);
244
- var triggerEvents = [];
245
- var entitiesMoved = this.getEntitiesMoved(gridBefore, gridAfter);
246
- if (entitiesMoved.length) {
247
- triggerEvents.push({ type: Effect_1.TriggerEventType.EntitiesMoved, player: this.player, entities: entitiesMoved });
248
- }
249
- var entitiesCrushed = this.getEntitiesCrushed(gridBefore, gridAfter);
250
- try {
251
- for (var entitiesCrushed_1 = __values(entitiesCrushed), entitiesCrushed_1_1 = entitiesCrushed_1.next(); !entitiesCrushed_1_1.done; entitiesCrushed_1_1 = entitiesCrushed_1.next()) {
252
- var cardIndex = entitiesCrushed_1_1.value;
253
- triggerEvents.push({ type: Effect_1.TriggerEventType.EntityCrushed, card: this.material(MaterialType_1.MaterialType.EntityCard).getItem(cardIndex), cardIndex: cardIndex });
254
- }
255
- }
256
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
257
- finally {
258
- try {
259
- if (entitiesCrushed_1_1 && !entitiesCrushed_1_1.done && (_a = entitiesCrushed_1.return)) _a.call(entitiesCrushed_1);
260
- }
261
- finally { if (e_1) throw e_1.error; }
262
- }
263
- for (var y = 0; y < 3; y++) {
264
- if (gridBefore[y].some(function (item) { return item === null; }) && gridAfter[y].every(function (item) { return item !== null; })) {
265
- triggerEvents.push({ type: Effect_1.TriggerEventType.LineEvent, eventType: Effect_1.LineEventType.Completed, player: this.player, y: y });
266
- }
267
- }
268
- var _loop_1 = function (x) {
269
- if (gridBefore.some(function (line) { return line[x] === null; }) && gridAfter.every(function (line) { return line[x] !== null; })) {
270
- triggerEvents.push({ type: Effect_1.TriggerEventType.ColumnEvent, eventType: Effect_1.LineEventType.Completed, player: this_1.player, x: x });
271
- }
272
- };
273
- var this_1 = this;
274
- for (var x = 0; x < 3; x++) {
275
- _loop_1(x);
276
- }
277
- return triggerEvents;
278
- };
279
- Pantheon.prototype.getEntitiesMoved = function (before, after) {
280
- var entities = [];
281
- for (var y = 0; y < 3; y++) {
282
- var _loop_2 = function (x) {
283
- var cardIndex = before[y][x];
284
- if (cardIndex !== null && cardIndex !== after[y][x] && after.some(function (line) { return line.includes(cardIndex); })) {
285
- entities.push(cardIndex);
286
- }
287
- };
288
- for (var x = 0; x < 3; x++) {
289
- _loop_2(x);
290
- }
291
- }
292
- return entities;
293
- };
294
- Pantheon.prototype.getEntitiesCrushed = function (before, after) {
295
- var entities = [];
296
- var allCardsIndexes = this.allCards.getIndexes();
297
- for (var y = 0; y < 3; y++) {
298
- var _loop_3 = function (x) {
299
- var cardIndex = before[y][x];
300
- if (cardIndex !== null && !after.some(function (line) { return line.includes(cardIndex); }) && allCardsIndexes.includes(cardIndex)) {
301
- entities.push(cardIndex);
302
- }
303
- };
304
- for (var x = 0; x < 3; x++) {
305
- _loop_3(x);
306
- }
307
- }
308
- return entities;
309
- };
310
- Pantheon.prototype.gainBonus = function (grid) {
311
- var e_2, _a, e_3, _b;
312
- if (grid === void 0) { grid = this.indexGrid; }
313
- var moves = [];
314
- var fullLines = (0, lodash_1.range)(0, 3).filter(function (y) { return !grid[y].includes(null); });
315
- try {
316
- for (var fullLines_1 = __values(fullLines), fullLines_1_1 = fullLines_1.next(); !fullLines_1_1.done; fullLines_1_1 = fullLines_1.next()) {
317
- var y = fullLines_1_1.value;
318
- moves.push.apply(moves, __spreadArray([], __read(this.gainLineBonus(y)), false));
319
- }
320
- }
321
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
322
- finally {
323
- try {
324
- if (fullLines_1_1 && !fullLines_1_1.done && (_a = fullLines_1.return)) _a.call(fullLines_1);
325
- }
326
- finally { if (e_2) throw e_2.error; }
327
- }
328
- var fullColumns = (0, lodash_1.range)(0, 3).filter(function (x) { return grid.every(function (line) { return line[x] !== null; }); });
329
- try {
330
- for (var fullColumns_1 = __values(fullColumns), fullColumns_1_1 = fullColumns_1.next(); !fullColumns_1_1.done; fullColumns_1_1 = fullColumns_1.next()) {
331
- var x = fullColumns_1_1.value;
332
- moves.push.apply(moves, __spreadArray([], __read(this.gainColumnBonus(x)), false));
333
- }
334
- }
335
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
336
- finally {
337
- try {
338
- if (fullColumns_1_1 && !fullColumns_1_1.done && (_b = fullColumns_1.return)) _b.call(fullColumns_1);
339
- }
340
- finally { if (e_3) throw e_3.error; }
341
- }
342
- return moves;
343
- };
344
- Pantheon.prototype.gainLineBonus = function (y) {
345
- var bonusGem = this.getBonusGem(y);
346
- return bonusGem.length ? [bonusGem.moveItem({ type: LocationType_1.LocationType.PlayerGems, player: this.player })] : [];
347
- };
348
- Pantheon.prototype.gainColumnBonus = function (x) {
349
- var bonusFavor = this.getBonusFavor(x);
350
- return bonusFavor.length ? [bonusFavor.moveItem({ type: LocationType_1.LocationType.PlayerFavor, player: this.player })] : [];
351
- };
352
- Pantheon.prototype.getBonusGem = function (y) {
353
- return this.material(MaterialType_1.MaterialType.GemToken)
354
- .location(LocationType_1.LocationType.PantheonLineBonus)
355
- .player(this.player)
356
- .location(function (l) { return l.y === y; });
357
- };
358
- Pantheon.prototype.getBonusFavor = function (x) {
359
- return this.material(MaterialType_1.MaterialType.FavorToken)
360
- .location(LocationType_1.LocationType.PantheonColumnBonus)
361
- .player(this.player)
362
- .location(function (l) { return l.x === x; });
363
- };
364
- Pantheon.prototype.onInvoke = function (move) {
365
- var e_4, _a;
366
- var moves = [];
367
- var card = this.material(MaterialType_1.MaterialType.EntityCard).index(move.itemIndex).getItem();
368
- var entity = card.id.front;
369
- if (!entity)
370
- return [];
371
- try {
372
- for (var _b = __values(this.game.players), _c = _b.next(); !_c.done; _c = _b.next()) {
373
- var player = _c.value;
374
- if (player !== this.player) {
375
- var favorTax = new Pantheon(this.game, player).getFavorTax(move.location);
376
- if (favorTax > 0) {
377
- var favor = this.material(MaterialType_1.MaterialType.FavorToken).location(LocationType_1.LocationType.PlayerFavor).player(this.player);
378
- moves.push(favor.moveItem({ type: LocationType_1.LocationType.PlayerFavor, player: player }, favorTax));
379
- }
380
- var gemTax = new Pantheon(this.game, player).getGemTax(move.location);
381
- if (gemTax > 0) {
382
- var gems = this.material(MaterialType_1.MaterialType.GemToken).location(LocationType_1.LocationType.PlayerGems).player(this.player);
383
- moves.push(gems.moveItem({ type: LocationType_1.LocationType.PlayerFavor, player: player }, gemTax));
384
- }
385
- }
386
- }
387
- }
388
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
389
- finally {
390
- try {
391
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
392
- }
393
- finally { if (e_4) throw e_4.error; }
394
- }
395
- moves.push.apply(moves, __spreadArray([], __read(this.getInvokeGains(entity, move.location.y)), false));
396
- return moves;
397
- };
398
- Pantheon.prototype.getInvokeGains = function (entity, line) {
399
- var moves = [];
400
- var invokeGain = EntityDescription_1.entities[entity].invoke[line];
401
- if (invokeGain.gem) {
402
- moves.push(this.gainGems(invokeGain.gem));
403
- }
404
- if (invokeGain.favor) {
405
- moves.push(this.gainFavor(invokeGain.favor));
406
- }
407
- return moves;
408
- };
409
- Pantheon.prototype.hasEntity = function (entity) {
410
- return this.visibleEntities.getItems().some(function (card) { return card.id.front === entity; });
411
- };
412
- Pantheon.prototype.getPiles = function (predicate) {
413
- if (predicate === void 0) { predicate = function () { return true; }; }
414
- var piles = [];
415
- var myEntities = this.material(MaterialType_1.MaterialType.EntityCard).player(this.player);
416
- var fullPantheon = myEntities.location(LocationType_1.LocationType.Pantheon);
417
- for (var x = 0; x < 3; x++) {
418
- for (var y = 0; y < 3; y++) {
419
- if (predicate({ x: x, y: y })) {
420
- var pile = this.getPile({ x: x, y: y }, fullPantheon);
421
- if (pile.length > 0) {
422
- piles.push(pile);
423
- }
424
- }
425
- }
426
- }
427
- return piles;
428
- };
429
- Pantheon.prototype.getPile = function (_a, fullPantheon) {
430
- var x = _a.x, y = _a.y;
431
- if (fullPantheon === void 0) { fullPantheon = this.material(MaterialType_1.MaterialType.EntityCard).location(LocationType_1.LocationType.Pantheon).player(this.player); }
432
- return fullPantheon.location(function (l) { return l.x === x && l.y === y; }).sort(function (item) { return item.location.z; });
433
- };
434
- Pantheon.prototype.isAbleToMove = function (entity) {
435
- return !this.isVisible(entity) || new PermanentEffectsRule_1.PermanentEffectsRule(this.game).canMove(entity);
436
- };
437
- Pantheon.prototype.isVisible = function (entity) {
438
- return this.getPile(entity.location).length - 1 === entity.location.z;
439
- };
440
- Object.defineProperty(Pantheon.prototype, "mythologies", {
441
- get: function () {
442
- return (0, lodash_1.uniq)(new Pantheon(this.game, this.player).visibleEntities.getItems().map(function (item) { return (0, Entity_1.entityMythology)(item.id.front); }));
443
- },
444
- enumerable: false,
445
- configurable: true
446
- });
447
- Object.defineProperty(Pantheon.prototype, "missingMythologies", {
448
- get: function () {
449
- return (0, lodash_1.difference)(new Destiny_1.Destiny(this.game).mythologies, this.mythologies);
450
- },
451
- enumerable: false,
452
- configurable: true
453
- });
454
- Pantheon.prototype.onEntitySacrificed = function (cardIndex) {
455
- var card = this.material(MaterialType_1.MaterialType.EntityCard).getItem(cardIndex);
456
- var _a = card.location, x = _a.x, y = _a.y, z = _a.z;
457
- var grid = this.indexGrid;
458
- if (grid[y][x] === cardIndex) {
459
- var cardUnder = this.allCards.location(function (l) { return l.x === x && l.y === y && l.z !== z; }).maxBy(function (item) { return item.location.z; });
460
- grid[y][x] = cardUnder.length ? cardUnder.getIndex() : null;
461
- this.memorize(Memory_1.Memory.PlayerGrid, grid, this.player);
462
- new TriggerEffectsRule_1.TriggerEffectsRule(this.game).triggerEffects({ type: Effect_1.TriggerEventType.EntitySacrificed, card: card, cardIndex: cardIndex });
463
- }
464
- };
465
- Pantheon.prototype.isOpponentOngoingEffect = function () {
466
- var ongoingEffect = this.remind(Memory_1.Memory.OngoingEffect);
467
- if (!ongoingEffect)
468
- return false;
469
- var effectOwner = this.material(MaterialType_1.MaterialType.EntityCard).getItem(ongoingEffect.cardIndex).location.player;
470
- return this.player !== effectOwner;
471
- };
472
- Pantheon.prototype.replaceSacrifice = function (cards) {
473
- return this.visibleEntities.filter(function (item) {
474
- return (0, EntityDescription_1.getEffects)(item.id.front).some(function (effect) { return !(0, Effect_1.isTriggeredEffect)(effect) && cards.some(function (card) { var _a; return (_a = effect.replaceSacrifice) === null || _a === void 0 ? void 0 : _a.call(effect, card, item); }); });
475
- });
476
- };
477
- Pantheon.prototype.sacrificeToPreventMove = function () {
478
- return this.visibleEntities
479
- .filter(function (item) { return (0, EntityDescription_1.getEffects)(item.id.front).some(function (effect) { return !(0, Effect_1.isTriggeredEffect)(effect) && effect.sacrificeInsteadOfMove; }); })
480
- .moveItems({ type: LocationType_1.LocationType.PlayerDiscard, player: this.player });
481
- };
482
- return Pantheon;
483
- }(rules_api_1.MaterialRulesPart));
484
- exports.Pantheon = Pantheon;
1
+ import { MaterialRulesPart } from '@gamepark/rules-api';
2
+ import { difference, range, sumBy, uniq } from 'es-toolkit';
3
+ import { Memory } from '../Memory';
4
+ import { MythologiesRules } from '../MythologiesRules';
5
+ import { PermanentEffectsRule } from '../rules/effects/PermanentEffectsRule';
6
+ import { TriggerEffectsRule } from '../rules/effects/TriggerEffectsRule';
7
+ import { Destiny } from './Destiny';
8
+ import { entityMythology, isGod } from './Entity';
9
+ import { isTriggeredEffect, LineEventType, TriggerEventType } from './entity/Effect';
10
+ import { entities, getEffects } from './entity/EntityDescription';
11
+ import { LocationType } from './LocationType';
12
+ import { MaterialType } from './MaterialType';
13
+ export class Pantheon extends MaterialRulesPart {
14
+ player;
15
+ constructor(game, player) {
16
+ super(game);
17
+ this.player = player;
18
+ }
19
+ get allCards() {
20
+ return this.material(MaterialType.EntityCard).location(LocationType.Pantheon).player(this.player);
21
+ }
22
+ get visibleEntities() {
23
+ const allCards = this.allCards;
24
+ return allCards.location(({ x, y, z }) => z === allCards.location((l) => l.x === x && l.y === y).length - 1);
25
+ }
26
+ get coveredEntities() {
27
+ const allCards = this.material(MaterialType.EntityCard).location(LocationType.Pantheon).player(this.player);
28
+ return allCards.location(({ x, y, z }) => z < allCards.location((l) => l.x === x && l.y === y).length - 1);
29
+ }
30
+ get grid() {
31
+ const visibleEntities = this.visibleEntities;
32
+ return range(0, 3).map((y) => range(0, 3).map((x) => visibleEntities.location((l) => l.x === x && l.y === y).getItem()?.id.front));
33
+ }
34
+ get indexGrid() {
35
+ const visibleEntities = this.visibleEntities;
36
+ return range(0, 3).map((y) => range(0, 3).map((x) => {
37
+ const entity = visibleEntities.location((l) => l.x === x && l.y === y);
38
+ return entity.length > 0 ? entity.getIndex() : null;
39
+ }));
40
+ }
41
+ get legalSpacesToInvoke() {
42
+ return this.legalSpaces.filter((space) => this.isLegalSpaceToInvoke(space));
43
+ }
44
+ isLegalSpaceToInvoke(space) {
45
+ const opponents = this.game.players.filter((player) => player !== this.player);
46
+ const favorTax = sumBy(opponents, (opponent) => new Pantheon(this.game, opponent).getFavorTax(space));
47
+ const gemTax = sumBy(opponents, (opponent) => new Pantheon(this.game, opponent).getGemTax(space));
48
+ return (!favorTax || this.favor >= favorTax) && (!gemTax || this.gems >= gemTax);
49
+ }
50
+ getFavorTax(space) {
51
+ return sumBy(this.visibleEntities.getItems(), (card) => sumBy(getEffects(card.id.front), (effect) => effect.favorTax?.(space, card) ?? 0));
52
+ }
53
+ getGemTax(space) {
54
+ return sumBy(this.visibleEntities.getItems(), (card) => sumBy(getEffects(card.id.front), (effect) => effect.gemTax?.(space, card) ?? 0));
55
+ }
56
+ get legalSpaces() {
57
+ const grid = this.grid;
58
+ return range(0, 3)
59
+ .flatMap((y) => range(0, 3).map((x) => ({ x, y })))
60
+ .filter((space) => this.isLegalSpace(space, grid));
61
+ }
62
+ isLegalSpace({ x, y }, grid = this.grid) {
63
+ const card = this.visibleEntities.location((l) => l.x === x && l.y === y).getItem();
64
+ return !card || (!isGod(grid[y][x]) && new PermanentEffectsRule(this.game).canCrush(card));
65
+ }
66
+ isFreeSpace({ x, y }) {
67
+ return this.allCards.location((l) => l.x === x && l.y === y).length === 0;
68
+ }
69
+ gainGems(quantity) {
70
+ return this.material(MaterialType.GemToken).createItem({ location: { type: LocationType.PlayerGems, player: this.player }, quantity });
71
+ }
72
+ get gemMaterial() {
73
+ return this.material(MaterialType.GemToken).location(LocationType.PlayerGems).player(this.player);
74
+ }
75
+ get gems() {
76
+ return this.gemMaterial.getQuantity();
77
+ }
78
+ spendGems(quantity) {
79
+ return this.gemMaterial.deleteItem(quantity);
80
+ }
81
+ gainFavor(quantity) {
82
+ return this.material(MaterialType.FavorToken).createItem({ location: { type: LocationType.PlayerFavor, player: this.player }, quantity });
83
+ }
84
+ get favor() {
85
+ return this.material(MaterialType.FavorToken).location(LocationType.PlayerFavor).player(this.player).getQuantity();
86
+ }
87
+ loseFavor(quantity = 1) {
88
+ return this.material(MaterialType.FavorToken).location(LocationType.PlayerFavor).player(this.player).deleteItem(quantity);
89
+ }
90
+ onCardPlaced(move) {
91
+ const moves = [];
92
+ const location = move.location;
93
+ const card = this.material(MaterialType.EntityCard).index(move.itemIndex);
94
+ const cardItem = card.getItem();
95
+ const entity = cardItem.id.front ?? (move.reveal?.id).front;
96
+ if (isGod(entity)) {
97
+ moves.push(this.spendGems(4));
98
+ }
99
+ const grid = this.indexGrid;
100
+ const crush = grid[move.location.y][move.location.x] !== null;
101
+ grid[move.location.y][move.location.x] = move.itemIndex;
102
+ moves.push(...this.gainBonus(grid));
103
+ const triggerEffectsRule = new TriggerEffectsRule(this.game);
104
+ triggerEffectsRule.triggerCardEffect(move.itemIndex, location, { type: TriggerEventType.SelfPlaced, crush });
105
+ const triggerEvents = this.updateGrid(grid);
106
+ const invoked = this.isInvoke;
107
+ if (invoked) {
108
+ moves.push(...this.onInvoke(move));
109
+ }
110
+ triggerEvents.push({ type: TriggerEventType.EntityPlaced, cardIndex: move.itemIndex, entity, location, invoked });
111
+ if (triggerEvents.length) {
112
+ triggerEffectsRule.triggerEffects(...triggerEvents);
113
+ }
114
+ return moves;
115
+ }
116
+ get isInvoke() {
117
+ return new MythologiesRules(this.game).delegate().isInvoke;
118
+ }
119
+ updateGrid(gridAfter = this.indexGrid) {
120
+ const gridBefore = this.remind(Memory.PlayerGrid, this.player) ?? this.indexGrid;
121
+ this.memorize(Memory.PlayerGrid, gridAfter, this.player);
122
+ const triggerEvents = [];
123
+ const entitiesMoved = this.getEntitiesMoved(gridBefore, gridAfter);
124
+ if (entitiesMoved.length) {
125
+ triggerEvents.push({ type: TriggerEventType.EntitiesMoved, player: this.player, entities: entitiesMoved });
126
+ }
127
+ const entitiesCrushed = this.getEntitiesCrushed(gridBefore, gridAfter);
128
+ for (const cardIndex of entitiesCrushed) {
129
+ triggerEvents.push({ type: TriggerEventType.EntityCrushed, card: this.material(MaterialType.EntityCard).getItem(cardIndex), cardIndex });
130
+ }
131
+ for (let y = 0; y < 3; y++) {
132
+ if (gridBefore[y].some((item) => item === null) && gridAfter[y].every((item) => item !== null)) {
133
+ triggerEvents.push({ type: TriggerEventType.LineEvent, eventType: LineEventType.Completed, player: this.player, y });
134
+ }
135
+ }
136
+ for (let x = 0; x < 3; x++) {
137
+ if (gridBefore.some((line) => line[x] === null) && gridAfter.every((line) => line[x] !== null)) {
138
+ triggerEvents.push({ type: TriggerEventType.ColumnEvent, eventType: LineEventType.Completed, player: this.player, x });
139
+ }
140
+ }
141
+ return triggerEvents;
142
+ }
143
+ getEntitiesMoved(before, after) {
144
+ const entities = [];
145
+ for (let y = 0; y < 3; y++) {
146
+ for (let x = 0; x < 3; x++) {
147
+ const cardIndex = before[y][x];
148
+ if (cardIndex !== null && cardIndex !== after[y][x] && after.some((line) => line.includes(cardIndex))) {
149
+ entities.push(cardIndex);
150
+ }
151
+ }
152
+ }
153
+ return entities;
154
+ }
155
+ getEntitiesCrushed(before, after) {
156
+ const entities = [];
157
+ const allCardsIndexes = this.allCards.getIndexes();
158
+ for (let y = 0; y < 3; y++) {
159
+ for (let x = 0; x < 3; x++) {
160
+ const cardIndex = before[y][x];
161
+ if (cardIndex !== null && !after.some((line) => line.includes(cardIndex)) && allCardsIndexes.includes(cardIndex)) {
162
+ entities.push(cardIndex);
163
+ }
164
+ }
165
+ }
166
+ return entities;
167
+ }
168
+ gainBonus(grid = this.indexGrid) {
169
+ const moves = [];
170
+ const fullLines = range(0, 3).filter((y) => !grid[y].includes(null));
171
+ for (const y of fullLines) {
172
+ moves.push(...this.gainLineBonus(y));
173
+ }
174
+ const fullColumns = range(0, 3).filter((x) => grid.every((line) => line[x] !== null));
175
+ for (const x of fullColumns) {
176
+ moves.push(...this.gainColumnBonus(x));
177
+ }
178
+ return moves;
179
+ }
180
+ gainLineBonus(y) {
181
+ const bonusGem = this.getBonusGem(y);
182
+ return bonusGem.length ? [bonusGem.moveItem({ type: LocationType.PlayerGems, player: this.player })] : [];
183
+ }
184
+ gainColumnBonus(x) {
185
+ const bonusFavor = this.getBonusFavor(x);
186
+ return bonusFavor.length ? [bonusFavor.moveItem({ type: LocationType.PlayerFavor, player: this.player })] : [];
187
+ }
188
+ getBonusGem(y) {
189
+ return this.material(MaterialType.GemToken)
190
+ .location(LocationType.PantheonLineBonus)
191
+ .player(this.player)
192
+ .location((l) => l.y === y);
193
+ }
194
+ getBonusFavor(x) {
195
+ return this.material(MaterialType.FavorToken)
196
+ .location(LocationType.PantheonColumnBonus)
197
+ .player(this.player)
198
+ .location((l) => l.x === x);
199
+ }
200
+ onInvoke(move) {
201
+ const moves = [];
202
+ const card = this.material(MaterialType.EntityCard).index(move.itemIndex).getItem();
203
+ const entity = card.id.front;
204
+ if (!entity)
205
+ return [];
206
+ for (const player of this.game.players) {
207
+ if (player !== this.player) {
208
+ const favorTax = new Pantheon(this.game, player).getFavorTax(move.location);
209
+ if (favorTax > 0) {
210
+ const favor = this.material(MaterialType.FavorToken).location(LocationType.PlayerFavor).player(this.player);
211
+ moves.push(favor.moveItem({ type: LocationType.PlayerFavor, player }, favorTax));
212
+ }
213
+ const gemTax = new Pantheon(this.game, player).getGemTax(move.location);
214
+ if (gemTax > 0) {
215
+ const gems = this.material(MaterialType.GemToken).location(LocationType.PlayerGems).player(this.player);
216
+ moves.push(gems.moveItem({ type: LocationType.PlayerFavor, player }, gemTax));
217
+ }
218
+ }
219
+ }
220
+ moves.push(...this.getInvokeGains(entity, move.location.y));
221
+ return moves;
222
+ }
223
+ getInvokeGains(entity, line) {
224
+ const moves = [];
225
+ const invokeGain = entities[entity].invoke[line];
226
+ if (invokeGain.gem) {
227
+ moves.push(this.gainGems(invokeGain.gem));
228
+ }
229
+ if (invokeGain.favor) {
230
+ moves.push(this.gainFavor(invokeGain.favor));
231
+ }
232
+ return moves;
233
+ }
234
+ hasEntity(entity) {
235
+ return this.visibleEntities.getItems().some((card) => card.id.front === entity);
236
+ }
237
+ getPiles(predicate = () => true) {
238
+ const piles = [];
239
+ const myEntities = this.material(MaterialType.EntityCard).player(this.player);
240
+ const fullPantheon = myEntities.location(LocationType.Pantheon);
241
+ for (let x = 0; x < 3; x++) {
242
+ for (let y = 0; y < 3; y++) {
243
+ if (predicate({ x, y })) {
244
+ const pile = this.getPile({ x, y }, fullPantheon);
245
+ if (pile.length > 0) {
246
+ piles.push(pile);
247
+ }
248
+ }
249
+ }
250
+ }
251
+ return piles;
252
+ }
253
+ getPile({ x, y }, fullPantheon = this.material(MaterialType.EntityCard).location(LocationType.Pantheon).player(this.player)) {
254
+ return fullPantheon.location((l) => l.x === x && l.y === y).sort((item) => item.location.z);
255
+ }
256
+ isAbleToMove(entity) {
257
+ return !this.isVisible(entity) || new PermanentEffectsRule(this.game).canMove(entity);
258
+ }
259
+ isVisible(entity) {
260
+ return this.getPile(entity.location).length - 1 === entity.location.z;
261
+ }
262
+ get mythologies() {
263
+ return uniq(new Pantheon(this.game, this.player).visibleEntities.getItems().map((item) => entityMythology(item.id.front)));
264
+ }
265
+ get missingMythologies() {
266
+ return difference(new Destiny(this.game).mythologies, this.mythologies);
267
+ }
268
+ onEntitySacrificed(cardIndex) {
269
+ const card = this.material(MaterialType.EntityCard).getItem(cardIndex);
270
+ const { x, y, z } = card.location;
271
+ const grid = this.indexGrid;
272
+ if (grid[y][x] === cardIndex) {
273
+ const cardUnder = this.allCards.location((l) => l.x === x && l.y === y && l.z !== z).maxBy((item) => item.location.z);
274
+ grid[y][x] = cardUnder.length ? cardUnder.getIndex() : null;
275
+ this.memorize(Memory.PlayerGrid, grid, this.player);
276
+ new TriggerEffectsRule(this.game).triggerEffects({ type: TriggerEventType.EntitySacrificed, card: card, cardIndex });
277
+ }
278
+ }
279
+ isOpponentOngoingEffect() {
280
+ const ongoingEffect = this.remind(Memory.OngoingEffect);
281
+ if (!ongoingEffect)
282
+ return false;
283
+ const effectOwner = this.material(MaterialType.EntityCard).getItem(ongoingEffect.cardIndex).location.player;
284
+ return this.player !== effectOwner;
285
+ }
286
+ replaceSacrifice(cards) {
287
+ return this.visibleEntities.filter((item) => getEffects(item.id.front).some((effect) => !isTriggeredEffect(effect) && cards.some((card) => effect.replaceSacrifice?.(card, item))));
288
+ }
289
+ sacrificeToPreventMove() {
290
+ return this.visibleEntities
291
+ .filter((item) => getEffects(item.id.front).some((effect) => !isTriggeredEffect(effect) && effect.sacrificeInsteadOfMove))
292
+ .moveItems({ type: LocationType.PlayerDiscard, player: this.player });
293
+ }
294
+ }