@takaro/modules 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BuiltinModule.js +0 -4
- package/dist/BuiltinModule.js.map +1 -1
- package/dist/community-modules.json +21 -0
- package/dist/dto/gameEvents.d.ts +3 -2
- package/dist/dto/gameEvents.js +1 -0
- package/dist/dto/gameEvents.js.map +1 -1
- package/dist/dto/index.d.ts +6 -0
- package/dist/dto/takaroEvents.d.ts +46 -0
- package/dist/dto/takaroEvents.js +129 -1
- package/dist/dto/takaroEvents.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +1 -1
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -1
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +2 -2
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -1
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -1
- package/dist/modules/economyUtils/commands/transfer.js +1 -1
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -1
- package/dist/modules/geoBlock/hooks/IPDetected.js +13 -15
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
- package/dist/modules/geoBlock/index.js +1 -1
- package/dist/modules/geoBlock/index.js.map +1 -1
- package/dist/modules/lottery/commands/nextDraw.js +1 -1
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -1
- package/dist/modules/playerOnboarding/index.js.map +1 -1
- package/dist/modules/teleports/commands/deletetp.js +1 -1
- package/dist/modules/teleports/commands/deletetp.js.map +1 -1
- package/dist/modules/teleports/commands/setprivate.js +4 -6
- package/dist/modules/teleports/commands/setprivate.js.map +1 -1
- package/dist/modules/teleports/commands/setpublic.js +8 -15
- package/dist/modules/teleports/commands/setpublic.js.map +1 -1
- package/dist/modules/teleports/commands/settp.js +2 -2
- package/dist/modules/teleports/commands/settp.js.map +1 -1
- package/dist/modules/teleports/commands/teleport.js +3 -8
- package/dist/modules/teleports/commands/teleport.js.map +1 -1
- package/dist/modules/teleports/commands/teleportwaypoint.js +9 -1
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/tplist.js +13 -12
- package/dist/modules/teleports/commands/tplist.js.map +1 -1
- package/dist/modules/teleports/functions/utils.d.ts +2 -2
- package/dist/modules/teleports/functions/utils.js +21 -3
- package/dist/modules/teleports/functions/utils.js.map +1 -1
- package/dist/modules.json +98 -78
- package/package.json +4 -8
- package/scripts/buildBuiltinJson.ts +20 -0
- package/src/BuiltinModule.ts +1 -1
- package/src/__tests__/aliases.integration.test.ts +2 -3
- package/src/__tests__/bugRepros.integration.test.ts +72 -0
- package/src/__tests__/commandArgs.integration.test.ts +2 -3
- package/src/__tests__/economyUtils.integration.test.ts +38 -39
- package/src/__tests__/geoblock.integration.test.ts +11 -12
- package/src/__tests__/gimme.integration.test.ts +4 -5
- package/src/__tests__/help.integration.test.ts +12 -13
- package/src/__tests__/lottery.integration.test.ts +6 -7
- package/src/__tests__/modulePermission.integration.test.ts +5 -6
- package/src/__tests__/onboarding.integration.test.ts +5 -6
- package/src/__tests__/ping.integration.test.ts +2 -3
- package/src/__tests__/roleExpiry.integration.test.ts +3 -4
- package/src/__tests__/serverMessages.integration.test.ts +5 -6
- package/src/__tests__/systemConfigCost.integration.test.ts +6 -7
- package/src/__tests__/teleports/listtp.integration.test.ts +84 -10
- package/src/__tests__/teleports/publicteleports.integration.test.ts +11 -12
- package/src/__tests__/teleports/teleport.integration.test.ts +4 -5
- package/src/__tests__/teleports/tpManagement.integration.test.ts +10 -11
- package/src/__tests__/teleports/waypoints.integration.test.ts +5 -6
- package/src/community-modules/README.md +5 -0
- package/src/community-modules/modules/vote.json +19 -0
- package/src/dto/gameEvents.ts +2 -2
- package/src/dto/takaroEvents.ts +79 -0
- package/src/main.ts +2 -3
- package/src/modules/chatBridge/hooks/GameToDiscord.js +1 -1
- package/src/modules/chatBridge/hooks/PlayerConnected.js +2 -2
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
- package/src/modules/chatBridge/index.ts +1 -1
- package/src/modules/economyUtils/commands/transfer.js +4 -4
- package/src/modules/economyUtils/index.ts +1 -1
- package/src/modules/geoBlock/hooks/IPDetected.js +12 -13
- package/src/modules/geoBlock/index.ts +2 -2
- package/src/modules/gimme/index.ts +1 -1
- package/src/modules/highPingKicker/index.ts +1 -1
- package/src/modules/lottery/commands/nextDraw.js +3 -1
- package/src/modules/lottery/index.ts +1 -1
- package/src/modules/playerOnboarding/index.ts +2 -1
- package/src/modules/serverMessages/index.ts +1 -1
- package/src/modules/teleports/commands/deletetp.js +1 -1
- package/src/modules/teleports/commands/setprivate.js +6 -6
- package/src/modules/teleports/commands/setpublic.js +18 -25
- package/src/modules/teleports/commands/settp.js +2 -2
- package/src/modules/teleports/commands/teleport.js +3 -10
- package/src/modules/teleports/commands/teleportwaypoint.js +12 -1
- package/src/modules/teleports/commands/tplist.js +16 -15
- package/src/modules/teleports/functions/utils.js +19 -3
- package/src/modules/teleports/index.ts +1 -1
- package/src/modules/utils/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takaro/modules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Built-in modules for Takaro",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"keywords": [],
|
|
18
18
|
"author": "",
|
|
19
19
|
"license": "ISC",
|
|
20
|
-
"dependencies": {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@takaro/test": "0.0.1"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
20
|
+
"dependencies": {},
|
|
21
|
+
"devDependencies": {}
|
|
22
|
+
}
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { getModules } from '@takaro/modules';
|
|
3
3
|
import { writeFile } from 'fs/promises';
|
|
4
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
4
8
|
|
|
5
9
|
async function main() {
|
|
10
|
+
// Built in modules
|
|
11
|
+
// TODO: we should probably 'export' them in CI and save it as JSON so it's consistent with the community modules
|
|
6
12
|
const modules = await getModules();
|
|
7
13
|
const modulesJson = JSON.stringify(modules, null, 2);
|
|
8
14
|
await writeFile('dist/modules.json', modulesJson);
|
|
9
15
|
await writeFile('../web-docs/pages/modules.json', modulesJson);
|
|
10
16
|
await writeFile('../e2e/src/web-main/fixtures/modules.json', modulesJson);
|
|
17
|
+
|
|
18
|
+
// Community modules
|
|
19
|
+
const files = await readdir(`${__dirname}/../src/community-modules/modules`);
|
|
20
|
+
const communityModules: Array<string> = [];
|
|
21
|
+
|
|
22
|
+
for (const file of files) {
|
|
23
|
+
const content = await readFile(`${__dirname}/../src/community-modules/modules/${file}`, 'utf-8');
|
|
24
|
+
communityModules.push(JSON.parse(content));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const communityModulesJson = JSON.stringify(communityModules, null, 2);
|
|
28
|
+
await writeFile('dist/community-modules.json', communityModulesJson);
|
|
29
|
+
await writeFile('../web-docs/pages/community-modules.json', communityModulesJson);
|
|
30
|
+
await writeFile('../e2e/src/web-main/fixtures/community-modules.json', communityModulesJson);
|
|
11
31
|
}
|
|
12
32
|
|
|
13
33
|
// eslint-disable-next-line no-console
|
package/src/BuiltinModule.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/index.js';
|
|
4
3
|
|
|
5
4
|
const group = 'Aliases';
|
|
@@ -23,7 +22,7 @@ const tests = [
|
|
|
23
22
|
},
|
|
24
23
|
},
|
|
25
24
|
}),
|
|
26
|
-
}
|
|
25
|
+
},
|
|
27
26
|
);
|
|
28
27
|
|
|
29
28
|
const setEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
2
|
+
import { GameEvents } from '../dto/index.js';
|
|
3
|
+
import { EventChatMessageChannelEnum } from '@takaro/apiclient';
|
|
4
|
+
|
|
5
|
+
const group = 'Bug repros';
|
|
6
|
+
|
|
7
|
+
const tests = [
|
|
8
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
9
|
+
group,
|
|
10
|
+
snapshot: false,
|
|
11
|
+
name: 'Bug repro: can trigger 2 hooks for the same event inside a single module',
|
|
12
|
+
setup: modulesTestSetup,
|
|
13
|
+
test: async function () {
|
|
14
|
+
const genFn = (param: string) => {
|
|
15
|
+
return `import { data, takaro } from '@takaro/helpers';
|
|
16
|
+
async function main() {
|
|
17
|
+
const { player } = data;
|
|
18
|
+
await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
|
|
19
|
+
message: '${param} hook',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
await main();`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const mod = (
|
|
26
|
+
await this.client.module.moduleControllerCreate({
|
|
27
|
+
name: 'Test module',
|
|
28
|
+
})
|
|
29
|
+
).data.data;
|
|
30
|
+
// Add the buggy hooks
|
|
31
|
+
await this.client.hook.hookControllerCreate({
|
|
32
|
+
name: 'Test hook 1',
|
|
33
|
+
moduleId: mod.id,
|
|
34
|
+
regex: 'test msg',
|
|
35
|
+
eventType: 'chat-message',
|
|
36
|
+
function: genFn('First'),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await this.client.hook.hookControllerCreate({
|
|
40
|
+
name: 'Test hook 2',
|
|
41
|
+
moduleId: mod.id,
|
|
42
|
+
regex: 'test msg',
|
|
43
|
+
eventType: 'chat-message',
|
|
44
|
+
function: genFn('Second'),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
await this.client.gameserver.gameServerControllerInstallModule(this.setupData.gameserver.id, mod.id);
|
|
48
|
+
|
|
49
|
+
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
50
|
+
|
|
51
|
+
await this.client.hook.hookControllerTrigger({
|
|
52
|
+
eventType: 'chat-message',
|
|
53
|
+
gameServerId: this.setupData.gameserver.id,
|
|
54
|
+
moduleId: mod.id,
|
|
55
|
+
playerId: this.setupData.players[0].id,
|
|
56
|
+
eventMeta: {
|
|
57
|
+
msg: 'test msg',
|
|
58
|
+
channel: EventChatMessageChannelEnum.Global,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect((await events).length).to.be.eq(2);
|
|
63
|
+
expect((await events).map((e) => e.data.msg)).to.include.members(['First hook', 'Second hook']);
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
describe(group, function () {
|
|
69
|
+
tests.forEach((test) => {
|
|
70
|
+
test.run();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/gameEvents.js';
|
|
4
3
|
import { CommandArgumentCreateDTO } from '@takaro/apiclient';
|
|
5
4
|
|
|
@@ -86,7 +85,7 @@ const tests = [
|
|
|
86
85
|
|
|
87
86
|
expect((await events).length).to.be.eq(1);
|
|
88
87
|
expect((await events)[0].data.msg).to.be.eq(
|
|
89
|
-
'The value for "test" should be a number. Please correct it and try again.'
|
|
88
|
+
'The value for "test" should be a number. Please correct it and try again.',
|
|
90
89
|
);
|
|
91
90
|
},
|
|
92
91
|
}),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup, chatMessageSorter } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, chatMessageSorter } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/index.js';
|
|
4
3
|
|
|
5
4
|
const group = 'Economy utils suite';
|
|
@@ -31,7 +30,7 @@ const tests = [
|
|
|
31
30
|
test: async function () {
|
|
32
31
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
33
32
|
this.setupData.gameserver.id,
|
|
34
|
-
this.setupData.economyUtilsModule.id
|
|
33
|
+
this.setupData.economyUtilsModule.id,
|
|
35
34
|
);
|
|
36
35
|
|
|
37
36
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
@@ -52,7 +51,7 @@ const tests = [
|
|
|
52
51
|
playerOnGameServer[0].playerId,
|
|
53
52
|
{
|
|
54
53
|
currency: 1000,
|
|
55
|
-
}
|
|
54
|
+
},
|
|
56
55
|
);
|
|
57
56
|
|
|
58
57
|
// trigger balance command
|
|
@@ -75,7 +74,7 @@ const tests = [
|
|
|
75
74
|
// install module
|
|
76
75
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
77
76
|
this.setupData.gameserver.id,
|
|
78
|
-
this.setupData.economyUtilsModule.id
|
|
77
|
+
this.setupData.economyUtilsModule.id,
|
|
79
78
|
);
|
|
80
79
|
|
|
81
80
|
const giveCurrencies = this.setupData.players.map(async (player, index) => {
|
|
@@ -90,7 +89,7 @@ const tests = [
|
|
|
90
89
|
playerOnGameServer[0].playerId,
|
|
91
90
|
{
|
|
92
91
|
currency: 1000 * index,
|
|
93
|
-
}
|
|
92
|
+
},
|
|
94
93
|
);
|
|
95
94
|
});
|
|
96
95
|
await Promise.all(giveCurrencies);
|
|
@@ -107,7 +106,7 @@ const tests = [
|
|
|
107
106
|
expect((await events).length).to.be.eq(6);
|
|
108
107
|
for (const message of messages) {
|
|
109
108
|
expect(message).to.match(
|
|
110
|
-
/(Richest players\:|1\. .+ - 4000 test coin|2\. .+ - 3000 test coin|3\. .+ - 2000 test coin|4\. .+ - 1000 test coin|5\. .+ - 0 test coin)
|
|
109
|
+
/(Richest players\:|1\. .+ - 4000 test coin|2\. .+ - 3000 test coin|3\. .+ - 2000 test coin|4\. .+ - 1000 test coin|5\. .+ - 0 test coin)/,
|
|
111
110
|
);
|
|
112
111
|
}
|
|
113
112
|
},
|
|
@@ -120,7 +119,7 @@ const tests = [
|
|
|
120
119
|
test: async function () {
|
|
121
120
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
122
121
|
this.setupData.gameserver.id,
|
|
123
|
-
this.setupData.economyUtilsModule.id
|
|
122
|
+
this.setupData.economyUtilsModule.id,
|
|
124
123
|
);
|
|
125
124
|
|
|
126
125
|
const transferAmount = 500;
|
|
@@ -133,12 +132,12 @@ const tests = [
|
|
|
133
132
|
senderPog.playerId,
|
|
134
133
|
{
|
|
135
134
|
currency: transferAmount,
|
|
136
|
-
}
|
|
135
|
+
},
|
|
137
136
|
);
|
|
138
137
|
|
|
139
138
|
const receiver = this.setupData.players[1];
|
|
140
139
|
const receiverPog = receiver.playerOnGameServers?.find(
|
|
141
|
-
(pog) => pog.gameServerId === this.setupData.gameserver.id
|
|
140
|
+
(pog) => pog.gameServerId === this.setupData.gameserver.id,
|
|
142
141
|
);
|
|
143
142
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
144
143
|
expect(receiverPog.currency).to.be.eq(0);
|
|
@@ -156,13 +155,13 @@ const tests = [
|
|
|
156
155
|
// check if balances are correct
|
|
157
156
|
const updatedSender = await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
158
157
|
senderPog.gameServerId,
|
|
159
|
-
senderPog.playerId
|
|
158
|
+
senderPog.playerId,
|
|
160
159
|
);
|
|
161
160
|
expect(updatedSender.data.data.currency).to.be.eq(0);
|
|
162
161
|
|
|
163
162
|
const updatedReceiver = await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
164
163
|
receiverPog.gameServerId,
|
|
165
|
-
receiverPog.playerId
|
|
164
|
+
receiverPog.playerId,
|
|
166
165
|
);
|
|
167
166
|
expect(updatedReceiver.data.data.currency).to.be.eq(transferAmount);
|
|
168
167
|
|
|
@@ -178,7 +177,7 @@ const tests = [
|
|
|
178
177
|
test: async function () {
|
|
179
178
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
180
179
|
this.setupData.gameserver.id,
|
|
181
|
-
this.setupData.economyUtilsModule.id
|
|
180
|
+
this.setupData.economyUtilsModule.id,
|
|
182
181
|
);
|
|
183
182
|
|
|
184
183
|
const sender = this.setupData.players[0];
|
|
@@ -195,7 +194,7 @@ const tests = [
|
|
|
195
194
|
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
196
195
|
expect((await events).length).to.be.eq(1);
|
|
197
196
|
expect(messages[0]).to.be.eq(
|
|
198
|
-
`Failed to transfer ${transferAmount} test coin to ${receiver.name}. Are you sure you have enough balance
|
|
197
|
+
`Failed to transfer ${transferAmount} test coin to ${receiver.name}. Are you sure you have enough balance?`,
|
|
199
198
|
);
|
|
200
199
|
},
|
|
201
200
|
}),
|
|
@@ -212,7 +211,7 @@ const tests = [
|
|
|
212
211
|
userConfig: JSON.stringify({
|
|
213
212
|
pendingAmount: 100,
|
|
214
213
|
}),
|
|
215
|
-
}
|
|
214
|
+
},
|
|
216
215
|
);
|
|
217
216
|
|
|
218
217
|
const transferAmount = 500;
|
|
@@ -228,12 +227,12 @@ const tests = [
|
|
|
228
227
|
senderPog.playerId,
|
|
229
228
|
{
|
|
230
229
|
currency: transferAmount,
|
|
231
|
-
}
|
|
230
|
+
},
|
|
232
231
|
);
|
|
233
232
|
|
|
234
233
|
const receiver = this.setupData.players[1];
|
|
235
234
|
const receiverPog = receiver.playerOnGameServers?.find(
|
|
236
|
-
(pog) => pog.gameServerId === this.setupData.gameserver.id
|
|
235
|
+
(pog) => pog.gameServerId === this.setupData.gameserver.id,
|
|
237
236
|
);
|
|
238
237
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
239
238
|
expect(receiverPog.currency).to.be.eq(0);
|
|
@@ -252,21 +251,21 @@ const tests = [
|
|
|
252
251
|
(
|
|
253
252
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
254
253
|
senderPog.gameServerId,
|
|
255
|
-
senderPog.playerId
|
|
254
|
+
senderPog.playerId,
|
|
256
255
|
)
|
|
257
|
-
).data.data.currency
|
|
256
|
+
).data.data.currency,
|
|
258
257
|
).to.be.eq(transferAmount);
|
|
259
258
|
expect(
|
|
260
259
|
(
|
|
261
260
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
262
261
|
receiverPog.gameServerId,
|
|
263
|
-
receiverPog.playerId
|
|
262
|
+
receiverPog.playerId,
|
|
264
263
|
)
|
|
265
|
-
).data.data.currency
|
|
264
|
+
).data.data.currency,
|
|
266
265
|
).to.be.eq(0);
|
|
267
266
|
expect(messages.length).to.be.eq(1);
|
|
268
267
|
expect(messages[0]).to.be.eq(
|
|
269
|
-
`You are about to send ${transferAmount} test coin to ${receiver.name}. (Please confirm by typing ${prefix}confirmtransfer)
|
|
268
|
+
`You are about to send ${transferAmount} test coin to ${receiver.name}. (Please confirm by typing ${prefix}confirmtransfer)`,
|
|
270
269
|
);
|
|
271
270
|
|
|
272
271
|
// =================================================
|
|
@@ -284,17 +283,17 @@ const tests = [
|
|
|
284
283
|
(
|
|
285
284
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
286
285
|
senderPog.gameServerId,
|
|
287
|
-
senderPog.playerId
|
|
286
|
+
senderPog.playerId,
|
|
288
287
|
)
|
|
289
|
-
).data.data.currency
|
|
288
|
+
).data.data.currency,
|
|
290
289
|
).to.be.eq(0);
|
|
291
290
|
expect(
|
|
292
291
|
(
|
|
293
292
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
294
293
|
receiverPog.gameServerId,
|
|
295
|
-
receiverPog.playerId
|
|
294
|
+
receiverPog.playerId,
|
|
296
295
|
)
|
|
297
|
-
).data.data.currency
|
|
296
|
+
).data.data.currency,
|
|
298
297
|
).to.be.eq(transferAmount);
|
|
299
298
|
|
|
300
299
|
expect(messages[0]).to.be.eq(`You received ${transferAmount} test coin from ${sender.name}`);
|
|
@@ -314,7 +313,7 @@ const tests = [
|
|
|
314
313
|
userConfig: JSON.stringify({
|
|
315
314
|
pendingAmount: 100,
|
|
316
315
|
}),
|
|
317
|
-
}
|
|
316
|
+
},
|
|
318
317
|
);
|
|
319
318
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
320
319
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
@@ -338,7 +337,7 @@ const tests = [
|
|
|
338
337
|
|
|
339
338
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
340
339
|
this.setupData.gameserver.id,
|
|
341
|
-
this.setupData.economyUtilsModule.id
|
|
340
|
+
this.setupData.economyUtilsModule.id,
|
|
342
341
|
);
|
|
343
342
|
|
|
344
343
|
// Change permissions of role to only have manageCurrency permission
|
|
@@ -352,7 +351,7 @@ const tests = [
|
|
|
352
351
|
});
|
|
353
352
|
|
|
354
353
|
const receiverPog = receiver.playerOnGameServers?.find(
|
|
355
|
-
(pog) => pog.gameServerId === this.setupData.gameserver.id
|
|
354
|
+
(pog) => pog.gameServerId === this.setupData.gameserver.id,
|
|
356
355
|
);
|
|
357
356
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
358
357
|
expect(receiverPog.currency).to.be.eq(0);
|
|
@@ -368,9 +367,9 @@ const tests = [
|
|
|
368
367
|
(
|
|
369
368
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
370
369
|
receiverPog.gameServerId,
|
|
371
|
-
receiverPog.playerId
|
|
370
|
+
receiverPog.playerId,
|
|
372
371
|
)
|
|
373
|
-
).data.data.currency
|
|
372
|
+
).data.data.currency,
|
|
374
373
|
).to.be.eq(grantAmount);
|
|
375
374
|
expect(messages[0]).to.be.eq(`Granted ${grantAmount} test coin by ${granter.name}`);
|
|
376
375
|
expect(messages[1]).to.be.eq(`You successfully granted ${grantAmount} test coin to ${receiver.name}`);
|
|
@@ -388,7 +387,7 @@ const tests = [
|
|
|
388
387
|
|
|
389
388
|
// make sure receiver has enough currency
|
|
390
389
|
const receiverPog = receiver.playerOnGameServers?.find(
|
|
391
|
-
(pog) => pog.gameServerId === this.setupData.gameserver.id
|
|
390
|
+
(pog) => pog.gameServerId === this.setupData.gameserver.id,
|
|
392
391
|
);
|
|
393
392
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
394
393
|
await this.client.playerOnGameserver.playerOnGameServerControllerSetCurrency(
|
|
@@ -396,12 +395,12 @@ const tests = [
|
|
|
396
395
|
receiverPog.playerId,
|
|
397
396
|
{
|
|
398
397
|
currency: revokeAmount,
|
|
399
|
-
}
|
|
398
|
+
},
|
|
400
399
|
);
|
|
401
400
|
|
|
402
401
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
403
402
|
this.setupData.gameserver.id,
|
|
404
|
-
this.setupData.economyUtilsModule.id
|
|
403
|
+
this.setupData.economyUtilsModule.id,
|
|
405
404
|
);
|
|
406
405
|
|
|
407
406
|
// Change permissions of role to only have manageCurrency permission
|
|
@@ -416,7 +415,7 @@ const tests = [
|
|
|
416
415
|
|
|
417
416
|
// currency before revoke
|
|
418
417
|
expect(
|
|
419
|
-
receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency
|
|
418
|
+
receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency,
|
|
420
419
|
).to.be.eq(0);
|
|
421
420
|
|
|
422
421
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
@@ -430,9 +429,9 @@ const tests = [
|
|
|
430
429
|
(
|
|
431
430
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
432
431
|
receiverPog.gameServerId,
|
|
433
|
-
receiverPog.playerId
|
|
432
|
+
receiverPog.playerId,
|
|
434
433
|
)
|
|
435
|
-
).data.data.currency
|
|
434
|
+
).data.data.currency,
|
|
436
435
|
).to.be.eq(0);
|
|
437
436
|
expect(messages[0]).to.be.eq(`${revokeAmount} test coin were revoked by ${revoker.name}`);
|
|
438
437
|
expect(messages[1]).to.be.eq(`You successfully revoked ${revokeAmount} test coin of ${receiver.name}'s balance`);
|
|
@@ -455,12 +454,12 @@ const tests = [
|
|
|
455
454
|
|
|
456
455
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
457
456
|
this.setupData.gameserver.id,
|
|
458
|
-
this.setupData.economyUtilsModule.id
|
|
457
|
+
this.setupData.economyUtilsModule.id,
|
|
459
458
|
);
|
|
460
459
|
|
|
461
460
|
// currency before revoke
|
|
462
461
|
expect(
|
|
463
|
-
receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency
|
|
462
|
+
receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency,
|
|
464
463
|
).to.be.eq(0);
|
|
465
464
|
|
|
466
465
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
3
2
|
import { HookEvents } from '../dto/index.js';
|
|
4
3
|
import { TakaroEventPlayerNewIpDetected } from '@takaro/modules';
|
|
5
4
|
import { faker } from '@faker-js/faker';
|
|
@@ -12,7 +11,7 @@ const customSetup = async function (this: IntegrationTest<IModuleTestsSetupData>
|
|
|
12
11
|
await Promise.all(
|
|
13
12
|
setupData.players.map(async (player) => {
|
|
14
13
|
await this.client.player.playerControllerRemoveRole(player.id, setupData.role.id);
|
|
15
|
-
})
|
|
14
|
+
}),
|
|
16
15
|
);
|
|
17
16
|
|
|
18
17
|
return setupData;
|
|
@@ -34,7 +33,7 @@ const tests = [
|
|
|
34
33
|
countries: ['RU'],
|
|
35
34
|
ban: false,
|
|
36
35
|
}),
|
|
37
|
-
}
|
|
36
|
+
},
|
|
38
37
|
);
|
|
39
38
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
40
39
|
await this.client.hook.hookControllerTrigger({
|
|
@@ -70,7 +69,7 @@ const tests = [
|
|
|
70
69
|
countries: ['RU'],
|
|
71
70
|
ban: false,
|
|
72
71
|
}),
|
|
73
|
-
}
|
|
72
|
+
},
|
|
74
73
|
);
|
|
75
74
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
76
75
|
|
|
@@ -109,7 +108,7 @@ const tests = [
|
|
|
109
108
|
countries: ['RU'],
|
|
110
109
|
ban: false,
|
|
111
110
|
}),
|
|
112
|
-
}
|
|
111
|
+
},
|
|
113
112
|
);
|
|
114
113
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
115
114
|
|
|
@@ -148,7 +147,7 @@ const tests = [
|
|
|
148
147
|
countries: ['RU'],
|
|
149
148
|
ban: false,
|
|
150
149
|
}),
|
|
151
|
-
}
|
|
150
|
+
},
|
|
152
151
|
);
|
|
153
152
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
154
153
|
|
|
@@ -185,7 +184,7 @@ const tests = [
|
|
|
185
184
|
countries: ['RU'],
|
|
186
185
|
ban: true,
|
|
187
186
|
}),
|
|
188
|
-
}
|
|
187
|
+
},
|
|
189
188
|
);
|
|
190
189
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
191
190
|
|
|
@@ -223,7 +222,7 @@ const tests = [
|
|
|
223
222
|
ban: true,
|
|
224
223
|
message: 'Custom message',
|
|
225
224
|
}),
|
|
226
|
-
}
|
|
225
|
+
},
|
|
227
226
|
);
|
|
228
227
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
229
228
|
|
|
@@ -261,7 +260,7 @@ const tests = [
|
|
|
261
260
|
ban: true,
|
|
262
261
|
message: 'Custom message',
|
|
263
262
|
}),
|
|
264
|
-
}
|
|
263
|
+
},
|
|
265
264
|
);
|
|
266
265
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
267
266
|
|
|
@@ -299,7 +298,7 @@ const tests = [
|
|
|
299
298
|
ban: true,
|
|
300
299
|
message: 'Custom message',
|
|
301
300
|
}),
|
|
302
|
-
}
|
|
301
|
+
},
|
|
303
302
|
);
|
|
304
303
|
const permissions = await this.client.permissionCodesToInputs(['GEOBLOCK_IMMUNITY']);
|
|
305
304
|
const roleRes = await this.client.role.roleControllerCreate({
|
|
@@ -347,7 +346,7 @@ const tests = [
|
|
|
347
346
|
ban: true,
|
|
348
347
|
message: 'Custom message',
|
|
349
348
|
}),
|
|
350
|
-
}
|
|
349
|
+
},
|
|
351
350
|
);
|
|
352
351
|
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
353
352
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/index.js';
|
|
4
3
|
|
|
5
4
|
const group = 'gimme suite';
|
|
@@ -19,7 +18,7 @@ const tests = [
|
|
|
19
18
|
items: ['apple', 'banana', 'orange'],
|
|
20
19
|
commands: [],
|
|
21
20
|
}),
|
|
22
|
-
}
|
|
21
|
+
},
|
|
23
22
|
);
|
|
24
23
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
25
24
|
|
|
@@ -46,7 +45,7 @@ const tests = [
|
|
|
46
45
|
items: [],
|
|
47
46
|
commands: ['say hello from test'],
|
|
48
47
|
}),
|
|
49
|
-
}
|
|
48
|
+
},
|
|
50
49
|
);
|
|
51
50
|
|
|
52
51
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
@@ -74,7 +73,7 @@ const tests = [
|
|
|
74
73
|
items: [],
|
|
75
74
|
commands: [],
|
|
76
75
|
}),
|
|
77
|
-
}
|
|
76
|
+
},
|
|
78
77
|
);
|
|
79
78
|
|
|
80
79
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup, chatMessageSorter } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, chatMessageSorter } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/gameEvents.js';
|
|
4
3
|
|
|
5
4
|
const group = 'Help command';
|
|
@@ -13,7 +12,7 @@ const tests = [
|
|
|
13
12
|
test: async function () {
|
|
14
13
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
15
14
|
this.setupData.gameserver.id,
|
|
16
|
-
this.setupData.utilsModule.id
|
|
15
|
+
this.setupData.utilsModule.id,
|
|
17
16
|
);
|
|
18
17
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 3);
|
|
19
18
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
@@ -26,7 +25,7 @@ const tests = [
|
|
|
26
25
|
|
|
27
26
|
expect(sortedEvents[0].data.msg).to.be.eq('Available commands:');
|
|
28
27
|
expect(sortedEvents[1].data.msg).to.be.eq(
|
|
29
|
-
'help: The text you are reading right now, displays information about commands.'
|
|
28
|
+
'help: The text you are reading right now, displays information about commands.',
|
|
30
29
|
);
|
|
31
30
|
expect(sortedEvents[2].data.msg).to.be.eq('ping: Replies with pong, useful for testing if the connection works.');
|
|
32
31
|
},
|
|
@@ -39,11 +38,11 @@ const tests = [
|
|
|
39
38
|
test: async function () {
|
|
40
39
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
41
40
|
this.setupData.gameserver.id,
|
|
42
|
-
this.setupData.utilsModule.id
|
|
41
|
+
this.setupData.utilsModule.id,
|
|
43
42
|
);
|
|
44
43
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
45
44
|
this.setupData.gameserver.id,
|
|
46
|
-
this.setupData.teleportsModule.id
|
|
45
|
+
this.setupData.teleportsModule.id,
|
|
47
46
|
);
|
|
48
47
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 13);
|
|
49
48
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
@@ -57,21 +56,21 @@ const tests = [
|
|
|
57
56
|
expect(sortedEvents[1].data.msg).to.be.eq('deletetp: Deletes a location.');
|
|
58
57
|
expect(sortedEvents[2].data.msg).to.be.eq('deletewaypoint: Deletes a waypoint.');
|
|
59
58
|
expect(sortedEvents[3].data.msg).to.be.eq(
|
|
60
|
-
'help: The text you are reading right now, displays information about commands.'
|
|
59
|
+
'help: The text you are reading right now, displays information about commands.',
|
|
61
60
|
);
|
|
62
61
|
expect(sortedEvents[4].data.msg).to.be.eq('listwaypoints: Lists all waypoints.');
|
|
63
62
|
expect(sortedEvents[5].data.msg).to.be.eq('ping: Replies with pong, useful for testing if the connection works.');
|
|
64
63
|
expect(sortedEvents[6].data.msg).to.be.eq(
|
|
65
|
-
'setprivate: Sets a teleport to be private, only the teleport owner can teleport to it.'
|
|
64
|
+
'setprivate: Sets a teleport to be private, only the teleport owner can teleport to it.',
|
|
66
65
|
);
|
|
67
66
|
expect(sortedEvents[7].data.msg).to.be.eq(
|
|
68
|
-
'setpublic: Sets a teleport to be public, allowing other players to teleport to it.'
|
|
67
|
+
'setpublic: Sets a teleport to be public, allowing other players to teleport to it.',
|
|
69
68
|
);
|
|
70
69
|
expect(sortedEvents[8].data.msg).to.be.eq('settp: Sets a location to teleport to.');
|
|
71
70
|
expect(sortedEvents[9].data.msg).to.be.eq('setwaypoint: Creates a new waypoint.');
|
|
72
71
|
expect(sortedEvents[10].data.msg).to.be.eq('teleport: Teleports to one of your set locations.');
|
|
73
72
|
expect(sortedEvents[11].data.msg).to.be.eq(
|
|
74
|
-
'teleportwaypoint: Placeholder command, this will not be used directly. The module will install aliases for this command corresponding to the waypoint '
|
|
73
|
+
'teleportwaypoint: Placeholder command, this will not be used directly. The module will install aliases for this command corresponding to the waypoint names.',
|
|
75
74
|
);
|
|
76
75
|
expect(sortedEvents[12].data.msg).to.be.eq('tplist: Lists all your set locations.');
|
|
77
76
|
},
|
|
@@ -84,7 +83,7 @@ const tests = [
|
|
|
84
83
|
test: async function () {
|
|
85
84
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
86
85
|
this.setupData.gameserver.id,
|
|
87
|
-
this.setupData.utilsModule.id
|
|
86
|
+
this.setupData.utilsModule.id,
|
|
88
87
|
);
|
|
89
88
|
|
|
90
89
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
@@ -108,7 +107,7 @@ const tests = [
|
|
|
108
107
|
test: async function () {
|
|
109
108
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
110
109
|
this.setupData.gameserver.id,
|
|
111
|
-
this.setupData.utilsModule.id
|
|
110
|
+
this.setupData.utilsModule.id,
|
|
112
111
|
);
|
|
113
112
|
|
|
114
113
|
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
@@ -120,7 +119,7 @@ const tests = [
|
|
|
120
119
|
|
|
121
120
|
expect((await events).length).to.be.eq(1);
|
|
122
121
|
expect((await events)[0].data.msg).to.be.eq(
|
|
123
|
-
'Unknown command "foobar", use this command without arguments to see all available commands.'
|
|
122
|
+
'Unknown command "foobar", use this command without arguments to see all available commands.',
|
|
124
123
|
);
|
|
125
124
|
},
|
|
126
125
|
}),
|