@takaro/modules 0.0.0-next.0da151e

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 (352) hide show
  1. package/README.md +3 -0
  2. package/dist/BuiltinModule.d.ts +62 -0
  3. package/dist/BuiltinModule.d.ts.map +1 -0
  4. package/dist/BuiltinModule.js +245 -0
  5. package/dist/BuiltinModule.js.map +1 -0
  6. package/dist/community-modules.json +21 -0
  7. package/dist/dto/base.d.ts +7 -0
  8. package/dist/dto/base.d.ts.map +1 -0
  9. package/dist/dto/base.js +28 -0
  10. package/dist/dto/base.js.map +1 -0
  11. package/dist/dto/discordEvents.d.ts +32 -0
  12. package/dist/dto/discordEvents.d.ts.map +1 -0
  13. package/dist/dto/discordEvents.js +92 -0
  14. package/dist/dto/discordEvents.js.map +1 -0
  15. package/dist/dto/gameEvents.d.ts +83 -0
  16. package/dist/dto/gameEvents.d.ts.map +1 -0
  17. package/dist/dto/gameEvents.js +205 -0
  18. package/dist/dto/gameEvents.js.map +1 -0
  19. package/dist/dto/index.d.ts +54 -0
  20. package/dist/dto/index.d.ts.map +1 -0
  21. package/dist/dto/index.js +18 -0
  22. package/dist/dto/index.js.map +1 -0
  23. package/dist/dto/takaroEvents.d.ts +276 -0
  24. package/dist/dto/takaroEvents.d.ts.map +1 -0
  25. package/dist/dto/takaroEvents.js +794 -0
  26. package/dist/dto/takaroEvents.js.map +1 -0
  27. package/dist/main.d.ts +5 -0
  28. package/dist/main.d.ts.map +1 -0
  29. package/dist/main.js +35 -0
  30. package/dist/main.js.map +1 -0
  31. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +2 -0
  32. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts.map +1 -0
  33. package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
  34. package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
  35. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +2 -0
  36. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts.map +1 -0
  37. package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
  38. package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
  39. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +2 -0
  40. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts.map +1 -0
  41. package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
  42. package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
  43. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +2 -0
  44. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts.map +1 -0
  45. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
  46. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
  47. package/dist/modules/chatBridge/index.d.ts +5 -0
  48. package/dist/modules/chatBridge/index.d.ts.map +1 -0
  49. package/dist/modules/chatBridge/index.js +64 -0
  50. package/dist/modules/chatBridge/index.js.map +1 -0
  51. package/dist/modules/dailyRewards/commands/daily.d.ts +2 -0
  52. package/dist/modules/dailyRewards/commands/daily.d.ts.map +1 -0
  53. package/dist/modules/dailyRewards/commands/daily.js +103 -0
  54. package/dist/modules/dailyRewards/commands/daily.js.map +1 -0
  55. package/dist/modules/dailyRewards/commands/streak.d.ts +2 -0
  56. package/dist/modules/dailyRewards/commands/streak.d.ts.map +1 -0
  57. package/dist/modules/dailyRewards/commands/streak.js +34 -0
  58. package/dist/modules/dailyRewards/commands/streak.js.map +1 -0
  59. package/dist/modules/dailyRewards/commands/topstreak.d.ts +2 -0
  60. package/dist/modules/dailyRewards/commands/topstreak.d.ts.map +1 -0
  61. package/dist/modules/dailyRewards/commands/topstreak.js +44 -0
  62. package/dist/modules/dailyRewards/commands/topstreak.js.map +1 -0
  63. package/dist/modules/dailyRewards/functions/utils.d.ts +6 -0
  64. package/dist/modules/dailyRewards/functions/utils.d.ts.map +1 -0
  65. package/dist/modules/dailyRewards/functions/utils.js +32 -0
  66. package/dist/modules/dailyRewards/functions/utils.js.map +1 -0
  67. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts +2 -0
  68. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts.map +1 -0
  69. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js +19 -0
  70. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js.map +1 -0
  71. package/dist/modules/dailyRewards/index.d.ts +5 -0
  72. package/dist/modules/dailyRewards/index.d.ts.map +1 -0
  73. package/dist/modules/dailyRewards/index.js +127 -0
  74. package/dist/modules/dailyRewards/index.js.map +1 -0
  75. package/dist/modules/economyUtils/commands/balance.d.ts +2 -0
  76. package/dist/modules/economyUtils/commands/balance.d.ts.map +1 -0
  77. package/dist/modules/economyUtils/commands/balance.js +7 -0
  78. package/dist/modules/economyUtils/commands/balance.js.map +1 -0
  79. package/dist/modules/economyUtils/commands/claim.d.ts +2 -0
  80. package/dist/modules/economyUtils/commands/claim.d.ts.map +1 -0
  81. package/dist/modules/economyUtils/commands/claim.js +35 -0
  82. package/dist/modules/economyUtils/commands/claim.js.map +1 -0
  83. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +2 -0
  84. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts.map +1 -0
  85. package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
  86. package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
  87. package/dist/modules/economyUtils/commands/grantCurrency.d.ts +2 -0
  88. package/dist/modules/economyUtils/commands/grantCurrency.d.ts.map +1 -0
  89. package/dist/modules/economyUtils/commands/grantCurrency.js +28 -0
  90. package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
  91. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +2 -0
  92. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts.map +1 -0
  93. package/dist/modules/economyUtils/commands/revokeCurrency.js +28 -0
  94. package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
  95. package/dist/modules/economyUtils/commands/shop.d.ts +2 -0
  96. package/dist/modules/economyUtils/commands/shop.d.ts.map +1 -0
  97. package/dist/modules/economyUtils/commands/shop.js +69 -0
  98. package/dist/modules/economyUtils/commands/shop.js.map +1 -0
  99. package/dist/modules/economyUtils/commands/topCurrency.d.ts +2 -0
  100. package/dist/modules/economyUtils/commands/topCurrency.d.ts.map +1 -0
  101. package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
  102. package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
  103. package/dist/modules/economyUtils/commands/transfer.d.ts +2 -0
  104. package/dist/modules/economyUtils/commands/transfer.d.ts.map +1 -0
  105. package/dist/modules/economyUtils/commands/transfer.js +55 -0
  106. package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
  107. package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts +2 -0
  108. package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts.map +1 -0
  109. package/dist/modules/economyUtils/cronJobs/zombieKillReward.js +66 -0
  110. package/dist/modules/economyUtils/cronJobs/zombieKillReward.js.map +1 -0
  111. package/dist/modules/economyUtils/index.d.ts +5 -0
  112. package/dist/modules/economyUtils/index.d.ts.map +1 -0
  113. package/dist/modules/economyUtils/index.js +192 -0
  114. package/dist/modules/economyUtils/index.js.map +1 -0
  115. package/dist/modules/geoBlock/hooks/IPDetected.d.ts +2 -0
  116. package/dist/modules/geoBlock/hooks/IPDetected.d.ts.map +1 -0
  117. package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
  118. package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
  119. package/dist/modules/geoBlock/index.d.ts +9 -0
  120. package/dist/modules/geoBlock/index.d.ts.map +1 -0
  121. package/dist/modules/geoBlock/index.js +329 -0
  122. package/dist/modules/geoBlock/index.js.map +1 -0
  123. package/dist/modules/gimme/commands/gimme.d.ts +2 -0
  124. package/dist/modules/gimme/commands/gimme.d.ts.map +1 -0
  125. package/dist/modules/gimme/commands/gimme.js +25 -0
  126. package/dist/modules/gimme/commands/gimme.js.map +1 -0
  127. package/dist/modules/gimme/index.d.ts +5 -0
  128. package/dist/modules/gimme/index.d.ts.map +1 -0
  129. package/dist/modules/gimme/index.js +75 -0
  130. package/dist/modules/gimme/index.js.map +1 -0
  131. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +2 -0
  132. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts.map +1 -0
  133. package/dist/modules/highPingKicker/cronJobs/Ping check.js +59 -0
  134. package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
  135. package/dist/modules/highPingKicker/index.d.ts +5 -0
  136. package/dist/modules/highPingKicker/index.d.ts.map +1 -0
  137. package/dist/modules/highPingKicker/index.js +44 -0
  138. package/dist/modules/highPingKicker/index.js.map +1 -0
  139. package/dist/modules/lottery/commands/buyTicket.d.ts +2 -0
  140. package/dist/modules/lottery/commands/buyTicket.d.ts.map +1 -0
  141. package/dist/modules/lottery/commands/buyTicket.js +51 -0
  142. package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
  143. package/dist/modules/lottery/commands/nextDraw.d.ts +2 -0
  144. package/dist/modules/lottery/commands/nextDraw.d.ts.map +1 -0
  145. package/dist/modules/lottery/commands/nextDraw.js +34 -0
  146. package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
  147. package/dist/modules/lottery/commands/viewTickets.d.ts +2 -0
  148. package/dist/modules/lottery/commands/viewTickets.d.ts.map +1 -0
  149. package/dist/modules/lottery/commands/viewTickets.js +20 -0
  150. package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
  151. package/dist/modules/lottery/cronJobs/drawLottery.d.ts +2 -0
  152. package/dist/modules/lottery/cronJobs/drawLottery.d.ts.map +1 -0
  153. package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
  154. package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
  155. package/dist/modules/lottery/index.d.ts +5 -0
  156. package/dist/modules/lottery/index.d.ts.map +1 -0
  157. package/dist/modules/lottery/index.js +85 -0
  158. package/dist/modules/lottery/index.js.map +1 -0
  159. package/dist/modules/playerOnboarding/commands/starterkit.d.ts +2 -0
  160. package/dist/modules/playerOnboarding/commands/starterkit.d.ts.map +1 -0
  161. package/dist/modules/playerOnboarding/commands/starterkit.js +47 -0
  162. package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
  163. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +2 -0
  164. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts.map +1 -0
  165. package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
  166. package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
  167. package/dist/modules/playerOnboarding/index.d.ts +5 -0
  168. package/dist/modules/playerOnboarding/index.d.ts.map +1 -0
  169. package/dist/modules/playerOnboarding/index.js +83 -0
  170. package/dist/modules/playerOnboarding/index.js.map +1 -0
  171. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +2 -0
  172. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts.map +1 -0
  173. package/dist/modules/serverMessages/cronJobs/Automated message.js +41 -0
  174. package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
  175. package/dist/modules/serverMessages/index.d.ts +5 -0
  176. package/dist/modules/serverMessages/index.d.ts.map +1 -0
  177. package/dist/modules/serverMessages/index.js +45 -0
  178. package/dist/modules/serverMessages/index.js.map +1 -0
  179. package/dist/modules/teleports/commands/deletetp.d.ts +2 -0
  180. package/dist/modules/teleports/commands/deletetp.d.ts.map +1 -0
  181. package/dist/modules/teleports/commands/deletetp.js +20 -0
  182. package/dist/modules/teleports/commands/deletetp.js.map +1 -0
  183. package/dist/modules/teleports/commands/deletewaypoint.d.ts +2 -0
  184. package/dist/modules/teleports/commands/deletewaypoint.d.ts.map +1 -0
  185. package/dist/modules/teleports/commands/deletewaypoint.js +20 -0
  186. package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
  187. package/dist/modules/teleports/commands/listwaypoints.d.ts +2 -0
  188. package/dist/modules/teleports/commands/listwaypoints.d.ts.map +1 -0
  189. package/dist/modules/teleports/commands/listwaypoints.js +17 -0
  190. package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
  191. package/dist/modules/teleports/commands/setprivate.d.ts +2 -0
  192. package/dist/modules/teleports/commands/setprivate.d.ts.map +1 -0
  193. package/dist/modules/teleports/commands/setprivate.js +29 -0
  194. package/dist/modules/teleports/commands/setprivate.js.map +1 -0
  195. package/dist/modules/teleports/commands/setpublic.d.ts +2 -0
  196. package/dist/modules/teleports/commands/setpublic.d.ts.map +1 -0
  197. package/dist/modules/teleports/commands/setpublic.js +45 -0
  198. package/dist/modules/teleports/commands/setpublic.js.map +1 -0
  199. package/dist/modules/teleports/commands/settp.d.ts +2 -0
  200. package/dist/modules/teleports/commands/settp.d.ts.map +1 -0
  201. package/dist/modules/teleports/commands/settp.js +40 -0
  202. package/dist/modules/teleports/commands/settp.js.map +1 -0
  203. package/dist/modules/teleports/commands/setwaypoint.d.ts +2 -0
  204. package/dist/modules/teleports/commands/setwaypoint.d.ts.map +1 -0
  205. package/dist/modules/teleports/commands/setwaypoint.js +28 -0
  206. package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
  207. package/dist/modules/teleports/commands/teleport.d.ts +2 -0
  208. package/dist/modules/teleports/commands/teleport.d.ts.map +1 -0
  209. package/dist/modules/teleports/commands/teleport.js +68 -0
  210. package/dist/modules/teleports/commands/teleport.js.map +1 -0
  211. package/dist/modules/teleports/commands/teleportwaypoint.d.ts +2 -0
  212. package/dist/modules/teleports/commands/teleportwaypoint.d.ts.map +1 -0
  213. package/dist/modules/teleports/commands/teleportwaypoint.js +43 -0
  214. package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
  215. package/dist/modules/teleports/commands/tplist.d.ts +2 -0
  216. package/dist/modules/teleports/commands/tplist.d.ts.map +1 -0
  217. package/dist/modules/teleports/commands/tplist.js +46 -0
  218. package/dist/modules/teleports/commands/tplist.js.map +1 -0
  219. package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts +2 -0
  220. package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts.map +1 -0
  221. package/dist/modules/teleports/cronJobs/Waypoint reconciler.js +6 -0
  222. package/dist/modules/teleports/cronJobs/Waypoint reconciler.js.map +1 -0
  223. package/dist/modules/teleports/functions/utils.d.ts +14 -0
  224. package/dist/modules/teleports/functions/utils.d.ts.map +1 -0
  225. package/dist/modules/teleports/functions/utils.js +156 -0
  226. package/dist/modules/teleports/functions/utils.js.map +1 -0
  227. package/dist/modules/teleports/index.d.ts +5 -0
  228. package/dist/modules/teleports/index.d.ts.map +1 -0
  229. package/dist/modules/teleports/index.js +208 -0
  230. package/dist/modules/teleports/index.js.map +1 -0
  231. package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts +2 -0
  232. package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts.map +1 -0
  233. package/dist/modules/timedShutdown/cronJobs/Shutdown.js +7 -0
  234. package/dist/modules/timedShutdown/cronJobs/Shutdown.js.map +1 -0
  235. package/dist/modules/timedShutdown/cronJobs/warning.d.ts +2 -0
  236. package/dist/modules/timedShutdown/cronJobs/warning.d.ts.map +1 -0
  237. package/dist/modules/timedShutdown/cronJobs/warning.js +10 -0
  238. package/dist/modules/timedShutdown/cronJobs/warning.js.map +1 -0
  239. package/dist/modules/timedShutdown/index.d.ts +5 -0
  240. package/dist/modules/timedShutdown/index.d.ts.map +1 -0
  241. package/dist/modules/timedShutdown/index.js +43 -0
  242. package/dist/modules/timedShutdown/index.js.map +1 -0
  243. package/dist/modules/utils/commands/help.d.ts +2 -0
  244. package/dist/modules/utils/commands/help.d.ts.map +1 -0
  245. package/dist/modules/utils/commands/help.js +84 -0
  246. package/dist/modules/utils/commands/help.js.map +1 -0
  247. package/dist/modules/utils/commands/ping.d.ts +2 -0
  248. package/dist/modules/utils/commands/ping.d.ts.map +1 -0
  249. package/dist/modules/utils/commands/ping.js +6 -0
  250. package/dist/modules/utils/commands/ping.js.map +1 -0
  251. package/dist/modules/utils/index.d.ts +5 -0
  252. package/dist/modules/utils/index.d.ts.map +1 -0
  253. package/dist/modules/utils/index.js +52 -0
  254. package/dist/modules/utils/index.js.map +1 -0
  255. package/dist/modules.json +757 -0
  256. package/package.json +17 -0
  257. package/scripts/buildBuiltinJson.ts +81 -0
  258. package/src/BuiltinModule.ts +159 -0
  259. package/src/__tests__/aliases.integration.test.ts +90 -0
  260. package/src/__tests__/bugRepros.integration.test.ts +485 -0
  261. package/src/__tests__/builtinmodule.unit.test.ts +15 -0
  262. package/src/__tests__/commandArgs.integration.test.ts +291 -0
  263. package/src/__tests__/crossServerPlayer.integration.test.ts +176 -0
  264. package/src/__tests__/economy/claim.integration.test.ts +250 -0
  265. package/src/__tests__/economy/economyUtils.integration.test.ts +495 -0
  266. package/src/__tests__/economy/shop.integration.test.ts +177 -0
  267. package/src/__tests__/economy/zombieKillReward.integration.test.ts +293 -0
  268. package/src/__tests__/geoblock.integration.test.ts +322 -0
  269. package/src/__tests__/gimme.integration.test.ts +106 -0
  270. package/src/__tests__/help.integration.test.ts +314 -0
  271. package/src/__tests__/highPingKicker.integration.test.ts +618 -0
  272. package/src/__tests__/lottery.integration.test.ts +344 -0
  273. package/src/__tests__/modulePermission.integration.test.ts +387 -0
  274. package/src/__tests__/onboarding.integration.test.ts +122 -0
  275. package/src/__tests__/ping.integration.test.ts +36 -0
  276. package/src/__tests__/roleExpiry.integration.test.ts +78 -0
  277. package/src/__tests__/serverMessages.integration.test.ts +116 -0
  278. package/src/__tests__/systemConfigCooldown.integration.test.ts +84 -0
  279. package/src/__tests__/systemConfigCost.integration.test.ts +194 -0
  280. package/src/__tests__/teleports/listtp.integration.test.ts +189 -0
  281. package/src/__tests__/teleports/publicteleports.integration.test.ts +345 -0
  282. package/src/__tests__/teleports/teleport.integration.test.ts +153 -0
  283. package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
  284. package/src/__tests__/teleports/waypoints.integration.test.ts +832 -0
  285. package/src/community-modules/README.md +5 -0
  286. package/src/community-modules/modules/vote.json +19 -0
  287. package/src/dto/base.ts +13 -0
  288. package/src/dto/discordEvents.ts +69 -0
  289. package/src/dto/gameEvents.ts +159 -0
  290. package/src/dto/index.ts +25 -0
  291. package/src/dto/takaroEvents.ts +525 -0
  292. package/src/main.ts +47 -0
  293. package/src/modules/.eslintrc +5 -0
  294. package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
  295. package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
  296. package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
  297. package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
  298. package/src/modules/chatBridge/index.ts +64 -0
  299. package/src/modules/dailyRewards/commands/daily.js +114 -0
  300. package/src/modules/dailyRewards/commands/streak.js +42 -0
  301. package/src/modules/dailyRewards/commands/topstreak.js +54 -0
  302. package/src/modules/dailyRewards/functions/utils.js +36 -0
  303. package/src/modules/dailyRewards/hooks/dailyLoginCheck.js +24 -0
  304. package/src/modules/dailyRewards/index.ts +138 -0
  305. package/src/modules/economyUtils/commands/balance.js +8 -0
  306. package/src/modules/economyUtils/commands/claim.js +42 -0
  307. package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
  308. package/src/modules/economyUtils/commands/grantCurrency.js +34 -0
  309. package/src/modules/economyUtils/commands/revokeCurrency.js +34 -0
  310. package/src/modules/economyUtils/commands/shop.js +87 -0
  311. package/src/modules/economyUtils/commands/topCurrency.js +29 -0
  312. package/src/modules/economyUtils/commands/transfer.js +73 -0
  313. package/src/modules/economyUtils/cronJobs/zombieKillReward.js +82 -0
  314. package/src/modules/economyUtils/index.ts +197 -0
  315. package/src/modules/geoBlock/hooks/IPDetected.js +53 -0
  316. package/src/modules/geoBlock/index.ts +333 -0
  317. package/src/modules/gimme/commands/gimme.js +30 -0
  318. package/src/modules/gimme/index.ts +76 -0
  319. package/src/modules/highPingKicker/cronJobs/Ping check.js +68 -0
  320. package/src/modules/highPingKicker/index.ts +44 -0
  321. package/src/modules/lottery/commands/buyTicket.js +64 -0
  322. package/src/modules/lottery/commands/nextDraw.js +47 -0
  323. package/src/modules/lottery/commands/viewTickets.js +28 -0
  324. package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
  325. package/src/modules/lottery/index.ts +86 -0
  326. package/src/modules/playerOnboarding/commands/starterkit.js +61 -0
  327. package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
  328. package/src/modules/playerOnboarding/index.ts +86 -0
  329. package/src/modules/serverMessages/cronJobs/Automated message.js +47 -0
  330. package/src/modules/serverMessages/index.ts +46 -0
  331. package/src/modules/teleports/commands/deletetp.js +25 -0
  332. package/src/modules/teleports/commands/deletewaypoint.js +24 -0
  333. package/src/modules/teleports/commands/listwaypoints.js +23 -0
  334. package/src/modules/teleports/commands/setprivate.js +39 -0
  335. package/src/modules/teleports/commands/setpublic.js +60 -0
  336. package/src/modules/teleports/commands/settp.js +50 -0
  337. package/src/modules/teleports/commands/setwaypoint.js +31 -0
  338. package/src/modules/teleports/commands/teleport.js +84 -0
  339. package/src/modules/teleports/commands/teleportwaypoint.js +57 -0
  340. package/src/modules/teleports/commands/tplist.js +62 -0
  341. package/src/modules/teleports/cronJobs/Waypoint reconciler.js +7 -0
  342. package/src/modules/teleports/functions/utils.js +189 -0
  343. package/src/modules/teleports/index.ts +217 -0
  344. package/src/modules/timedShutdown/cronJobs/Shutdown.js +8 -0
  345. package/src/modules/timedShutdown/cronJobs/warning.js +13 -0
  346. package/src/modules/timedShutdown/index.ts +45 -0
  347. package/src/modules/utils/commands/help.js +100 -0
  348. package/src/modules/utils/commands/ping.js +7 -0
  349. package/src/modules/utils/index.ts +53 -0
  350. package/tsconfig.build.json +10 -0
  351. package/tsconfig.json +9 -0
  352. package/typedoc.json +3 -0
