From 1d4b6b995cc5ed23d2c217825f5f0aa9dfe4848f Mon Sep 17 00:00:00 2001 From: Shiroi Kitsu <108461408+shiroikitsu8@users.noreply.github.com> Date: Tue, 21 Feb 2023 11:23:39 +0700 Subject: [PATCH] add optional screenshot, and delete car feature --- .gitignore | 3 +- config.example.json | 3 +- src/config.ts | 8 +++- src/modules/cars.ts | 83 ++++++++++++++++++++++++----------- src/modules/game.ts | 14 +++--- src/modules/game/functions.ts | 40 +++++++++++++++++ src/modules/users.ts | 3 ++ 7 files changed, 118 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index acf29b7..3639a88 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ key.pem config.json package-lock.json ecosystem.config.js -static/* \ No newline at end of file +static/* +screenshot/* \ No newline at end of file diff --git a/config.example.json b/config.example.json index 386d268..025e00f 100644 --- a/config.example.json +++ b/config.example.json @@ -12,6 +12,7 @@ "scratchEnabled": 1, "scratchType": 1, "giveMeterReward": 0, - "newCardsBanned": 0 + "newCardsBanned": 0, + "enableScreenshot": 0 } } \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index d8ed0e4..d3ac8c1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -47,12 +47,16 @@ export interface GameOptions { grantFullTuneTicketToNewUsers: number; // Give meter reward every n*100 play - giveMeterReward: number; //1 is on, 0 is off + giveMeterReward: number; // 1 is on, 0 is off // if the new card is not in the User databese // set this option to 1 will not create a new card // and prevent new card registration - newCardsBanned: number;//1 is on, 0 is off + newCardsBanned: number; // 1 is on, 0 is off + + // revision check + // set this option to 1 to enable screenshot feature + enableScreenshot: number; // 1 is on, 0 is off } export class Config { diff --git a/src/modules/cars.ts b/src/modules/cars.ts index d164244..50c2e83 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -1,4 +1,5 @@ import { Application } from "express"; +import { Config } from "../config"; import { Module } from "module"; import { prisma } from ".."; @@ -28,6 +29,19 @@ export default class CarModule extends Module { // Get Challenger Data let opponentsTarget = await carFunctions.getOpponentsTarget(body.carId, registeredTarget.registeredargetAvailable); + // Set Screenshot Count + let screenshotCount = 0; + + // Check if screenshot feature enabled or not + let enableScreenshot = Config.getConfig().gameOptions.enableScreenshot || 0; + + // Screenshot feature enabled + if(enableScreenshot === 1) + { + // Set the screnshot chance count + screenshotCount = 99; + } + // Response data let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, @@ -43,7 +57,7 @@ export default class CarModule extends Module { rgPreviousVersionPlayCount: 0, stCompleted_100Episodes: car!.stCompleted100Episodes, auraMotifAutoChange: false, - screenshotCount: 0, + screenshotCount: screenshotCount, transferred: false, // Stamp or Challenger @@ -136,33 +150,52 @@ export default class CarModule extends Module { // Get the request body for the update car request let body = wm.wm.protobuf.UpdateCarRequest.decode(req.body); - // Update the car - await carFunctions.updateCar(body); - - // Update the car setting - await carFunctions.updateCarSetting(body); - - // Update the car window Sticker - await carFunctions.updateCarWindowSticker(body); - - // Update the car Custom Wing - await carFunctions.updateCarCustomWing(body); - - // Get car item (custom color or discarded card) - if(body.earnedItems.length !== 0) + // Not deleting car + if(body.toBeDeleted === false || body.toBeDeleted === undefined || body.toBeDeleted === null) { - console.log('Car Item reward available, continuing ...'); - for(let i=0; i