From aa9f85df5b5d38629dd26d83a565b4170d00ef4d Mon Sep 17 00:00:00 2001 From: ghkkk090 <108461408+ghkkk090@users.noreply.github.com> Date: Sat, 23 Jul 2022 21:49:23 +0700 Subject: [PATCH] add toggleable feature to give meter every n*100 plays --- config.example.json | 3 +- src/config.ts | 3 ++ src/modules/game.ts | 110 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 113 insertions(+), 3 deletions(-) diff --git a/config.example.json b/config.example.json index de3bae4..4375050 100644 --- a/config.example.json +++ b/config.example.json @@ -7,6 +7,7 @@ "grantFullTuneTicketToNewUsers": 3, "giftCarsFullyTuned": 0, "scratchEnabled": 1, - "scratchType": 1 + "scratchType": 1, + "giveMeterReward": 0 } } \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 6e9d777..a8d5807 100644 --- a/src/config.ts +++ b/src/config.ts @@ -42,6 +42,9 @@ export interface GameOptions { // Amount of full-tunes to grant to newly registered cards grantFullTuneTicketToNewUsers: number; + + // Give meter reward every n*100 play + giveMeterReward: number; //1 is on, 0 is off } export class Config { diff --git a/src/modules/game.ts b/src/modules/game.ts index 0ceb0df..1fbe396 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -256,6 +256,7 @@ export default class GameModule extends Module { } saveEx.rgWinCount = winCounter; saveEx.rgScore = winCounter; + saveEx.rgTrophy = winCounter; let c = await prisma.car.update({ where: { @@ -312,8 +313,7 @@ export default class GameModule extends Module { title: body.car!.title!, tunePower: body.car!.tunePower!, tuneHandling: body.car!.tuneHandling!, - windowSticker: body.car!.windowSticker!, - earnedCustomColor: body.earnedCustomColor! + windowSticker: body.car!.windowSticker! } }) @@ -327,6 +327,111 @@ export default class GameModule extends Module { } }); + // Every n*100 play give reward + let giveMeterReward = Config.getConfig().gameOptions.giveMeterReward; + if(giveMeterReward === 1 && body.playCount % 100 === 0){ + let carItemCount = await prisma.carItem.findMany({ + where: { + carId: body.carId, + category: 15, + itemId: { + lte: 22, + gte: 1, + }, + }, + }) + let sqlVal = 0; + for(let i=0; i