Skip to content

Commit cdbae83

Browse files
authored
Merge pull request #62 from x-team/develop
Merging Develop into Main
2 parents 7b747fc + 398ae11 commit cdbae83

28 files changed

+397
-96
lines changed
+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
import Joi from 'joi';
22

3-
export const addTowerRequestSchema = Joi.object({
3+
export const addTowerFloorRequestSchema = Joi.object({
44
number: Joi.number().required(),
55
}).required();
66

7-
export const addTowerResponseSchema = Joi.object({
7+
export const addTowerFloorResponseSchema = Joi.object({
88
id: Joi.number().required(),
99
_towerGameId: Joi.number().required(),
1010
isEveryoneVisible: Joi.boolean().required(),
1111
number: Joi.number().required(),
1212
}).required();
13+
14+
export const updateTowerRequestSchema = Joi.object({
15+
name: Joi.string().optional(),
16+
isOpen: Joi.boolean().optional(),
17+
coinPrize: Joi.number().optional(),
18+
lunaPrize: Joi.number().optional(),
19+
}).required();
20+
21+
export const updateTowerResponseSchema = Joi.object({
22+
name: Joi.string().required(),
23+
isOpen: Joi.boolean().required(),
24+
coinPrize: Joi.number().required(),
25+
lunaPrize: Joi.number().required(),
26+
}).required();

src/games/arena/repositories/arena/actions/admin/list-players.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function listIdlePlayers(userRequesting: User) {
5555
return getGameError(arenaCommandReply.noActiveRound());
5656
}
5757
const actions = round._actions || [];
58-
const idlePlayers = await getIdlePlayers(round._gameId, actions, transaction);
58+
const idlePlayers = await getIdlePlayers(round._arenaGame?._gameId!, actions, transaction);
5959
return getGameResponse(arenaCommandReply.adminIdlePlayers(idlePlayers));
6060
});
6161
}

src/games/arena/repositories/arena/actions/admin/make-all-visible.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function makeAllVisible(channelId: string, userRequesting: User) {
1818
return getGameError(arenaCommandReply.noActiveRound());
1919
}
2020
await round.makeEveryoneVisible(transaction);
21-
await setAllPlayerVisibility(round._gameId, true, transaction);
21+
await setAllPlayerVisibility(round._arenaGame?._gameId!, true, transaction);
2222
await publishArenaMessage(arenaCommandReply.channelAllVisible(), true);
2323
await notifyPlayersWhoWantedToHide(round.id, channelId);
2424
await removeActionFromRound(round.id, ARENA_ACTIONS.HIDE, transaction);

src/games/arena/repositories/arena/actions/admin/revive-boss.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function reviveBoss(commandText: string, userRequesting: User) {
3232
}
3333

3434
const targetBossPlayer = await findPlayerByUser(
35-
round._gameId,
35+
round._arenaGame?._gameId!,
3636
targetUser.id,
3737
false,
3838
transaction

src/games/arena/repositories/arena/actions/admin/start-round.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export async function startRoundCommand(userRequesting: User) {
4545
// 2. Movement: Players Location
4646
await arenaGameEngine.processChangeLocation(round._actions ?? [], transaction);
4747

48-
const playersAlive = await findLivingPlayersByGame(round._gameId, false, transaction);
48+
const playersAlive = await findLivingPlayersByGame(
49+
round._arenaGame?._gameId!,
50+
false,
51+
transaction
52+
);
4953
const amountOfPlayersAlive = playersAlive.length;
5054

5155
await publishArenaMessage(arenaCommandReply.channelTotalPlayersAlive(amountOfPlayersAlive));
@@ -57,12 +61,12 @@ export async function startRoundCommand(userRequesting: User) {
5761

5862
const activeZonesForCurrentRound = await findActiveArenaZones(transaction);
5963

60-
if (round._game?._arena?.hasZoneDeactivation && activeZonesForCurrentRound.length > ONE) {
64+
if (round._arenaGame?.hasZoneDeactivation && activeZonesForCurrentRound.length > ONE) {
6165
if ((roundsCompleted + ONE) % THREE === ZERO) {
6266
const zonesToDeactivate = await findRingSystemZonesToDeactivate(
6367
{
64-
ringSystemAlgorithm: round._game?._arena?.ringSystemAlgorithm,
65-
currentRingDeactivation: round._game?._arena?.currentRingDeactivation,
68+
ringSystemAlgorithm: round._arenaGame?.ringSystemAlgorithm,
69+
currentRingDeactivation: round._arenaGame?.currentRingDeactivation,
6670
},
6771
transaction
6872
);
@@ -71,7 +75,7 @@ export async function startRoundCommand(userRequesting: User) {
7175

7276
if (roundsCompleted % THREE === ZERO) {
7377
await publishArenaMessage(arenaCommandReply.channelRunningRingSystem());
74-
await ringDeactivationSystem(round._game._arena, transaction);
78+
await ringDeactivationSystem(round._arenaGame, transaction);
7579
}
7680
}
7781

src/games/arena/repositories/arena/actions/admin/weapons.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ export async function giveEveryoneWeapon(userRequesting: User, selectedWeapon: n
4848
if (!round) {
4949
return getGameError(arenaCommandReply.noActiveRound());
5050
}
51-
const livingPlayers = await findLivingPlayersByGame(round._gameId, true, transaction);
51+
const livingPlayers = await findLivingPlayersByGame(
52+
round._arenaGame?._gameId!,
53+
true,
54+
transaction
55+
);
5256
const weaponToGive = await findWeaponById(selectedWeapon, transaction);
5357
if (!weaponToGive) {
5458
return getGameError(arenaCommandReply.weaponNotFound());
@@ -69,7 +73,7 @@ export async function startNarrowWeaponsQuestion(userRequesting: User) {
6973
if (!round) {
7074
return getGameError(arenaCommandReply.noActiveRound());
7175
}
72-
const game = round._game;
76+
const game = round._arenaGame?._game;
7377
if (!game) {
7478
return getGameError(arenaCommandReply.noActiveGame());
7579
}

src/games/arena/repositories/arena/actions/player/actions-menu.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function actionsMenu(userRequesting: User) {
2323

2424
const playerPerformance = await findSinglePlayerPerformance(
2525
player.id,
26-
round._gameId,
26+
round._arenaGame?._gameId!,
2727
transaction
2828
);
2929
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -47,7 +47,7 @@ export async function status(userRequesting: User) {
4747

4848
const playerPerformance = await findSinglePlayerPerformance(
4949
player.id,
50-
round._gameId,
50+
round._arenaGame?._gameId!,
5151
transaction
5252
);
5353
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);

src/games/arena/repositories/arena/actions/player/change-location.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function changeLocation(userRequesting: User, arenaZoneId: number)
3030
const roundAction = await findPlayerRoundAction(player.id, round.id, transaction);
3131
const playerPerformance = await findSinglePlayerPerformance(
3232
player.id,
33-
round._gameId,
33+
round._arenaGame?._gameId!,
3434
transaction
3535
);
3636
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -85,7 +85,7 @@ export async function bossChangeLocation(userRequesting: User) {
8585

8686
const playerPerformance = await findSinglePlayerPerformance(
8787
player.id,
88-
round._gameId,
88+
round._arenaGame?._gameId!,
8989
transaction
9090
);
9191
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);

src/games/arena/repositories/arena/actions/player/cheer.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function cheer(userRequesting: User) {
3434
return getGameResponse(actionBlockkit);
3535
}
3636

37-
const allPlayers = await findPlayersByGame(round._gameId, false, transaction);
37+
const allPlayers = await findPlayersByGame(round._arenaGame?._gameId!, false, transaction);
3838
// You can't cheer yourself or dead players
3939
const filteredPlayers = allPlayers.filter((p) => p.id !== player.id && p.isAlive());
4040
const slackBlocks = generateArenaTargetPickerBlock(filteredPlayers, 'cheer');
@@ -57,12 +57,12 @@ export async function completeCheer(userRequesting: User, selectedTargetId: numb
5757

5858
const playerPerformance = await findSinglePlayerPerformance(
5959
player.id,
60-
round._gameId,
60+
round._arenaGame?._gameId!,
6161
transaction
6262
);
6363
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
6464
const targetPlayer = await findPlayerByUser(
65-
round._gameId,
65+
round._arenaGame?._gameId!,
6666
selectedTargetId,
6767
false,
6868
transaction
@@ -111,13 +111,13 @@ export async function repeatLastCheer(userRequesting: User) {
111111

112112
const playerPerformance = await findSinglePlayerPerformance(
113113
player.id,
114-
round._gameId,
114+
round._arenaGame?._gameId!,
115115
transaction
116116
);
117117
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
118118
const [lastCheerAction] = await findPlayerActionsByGame(
119119
player.id,
120-
round._gameId,
120+
round._arenaGame?._gameId!,
121121
ARENA_ACTIONS.CHEER,
122122
transaction
123123
);

src/games/arena/repositories/arena/actions/player/hide.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function hide(userRequesting: User) {
2525

2626
const playerPerformance = await findSinglePlayerPerformance(
2727
player.id,
28-
round._gameId,
28+
round._arenaGame?._gameId!,
2929
transaction
3030
);
3131
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);

src/games/arena/repositories/arena/actions/player/hunt.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function hunt(userRequesting: User) {
3737

3838
const playerPerformance = await findSinglePlayerPerformance(
3939
player.id,
40-
round._gameId,
40+
round._arenaGame?._gameId!,
4141
transaction
4242
);
4343
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -48,7 +48,7 @@ export async function hunt(userRequesting: User) {
4848
const targetGroup = generateTargetGroup(
4949
player,
5050
zone._players ?? [],
51-
!!round._game?._arena?.teamBased
51+
!!round._arenaGame?.teamBased
5252
);
5353

5454
if (targetGroup.length === 0) {
@@ -190,7 +190,7 @@ export async function chooseWeapon(userRequesting: User, selectedWeapon: number,
190190

191191
const playerPerformance = await findSinglePlayerPerformance(
192192
player.id,
193-
round._gameId,
193+
round._arenaGame?._gameId!,
194194
transaction
195195
);
196196
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -203,7 +203,7 @@ export async function chooseWeapon(userRequesting: User, selectedWeapon: number,
203203
const targetGroup = generateTargetGroup(
204204
player,
205205
zone._players ?? [],
206-
!!round._game?._arena?.teamBased
206+
!!round._arenaGame?.teamBased
207207
);
208208

209209
const visiblePlayers = weapon?.hasTrait(TRAIT.DETECT)
@@ -259,15 +259,15 @@ export async function chooseTarget(userRequesting: User, selectedTargetId: numbe
259259
}
260260

261261
const targetPlayer = await findPlayerByUser(
262-
round._gameId,
262+
round._arenaGame?._gameId!,
263263
selectedTargetId,
264264
false,
265265
transaction
266266
);
267267

268268
const playerPerformance = await findSinglePlayerPerformance(
269269
player.id,
270-
round._gameId,
270+
round._arenaGame?._gameId!,
271271
transaction
272272
);
273273
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);

src/games/arena/repositories/arena/actions/player/revive.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function reviveSelf(userRequesting: User) {
3333

3434
const playerPerformance = await findSinglePlayerPerformance(
3535
player.id,
36-
round._gameId,
36+
round._arenaGame?._gameId!,
3737
transaction
3838
);
3939
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -90,15 +90,15 @@ export async function completeRevive(userRequesting: User, selectedTargetId: num
9090
}
9191

9292
const targetPlayer = await findPlayerByUser(
93-
round._gameId,
93+
round._arenaGame?._gameId!,
9494
selectedTargetId,
9595
false,
9696
transaction
9797
);
9898

9999
const playerPerformance = await findSinglePlayerPerformance(
100100
player.id,
101-
round._gameId,
101+
round._arenaGame?._gameId!,
102102
transaction
103103
);
104104
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -184,7 +184,7 @@ export async function reviveOther(userRequesting: User) {
184184

185185
const playerPerformance = await findSinglePlayerPerformance(
186186
player.id,
187-
round._gameId,
187+
round._arenaGame?._gameId!,
188188
transaction
189189
);
190190
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);
@@ -198,7 +198,7 @@ export async function reviveOther(userRequesting: User) {
198198
return getGameResponse(actionBlockkit);
199199
}
200200

201-
const allPlayers = await findPlayersByGame(round._gameId, false, transaction);
201+
const allPlayers = await findPlayersByGame(round._arenaGame?._gameId!, false, transaction);
202202
const playersToDropdown = allPlayers.filter(
203203
(p) =>
204204
p.id !== player.id &&

src/games/arena/repositories/arena/actions/player/search.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function searchForHealth(userRequesting: User) {
6868
if (playerHasHealthkit) {
6969
const playerPerformance = await findSinglePlayerPerformance(
7070
player.id,
71-
round._gameId,
71+
round._arenaGame?._gameId!,
7272
transaction
7373
);
7474
const hud = arenaCommandReply.playerHUD(player, zone, playerPerformance);

src/games/arena/repositories/arena/engine/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export class ArenaEngine {
4242
}
4343

4444
async assignZoneActionToIdlePlayers(round: ArenaRound, transaction: Transaction) {
45-
const idlePlayers = await getIdlePlayers(round._gameId, round._actions || [], transaction);
45+
const idlePlayers = await getIdlePlayers(
46+
round._arenaGame?._gameId!,
47+
round._actions || [],
48+
transaction
49+
);
4650
await Promise.all(
4751
idlePlayers.map(async (player) => {
4852
const zone = await findArenaZoneById(player._arenaZoneId!, transaction);
@@ -71,7 +75,7 @@ export class ArenaEngine {
7175
}
7276
if (!zone.isActive && zone.name !== 'Streaming Zone') {
7377
await this.processRingSystemPenalty(
74-
round._game?._arena?.inactiveZonePenaltyPower ?? DEFAULT_INACTIVE_ZONE_PENALTY_POWER,
78+
round._arenaGame?.inactiveZonePenaltyPower ?? DEFAULT_INACTIVE_ZONE_PENALTY_POWER,
7579
actions,
7680
transaction
7781
);

src/games/arena/repositories/arena/engine/processCheer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function processCheers(
1919
const player = action._player!;
2020
await setPlayerPerformanceAction(
2121
player.id,
22-
round._gameId,
22+
round._arenaGame?._gameId!,
2323
{ field: ARENA_PLAYER_PERFORMANCE.CHEERS_GIVEN, value: ONE },
2424
transaction
2525
);
@@ -37,7 +37,7 @@ export async function processCheers(
3737
);
3838
const playerPerformance = await setPlayerPerformanceAction(
3939
targetPlayer?.id,
40-
round._gameId,
40+
round._arenaGame?._gameId!,
4141
{ field: ARENA_PLAYER_PERFORMANCE.CHEERS_RECEIVED, value: ONE },
4242
transaction
4343
);

src/games/arena/repositories/arena/engine/processHealOrRevive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function processHealOrRevive(
7777
}
7878
await setPlayerPerformanceAction(
7979
targetPlayerId!,
80-
round._gameId,
80+
round._arenaGame?._gameId!,
8181
{
8282
field: ARENA_PLAYER_PERFORMANCE.HEALED,
8383
value: healthKit?._healthkit?.healingPower ?? ZERO,

0 commit comments

Comments
 (0)