1
0
mirror of synced 2025-02-20 20:41:19 +01:00

Add the option to grant a certain amount of FTs to new users

This commit is contained in:
Rin 2022-07-17 10:41:26 +01:00
parent cc37ad102f
commit 6fb44daa1f
3 changed files with 26 additions and 2 deletions

View File

@ -2,5 +2,8 @@
"shopName": "Bayshore",
"shopNickname": "BSH",
"regionName": "Bayshore",
"serverIp": "127.0.0.1"
"serverIp": "127.0.0.1",
"gameOptions": {
"grantFullTuneTicketToNewUsers": 0
}
}

View File

@ -5,6 +5,12 @@ export interface ConfigFile {
shopNickname: string;
regionName: string;
serverIp?: string;
gameOptions: GameOptions;
}
export interface GameOptions {
// Amount of full-tunes to grant to newly registered cards
grantFullTuneTicketToNewUsers: number;
}
export class Config {

View File

@ -4,6 +4,7 @@ import * as wm from "../wmmt/wm.proto";
import * as svc from "../wmmt/service.proto";
import { prisma } from "..";
import { User } from "@prisma/client";
import { Config } from "../config";
export default class GameModule extends Module {
register(app: Application): void {
@ -212,6 +213,20 @@ export default class GameModule extends Module {
if (!user) {
msg.error = wm.wm.protobuf.ErrorCode.ERR_REQUEST;
}
let ftTicketGrant = Config.getConfig().gameOptions.grantFullTuneTicketToNewUsers;
if (ftTicketGrant > 0) {
console.log(`Granting Full-Tune Ticket x${ftTicketGrant} to new user...`);
for (let i=0; i<ftTicketGrant; i++) {
await prisma.userItem.create({
data: {
userId: user.id,
category: wm.wm.protobuf.ItemCategory.CAT_CAR_TICKET_FREE,
itemId: 5
}
});
}
console.log('Done!');
}
let resp = wm.wm.protobuf.LoadUserResponse.encode(msg);
let end = resp.finish();
let r = res
@ -404,7 +419,7 @@ export default class GameModule extends Module {
.header('Content-Length', end.length.toString())
.status(200);
r.send(Buffer.from(end));
})
});
app.post('/method/update_car', async (req, res) => {
let body = wm.wm.protobuf.UpdateCarRequest.decode(req.body);