@takaro/modules 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/BuiltinModule.d.ts +49 -0
- package/dist/BuiltinModule.js +194 -0
- package/dist/BuiltinModule.js.map +1 -0
- package/dist/dto/base.d.ts +6 -0
- package/dist/dto/base.js +28 -0
- package/dist/dto/base.js.map +1 -0
- package/dist/dto/discordEvents.d.ts +31 -0
- package/dist/dto/discordEvents.js +92 -0
- package/dist/dto/discordEvents.js.map +1 -0
- package/dist/dto/gameEvents.d.ts +84 -0
- package/dist/dto/gameEvents.js +190 -0
- package/dist/dto/gameEvents.js.map +1 -0
- package/dist/dto/index.d.ts +37 -0
- package/dist/dto/index.js +18 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/takaroEvents.d.ts +150 -0
- package/dist/dto/takaroEvents.js +422 -0
- package/dist/dto/takaroEvents.js.map +1 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.js +31 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
- package/dist/modules/chatBridge/index.d.ts +4 -0
- package/dist/modules/chatBridge/index.js +54 -0
- package/dist/modules/chatBridge/index.js.map +1 -0
- package/dist/modules/economyUtils/commands/balance.d.ts +1 -0
- package/dist/modules/economyUtils/commands/balance.js +7 -0
- package/dist/modules/economyUtils/commands/balance.js.map +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js +31 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js +31 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
- package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/transfer.js +55 -0
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
- package/dist/modules/economyUtils/index.d.ts +4 -0
- package/dist/modules/economyUtils/index.js +117 -0
- package/dist/modules/economyUtils/index.js.map +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
- package/dist/modules/geoBlock/index.d.ts +8 -0
- package/dist/modules/geoBlock/index.js +321 -0
- package/dist/modules/geoBlock/index.js.map +1 -0
- package/dist/modules/gimme/commands/gimme.d.ts +1 -0
- package/dist/modules/gimme/commands/gimme.js +23 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -0
- package/dist/modules/gimme/index.d.ts +4 -0
- package/dist/modules/gimme/index.js +43 -0
- package/dist/modules/gimme/index.js.map +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js +54 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
- package/dist/modules/highPingKicker/index.d.ts +4 -0
- package/dist/modules/highPingKicker/index.js +34 -0
- package/dist/modules/highPingKicker/index.js.map +1 -0
- package/dist/modules/lottery/commands/buyTicket.d.ts +1 -0
- package/dist/modules/lottery/commands/buyTicket.js +54 -0
- package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts +1 -0
- package/dist/modules/lottery/commands/nextDraw.js +34 -0
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts +1 -0
- package/dist/modules/lottery/commands/viewTickets.js +23 -0
- package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
- package/dist/modules/lottery/index.d.ts +4 -0
- package/dist/modules/lottery/index.js +73 -0
- package/dist/modules/lottery/index.js.map +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js +34 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
- package/dist/modules/playerOnboarding/index.d.ts +4 -0
- package/dist/modules/playerOnboarding/index.js +51 -0
- package/dist/modules/playerOnboarding/index.js.map +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js +9 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
- package/dist/modules/serverMessages/index.d.ts +4 -0
- package/dist/modules/serverMessages/index.js +35 -0
- package/dist/modules/serverMessages/index.js.map +1 -0
- package/dist/modules/teleports/commands/deletetp.d.ts +1 -0
- package/dist/modules/teleports/commands/deletetp.js +20 -0
- package/dist/modules/teleports/commands/deletetp.js.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.js +54 -0
- package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/listwaypoints.d.ts +1 -0
- package/dist/modules/teleports/commands/listwaypoints.js +36 -0
- package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
- package/dist/modules/teleports/commands/setprivate.d.ts +1 -0
- package/dist/modules/teleports/commands/setprivate.js +31 -0
- package/dist/modules/teleports/commands/setprivate.js.map +1 -0
- package/dist/modules/teleports/commands/setpublic.d.ts +1 -0
- package/dist/modules/teleports/commands/setpublic.js +55 -0
- package/dist/modules/teleports/commands/setpublic.js.map +1 -0
- package/dist/modules/teleports/commands/settp.d.ts +1 -0
- package/dist/modules/teleports/commands/settp.js +42 -0
- package/dist/modules/teleports/commands/settp.js.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/setwaypoint.js +88 -0
- package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/teleport.d.ts +1 -0
- package/dist/modules/teleports/commands/teleport.js +74 -0
- package/dist/modules/teleports/commands/teleport.js.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js +50 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/tplist.d.ts +1 -0
- package/dist/modules/teleports/commands/tplist.js +45 -0
- package/dist/modules/teleports/commands/tplist.js.map +1 -0
- package/dist/modules/teleports/functions/utils.d.ts +2 -0
- package/dist/modules/teleports/functions/utils.js +18 -0
- package/dist/modules/teleports/functions/utils.js.map +1 -0
- package/dist/modules/teleports/index.d.ts +4 -0
- package/dist/modules/teleports/index.js +184 -0
- package/dist/modules/teleports/index.js.map +1 -0
- package/dist/modules/utils/commands/help.d.ts +1 -0
- package/dist/modules/utils/commands/help.js +29 -0
- package/dist/modules/utils/commands/help.js.map +1 -0
- package/dist/modules/utils/commands/ping.d.ts +1 -0
- package/dist/modules/utils/commands/ping.js +6 -0
- package/dist/modules/utils/commands/ping.js.map +1 -0
- package/dist/modules/utils/index.d.ts +4 -0
- package/dist/modules/utils/index.js +35 -0
- package/dist/modules/utils/index.js.map +1 -0
- package/dist/modules.json +478 -0
- package/package.json +26 -0
- package/scripts/buildBuiltinJson.ts +14 -0
- package/src/BuiltinModule.ts +125 -0
- package/src/__tests__/aliases.integration.test.ts +54 -0
- package/src/__tests__/builtinmodule.unit.test.ts +13 -0
- package/src/__tests__/commandArgs.integration.test.ts +285 -0
- package/src/__tests__/economyUtils.integration.test.ts +488 -0
- package/src/__tests__/geoblock.integration.test.ts +380 -0
- package/src/__tests__/gimme.integration.test.ts +97 -0
- package/src/__tests__/help.integration.test.ts +133 -0
- package/src/__tests__/lottery.integration.test.ts +332 -0
- package/src/__tests__/modulePermission.integration.test.ts +192 -0
- package/src/__tests__/onboarding.integration.test.ts +123 -0
- package/src/__tests__/ping.integration.test.ts +36 -0
- package/src/__tests__/roleExpiry.integration.test.ts +74 -0
- package/src/__tests__/serverMessages.integration.test.ts +104 -0
- package/src/__tests__/systemConfigCost.integration.test.ts +196 -0
- package/src/__tests__/teleports/listtp.integration.test.ts +115 -0
- package/src/__tests__/teleports/publicteleports.integration.test.ts +350 -0
- package/src/__tests__/teleports/teleport.integration.test.ts +109 -0
- package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
- package/src/__tests__/teleports/waypoints.integration.test.ts +613 -0
- package/src/dto/base.ts +13 -0
- package/src/dto/discordEvents.ts +69 -0
- package/src/dto/gameEvents.ts +154 -0
- package/src/dto/index.ts +25 -0
- package/src/dto/takaroEvents.ts +290 -0
- package/src/main.ts +36 -0
- package/src/modules/.eslintrc +5 -0
- package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
- package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
- package/src/modules/chatBridge/index.ts +59 -0
- package/src/modules/economyUtils/commands/balance.js +8 -0
- package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
- package/src/modules/economyUtils/commands/grantCurrency.js +38 -0
- package/src/modules/economyUtils/commands/revokeCurrency.js +38 -0
- package/src/modules/economyUtils/commands/topCurrency.js +29 -0
- package/src/modules/economyUtils/commands/transfer.js +73 -0
- package/src/modules/economyUtils/index.ts +125 -0
- package/src/modules/geoBlock/hooks/IPDetected.js +52 -0
- package/src/modules/geoBlock/index.ts +331 -0
- package/src/modules/gimme/commands/gimme.js +28 -0
- package/src/modules/gimme/index.ts +49 -0
- package/src/modules/highPingKicker/cronJobs/Ping check.js +66 -0
- package/src/modules/highPingKicker/index.ts +39 -0
- package/src/modules/lottery/commands/buyTicket.js +68 -0
- package/src/modules/lottery/commands/nextDraw.js +45 -0
- package/src/modules/lottery/commands/viewTickets.js +32 -0
- package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
- package/src/modules/lottery/index.ts +80 -0
- package/src/modules/playerOnboarding/commands/starterkit.js +47 -0
- package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
- package/src/modules/playerOnboarding/index.ts +58 -0
- package/src/modules/serverMessages/cronJobs/Automated message.js +12 -0
- package/src/modules/serverMessages/index.ts +40 -0
- package/src/modules/teleports/commands/deletetp.js +25 -0
- package/src/modules/teleports/commands/deletewaypoint.js +77 -0
- package/src/modules/teleports/commands/listwaypoints.js +55 -0
- package/src/modules/teleports/commands/setprivate.js +39 -0
- package/src/modules/teleports/commands/setpublic.js +71 -0
- package/src/modules/teleports/commands/settp.js +54 -0
- package/src/modules/teleports/commands/setwaypoint.js +112 -0
- package/src/modules/teleports/commands/teleport.js +93 -0
- package/src/modules/teleports/commands/teleportwaypoint.js +72 -0
- package/src/modules/teleports/commands/tplist.js +61 -0
- package/src/modules/teleports/functions/utils.js +20 -0
- package/src/modules/teleports/index.ts +193 -0
- package/src/modules/utils/commands/help.js +38 -0
- package/src/modules/utils/commands/ping.js +7 -0
- package/src/modules/utils/index.ts +40 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +3 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import { IntegrationTest, expect, integrationConfig } from '@takaro/test';
|
|
2
|
+
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
3
|
+
import { GameEvents } from '../../dto/index.js';
|
|
4
|
+
import { GameServerTypesOutputDTOTypeEnum, PlayerOutputDTO, RoleOutputDTO } from '@takaro/apiclient';
|
|
5
|
+
|
|
6
|
+
const group = 'Teleports - waypoints';
|
|
7
|
+
|
|
8
|
+
interface WaypointsSetup extends IModuleTestsSetupData {
|
|
9
|
+
playerRole: RoleOutputDTO;
|
|
10
|
+
manageWaypointsRole: RoleOutputDTO;
|
|
11
|
+
player: PlayerOutputDTO;
|
|
12
|
+
moderator: PlayerOutputDTO;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const waypointsSetup = async function (this: IntegrationTest<WaypointsSetup>): Promise<WaypointsSetup> {
|
|
16
|
+
const setupData = await modulesTestSetup.bind(this as unknown as IntegrationTest<IModuleTestsSetupData>)();
|
|
17
|
+
|
|
18
|
+
await this.client.gameserver.gameServerControllerInstallModule(setupData.gameserver.id, setupData.teleportsModule.id);
|
|
19
|
+
|
|
20
|
+
const playersRes = await this.client.player.playerControllerSearch();
|
|
21
|
+
|
|
22
|
+
await Promise.all(
|
|
23
|
+
playersRes.data.data.map(async (player) => {
|
|
24
|
+
await this.client.player.playerControllerRemoveRole(player.id, setupData.role.id);
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const manageWaypointsPermission = await this.client.permissionCodesToInputs(['TELEPORTS_MANAGE_WAYPOINTS']);
|
|
29
|
+
const manageWaypointsRole = (
|
|
30
|
+
await this.client.role.roleControllerCreate({
|
|
31
|
+
name: 'ManageWaypoints',
|
|
32
|
+
permissions: manageWaypointsPermission,
|
|
33
|
+
})
|
|
34
|
+
).data.data;
|
|
35
|
+
|
|
36
|
+
const playerRole = (await this.client.role.roleControllerSearch({ filters: { name: ['Player'] } })).data.data[0];
|
|
37
|
+
|
|
38
|
+
const player = setupData.players[0];
|
|
39
|
+
const moderator = setupData.players[1];
|
|
40
|
+
|
|
41
|
+
await this.client.player.playerControllerAssignRole(moderator.id, manageWaypointsRole.id);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...setupData,
|
|
45
|
+
manageWaypointsRole: manageWaypointsRole,
|
|
46
|
+
player,
|
|
47
|
+
moderator,
|
|
48
|
+
playerRole,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
async function setupSecondServer() {
|
|
53
|
+
const newGameServer = await this.client.gameserver.gameServerControllerCreate({
|
|
54
|
+
name: 'newServer',
|
|
55
|
+
connectionInfo: JSON.stringify({
|
|
56
|
+
host: integrationConfig.get('mockGameserver.host'),
|
|
57
|
+
name: 'newServer',
|
|
58
|
+
}),
|
|
59
|
+
type: GameServerTypesOutputDTOTypeEnum.Mock,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await this.client.gameserver.gameServerControllerInstallModule(
|
|
63
|
+
newGameServer.data.data.id,
|
|
64
|
+
this.setupData.teleportsModule.id
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const connectedEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.PLAYER_CONNECTED, 5);
|
|
68
|
+
|
|
69
|
+
await this.client.gameserver.gameServerControllerExecuteCommand(newGameServer.data.data.id, {
|
|
70
|
+
command: 'connectAll',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
await connectedEvents;
|
|
74
|
+
|
|
75
|
+
const newServerPlayers = (
|
|
76
|
+
await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
|
|
77
|
+
filters: { gameServerId: [newGameServer.data.data.id] },
|
|
78
|
+
})
|
|
79
|
+
).data.data;
|
|
80
|
+
const newServerModerator = newServerPlayers[0];
|
|
81
|
+
const newServerPlayer = newServerPlayers[1];
|
|
82
|
+
|
|
83
|
+
await this.client.player.playerControllerAssignRole(
|
|
84
|
+
newServerModerator.playerId,
|
|
85
|
+
this.setupData.manageWaypointsRole.id
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
newGameServer,
|
|
90
|
+
newServerModerator,
|
|
91
|
+
newServerPlayer,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const tests = [
|
|
96
|
+
new IntegrationTest<WaypointsSetup>({
|
|
97
|
+
group,
|
|
98
|
+
snapshot: false,
|
|
99
|
+
setup: waypointsSetup,
|
|
100
|
+
name: 'Can create a waypoint with /setwaypoint',
|
|
101
|
+
test: async function () {
|
|
102
|
+
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
103
|
+
|
|
104
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
105
|
+
msg: '/setwaypoint A',
|
|
106
|
+
playerId: this.setupData.moderator.id,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
expect((await events).length).to.be.eq(1);
|
|
110
|
+
expect((await events)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
new IntegrationTest<WaypointsSetup>({
|
|
114
|
+
group,
|
|
115
|
+
snapshot: false,
|
|
116
|
+
setup: waypointsSetup,
|
|
117
|
+
name: 'Errors when creating duplicate waypoints',
|
|
118
|
+
test: async function () {
|
|
119
|
+
const firstEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
120
|
+
|
|
121
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
122
|
+
msg: '/setwaypoint A',
|
|
123
|
+
playerId: this.setupData.moderator.id,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect((await firstEvents).length).to.be.eq(1);
|
|
127
|
+
expect((await firstEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
128
|
+
|
|
129
|
+
const secondEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
130
|
+
|
|
131
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
132
|
+
msg: '/setwaypoint A',
|
|
133
|
+
playerId: this.setupData.moderator.id,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect((await secondEvents).length).to.be.eq(1);
|
|
137
|
+
expect((await secondEvents)[0].data.msg).to.be.eq('Waypoint A already exists.');
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
new IntegrationTest<WaypointsSetup>({
|
|
141
|
+
group,
|
|
142
|
+
snapshot: false,
|
|
143
|
+
setup: waypointsSetup,
|
|
144
|
+
name: '/setwaypoint requires TELEPORTS_MANAGE_WAYPOINTS permission',
|
|
145
|
+
test: async function () {
|
|
146
|
+
const firstEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
147
|
+
|
|
148
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
149
|
+
msg: '/setwaypoint A',
|
|
150
|
+
playerId: this.setupData.player.id,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect((await firstEvents).length).to.be.eq(1);
|
|
154
|
+
expect((await firstEvents)[0].data.msg).to.be.eq('You do not have permission to manage waypoints.');
|
|
155
|
+
|
|
156
|
+
await this.client.player.playerControllerAssignRole(
|
|
157
|
+
this.setupData.player.id,
|
|
158
|
+
this.setupData.manageWaypointsRole.id
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const secondEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
162
|
+
|
|
163
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
164
|
+
msg: '/setwaypoint A',
|
|
165
|
+
playerId: this.setupData.moderator.id,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect((await secondEvents).length).to.be.eq(1);
|
|
169
|
+
expect((await secondEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
170
|
+
},
|
|
171
|
+
}),
|
|
172
|
+
new IntegrationTest<WaypointsSetup>({
|
|
173
|
+
group,
|
|
174
|
+
snapshot: false,
|
|
175
|
+
setup: waypointsSetup,
|
|
176
|
+
name: 'Can delete a waypoint with /deletewaypoint',
|
|
177
|
+
test: async function () {
|
|
178
|
+
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
179
|
+
|
|
180
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
181
|
+
msg: '/setwaypoint A',
|
|
182
|
+
playerId: this.setupData.moderator.id,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect((await events).length).to.be.eq(1);
|
|
186
|
+
expect((await events)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
187
|
+
|
|
188
|
+
const teleportEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
189
|
+
|
|
190
|
+
const useWaypointPermission = await this.client.permissionCodesToInputs([
|
|
191
|
+
`WAYPOINTS_USE_A_${this.setupData.gameserver.id}`,
|
|
192
|
+
]);
|
|
193
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
194
|
+
permissions: useWaypointPermission,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
198
|
+
msg: '/A',
|
|
199
|
+
playerId: this.setupData.player.id,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
expect((await teleportEvents).length).to.be.eq(1);
|
|
203
|
+
expect((await teleportEvents)[0].data.msg).to.be.eq('Teleported to waypoint A.');
|
|
204
|
+
|
|
205
|
+
const deleteEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
206
|
+
|
|
207
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
208
|
+
msg: '/deletewaypoint A',
|
|
209
|
+
playerId: this.setupData.moderator.id,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
expect((await deleteEvents).length).to.be.eq(1);
|
|
213
|
+
expect((await deleteEvents)[0].data.msg).to.be.eq('Waypoint A deleted.');
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
new IntegrationTest<WaypointsSetup>({
|
|
217
|
+
group,
|
|
218
|
+
snapshot: false,
|
|
219
|
+
setup: waypointsSetup,
|
|
220
|
+
name: 'Errors when trying to delete a waypoint that does not exist',
|
|
221
|
+
test: async function () {
|
|
222
|
+
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
223
|
+
|
|
224
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
225
|
+
msg: '/deletewaypoint A',
|
|
226
|
+
playerId: this.setupData.moderator.id,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
expect((await events).length).to.be.eq(1);
|
|
230
|
+
// eslint-disable-next-line quotes
|
|
231
|
+
expect((await events)[0].data.msg).to.be.eq("Waypoint A doesn't exist.");
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
new IntegrationTest<WaypointsSetup>({
|
|
235
|
+
group,
|
|
236
|
+
snapshot: false,
|
|
237
|
+
setup: waypointsSetup,
|
|
238
|
+
name: '/deletewaypoint requires TELEPORTS_MANAGE_WAYPOINTS permission',
|
|
239
|
+
test: async function () {
|
|
240
|
+
// First set waypoint
|
|
241
|
+
// Then try to delete as player -> error
|
|
242
|
+
// Then try to delete as moderator -> success
|
|
243
|
+
|
|
244
|
+
const firstEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
245
|
+
|
|
246
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
247
|
+
msg: '/setwaypoint A',
|
|
248
|
+
playerId: this.setupData.moderator.id,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
expect((await firstEvents).length).to.be.eq(1);
|
|
252
|
+
expect((await firstEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
253
|
+
|
|
254
|
+
const secondEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
255
|
+
|
|
256
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
257
|
+
msg: '/deletewaypoint A',
|
|
258
|
+
playerId: this.setupData.player.id,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
expect((await secondEvents).length).to.be.eq(1);
|
|
262
|
+
expect((await secondEvents)[0].data.msg).to.be.eq('You do not have permission to manage waypoints.');
|
|
263
|
+
|
|
264
|
+
const thirdEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
265
|
+
|
|
266
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
267
|
+
msg: '/deletewaypoint A',
|
|
268
|
+
playerId: this.setupData.moderator.id,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
expect((await thirdEvents).length).to.be.eq(1);
|
|
272
|
+
expect((await thirdEvents)[0].data.msg).to.be.eq('Waypoint A deleted.');
|
|
273
|
+
},
|
|
274
|
+
}),
|
|
275
|
+
new IntegrationTest<WaypointsSetup>({
|
|
276
|
+
group,
|
|
277
|
+
snapshot: false,
|
|
278
|
+
setup: waypointsSetup,
|
|
279
|
+
name: 'Can list waypoints (and shows only waypoints you have permission for)',
|
|
280
|
+
test: async function () {
|
|
281
|
+
// Create waypoint A & B
|
|
282
|
+
// Give players access to both
|
|
283
|
+
// /waypoints -> shows A & B
|
|
284
|
+
// Remove access to B
|
|
285
|
+
// /waypoints -> shows only A
|
|
286
|
+
|
|
287
|
+
const setEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
288
|
+
|
|
289
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
290
|
+
msg: '/setwaypoint A',
|
|
291
|
+
playerId: this.setupData.moderator.id,
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
295
|
+
msg: '/setwaypoint B',
|
|
296
|
+
playerId: this.setupData.moderator.id,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
expect((await setEvents).length).to.be.eq(2);
|
|
300
|
+
expect((await setEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
301
|
+
expect((await setEvents)[1].data.msg).to.be.eq('Waypoint B set.');
|
|
302
|
+
|
|
303
|
+
const useWaypointAPermission = await this.client.permissionCodesToInputs([
|
|
304
|
+
`WAYPOINTS_USE_A_${this.setupData.gameserver.id}`,
|
|
305
|
+
]);
|
|
306
|
+
const useWaypointBPermission = await this.client.permissionCodesToInputs([
|
|
307
|
+
`WAYPOINTS_USE_B_${this.setupData.gameserver.id}`,
|
|
308
|
+
]);
|
|
309
|
+
|
|
310
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
311
|
+
permissions: [...useWaypointAPermission, ...useWaypointBPermission],
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
const listEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
315
|
+
|
|
316
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
317
|
+
msg: '/waypoints',
|
|
318
|
+
playerId: this.setupData.player.id,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
expect((await listEvents).length).to.be.eq(1);
|
|
322
|
+
expect((await listEvents)[0].data.msg).to.be.eq('Available waypoints: A, B');
|
|
323
|
+
|
|
324
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
325
|
+
permissions: useWaypointAPermission,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const listEvents2 = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
329
|
+
|
|
330
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
331
|
+
msg: '/waypoints',
|
|
332
|
+
playerId: this.setupData.player.id,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
expect((await listEvents2).length).to.be.eq(1);
|
|
336
|
+
expect((await listEvents2)[0].data.msg).to.be.eq('Available waypoints: A');
|
|
337
|
+
},
|
|
338
|
+
}),
|
|
339
|
+
new IntegrationTest<WaypointsSetup>({
|
|
340
|
+
group,
|
|
341
|
+
snapshot: false,
|
|
342
|
+
setup: waypointsSetup,
|
|
343
|
+
name: 'Has a user friendly message when listing waypoints and there are none',
|
|
344
|
+
test: async function () {
|
|
345
|
+
const listEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
346
|
+
|
|
347
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
348
|
+
msg: '/waypoints',
|
|
349
|
+
playerId: this.setupData.player.id,
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
expect((await listEvents).length).to.be.eq(1);
|
|
353
|
+
expect((await listEvents)[0].data.msg).to.be.eq('There are no waypoints available.');
|
|
354
|
+
},
|
|
355
|
+
}),
|
|
356
|
+
new IntegrationTest<WaypointsSetup>({
|
|
357
|
+
group,
|
|
358
|
+
snapshot: false,
|
|
359
|
+
setup: waypointsSetup,
|
|
360
|
+
name: 'Players can teleport to a waypoint',
|
|
361
|
+
test: async function () {
|
|
362
|
+
const events = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
363
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
364
|
+
msg: '/setwaypoint trader',
|
|
365
|
+
playerId: this.setupData.moderator.id,
|
|
366
|
+
});
|
|
367
|
+
expect((await events).length).to.be.eq(1);
|
|
368
|
+
expect((await events)[0].data.msg).to.be.eq('Waypoint trader set.');
|
|
369
|
+
|
|
370
|
+
const useWaypointPermission = await this.client.permissionCodesToInputs([
|
|
371
|
+
`WAYPOINTS_USE_TRADER_${this.setupData.gameserver.id}`,
|
|
372
|
+
]);
|
|
373
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
374
|
+
permissions: useWaypointPermission,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
const teleportEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
378
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
379
|
+
msg: '/trader',
|
|
380
|
+
playerId: this.setupData.player.id,
|
|
381
|
+
});
|
|
382
|
+
expect((await teleportEvents).length).to.be.eq(1);
|
|
383
|
+
expect((await teleportEvents)[0].data.msg).to.be.eq('Teleported to waypoint trader.');
|
|
384
|
+
},
|
|
385
|
+
}),
|
|
386
|
+
new IntegrationTest<WaypointsSetup>({
|
|
387
|
+
group,
|
|
388
|
+
snapshot: false,
|
|
389
|
+
setup: waypointsSetup,
|
|
390
|
+
name: 'Can set multiple waypoints and teleport to them',
|
|
391
|
+
test: async function () {
|
|
392
|
+
const setEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
393
|
+
|
|
394
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
395
|
+
msg: '/setwaypoint A',
|
|
396
|
+
playerId: this.setupData.moderator.id,
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
400
|
+
msg: '/setwaypoint B',
|
|
401
|
+
playerId: this.setupData.moderator.id,
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
expect((await setEvents).length).to.be.eq(2);
|
|
405
|
+
expect((await setEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
406
|
+
expect((await setEvents)[1].data.msg).to.be.eq('Waypoint B set.');
|
|
407
|
+
|
|
408
|
+
const useWaypointPermission = await this.client.permissionCodesToInputs([
|
|
409
|
+
`WAYPOINTS_USE_A_${this.setupData.gameserver.id}`,
|
|
410
|
+
`WAYPOINTS_USE_B_${this.setupData.gameserver.id}`,
|
|
411
|
+
]);
|
|
412
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
413
|
+
permissions: useWaypointPermission,
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
const teleportAEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
417
|
+
|
|
418
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
419
|
+
msg: '/A',
|
|
420
|
+
playerId: this.setupData.player.id,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
expect((await teleportAEvents).length).to.be.eq(1);
|
|
424
|
+
expect((await teleportAEvents)[0].data.msg).to.be.eq('Teleported to waypoint A.');
|
|
425
|
+
|
|
426
|
+
const teleportBEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
427
|
+
|
|
428
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
429
|
+
msg: '/B',
|
|
430
|
+
playerId: this.setupData.player.id,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
expect((await teleportBEvents).length).to.be.eq(1);
|
|
434
|
+
expect((await teleportBEvents)[0].data.msg).to.be.eq('Teleported to waypoint B.');
|
|
435
|
+
},
|
|
436
|
+
}),
|
|
437
|
+
new IntegrationTest<WaypointsSetup>({
|
|
438
|
+
group,
|
|
439
|
+
snapshot: false,
|
|
440
|
+
setup: waypointsSetup,
|
|
441
|
+
name: 'Can control who can use which waypoints using permissions (Player can use waypoint A but not waypoint B)',
|
|
442
|
+
test: async function () {
|
|
443
|
+
// Create 2 waypoints A and B
|
|
444
|
+
// Give player permission to use A
|
|
445
|
+
// Player uses A -> success
|
|
446
|
+
// Player uses B -> error
|
|
447
|
+
|
|
448
|
+
const setEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
449
|
+
|
|
450
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
451
|
+
msg: '/setwaypoint A',
|
|
452
|
+
playerId: this.setupData.moderator.id,
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
456
|
+
msg: '/setwaypoint B',
|
|
457
|
+
playerId: this.setupData.moderator.id,
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
expect((await setEvents).length).to.be.eq(2);
|
|
461
|
+
expect((await setEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
462
|
+
expect((await setEvents)[1].data.msg).to.be.eq('Waypoint B set.');
|
|
463
|
+
|
|
464
|
+
const useWaypointPermission = await this.client.permissionCodesToInputs([
|
|
465
|
+
`WAYPOINTS_USE_A_${this.setupData.gameserver.id}`,
|
|
466
|
+
]);
|
|
467
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
468
|
+
permissions: useWaypointPermission,
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
const teleportAEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
472
|
+
|
|
473
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
474
|
+
msg: '/A',
|
|
475
|
+
playerId: this.setupData.player.id,
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
expect((await teleportAEvents).length).to.be.eq(1);
|
|
479
|
+
expect((await teleportAEvents)[0].data.msg).to.be.eq('Teleported to waypoint A.');
|
|
480
|
+
|
|
481
|
+
const teleportBEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
482
|
+
|
|
483
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
484
|
+
msg: '/B',
|
|
485
|
+
playerId: this.setupData.player.id,
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
expect((await teleportBEvents).length).to.be.eq(1);
|
|
489
|
+
expect((await teleportBEvents)[0].data.msg).to.be.eq('You are not allowed to use the waypoint B.');
|
|
490
|
+
},
|
|
491
|
+
}),
|
|
492
|
+
new IntegrationTest<WaypointsSetup>({
|
|
493
|
+
group,
|
|
494
|
+
snapshot: false,
|
|
495
|
+
setup: waypointsSetup,
|
|
496
|
+
name: 'Cannot use a waypoint from a different gameserver',
|
|
497
|
+
test: async function () {
|
|
498
|
+
// Add a new gameserver first
|
|
499
|
+
// Create a waypoint on the new gameserver
|
|
500
|
+
// Try to use the waypoint from the new gameserver -> success
|
|
501
|
+
// Try to use the waypoint from the original gameserver -> "waypoint does not exist"
|
|
502
|
+
const { newGameServer, newServerModerator, newServerPlayer } = await setupSecondServer.bind(this)();
|
|
503
|
+
|
|
504
|
+
// Make a waypoint on the new gameserver
|
|
505
|
+
const setEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
506
|
+
await this.client.command.commandControllerTrigger(newGameServer.data.data.id, {
|
|
507
|
+
msg: '/setwaypoint A',
|
|
508
|
+
playerId: newServerModerator.playerId,
|
|
509
|
+
});
|
|
510
|
+
expect((await setEvents).length).to.be.eq(1);
|
|
511
|
+
expect((await setEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
512
|
+
|
|
513
|
+
// Make a waypoint on the original gameserver
|
|
514
|
+
const setEvents2 = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
515
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
516
|
+
msg: '/setwaypoint notused',
|
|
517
|
+
playerId: this.setupData.moderator.id,
|
|
518
|
+
});
|
|
519
|
+
expect((await setEvents2).length).to.be.eq(1);
|
|
520
|
+
expect((await setEvents2)[0].data.msg).to.be.eq('Waypoint notused set.');
|
|
521
|
+
|
|
522
|
+
const useWaypointPermission = await this.client.permissionCodesToInputs([
|
|
523
|
+
`WAYPOINTS_USE_A_${newGameServer.data.data.id}`,
|
|
524
|
+
]);
|
|
525
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
526
|
+
permissions: useWaypointPermission,
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// Use the waypoint from the new gameserver -> success
|
|
530
|
+
const teleportEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
531
|
+
await this.client.command.commandControllerTrigger(newGameServer.data.data.id, {
|
|
532
|
+
msg: '/A',
|
|
533
|
+
playerId: newServerPlayer.playerId,
|
|
534
|
+
});
|
|
535
|
+
expect((await teleportEvents).length).to.be.eq(1);
|
|
536
|
+
expect((await teleportEvents)[0].data.msg).to.be.eq('Teleported to waypoint A.');
|
|
537
|
+
|
|
538
|
+
// Use the waypoint from the original gameserver -> "waypoint does not exist"
|
|
539
|
+
const teleportEvents2 = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
540
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
541
|
+
msg: '/A',
|
|
542
|
+
playerId: this.setupData.player.id,
|
|
543
|
+
});
|
|
544
|
+
expect((await teleportEvents2).length).to.be.eq(1);
|
|
545
|
+
expect((await teleportEvents2)[0].data.msg).to.be.eq('You are not allowed to use the waypoint A.');
|
|
546
|
+
},
|
|
547
|
+
}),
|
|
548
|
+
new IntegrationTest<WaypointsSetup>({
|
|
549
|
+
group,
|
|
550
|
+
snapshot: false,
|
|
551
|
+
setup: waypointsSetup,
|
|
552
|
+
name: 'Creating waypoint with same name on 2 different gameservers does not conflict',
|
|
553
|
+
test: async function () {
|
|
554
|
+
// Create new gameserver
|
|
555
|
+
// Create waypoint A on original gameserver
|
|
556
|
+
// Create waypoint A on new gameserver
|
|
557
|
+
// Allow player to use waypoint A on original gameserver but not new gameserver
|
|
558
|
+
// Player uses A on original gameserver -> success
|
|
559
|
+
// Player uses A on new gameserver -> error
|
|
560
|
+
|
|
561
|
+
const { newGameServer, newServerModerator, newServerPlayer } = await setupSecondServer.bind(this)();
|
|
562
|
+
|
|
563
|
+
// Make a waypoint on the original gameserver
|
|
564
|
+
const setEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
565
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
566
|
+
msg: '/setwaypoint A',
|
|
567
|
+
playerId: this.setupData.moderator.id,
|
|
568
|
+
});
|
|
569
|
+
expect((await setEvents)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
570
|
+
|
|
571
|
+
// Make a waypoint on the new gameserver
|
|
572
|
+
const setEvents2 = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
573
|
+
await this.client.command.commandControllerTrigger(newGameServer.data.data.id, {
|
|
574
|
+
msg: '/setwaypoint A',
|
|
575
|
+
playerId: newServerModerator.playerId,
|
|
576
|
+
});
|
|
577
|
+
expect((await setEvents2)[0].data.msg).to.be.eq('Waypoint A set.');
|
|
578
|
+
|
|
579
|
+
const useWaypointPermission = await this.client.permissionCodesToInputs([
|
|
580
|
+
`WAYPOINTS_USE_A_${this.setupData.gameserver.id}`,
|
|
581
|
+
]);
|
|
582
|
+
await this.client.role.roleControllerUpdate(this.setupData.playerRole.id, {
|
|
583
|
+
permissions: useWaypointPermission,
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
// Use the waypoint from the original gameserver -> success
|
|
587
|
+
const teleportEvents = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1, {
|
|
588
|
+
gameServerId: this.setupData.gameserver.id,
|
|
589
|
+
});
|
|
590
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
591
|
+
msg: '/A',
|
|
592
|
+
playerId: this.setupData.player.id,
|
|
593
|
+
});
|
|
594
|
+
expect((await teleportEvents)[0].data.msg).to.be.eq('Teleported to waypoint A.');
|
|
595
|
+
|
|
596
|
+
// Use the waypoint from the new gameserver -> error
|
|
597
|
+
const teleportEvents2 = this.setupData.eventAwaiter.waitForEvents(GameEvents.CHAT_MESSAGE, 1, {
|
|
598
|
+
gameServerId: newGameServer.data.data.id,
|
|
599
|
+
});
|
|
600
|
+
await this.client.command.commandControllerTrigger(newGameServer.data.data.id, {
|
|
601
|
+
msg: '/A',
|
|
602
|
+
playerId: newServerPlayer.playerId,
|
|
603
|
+
});
|
|
604
|
+
expect((await teleportEvents2)[0].data.msg).to.be.eq('You are not allowed to use the waypoint A.');
|
|
605
|
+
},
|
|
606
|
+
}),
|
|
607
|
+
];
|
|
608
|
+
|
|
609
|
+
describe(group, function () {
|
|
610
|
+
tests.forEach((test) => {
|
|
611
|
+
test.run();
|
|
612
|
+
});
|
|
613
|
+
});
|
package/src/dto/base.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TakaroDTO } from '@takaro/util';
|
|
2
|
+
import { IsISO8601, IsString } from 'class-validator';
|
|
3
|
+
import { EventTypes } from './index.js';
|
|
4
|
+
import { Exclude } from 'class-transformer';
|
|
5
|
+
|
|
6
|
+
export class BaseEvent<T> extends TakaroDTO<T> {
|
|
7
|
+
@IsISO8601()
|
|
8
|
+
timestamp: string = new Date().toISOString();
|
|
9
|
+
|
|
10
|
+
@IsString()
|
|
11
|
+
@Exclude({ toPlainOnly: true })
|
|
12
|
+
type: EventTypes;
|
|
13
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IsBoolean, IsEnum, IsString, ValidateNested } from 'class-validator';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
import { TakaroDTO } from '@takaro/util';
|
|
4
|
+
import { ValueOf } from 'type-fest';
|
|
5
|
+
import { BaseEvent } from './base.js';
|
|
6
|
+
|
|
7
|
+
export const DiscordEvents = {
|
|
8
|
+
DISCORD_MESSAGE: 'discord-message',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
export class BaseDiscordEvent<T> extends BaseEvent<T> {
|
|
12
|
+
@IsEnum(DiscordEvents)
|
|
13
|
+
declare type: ValueOf<typeof DiscordEvents>;
|
|
14
|
+
|
|
15
|
+
@IsString()
|
|
16
|
+
msg: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class EventDiscordUser extends TakaroDTO<EventDiscordUser> {
|
|
20
|
+
@IsString()
|
|
21
|
+
id: string;
|
|
22
|
+
|
|
23
|
+
@IsString()
|
|
24
|
+
username: string;
|
|
25
|
+
|
|
26
|
+
@IsString()
|
|
27
|
+
displayName: string;
|
|
28
|
+
|
|
29
|
+
@IsBoolean()
|
|
30
|
+
isBot: boolean;
|
|
31
|
+
|
|
32
|
+
@IsBoolean()
|
|
33
|
+
isTakaroBot: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class EventDiscordChannel extends TakaroDTO<EventDiscordChannel> {
|
|
37
|
+
@IsString()
|
|
38
|
+
id: string;
|
|
39
|
+
|
|
40
|
+
@IsString()
|
|
41
|
+
name: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class HookEventDiscordMessage extends BaseEvent<HookEventDiscordMessage> {
|
|
45
|
+
@IsString()
|
|
46
|
+
type = DiscordEvents.DISCORD_MESSAGE;
|
|
47
|
+
|
|
48
|
+
@IsString()
|
|
49
|
+
msg: string;
|
|
50
|
+
|
|
51
|
+
@ValidateNested()
|
|
52
|
+
@Type(() => EventDiscordUser)
|
|
53
|
+
author: EventDiscordUser;
|
|
54
|
+
|
|
55
|
+
@ValidateNested()
|
|
56
|
+
@Type(() => EventDiscordChannel)
|
|
57
|
+
channel: EventDiscordChannel;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isDiscordMessageEvent(a: unknown): a is HookEventDiscordMessage {
|
|
61
|
+
if (typeof a === 'object' && a !== null) {
|
|
62
|
+
return 'type' in a && a.type === DiscordEvents.DISCORD_MESSAGE;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const DiscordEventsMapping = {
|
|
68
|
+
[DiscordEvents.DISCORD_MESSAGE]: HookEventDiscordMessage,
|
|
69
|
+
} as const;
|