@@ -0,0 +1,495 @@
1
+ import {
2
+ IntegrationTest,
3
+ expect,
4
+ IModuleTestsSetupData,
5
+ modulesTestSetup,
6
+ chatMessageSorter,
7
+ EventsAwaiter,
8
+ } from '@takaro/test';
9
+ import { GameEvents } from '../../dto/index.js';
10
+ import { describe } from 'node:test';
11
+
12
+ const group = 'EconomyUtils';
13
+
14
+ const customSetup = async function (this: IntegrationTest<IModuleTestsSetupData>): Promise<IModuleTestsSetupData> {
15
+ const setupData = await modulesTestSetup.bind(this)();
16
+
17
+ await this.client.settings.settingsControllerSet('economyEnabled', {
18
+ value: 'true',
19
+ gameServerId: setupData.gameserver.id,
20
+ });
21
+
22
+ await this.client.settings.settingsControllerSet('economyEnabled', {
23
+ value: 'true',
24
+ });
25
+ await this.client.settings.settingsControllerSet('currencyName', {
26
+ gameServerId: setupData.gameserver.id,
27
+ value: 'test coin',
28
+ });
29
+ return setupData;
30
+ };
31
+
32
+ const tests = [
33
+ new IntegrationTest<IModuleTestsSetupData>({
34
+ group,
35
+ snapshot: false,
36
+ setup: customSetup,
37
+ name: 'Can get balance',
38
+ test: async function () {
39
+ await this.client.module.moduleInstallationsControllerInstallModule({
40
+ gameServerId: this.setupData.gameserver.id,
41
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
42
+ });
43
+
44
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
45
+
46
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
47
+ msg: '/balance',
48
+ playerId: this.setupData.players[0].id,
49
+ });
50
+
51
+ const playerOnGameServer = (
52
+ await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
53
+ filters: { playerId: [this.setupData.players[0].id], gameServerId: [this.setupData.gameserver.id] },
54
+ })
55
+ ).data.data;
56
+ if (playerOnGameServer.length === 0) throw new Error('player not found');
57
+ await this.client.playerOnGameserver.playerOnGameServerControllerSetCurrency(
58
+ playerOnGameServer[0].gameServerId,
59
+ playerOnGameServer[0].playerId,
60
+ {
61
+ currency: 1000,
62
+ },
63
+ );
64
+
65
+ // trigger balance command
66
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
67
+ msg: '/balance',
68
+ playerId: this.setupData.players[0].id,
69
+ });
70
+
71
+ expect((await events).length).to.be.eq(2);
72
+ expect((await events)[0].data.meta.msg).to.be.eq('balance: 0 test coin');
73
+ expect((await events)[1].data.meta.msg).to.be.eq('balance: 1000 test coin');
74
+ },
75
+ }),
76
+ new IntegrationTest<IModuleTestsSetupData>({
77
+ group,
78
+ snapshot: false,
79
+ setup: customSetup,
80
+ name: 'Can show list of top (max 10) players with highest balance',
81
+ test: async function () {
82
+ // install module
83
+ await this.client.module.moduleInstallationsControllerInstallModule({
84
+ gameServerId: this.setupData.gameserver.id,
85
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
86
+ });
87
+
88
+ const giveCurrencies = this.setupData.players.map(async (player, index) => {
89
+ const playerOnGameServer = (
90
+ await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
91
+ filters: { playerId: [player.id], gameServerId: [this.setupData.gameserver.id] },
92
+ })
93
+ ).data.data;
94
+ if (playerOnGameServer.length === 0) throw new Error('player not found');
95
+ return this.client.playerOnGameserver.playerOnGameServerControllerSetCurrency(
96
+ playerOnGameServer[0].gameServerId,
97
+ playerOnGameServer[0].playerId,
98
+ {
99
+ currency: 1000 * index + 1,
100
+ },
101
+ );
102
+ });
103
+ await Promise.all(giveCurrencies);
104
+
105
+ // title message (1) + balance of player messages (5)
106
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 6);
107
+
108
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
109
+ msg: '/topcurrency',
110
+ playerId: this.setupData.players[0].id,
111
+ });
112
+
113
+ const messages = (await events).map((e) => e.data.meta.msg as string);
114
+ expect((await events).length).to.be.eq(6);
115
+ for (const message of messages) {
116
+ expect(message).to.match(
117
+ /(Richest players\:|1\. .+ - 9001 test coin|2\. .+ - 8001 test coin|3\. .+ - 7001 test coin|4\. .+ - 6001 test coin|5\. .+ - 5001 test coin)/,
118
+ );
119
+ }
120
+ },
121
+ }),
122
+ new IntegrationTest<IModuleTestsSetupData>({
123
+ group,
124
+ snapshot: false,
125
+ setup: customSetup,
126
+ name: 'Can transfer money to another player',
127
+ test: async function () {
128
+ await this.client.module.moduleInstallationsControllerInstallModule({
129
+ gameServerId: this.setupData.gameserver.id,
130
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
131
+ });
132
+
133
+ const transferAmount = 500;
134
+
135
+ const sender = this.setupData.players[0];
136
+ const senderPog = sender.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id);
137
+ if (!senderPog) throw new Error('Sender playerOnGameServer does not exist');
138
+ await this.client.playerOnGameserver.playerOnGameServerControllerSetCurrency(
139
+ senderPog.gameServerId,
140
+ senderPog.playerId,
141
+ {
142
+ currency: transferAmount,
143
+ },
144
+ );
145
+
146
+ const receiver = this.setupData.players[1];
147
+ const receiverPog = receiver.playerOnGameServers?.find(
148
+ (pog) => pog.gameServerId === this.setupData.gameserver.id,
149
+ );
150
+ if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
151
+ expect(receiverPog.currency).to.be.eq(0);
152
+
153
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
154
+
155
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
156
+ msg: `/transfer ${receiver.name} ${transferAmount}`,
157
+ playerId: sender.id,
158
+ });
159
+
160
+ const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
161
+ expect((await events).length).to.be.eq(2);
162
+
163
+ // check if balances are correct
164
+ const updatedSender = await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
165
+ senderPog.gameServerId,
166
+ senderPog.playerId,
167
+ );
168
+ expect(updatedSender.data.data.currency).to.be.eq(0);
169
+
170
+ const updatedReceiver = await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
171
+ receiverPog.gameServerId,
172
+ receiverPog.playerId,
173
+ );
174
+ expect(updatedReceiver.data.data.currency).to.be.eq(transferAmount);
175
+
176
+ expect(messages[0]).to.be.eq(`You received ${transferAmount} test coin from ${sender.name}`);
177
+ expect(messages[1]).to.be.eq(`You successfully transferred ${transferAmount} test coin to ${receiver.name}`);
178
+ },
179
+ }),
180
+ new IntegrationTest<IModuleTestsSetupData>({
181
+ group,
182
+ snapshot: false,
183
+ setup: customSetup,
184
+ name: 'Should return friendly user error when not enough currency',
185
+ test: async function () {
186
+ await this.client.module.moduleInstallationsControllerInstallModule({
187
+ gameServerId: this.setupData.gameserver.id,
188
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
189
+ });
190
+
191
+ const sender = this.setupData.players[0];
192
+ const receiver = this.setupData.players[1];
193
+ const transferAmount = 500;
194
+
195
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
196
+
197
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
198
+ msg: `/transfer ${receiver.name} ${transferAmount}`,
199
+ playerId: sender.id,
200
+ });
201
+
202
+ const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
203
+ expect((await events).length).to.be.eq(1);
204
+ expect(messages[0]).to.be.eq(
205
+ `Failed to transfer ${transferAmount} test coin to ${receiver.name}. Are you sure you have enough balance?`,
206
+ );
207
+ },
208
+ }),
209
+ new IntegrationTest<IModuleTestsSetupData>({
210
+ group,
211
+ snapshot: false,
212
+ setup: customSetup,
213
+ name: 'Should require confirmation when transfer amount is above pendingAmount',
214
+ test: async function () {
215
+ await this.client.module.moduleInstallationsControllerInstallModule({
216
+ gameServerId: this.setupData.gameserver.id,
217
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
218
+ userConfig: JSON.stringify({
219
+ pendingAmount: 100,
220
+ }),
221
+ });
222
+
223
+ const transferAmount = 500;
224
+ const prefix = (
225
+ await this.client.settings.settingsControllerGetOne('commandPrefix', this.setupData.gameserver.id)
226
+ ).data.data.value;
227
+
228
+ const sender = this.setupData.players[0];
229
+ const senderPog = sender.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id);
230
+ if (!senderPog) throw new Error('Sender playerOnGameServer does not exist');
231
+ await this.client.playerOnGameserver.playerOnGameServerControllerSetCurrency(
232
+ senderPog.gameServerId,
233
+ senderPog.playerId,
234
+ {
235
+ currency: transferAmount,
236
+ },
237
+ );
238
+
239
+ const receiver = this.setupData.players[1];
240
+ const receiverPog = receiver.playerOnGameServers?.find(
241
+ (pog) => pog.gameServerId === this.setupData.gameserver.id,
242
+ );
243
+ if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
244
+ expect(receiverPog.currency).to.be.eq(0);
245
+
246
+ let events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
247
+
248
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
249
+ msg: `/transfer ${receiver.name} ${transferAmount}`,
250
+ playerId: sender.id,
251
+ });
252
+
253
+ let messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
254
+
255
+ // check if balances have not changed yet
256
+ expect(
257
+ (
258
+ await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
259
+ senderPog.gameServerId,
260
+ senderPog.playerId,
261
+ )
262
+ ).data.data.currency,
263
+ ).to.be.eq(transferAmount);
264
+ expect(
265
+ (
266
+ await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
267
+ receiverPog.gameServerId,
268
+ receiverPog.playerId,
269
+ )
270
+ ).data.data.currency,
271
+ ).to.be.eq(0);
272
+ expect(messages.length).to.be.eq(1);
273
+ expect(messages[0]).to.be.eq(
274
+ `You are about to send ${transferAmount} test coin to ${receiver.name}. (Please confirm by typing ${prefix}confirmtransfer)`,
275
+ );
276
+
277
+ // =================================================
278
+ // transfer confirmed
279
+ // =================================================
280
+ events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
281
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
282
+ msg: `${prefix}confirmtransfer`,
283
+ playerId: sender.id,
284
+ });
285
+
286
+ messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
287
+ expect((await events).length).to.be.eq(2);
288
+ expect(
289
+ (
290
+ await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
291
+ senderPog.gameServerId,
292
+ senderPog.playerId,
293
+ )
294
+ ).data.data.currency,
295
+ ).to.be.eq(0);
296
+ expect(
297
+ (
298
+ await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
299
+ receiverPog.gameServerId,
300
+ receiverPog.playerId,
301
+ )
302
+ ).data.data.currency,
303
+ ).to.be.eq(transferAmount);
304
+
305
+ expect(messages[0]).to.be.eq(`You received ${transferAmount} test coin from ${sender.name}`);
306
+ expect(messages[1]).to.be.eq(`You successfully transferred ${transferAmount} test coin to ${receiver.name}`);
307
+ },
308
+ }),
309
+ new IntegrationTest<IModuleTestsSetupData>({
310
+ group,
311
+ snapshot: false,
312
+ setup: customSetup,
313
+ name: 'Should return no pending transfers when there are none',
314
+ test: async function () {
315
+ await this.client.module.moduleInstallationsControllerInstallModule({
316
+ gameServerId: this.setupData.gameserver.id,
317
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
318
+ userConfig: JSON.stringify({
319
+ pendingAmount: 100,
320
+ }),
321
+ });
322
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
323
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
324
+ msg: '/confirmtransfer',
325
+ playerId: this.setupData.players[0].id,
326
+ });
327
+
328
+ const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
329
+ expect(messages[0]).to.be.eq('You have no pending transfer.');
330
+ },
331
+ }),
332
+ new IntegrationTest<IModuleTestsSetupData>({
333
+ group,
334
+ snapshot: false,
335
+ setup: customSetup,
336
+ name: 'Can grant currency to a player',
337
+ test: async function () {
338
+ const granter = this.setupData.players[0];
339
+ const receiver = this.setupData.players[1];
340
+ const grantAmount = 500;
341
+
342
+ await this.client.module.moduleInstallationsControllerInstallModule({
343
+ gameServerId: this.setupData.gameserver.id,
344
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
345
+ });
346
+
347
+ // Change permissions of role to only have manageCurrency permission
348
+ const manageCurrencyPermission = await this.client.permissionCodesToInputs(['ECONOMY_UTILS_MANAGE_CURRENCY']);
349
+ await this.client.role.roleControllerUpdate(this.setupData.role.id, {
350
+ permissions: [
351
+ {
352
+ permissionId: manageCurrencyPermission[0].permissionId,
353
+ },
354
+ ],
355
+ });
356
+
357
+ const receiverPog = receiver.playerOnGameServers?.find(
358
+ (pog) => pog.gameServerId === this.setupData.gameserver.id,
359
+ );
360
+ if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
361
+ expect(receiverPog.currency).to.be.eq(0);
362
+
363
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
364
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
365
+ msg: `/grantcurrency ${receiver.name} ${grantAmount}`,
366
+ playerId: granter.id,
367
+ });
368
+
369
+ const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
370
+ expect(
371
+ (
372
+ await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
373
+ receiverPog.gameServerId,
374
+ receiverPog.playerId,
375
+ )
376
+ ).data.data.currency,
377
+ ).to.be.eq(grantAmount);
378
+ expect(messages[0]).to.be.eq(`Granted ${grantAmount} test coin by ${granter.name}`);
379
+ expect(messages[1]).to.be.eq(`You successfully granted ${grantAmount} test coin to ${receiver.name}`);
380
+ },
381
+ }),
382
+ new IntegrationTest<IModuleTestsSetupData>({
383
+ group,
384
+ snapshot: false,
385
+ setup: customSetup,
386
+ name: 'Can revoke currency from a player',
387
+ test: async function () {
388
+ const revoker = this.setupData.players[0];
389
+ const receiver = this.setupData.players[1];
390
+ const revokeAmount = 500;
391
+
392
+ // make sure receiver has enough currency
393
+ const receiverPog = receiver.playerOnGameServers?.find(
394
+ (pog) => pog.gameServerId === this.setupData.gameserver.id,
395
+ );
396
+ if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
397
+ await this.client.playerOnGameserver.playerOnGameServerControllerSetCurrency(
398
+ receiverPog.gameServerId,
399
+ receiverPog.playerId,
400
+ {
401
+ currency: revokeAmount,
402
+ },
403
+ );
404
+
405
+ await this.client.module.moduleInstallationsControllerInstallModule({
406
+ gameServerId: this.setupData.gameserver.id,
407
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
408
+ });
409
+
410
+ // Change permissions of role to only have manageCurrency permission
411
+ const manageCurrencyPermission = await this.client.permissionCodesToInputs(['ECONOMY_UTILS_MANAGE_CURRENCY']);
412
+ await this.client.role.roleControllerUpdate(this.setupData.role.id, {
413
+ permissions: [
414
+ {
415
+ permissionId: manageCurrencyPermission[0].permissionId,
416
+ },
417
+ ],
418
+ });
419
+
420
+ // currency before revoke
421
+ expect(
422
+ receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency,
423
+ ).to.be.eq(0);
424
+
425
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
426
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
427
+ msg: `/revokecurrency ${receiver.name} ${revokeAmount}`,
428
+ playerId: revoker.id,
429
+ });
430
+
431
+ const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
432
+ expect(
433
+ (
434
+ await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
435
+ receiverPog.gameServerId,
436
+ receiverPog.playerId,
437
+ )
438
+ ).data.data.currency,
439
+ ).to.be.eq(0);
440
+ expect(messages[0]).to.be.eq(`${revokeAmount} test coin were revoked by ${revoker.name}`);
441
+ expect(messages[1]).to.be.eq(`You successfully revoked ${revokeAmount} test coin of ${receiver.name}'s balance`);
442
+ },
443
+ }),
444
+ new IntegrationTest<IModuleTestsSetupData>({
445
+ group,
446
+ snapshot: false,
447
+ setup: customSetup,
448
+ name: 'Cannot use commands that require manageCurrency permission without it',
449
+ test: async function () {
450
+ const sender = this.setupData.players[0];
451
+ const receiver = this.setupData.players[1];
452
+ const amount = 500;
453
+
454
+ // by default all users get root permission => remove all permissions
455
+ await this.client.role.roleControllerUpdate(this.setupData.role.id, {
456
+ permissions: [],
457
+ });
458
+
459
+ await this.client.module.moduleInstallationsControllerInstallModule({
460
+ gameServerId: this.setupData.gameserver.id,
461
+ versionId: this.setupData.economyUtilsModule.latestVersion.id,
462
+ });
463
+
464
+ // currency before revoke
465
+ expect(
466
+ receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency,
467
+ ).to.be.eq(0);
468
+
469
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
470
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
471
+ msg: `/grantcurrency ${receiver.name} ${amount}`,
472
+ playerId: sender.id,
473
+ });
474
+
475
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
476
+ msg: `/revokecurrency ${receiver.name} ${amount}`,
477
+ playerId: sender.id,
478
+ });
479
+
480
+ const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
481
+ expect(messages[0]).to.be.eq(
482
+ "⚠️ You need the 'Economy Utils Manage Currency' permission to use this command. Please contact an admin if you need access.",
483
+ );
484
+ expect(messages[1]).to.be.eq(
485
+ "⚠️ You need the 'Economy Utils Manage Currency' permission to use this command. Please contact an admin if you need access.",
486
+ );
487
+ },
488
+ }),
489
+ ];
490
+
491
+ describe(group, function () {
492
+ tests.forEach((test) => {
493
+ test.run();
494
+ });
495
+ });
@@ -0,0 +1,177 @@
1
+ import { EventsAwaiter, expect, IntegrationTest, IShopSetup, shopSetup } from '@takaro/test';
2
+ import { HookEvents } from '../../dto/index.js';
3
+ import { describe } from 'node:test';
4
+
5
+ const group = 'EconomyUtils:Shop:Browse';
6
+
7
+ const tests = [
8
+ new IntegrationTest<IShopSetup>({
9
+ group,
10
+ snapshot: false,
11
+ setup: shopSetup,
12
+ name: 'Calling /shop without arguments displays help information',
13
+ test: async function () {
14
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 5);
15
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
16
+ msg: '/shop',
17
+ playerId: this.setupData.players[0].id,
18
+ });
19
+
20
+ expect(await events).to.have.length(5);
21
+ expect((await events)[0].data.meta.msg).to.eq(
22
+ 'This command allows you to browse the shop and view available items.',
23
+ );
24
+ expect((await events)[1].data.meta.msg).to.eq('Usage: /shop [page] [item] [action]');
25
+ expect((await events)[2].data.meta.msg).to.eq('/shop 2 - View the second page of shop items');
26
+ expect((await events)[3].data.meta.msg).to.eq('/shop 1 3 - View details about the third item on the first page');
27
+ expect((await events)[4].data.meta.msg).to.eq('/shop 1 3 buy - Purchase the third item on the first page');
28
+ },
29
+ }),
30
+ new IntegrationTest<IShopSetup>({
31
+ group,
32
+ snapshot: false,
33
+ setup: shopSetup,
34
+ name: 'First page shows the first 5 items',
35
+ test: async function () {
36
+ await this.setupData.createListings(this.client, { gameServerId: this.setupData.gameserver.id, amount: 5 });
37
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 5);
38
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
39
+ msg: '/shop 1',
40
+ playerId: this.setupData.players[0].id,
41
+ });
42
+
43
+ console.log(JSON.stringify((await events)[0].data.meta.msg, null, 2));
44
+ expect(await events).to.have.length(5);
45
+ },
46
+ }),
47
+ new IntegrationTest<IShopSetup>({
48
+ group,
49
+ snapshot: false,
50
+ setup: shopSetup,
51
+ name: 'Can view the second page of shop items',
52
+ test: async function () {
53
+ await this.client.module.moduleInstallationsControllerInstallModule({
54
+ gameServerId: this.setupData.gameserver.id,
55
+ versionId: this.setupData.utilsModule.latestVersion.id,
56
+ });
57
+ await this.setupData.createListings(this.client, { gameServerId: this.setupData.gameserver.id, amount: 5 });
58
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 3);
59
+ const commandExecutedEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(
60
+ HookEvents.COMMAND_EXECUTED,
61
+ 1,
62
+ );
63
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
64
+ msg: '/shop 2',
65
+ playerId: this.setupData.players[0].id,
66
+ });
67
+
68
+ await commandExecutedEvent;
69
+
70
+ // We trigger the ping command to make sure we can see the FULL output of the previous command
71
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
72
+ msg: '/ping',
73
+ playerId: this.setupData.players[0].id,
74
+ });
75
+
76
+ expect(await events).to.have.length(3);
77
+ expect((await events)[(await events).length - 1].data.meta.msg).to.eq('Pong!');
78
+ },
79
+ }),
80
+ new IntegrationTest<IShopSetup>({
81
+ group,
82
+ snapshot: false,
83
+ setup: shopSetup,
84
+ name: 'When no items are available, shows a message',
85
+ test: async function () {
86
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 1);
87
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
88
+ msg: '/shop 5',
89
+ playerId: this.setupData.players[0].id,
90
+ });
91
+
92
+ expect(await events).to.have.length(1);
93
+ expect((await events)[0].data.meta.msg).to.equal('No items found.');
94
+ },
95
+ }),
96
+ new IntegrationTest<IShopSetup>({
97
+ group,
98
+ snapshot: false,
99
+ setup: shopSetup,
100
+ name: 'Can show details about an item',
101
+ test: async function () {
102
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 2);
103
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
104
+ msg: '/shop 1 1',
105
+ playerId: this.setupData.players[0].id,
106
+ });
107
+
108
+ expect(await events).to.have.length(2);
109
+ expect((await events)[0].data.meta.msg).to.equal('Listing Test item - 100 test coin');
110
+ expect((await events)[1].data.meta.msg).to.equal('- 1x Stone. Description: Stone can get you stoned');
111
+ },
112
+ }),
113
+ new IntegrationTest<IShopSetup>({
114
+ group,
115
+ snapshot: false,
116
+ setup: shopSetup,
117
+ name: 'Shows an error when requesting details for an invalid item',
118
+ test: async function () {
119
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 1);
120
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
121
+ msg: '/shop 1 5',
122
+ playerId: this.setupData.players[0].id,
123
+ });
124
+
125
+ expect(await events).to.have.length(1);
126
+ expect((await events)[0].data.meta.msg).to.equal(
127
+ 'Item not found. Please select an item from the list, valid options are 1-2.',
128
+ );
129
+ },
130
+ }),
131
+ new IntegrationTest<IShopSetup>({
132
+ group,
133
+ snapshot: false,
134
+ setup: shopSetup,
135
+ name: 'Can buy an item',
136
+ test: async function () {
137
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 2);
138
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
139
+ msg: '/shop 1 1 buy',
140
+ playerId: this.setupData.players[0].id,
141
+ });
142
+
143
+ expect(await events).to.have.length(2);
144
+ expect((await events)[0].data.meta.msg).to.equal('You have purchased Test item for 100 test coin.');
145
+ expect((await events)[1].data.meta.msg).to.equal('You have received items from a shop order.');
146
+ },
147
+ }),
148
+ new IntegrationTest<IShopSetup>({
149
+ group,
150
+ snapshot: false,
151
+ setup: shopSetup,
152
+ name: 'Can buy an item when not linked to a user',
153
+ test: async function () {
154
+ const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 2);
155
+ const unlinkedPlayer = this.setupData.players[1];
156
+ await this.client.playerOnGameserver.playerOnGameServerControllerAddCurrency(
157
+ this.setupData.gameserver.id,
158
+ unlinkedPlayer.id,
159
+ { currency: 250 },
160
+ );
161
+ await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
162
+ msg: '/shop 1 1 buy',
163
+ playerId: unlinkedPlayer.id,
164
+ });
165
+
166
+ expect(await events).to.have.length(2);
167
+ expect((await events)[0].data.meta.msg).to.equal('You have purchased Test item for 100 test coin.');
168
+ expect((await events)[1].data.meta.msg).to.equal('You have received items from a shop order.');
169
+ },
170
+ }),
171
+ ];
172
+
173
+ describe(group, function () {
174
+ tests.forEach((test) => {
175
+ test.run();
176
+ });
177
+ });