diff --git a/config.example.json b/config.example.json index 3ea5d1e..64db421 100644 --- a/config.example.json +++ b/config.example.json @@ -1,6 +1,9 @@ { + "placeId": "JPN0123", "shopName": "Bayshore", "shopNickname": "Bayshore", + "regionId": "1", + "country": "JPN", "regionName": "JPN0123", "serverIp": "127.0.0.1", "gameOptions": { diff --git a/prisma/migrations/20220824075745_ghost_stamp/migration.sql b/prisma/migrations/20220824075745_ghost_stamp/migration.sql new file mode 100644 index 0000000..0c9cf68 --- /dev/null +++ b/prisma/migrations/20220824075745_ghost_stamp/migration.sql @@ -0,0 +1,35 @@ +-- AlterTable +ALTER TABLE "Car" ADD COLUMN "stampSheet" INTEGER[], +ADD COLUMN "stampSheetCount" INTEGER NOT NULL DEFAULT 0, +ADD COLUMN "vsStarCountMax" INTEGER NOT NULL DEFAULT 0, +ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- CreateTable +CREATE TABLE "CarChallenger" ( + "id" SERIAL NOT NULL, + "carId" INTEGER NOT NULL, + "challengerCarId" INTEGER NOT NULL, + "stamp" INTEGER NOT NULL, + "result" INTEGER NOT NULL, + "area" INTEGER NOT NULL, + + CONSTRAINT "CarChallenger_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "CarStampTarget" ( + "id" SERIAL NOT NULL, + "carId" INTEGER NOT NULL, + "stampTargetCarId" INTEGER NOT NULL, + "returnCount" INTEGER NOT NULL, + "locked" BOOLEAN NOT NULL, + "recommended" BOOLEAN NOT NULL, + + CONSTRAINT "CarStampTarget_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "CarChallenger" ADD CONSTRAINT "CarChallenger_challengerCarId_fkey" FOREIGN KEY ("challengerCarId") REFERENCES "Car"("carId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CarStampTarget" ADD CONSTRAINT "CarStampTarget_stampTargetCarId_fkey" FOREIGN KEY ("stampTargetCarId") REFERENCES "Car"("carId") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20220824080810_volume_default_value/migration.sql b/prisma/migrations/20220824080810_volume_default_value/migration.sql new file mode 100644 index 0000000..76b80df --- /dev/null +++ b/prisma/migrations/20220824080810_volume_default_value/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- AlterTable +ALTER TABLE "CarSettings" ALTER COLUMN "volume" SET DEFAULT 2; diff --git a/prisma/migrations/20220824085616_place_list/migration.sql b/prisma/migrations/20220824085616_place_list/migration.sql new file mode 100644 index 0000000..004c43c --- /dev/null +++ b/prisma/migrations/20220824085616_place_list/migration.sql @@ -0,0 +1,17 @@ +-- AlterTable +ALTER TABLE "Car" ADD COLUMN "lastPlayedPlaceId" INTEGER, +ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- CreateTable +CREATE TABLE "PlaceList" ( + "id" SERIAL NOT NULL, + "placeId" TEXT NOT NULL, + "regionId" INTEGER NOT NULL, + "locked" BOOLEAN NOT NULL, + "recommended" BOOLEAN NOT NULL, + + CONSTRAINT "PlaceList_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Car" ADD CONSTRAINT "Car_lastPlayedPlaceId_fkey" FOREIGN KEY ("lastPlayedPlaceId") REFERENCES "PlaceList"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/migrations/20220824090041_place_list/migration.sql b/prisma/migrations/20220824090041_place_list/migration.sql new file mode 100644 index 0000000..39add9d --- /dev/null +++ b/prisma/migrations/20220824090041_place_list/migration.sql @@ -0,0 +1,17 @@ +/* + Warnings: + + - You are about to drop the column `locked` on the `PlaceList` table. All the data in the column will be lost. + - You are about to drop the column `recommended` on the `PlaceList` table. All the data in the column will be lost. + - Added the required column `country` to the `PlaceList` table without a default value. This is not possible if the table is not empty. + - Added the required column `shopName` to the `PlaceList` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- AlterTable +ALTER TABLE "PlaceList" DROP COLUMN "locked", +DROP COLUMN "recommended", +ADD COLUMN "country" TEXT NOT NULL, +ADD COLUMN "shopName" TEXT NOT NULL; diff --git a/prisma/migrations/20220825040457_challenger_history/migration.sql b/prisma/migrations/20220825040457_challenger_history/migration.sql new file mode 100644 index 0000000..65d5ce6 --- /dev/null +++ b/prisma/migrations/20220825040457_challenger_history/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- AlterTable +ALTER TABLE "CarChallenger" ADD COLUMN "lastPlayedAt" INTEGER NOT NULL DEFAULT 0; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 992586e..b14ead5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -88,8 +88,6 @@ model Car { rivalMarker Int @default(0) lastPlayedAt Int @default(0) aura Int @default(0) - auraMotif Int @default(0) - ghostLevel Int @default(1) // This is more data about the car tuningPoints Int @default(0) @@ -98,15 +96,20 @@ model Car { earnedCustomColor Boolean @default(false) carSettingsDbId Int @unique settings CarSettings @relation(fields: [carSettingsDbId], references: [dbId]) + + auraMotif Int @default(0) vsPlayCount Int @default(0) vsBurstCount Int @default(0) vsStarCount Int @default(0) + vsStarCountMax Int @default(0) vsCoolOrWild Int @default(0) vsSmoothOrRough Int @default(0) vsTripleStarMedals Int @default(0) vsDoubleStarMedals Int @default(0) vsSingleStarMedals Int @default(0) vsPlainMedals Int @default(0) + + ghostLevel Int @default(1) rgPlayCount Int @default(0) rgWinCount Int @default(0) rgTrophy Int @default(0) @@ -114,8 +117,12 @@ model Car { rgStamp Int @default(0) rgAcquireAllCrowns Boolean @default(false) rgRegionMapScore Int[] + stampSheetCount Int @default(0) + stampSheet Int[] + dressupLevel Int @default(0) dressupPoint Int @default(0) + stPlayCount Int @default(0) stClearBits Int @default(0) stClearDivCount Int @default(0) @@ -125,24 +132,27 @@ model Car { stConsecutiveWinsMax Int @default(0) stCompleted100Episodes Boolean @default(false) - items CarItem[] - carGTWingDbId Int @unique - gtWing CarGTWing @relation(fields: [carGTWingDbId], references: [dbId]) - carStateDbId Int @unique - state CarState @relation(fields: [carStateDbId], references: [dbId]) - TimeAttackRecord TimeAttackRecord[] - - CarCrown CarCrown[] - GhostTrail GhostTrail[] - GhostBattleRecord GhostBattleRecord[] - CarPathandTuning CarPathandTuning[] + lastPlayedPlaceId Int? + lastPlayedPlace PlaceList? @relation(fields: [lastPlayedPlaceId], references: [id]) + items CarItem[] + carGTWingDbId Int @unique + gtWing CarGTWing @relation(fields: [carGTWingDbId], references: [dbId]) + carStateDbId Int @unique + state CarState @relation(fields: [carStateDbId], references: [dbId]) + TimeAttackRecord TimeAttackRecord[] + CarCrown CarCrown[] + GhostTrail GhostTrail[] + GhostBattleRecord GhostBattleRecord[] + CarPathandTuning CarPathandTuning[] OCMGhostBattleRecord OCMGhostBattleRecord[] OCMTally OCMTally[] OCMTop1Ghost OCMTop1Ghost[] OCMGhostTrail OCMGhostTrail[] OCMPlayRecord OCMPlayRecord[] GhostRegisteredFromTerminal GhostRegisteredFromTerminal[] + CarStampTarget CarStampTarget[] + CarChallenger CarChallenger[] } model CarGTWing { @@ -175,7 +185,7 @@ model CarSettings { retire Boolean @default(false) meter Int @default(0) navigationMap Boolean @default(true) - volume Int @default(1) + volume Int @default(2) bgm Int @default(0) nameplate Int @default(0) nameplateColor Int @default(0) @@ -394,4 +404,36 @@ model GhostRegisteredFromTerminal { carId Int competitionId Int? opponentCarId Int +} + +model CarChallenger { + id Int @id @default(autoincrement()) + challengerCar Car @relation(fields: [challengerCarId], references: [carId]) + + carId Int + challengerCarId Int + stamp Int + result Int + area Int + lastPlayedAt Int @default(0) +} + +model CarStampTarget { + id Int @id @default(autoincrement()) + stampTargetCar Car @relation(fields: [stampTargetCarId], references: [carId]) + carId Int + stampTargetCarId Int + returnCount Int + locked Boolean + recommended Boolean +} + +model PlaceList { + id Int @id @default(autoincrement()) + car Car[] + + placeId String + regionId Int + shopName String + country String } \ No newline at end of file diff --git a/src/allnet.ts b/src/allnet.ts index 425ed35..9e51e7b 100644 --- a/src/allnet.ts +++ b/src/allnet.ts @@ -72,6 +72,9 @@ export default class AllnetModule extends Module { let shopName = Config.getConfig().shopName; let shopNick = Config.getConfig().shopNickname; let regionName = Config.getConfig().regionName; + let placeId = Config.getConfig().placeId; + let country = Config.getConfig().country; + let regionId = Config.getConfig().regionId; // TODO: Implement board authentication here. @@ -79,15 +82,15 @@ export default class AllnetModule extends Module { stat: 1, uri: STARTUP_URI, host: STARTUP_HOST, - place_id: "JPN0123", + place_id: placeId, name: shopName, nickname: shopNick, - region0: "1", + region0: regionId, region_name0: regionName, region_name1: "X", region_name2: "Y", region_name3: "Z", - country: "JPN", + country: country, allnet_id: "456", timezone: "002:00", setting: "", diff --git a/src/config.ts b/src/config.ts index a8d5807..0e3ed35 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,8 +1,11 @@ import fs from 'fs'; export interface ConfigFile { + placeId: string; shopName: string; shopNickname: string; + regionId: number; + country: string; regionName: string; serverIp?: string; gameOptions: GameOptions; diff --git a/src/modules/cars.ts b/src/modules/cars.ts index 5358a9c..97c8de5 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -30,7 +30,8 @@ export default class CarModule extends Module { include: { settings: true, items: true, - gtWing: true + gtWing: true, + lastPlayedPlace: true, } }); @@ -51,30 +52,12 @@ export default class CarModule extends Module { // Get current / previous active OCM Event let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, - - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], - }, + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, + + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, + }, orderBy: [ { dbId: 'desc' @@ -140,18 +123,11 @@ export default class CarModule extends Module { carId: carId }, include:{ - gtWing: true + gtWing: true, + lastPlayedPlace: true } }); - // Get Place - let playedPlace = wm.wm.protobuf.Place.create({ - placeId: 'JPN0123', - shopName: Config.getConfig().shopName, - regionId: 18, - country: 'JPN' - }); - // Get Ghost Trail let ghostTrailNo1 = await prisma.oCMTop1GhostTrail.findFirst({ where:{ @@ -166,7 +142,6 @@ export default class CarModule extends Module { ghostCarsNo1 = wm.wm.protobuf.GhostCar.create({ car: { ...cars!, - lastPlayedPlace: playedPlace }, area: ghostTrailNo1!.area, ramp: ghostTrailNo1!.ramp, @@ -180,15 +155,70 @@ export default class CarModule extends Module { } } + // Check opponents target + let opponentTarget = await prisma.carStampTarget.findMany({ + where:{ + stampTargetCarId: body.carId, + locked: false, + recommended: true, + } + }) + + let carsChallengers: wm.wm.protobuf.ChallengerCar[] = []; + + let returnCount = 1; + if(opponentTarget.length > 0) + { + console.log('Challengers Available'); + + for(let i=0; i { - // ---For testing only--- - let cars = await prisma.car.findMany({ - where: { - OR: [ - { - name: { startsWith: 'KITSU' } - }, - { - name: { startsWith: 'きつ' } - }, - ], - }, - include:{ - gtWing: true + // Get the request body for the load stamp target request + let body = wm.wm.protobuf.LoadGhostBattleInfoRequest.decode(req.body); + + let car = await prisma.car.findFirst({ + where:{ + carId: body.carId }, - orderBy: { - carId: 'asc' + include:{ + gtWing: true, + lastPlayedPlace: true + } + }) + + // Car History + let findChallenger = await prisma.carChallenger.findMany({ + where: { + challengerCarId: body.carId + }, + orderBy:{ + lastPlayedAt: 'desc' }, take: 10 - }); + }) - for(let i=0; i 0) { - // If regionId is 0 or not set, game will crash after defeating the ghost - if(cars[i].regionId === 0) - { - let randomRegionId = Math.floor(Math.random() * 47) + 1; - cars[i].regionId = randomRegionId; + for(let i=0; i { // Get the request body for the load stamp target request - let body = wm.wm.protobuf.LoadStampTargetRequest.encode(req.body); + let body = wm.wm.protobuf.LoadStampTargetRequest.decode(req.body); - // TODO: Actual stamp stuff here - // This is literally just bare-bones + let carsStamp: wm.wm.protobuf.StampTargetCar[] = []; + let carsChallenger: wm.wm.protobuf.ChallengerCar[] = []; + + // Get all of the friend cars for the carId provided + let stampTargets = await prisma.carStampTarget.findMany({ + where: { + carId: body.carId + } + }); + + if(stampTargets) + { + for(let i=0; i { // Get the request body for the search cars by level request let body = wm.wm.protobuf.SearchCarsByLevelRequest.decode(req.body); - // Find ghost car by selected level - let car = await prisma.car.findMany({ - where: { - ghostLevel: body.ghostLevel - }, - include:{ - gtWing: true - } - }); + let car; + + if(body.regionId !== null && body.regionId !== undefined && body.regionId !== 0) + { + // Find ghost car by selected level and region ID + car = await prisma.car.findMany({ + where: { + ghostLevel: body.ghostLevel, + regionId: body.regionId + }, + include:{ + gtWing: true, + lastPlayedPlace: true, + } + }); + } + else + { + // Find ghost car by selected level + car = await prisma.car.findMany({ + where: { + ghostLevel: body.ghostLevel, + }, + include:{ + gtWing: true, + lastPlayedPlace: true, + } + }); + } // Randomizing the starting ramp and path based on selected area let rampVal = 0; @@ -176,17 +351,19 @@ export default class GhostModule extends Module { let maxNumber = 0; // If all user car data available is more than 10 for certain level - if(car.length > 10){ + if(car.length > 10) + { maxNumber = 10 // Limit to 10 (game default) } // If no more than 10 - else{ + else + { maxNumber = car.length; } // Choose the user's car data randomly to appear - while(arr.length < maxNumber){ - + while(arr.length < maxNumber) + { // Pick random car Id let randomNumber: number = Math.floor(Math.random() * car.length); if(arr.indexOf(randomNumber) === -1){ @@ -214,14 +391,15 @@ export default class GhostModule extends Module { } // Push user's car data without ghost trail - if(!(ghost_trails)){ + if(!(ghost_trails)) + { lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({ car: car[randomNumber] })); } // Push user's car data with ghost trail - else{ - + else + { // Set the tunePower used when playing certain area car[randomNumber].tunePower = ghost_trails!.tunePower; @@ -239,6 +417,124 @@ export default class GhostModule extends Module { } } + // Check again if car list for that selected region is available of not + if(body.regionId !== null && body.regionId !== undefined && body.regionId !== 0) + { + if(car.length < 1) + { + // Get current date + let date = Math.floor(new Date().getTime() / 1000); + let playedPlace = wm.wm.protobuf.Place.create({ + placeId: Config.getConfig().placeId, + regionId: Config.getConfig().regionId, + shopName: Config.getConfig().shopName, + country: Config.getConfig().country + }); + + let tunePowerDefault = 0 + let tuneHandlingDefault = 0; + if(body.ghostLevel === 1) + { + tunePowerDefault = 1; + tuneHandlingDefault = 4; + } + else if(body.ghostLevel === 2) + { + tunePowerDefault = 5; + tuneHandlingDefault = 5; + } + else if(body.ghostLevel === 3) + { + tunePowerDefault = 8; + tuneHandlingDefault = 7; + } + else if(body.ghostLevel === 4) + { + tunePowerDefault = 10; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 5) + { + tunePowerDefault = 15; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 6) + { + tunePowerDefault = 18; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 7) + { + tunePowerDefault = 20; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 8) + { + tunePowerDefault = 21; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 9) + { + tunePowerDefault = 22; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 10) + { + tunePowerDefault = 24; + tuneHandlingDefault = 10; + } + else if(body.ghostLevel === 11) + { + tunePowerDefault = 24; + tuneHandlingDefault = 24; + } + + // Generate default S660 car data + car = wm.wm.protobuf.Car.create({ + carId: 999999999, // Don't change this + name: 'S660', + regionId: body.regionId, // IDN (福井) + manufacturer: 12, // HONDA + model: 105, // S660 [JW5] + visualModel: 130, // S660 [JW5] + defaultColor: 0, + customColor: 0, + wheel: 20, + wheelColor: 0, + aero: 0, + bonnet: 0, + wing: 0, + mirror: 0, + neon: 0, + trunk: 0, + plate: 0, + plateColor: 0, + plateNumber: 0, + tunePower: tunePowerDefault, + tuneHandling: tuneHandlingDefault, + rivalMarker: 32, + aura: 551, + windowSticker: true, + windowStickerString: 'BAYSHORE', + windowStickerFont: 0, + title: 'No Ghost for this Region', + level: 65, // SSSSS + lastPlayedAt: date, + country: 'JPN', + lastPlayedPlace: playedPlace + }); + + // Push data to Ghost car proto + lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({ + car: car, + nonhuman: true, + type: wm.wm.protobuf.GhostType.GHOST_DEFAULT, + })); + } + + // else{} have car list + } + // Response data let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, @@ -269,8 +565,8 @@ export default class GhostModule extends Module { let lists_ghostcar: wm.wm.protobuf.LoadGhostDriveDataResponse.GhostDriveData[] = []; // Check how many opponent ghost data available (including user data) - for(let i=0; i { - - // Response data - let msg = { - error: wmsrv.wm.protobuf.ErrorCode.ERR_SUCCESS, - }; - - // Encode the response - let message = wmsrv.wm.protobuf.LockStampTargetResponse.encode(msg); - - // Send the response to the client - common.sendResponse(message, res); - }) - - - app.get('/resource/ghost_list', async (req, res) => { - - // Response data - let msg = { - error: wmsrv.wm.protobuf.ErrorCode.ERR_SUCCESS, - }; - - // Encode the response - let message = wmsrv.wm.protobuf.GhostList.encode(msg); - - // Send the response to the client - common.sendResponse(message, res); - }) - */ } } \ No newline at end of file diff --git a/src/modules/ghost_ocm.ts b/src/modules/ghost_ocm.ts index 72fea83..cef0738 100644 --- a/src/modules/ghost_ocm.ts +++ b/src/modules/ghost_ocm.ts @@ -9,8 +9,8 @@ import * as wm from "../wmmt/wm.proto"; // Import Util import * as common from "../util/common"; -import * as ghost_ocm from "../util/games/ghost_ocm"; -import * as ghost_ocm_area from "../util/games/games_util/ghost_ocm_area"; +import * as ghost_ocm from "../util/ghost/ghost_ocm"; +import * as ghost_ocm_area from "../util/ghost/ghost_ocm_area"; export default class GhostModule extends Module { @@ -28,30 +28,12 @@ export default class GhostModule extends Module { // Get currently active OCM event (query still not complete) let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, - - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], - }, + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, + + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, + }, orderBy:{ dbId: 'desc' } @@ -417,36 +399,14 @@ export default class GhostModule extends Module { // Get currently active OCM event let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - competitionId: competition_id, - - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, - - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - competitionId: competition_id, - - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - competitionId: competition_id, - - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], - }, + competitionId: competition_id, + + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, + + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, + }, orderBy:{ dbId: 'desc' } @@ -471,10 +431,10 @@ export default class GhostModule extends Module { let ghostTypes; let cars: wm.wm.protobuf.ICar | (Car & { gtWing: CarGTWing; }) | null; let playedPlace = wm.wm.protobuf.Place.create({ - placeId: 'JPN0123', - shopName: Config.getConfig().shopName, - regionId: 18, - country: 'JPN' + placeId: Config.getConfig().placeId, + regionId: Config.getConfig().regionId, + shopName: Config.getConfig().shopName, + country: Config.getConfig().country }); // Get default trail id @@ -520,7 +480,8 @@ export default class GhostModule extends Module { carId: checkGhostTrail!.carId }, include:{ - gtWing: true + gtWing: true, + lastPlayedPlace: true } }); @@ -594,7 +555,8 @@ export default class GhostModule extends Module { title: 'Don\'t have S660?', level: 65, // SSSSS lastPlayedAt: checkGhostTrail!.playedAt, - country: 'GLB' + country: 'IDN', + lastPlayedPlace: playedPlace }); // Set Ghost stuff Value @@ -603,7 +565,8 @@ export default class GhostModule extends Module { } else if(ocmEventDate!.competitionCloseAt < date && ocmEventDate!.competitionEndAt > date) { - // TODO: IDK + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots } else { @@ -644,7 +607,8 @@ export default class GhostModule extends Module { carId: checkGhostTrail!.carId }, include:{ - gtWing: true + gtWing: true, + lastPlayedPlace: true } }); @@ -670,10 +634,7 @@ export default class GhostModule extends Module { // Push the Top 1 OCM ghost car data ghostCars = wm.wm.protobuf.GhostCar.create({ - car: { - ...cars!, - lastPlayedPlace: playedPlace - }, + car: cars!, area: areaVal, ramp: rampVal, path: pathVal, diff --git a/src/modules/resource.ts b/src/modules/resource.ts new file mode 100644 index 0000000..2ebb910 --- /dev/null +++ b/src/modules/resource.ts @@ -0,0 +1,495 @@ +import { Application } from "express"; +import {Module} from "module"; +import { Config } from "../config"; +import { prisma } from ".."; + +// Import Proto +import * as wm from "../wmmt/wm.proto"; +import * as wmsrv from "../wmmt/service.proto"; + +// Import Util +import * as common from "../util/common"; + + +export default class ResourceModule extends Module { + register(app: Application): void { + + // Place List + app.get('/resource/place_list', async (req, res) => { + + console.log('place list'); + + // Empty list of place records + let places: wm.wm.protobuf.Place[] = []; + + // Response data + places.push(new wm.wm.protobuf.Place({ + placeId: Config.getConfig().placeId, + regionId: Config.getConfig().regionId, + shopName: Config.getConfig().shopName, + country: Config.getConfig().country + })); + + let checkPlaceList = await prisma.placeList.findFirst({ + where:{ + placeId: Config.getConfig().placeId, + } + }) + + if(!(checkPlaceList)) + { + console.log('Creating new Place List entry') + + await prisma.placeList.create({ + data:{ + placeId: Config.getConfig().placeId, + regionId: Number(Config.getConfig().regionId), + shopName: Config.getConfig().shopName, + country: Config.getConfig().country + } + }) + } + + // Encode the response + let message = wm.wm.protobuf.PlaceList.encode({places}); + + // Send the response to the client + common.sendResponse(message, res); + }) + + // Get Ranking data for attract screen (TA, Ghost, VS) + app.get('/resource/ranking', async (req, res) => { + + console.log('ranking'); + + // Empty list of all ranking records (Combination of TA, VS Stars, and Ghost Battle Win) + let lists: wmsrv.wm.protobuf.Ranking.List[] = []; + + // Get TA Ranking + for(let i=0; i<25; i++){ // GID_TACOURSE ID + + // Get the TA time per course + let ta_time = await prisma.timeAttackRecord.findMany({ + where: { + course: i + }, + orderBy: { + time: 'asc' + }, + take: 10, // Take top 10 + }); + + // TA time record by user is available for certain course + if(ta_time.length > 0){ + + // Empty list of ranking records for user time attack + let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = []; + + // Get the TA time data + for(let j=0; j { + + console.log('crown_list'); + + // Empty list of crown records + let list_crown: wmsrv.wm.protobuf.Crown[] = []; + + // Get the crown holder data + let car_crown = await prisma.carCrown.findMany({ + orderBy: { + area: 'asc' + } + }); + + // Crown holder data available + if(car_crown.length !== 0) + { + let counter = 0; + + // Loop GID_RUNAREA + for(let i=0; i<19; i++) + { + // 14 - 16 are dummy area, 17 is C1 Closed + if(i >= 14) + { + i = 18; // GID_RUNAREA_HIROSHIMA + } + + // Crown holder for certain area available + if(car_crown[counter].area === i){ + + // Get user's data + let car = await prisma.car.findFirst({ + where: { + carId: car_crown[counter].carId + }, + include: { + gtWing: true, + lastPlayedPlace: true + } + }); + + // If regionId is 0 or not set, game will crash after defeating the ghost + if(car!.regionId === 0) + { + car!.regionId = i + 1; // Change car region id + } + + // Set the tunePower and tuneHandling used when capturing ghost crown + car!.tunePower = car_crown[counter].tunePower; + car!.tuneHandling = car_crown[counter].tuneHandling; + + // Error handling if played At timestamp value is current date and timestamp is bigger than 9 July 2022 (using GMT+7 timestamp) + if(car_crown[counter].playedAt !== 0 && car_crown[counter].playedAt >= 1657299600) + { + // Acquired crown timestamp - 1 day + car!.lastPlayedAt = car_crown[counter].playedAt - 172800; + + // Acquired crown timestamp - 1 day + car_crown[counter].playedAt = car_crown[counter].playedAt - 172800; + } + // Error handling if played At timestamp value is 0 or timestamp is less than 9 July 2022 (using GMT+7 timestamp) + else if(car_crown[counter].playedAt === 0 || car_crown[counter].playedAt < 1657299600) + { + // Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp) + car!.lastPlayedAt = 1657299600; + + // Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp) + car_crown[counter].playedAt = 1657299600; + } + + // Push the car data to the crown holder data + list_crown.push(wmsrv.wm.protobuf.Crown.create({ + carId: car_crown[counter].carId, + area: car_crown[counter].area, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA + unlockAt: car_crown[counter].playedAt, + car: car! + + })); + + if(counter < car_crown.length-1){ + counter++; + } + } + // Crown holder for certain area not available + else{ + + // Push the default data by the game to the crown holder data + list_crown.push(wmsrv.wm.protobuf.Crown.create({ + carId: i, + area: i, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA + unlockAt: 0, + })); + } + } + } + // There is no user's crown holder data available + else{ + + // Loop GID_RUNAREA + for(let i=0; i<19; i++) + { + // 14 - 16 are dummy area, 17 is C1 Closed + if(i >= 14) + { + i = 18; // GID_RUNAREA_HIROSHIMA + } + + // Push the default data by the game to the crown holder data + list_crown.push(wmsrv.wm.protobuf.Crown.create({ + carId: i, + area: i, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA + unlockAt: 0, + })); + } + } + + // Response data + let msg = { + crowns: list_crown + }; + + // Encode the response + let message = wmsrv.wm.protobuf.CrownList.encode(msg); + + // Send the response to the client + common.sendResponse(message, res); + }) + + app.get('/resource/file_list', async (req, res) => { + + console.log('file_list'); + + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots + + // Response data + let msg = { + error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, + files: null, + interval: null + } + + // Encode the response + let message = wm.wm.protobuf.FileList.encode(msg); + + // Send the response to the client + common.sendResponse(message, res); + }) + + app.get('/resource/ghost_list', async (req, res) => { + + console.log('ghost_list'); + + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots + + // Response data + let msg = { + error: wmsrv.wm.protobuf.ErrorCode.ERR_SUCCESS, + ghosts: null + }; + + // Encode the response + let message = wmsrv.wm.protobuf.GhostList.encode(msg); + + // Send the response to the client + common.sendResponse(message, res); + }) + } +} \ No newline at end of file diff --git a/src/modules/startup.ts b/src/modules/startup.ts index b5aea81..367cd66 100644 --- a/src/modules/startup.ts +++ b/src/modules/startup.ts @@ -1,11 +1,9 @@ import { Application } from "express"; import {Module} from "module"; -import { Config } from "../config"; import { prisma } from ".."; // Import Proto import * as wm from "../wmmt/wm.proto"; -import * as wmsrv from "../wmmt/service.proto"; // Import Util import * as common from "../util/common"; @@ -26,30 +24,12 @@ export default class StartupModule extends Module { // Get current / previous active OCM Event let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, - - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], - }, + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, + + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, + }, orderBy: [ { dbId: 'desc' @@ -154,295 +134,31 @@ export default class StartupModule extends Module { }) - // Place List - app.get('/resource/place_list', (req, res) => { - console.log('place list'); + // Update Event Mode Serial + app.post('/method/update_user_session', (req, res) => { - // Empty list of place records - let places: wm.wm.protobuf.Place[] = []; + let body = wm.wm.protobuf.UpdateUserSessionRequest.decode(req.body); + + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots // Response data - places.push(new wm.wm.protobuf.Place({ - placeId: "JPN0123", - regionId: 1, - shopName: Config.getConfig().shopName, - country: "JPN" - })); + let msg = { + error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, + } - // Encode the response - let message = wm.wm.protobuf.PlaceList.encode({places}); - - // Send the response to the client - common.sendResponse(message, res); - }) - - - // Get Ranking data for attract screen (TA, Ghost, VS) - app.get('/resource/ranking', async (req, res) => { - console.log('ranking'); + // Generate the response message + let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg); - // Empty list of all ranking records (Combination of TA, VS Stars, and Ghost Battle Win) - let lists: wmsrv.wm.protobuf.Ranking.List[] = []; - - // Get TA Ranking - for(let i=0; i<25; i++){ // GID_TACOURSE ID - - // Get the TA time per course - let ta_time = await prisma.timeAttackRecord.findMany({ - where: { - course: i - }, - orderBy: { - time: 'asc' - }, - take: 10, // Take top 10 - }); - - // TA time record by user is available for certain course - if(ta_time.length > 0){ - - // Empty list of ranking records for user time attack - let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = []; - - // Get the TA time data - for(let j=0; j { + console.log('ping'); + let body = wm.wm.protobuf.PingRequest.decode(req.body); // Response data @@ -458,163 +174,14 @@ export default class StartupModule extends Module { common.sendResponse(message, res); }) - - // Crown List for attract screen and Crown Ghost Battle mode - app.get('/resource/crown_list', async (req, res) => { - console.log('crown_list'); - - // Empty list of crown records - let list_crown: wmsrv.wm.protobuf.Crown[] = []; - - // Get the crown holder data - let car_crown = await prisma.carCrown.findMany({ - orderBy: { - area: 'asc' - } - }); - - // Crown holder data available - if(car_crown.length !== 0){ - let counter = 0; - - // Loop GID_RUNAREA - for(let i=0; i<19; i++){ - - // 14 - 16 are dummy area, 17 is C1 Closed - if(i >= 14){ - i = 18; // GID_RUNAREA_HIROSHIMA - } - - // Crown holder for certain area available - if(car_crown[counter].area === i){ - - // Get user's data - let car = await prisma.car.findFirst({ - where: { - carId: car_crown[counter].carId - }, - include: { - gtWing: true - } - }); - - // If regionId is 0 or not set, game will crash after defeating the ghost - if(car!.regionId === 0) - { - /* Region Id - 01 = Hokkaido 北海道 - 02 = Aomori 青森 - 03 = Iwate 岩手 - 04 = Miyagi 宮城 - 05 = Akita 秋田 - 06 = Yamagata 山形 - 07 = Fukushima 福島 - 08 = Ibaraki 茨城 - 09 = Tochigi 栃木 - 10 = Gunma 群馬 - 11 = Saitama 埼玉 - 12 = Chiba 千葉 - 13 = Tokyo 東京 - 19 = Yamanashi 山梨 - */ - car!.regionId = i + 1; // Change car region id - } - - // Set the tunePower used when capturing ghost crown - car!.tunePower = car_crown[counter].tunePower; - - // Set the tunePower used when capturing ghost crown - car!.tuneHandling = car_crown[counter].tuneHandling; - - // Error handling if played At timestamp value is current date and timestamp is bigger than 9 July 2022 (using GMT+7 timestamp) - if(car_crown[counter].playedAt !== 0 && car_crown[counter].playedAt >= 1657299600) - { - // Acquired crown timestamp - 1 day - car!.lastPlayedAt = car_crown[counter].playedAt - 172800; - - // Acquired crown timestamp - 1 day - car_crown[counter].playedAt = car_crown[counter].playedAt - 172800; - } - // Error handling if played At timestamp value is 0 or timestamp is less than 9 July 2022 (using GMT+7 timestamp) - else if(car_crown[counter].playedAt === 0 || car_crown[counter].playedAt < 1657299600) - { - // Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp) - car!.lastPlayedAt = 1657299600; - - // Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp) - car_crown[counter].playedAt = 1657299600; - } - - let playedPlace = wm.wm.protobuf.Place.create({ - placeId: 'JPN0123', - shopName: Config.getConfig().shopName, - regionId: 18, - country: 'JPN' - }); - - // Push the car data to the crown holder data - list_crown.push(wmsrv.wm.protobuf.Crown.create({ - carId: car_crown[counter].carId, - area: car_crown[counter].area, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA - unlockAt: car_crown[counter].playedAt, - car: { - ...car!, - lastPlayedPlace: playedPlace - } - })); - - if(counter < car_crown.length-1){ - counter++; - } - } - // Crown holder for certain area not available - else{ - - // Push the default data by the game to the crown holder data - list_crown.push(wmsrv.wm.protobuf.Crown.create({ - carId: i, - area: i, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA - unlockAt: 0, - })); - } - } - } - // There is no user's crown holder data available - else{ - - // Loop GID_RUNAREA - for(let i=0; i<19; i++){ - - // 14 - 16 are dummy area, 17 is C1 Closed - if(i >= 14){ - i = 18; // GID_RUNAREA_HIROSHIMA - } - - // Push the default data by the game to the crown holder data - list_crown.push(wmsrv.wm.protobuf.Crown.create({ - carId: i, - area: i, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA - unlockAt: 0, - })); - } - } - - // Response data - let msg = { - crowns: list_crown - }; - - // Encode the response - let message = wmsrv.wm.protobuf.CrownList.encode(msg); - - // Send the response to the client - common.sendResponse(message, res); - }) - - - /* + app.post('/method/register_system_stats', async (req, res) => { + let body = wm.wm.protobuf.RegisterSystemStatsRequest.decode(req.body); + + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots + // Response data let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, @@ -630,9 +197,15 @@ export default class StartupModule extends Module { app.post('/method/update_event_mode_serial', async (req, res) => { + let body = wm.wm.protobuf.UpdateEventModeSerialRequest.decode(req.body); + + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots + // Response data let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, + serialError: wm.wm.protobuf.EventModeSerialErrorCode.SERIAL_NO_INPUT } // Encode the response @@ -642,8 +215,14 @@ export default class StartupModule extends Module { common.sendResponse(message, res); }) + app.post('/method/submit_client_log', async (req, res) => { + let body = wm.wm.protobuf.SubmitClientLogRequest.decode(req.body); + + // TODO: Actual stuff here + // This is literally just bare-bones so the shit boots + // Response data let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, @@ -655,20 +234,5 @@ export default class StartupModule extends Module { // Send the response to the client common.sendResponse(message, res); }) - - app.get('/resource/file_list', async (req, res) => { - - // Response data - let msg = { - error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, - } - - // Encode the response - let message = wm.wm.protobuf.FileList.encode(msg); - - // Send the response to the client - common.sendResponse(message, res); - }) - */ } } diff --git a/src/modules/terminal.ts b/src/modules/terminal.ts index 30c2d84..2963882 100644 --- a/src/modules/terminal.ts +++ b/src/modules/terminal.ts @@ -121,6 +121,10 @@ export default class TerminalModule extends Module { let car = await prisma.car.findFirst({ where: { carId: carId + }, + include:{ + gtWing: true, + lastPlayedPlace: true } }); @@ -185,16 +189,47 @@ export default class TerminalModule extends Module { // Get the query from the request let query = req.query; + // Check the query limit + let queryLimit = 10 + if(query.limit) + { + queryLimit = Number(query.limit); + } + + // Check the last played place id + let queryLastPlayedPlaceId = 1; + if(query.limit) + { + let getLastPlayedPlaceId = await prisma.placeList.findFirst({ + where:{ + placeId: String(query.last_played_place_id) + } + }) + + if(getLastPlayedPlaceId) + { + queryLastPlayedPlaceId = getLastPlayedPlaceId.id + } + } + // Get all of the cars matching the query let cars = await prisma.car.findMany({ - take: Number(query.limit), + take: queryLimit, where: { - name: { - startsWith: String(query.name) - } + OR:[ + { + name: { + startsWith: String(query.name) + } + }, + { + lastPlayedPlaceId: queryLastPlayedPlaceId + } + ] }, include:{ - gtWing: true + gtWing: true, + lastPlayedPlace: true } }); @@ -532,36 +567,12 @@ export default class TerminalModule extends Module { // Get current active OCM Event let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - competitionId: body.competitionId, - - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, - - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - competitionId: body.competitionId, - - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - competitionId: body.competitionId, - - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], - }, + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, + + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, + }, orderBy:{ dbId: 'desc' } @@ -669,6 +680,10 @@ export default class TerminalModule extends Module { let cars = await prisma.car.findFirst({ where:{ carId: ocmParticipant[i].carId + }, + include:{ + gtWing: true, + lastPlayedPlace: true } }); @@ -745,6 +760,10 @@ export default class TerminalModule extends Module { let cars = await prisma.car.findFirst({ where:{ carId: ocmParticipant[i].carId + }, + include:{ + gtWing: true, + lastPlayedPlace: true } }) @@ -815,6 +834,10 @@ export default class TerminalModule extends Module { let cars = await prisma.car.findFirst({ where:{ carId: ocmParticipant[i].carId + }, + include:{ + gtWing: true, + lastPlayedPlace: true } }); diff --git a/src/modules/users.ts b/src/modules/users.ts index 351b54d..8e0774c 100644 --- a/src/modules/users.ts +++ b/src/modules/users.ts @@ -30,15 +30,18 @@ export default class UserModule extends Module { cars: { include: { state: true, - gtWing: true + gtWing: true, + lastPlayedPlace: true } } } }); // No user returned - if (!user) { + if (!user) + { console.log('no such user'); + let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, numOfOwnedCars: 0, @@ -46,75 +49,86 @@ export default class UserModule extends Module { spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED, transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED, }; - if (!body.cardChipId || !body.accessCode) { + + if (!body.cardChipId || !body.accessCode) + { let msg = { error: wm.wm.protobuf.ErrorCode.ERR_ID_BANNED, numOfOwnedCars: 0, spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED, transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED } - let resp = wm.wm.protobuf.LoadUserResponse.encode(msg); - let end = resp.finish(); - let r = res - .header('Server', 'v388 wangan') - .header('Content-Type', 'application/x-protobuf; revision=8053') - .header('Content-Length', end.length.toString()) - .status(200); - r.send(Buffer.from(end)); + + // Encode the response + let message = wm.wm.protobuf.LoadUserResponse.encode(msg); + + // Send the response to the client + common.sendResponse(message, res); + return; } + let user = await prisma.user.create({ data: { chipId: body.cardChipId, accessCode: body.accessCode, tutorials: [ - false, //TUTORIAL_ID_STORY - false, //TUTORIAL_ID_TIME_ATTACK - false, //TUTORIAL_ID_GHOST - false, //TUTORIAL_ID_GHOST_CHALLENGE - false, //TUTORIAL_ID_GHOST_LEVEL - false, //TUTORIAL_ID_UNUSED_5 - false, //TUTORIAL_ID_GHOST_SEARCH - false, //TUTORIAL_ID_GHOST_COMPETITION - false, //TUTORIAL_ID_HP600_CARD - false, //TUTORIAL_ID_UNUSED_9 - false, //TUTORIAL_ID_COMPETITION_QUALIFIED - false, //TUTORIAL_ID_COMPETITION_TERMINAL - false, //TUTORIAL_ID_COMPETITION_NOTICE - false, //TUTORIAL_ID_COMPETITION_FINISHED - false, //TUTORIAL_ID_UNUSED_14 - false, //TUTORIAL_ID_UNUSED_15 - false, //TUTORIAL_ID_UNUSED_16 - false, //TUTORIAL_ID_UNUSED_17 - false, //TUTORIAL_ID_UNUSED_18 - false, //TUTORIAL_ID_UNUSED_19 - false, //TUTORIAL_ID_GHOST_STAMP - false, //TUTORIAL_ID_GHOST_STAMP_DECLINED - false, //TUTORIAL_ID_GHOST_STAMP_FRIENDS - true, //TUTORIAL_ID_TERMINAL_SCRATCH - true, //TUTORIAL_ID_TURN_SCRATCH_SHEET - false, //TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN - false, //TUTORIAL_ID_CAR_COUPON_FULL_TUNED_RECEIVABLE - false, //TUTORIAL_ID_VS_CONTINUE_TICKET - false, //TUTORIAL_ID_UNUSED_28 - false, //TUTORIAL_ID_UNUSED_29 - false, //TUTORIAL_ID_UNUSED_30 - false, //TUTORIAL_ID_DRESS_UP - true, //TUTORIAL_ID_MULTI_GHOST - true, //TUTORIAL_ID_STORY_NEW_FEATURE - true, //TUTORIAL_ID_GHOST_NEW_FEATURE - true, //TUTORIAL_ID_GHOST_REGION_MAP + false, //TUTORIAL_ID_STORY = 0, + false, //TUTORIAL_ID_TIME_ATTACK = 1, + false, //TUTORIAL_ID_GHOST = 2, + false, //TUTORIAL_ID_GHOST_CHALLENGE = 3, + false, //TUTORIAL_ID_GHOST_LEVEL = 4, + false, //TUTORIAL_ID_UNUSED_5 = 5, + false, //TUTORIAL_ID_GHOST_SEARCH = 6, + false, //TUTORIAL_ID_GHOST_COMPETITION = 7, + false, //TUTORIAL_ID_HP600_CARD = 8, + false, //TUTORIAL_ID_UNUSED_9 = 9, + false, //TUTORIAL_ID_COMPETITION_QUALIFIED = 10, + false, //TUTORIAL_ID_COMPETITION_TERMINAL = 11, + false, //TUTORIAL_ID_COMPETITION_NOTICE = 12, + false, //TUTORIAL_ID_COMPETITION_FINISHED = 13, + false, //TUTORIAL_ID_UNUSED_14 = 14, + false, //TUTORIAL_ID_UNUSED_15 = 15, + false, //TUTORIAL_ID_UNUSED_16 = 16, + false, //TUTORIAL_ID_UNUSED_17 = 17, + false, //TUTORIAL_ID_UNUSED_18 = 18, + false, //TUTORIAL_ID_UNUSED_19 = 19, + true, //TUTORIAL_ID_GHOST_STAMP = 20, + true, //TUTORIAL_ID_GHOST_STAMP_DECLINED = 21, + true, //TUTORIAL_ID_GHOST_STAMP_FRIENDS = 22, + true, //TUTORIAL_ID_TERMINAL_SCRATCH = 23, + true, //TUTORIAL_ID_TURN_SCRATCH_SHEET = 24, + false, //TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN = 25, + false, //TUTORIAL_ID_CAR_COUPON_FULL_TUNED_RECEIVABLE = 26, + false, //TUTORIAL_ID_VS_CONTINUE_TICKET = 27, + false, //TUTORIAL_ID_UNUSED_28 = 28, + false, //TUTORIAL_ID_UNUSED_29 = 29, + false, //TUTORIAL_ID_UNUSED_30 = 30, + false, //TUTORIAL_ID_DRESS_UP = 31, + true, //TUTORIAL_ID_MULTI_GHOST = 32, + true, //TUTORIAL_ID_STORY_NEW_FEATURE = 33, + true, //TUTORIAL_ID_GHOST_NEW_FEATURE = 34, + true, //TUTORIAL_ID_GHOST_REGION_MAP = 35 + ], } }); + console.log('user made') - if (!user) { + + if (!user) + { msg.error = wm.wm.protobuf.ErrorCode.ERR_REQUEST; } + let ftTicketGrant = Config.getConfig().gameOptions.grantFullTuneTicketToNewUsers; - if (ftTicketGrant > 0) { + + if (ftTicketGrant > 0) + { console.log(`Granting Full-Tune Ticket x${ftTicketGrant} to new user...`); - for (let i=0; i 0) { // User atleast have 1 car if(user.cars[0]?.windowStickerString !== null && user.cars[0]?.windowStickerString !== undefined && @@ -243,8 +257,45 @@ export default class UserModule extends Module { wsFont = user.cars[0].windowStickerFont; } // else{} User don't have a car... returning default windowStickerString and windowStickerFont value + + if(user.cars[0].lastPlayedPlaceId === null || user.cars[0].lastPlayedPlaceId === undefined) + { + for(let i=0; i 0 && ocmEventDate) @@ -333,31 +367,21 @@ export default class UserModule extends Module { if(checkParticipation) { ParticipationMainDrawCounter++ - } - // Check Car State - // Get OCM Data - let ocmTallyRecord = await prisma.oCMTally.findMany({ - where:{ - competitionId: ocmEventDate!.competitionId - }, - orderBy: [ - { - competitionId: 'desc', - }, - { - periodId: 'desc', - }, - { - result: 'desc', - }, - ], - }); + // Check Car State + // Get OCM Data + let ocmTallyRecord = await prisma.oCMTally.findFirst({ + where:{ + carId: user.cars[i].carId, + competitionId: ocmEventDate!.competitionId + } + }); - for(let j=0; j date) - { + { // Check ghost battle record let checkParticipation = await prisma.oCMPlayRecord.findFirst({ where:{ @@ -420,33 +432,22 @@ export default class UserModule extends Module { if(checkParticipation) { ParticipationEndedCounter++ - } - // Check Car State - // Get OCM Data - let ocmTallyRecord = await prisma.oCMTally.findMany({ - where:{ - competitionId: ocmEventDate!.competitionId, - periodId: 999999999 - }, - orderBy: [ - { - result: 'desc', + // Check Car State + // Get OCM Data + let ocmTallyRecord = await prisma.oCMTally.findFirst({ + where:{ + carId: user.cars[i].carId, + competitionId: ocmEventDate!.competitionId, + periodId: 999999999 }, - ], - }); + }); - for(let j=0; j 0) { console.log('OCM Participation : '+ParticipationEndedCounter+' car(s) played OCM Event'); + msg.competitionUserState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_QUALIFIED; } - else{ + else if(ocmEventDate) + { console.log('OCM Participation : Not Participated / Qualified'); } + else + { + console.log('No OCM Event Available'); + } // Response data if user is banned - if (user.userBanned) { + if (user.userBanned) + { msg.error = wm.wm.protobuf.ErrorCode.ERR_ID_BANNED; } diff --git a/src/util/common.ts b/src/util/common.ts index d8b6c15..77c19bf 100644 --- a/src/util/common.ts +++ b/src/util/common.ts @@ -43,7 +43,8 @@ export function getBigIntFromLong(n: Long) return Number(bigInt); } -export function sanitizeInput(value: any){ +export function sanitizeInput(value: any) +{ return (value == null || value == undefined) ? undefined : value; } diff --git a/src/util/games/ghost.ts b/src/util/games/ghost.ts index b7f3a07..e6bcc93 100644 --- a/src/util/games/ghost.ts +++ b/src/util/games/ghost.ts @@ -6,7 +6,8 @@ import wmproto from "../../wmmt/wm.proto"; // Import Util import * as common from "../../util/common"; -import * as ghost_history from "../games/games_util/ghost_history"; +import * as ghost_history from "../ghost/ghost_history"; +import * as ghost_stamp from "../ghost/ghost_stamp"; // Save ghost battle result export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any) @@ -24,25 +25,10 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ // Set ghost mode play to true for saving the ghost trail later ghostModePlay = true; - // Get the ghost result for the car - let ghostResult = body?.rgResult; - // Declare data let dataGhost : any; let dataCar : any; - // ghostResult is set - if (ghostResult) - { - // Ghost update data - dataGhost = { - rgRegionMapScore: common.sanitizeInput(ghostResult.rgRegionMapScore), - rgPlayCount: common.sanitizeInput(ghostResult.rgPlayCount), - dressupLevel: common.sanitizeInput(ghostResult.dressupLevel), - dressupPoint: common.sanitizeInput(ghostResult.dressupPoint), - } - } - // Get the ghost result for the car let cars = body?.car; @@ -79,21 +65,38 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ } } - // Count total win based on region map score - if(body.rgResult?.rgRegionMapScore && body.rgResult?.rgRegionMapScore.length !== 0) - { - let winCounter = 0; + // Get the ghost result for the car + let ghostResult = body?.rgResult; - // Count the total win - for(let i=0; i date) + { + console.log('OCM Ghost Mode Found but Retiring'); + + // Get the rg result for the car + let rgResult = body?.rgResult; + + // rgResult is set + if (rgResult) + { + let data : any = { + carId: body.carId, + competitionId: common.sanitizeInput(rgResult.competitionId), + periodId: common.sanitizeInput(rgResult.periodId) || 0, + brakingPoint: common.sanitizeInput(rgResult.brakingPoint) || 0, + playedAt: common.sanitizeInput(body.playedAt), } // Get the user's available OCM Battle data let countOCM = await prisma.oCMPlayRecord.count({ where: { - competitionId: saveExOCM.competitionId, + competitionId: data.competitionId, carId: body.carId } }); - + // User's OCM Battle data available if(countOCM !== 0) { @@ -388,10 +557,10 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ await prisma.oCMPlayRecord.updateMany({ where:{ - carId: saveExOCM.carId, - competitionId: saveExOCM.competitionId, + carId: data.carId, + competitionId: data.competitionId, }, - data: saveExOCM + data: data }); } // First time User playing OCM Battle @@ -401,16 +570,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ console.log('Creating new OCM Play Record entry'); await prisma.oCMPlayRecord.create({ - data: saveExOCM + data: data }); } - - ghost_historys = await ghost_history.saveOCMGhostHistory(body); - - // Update the updateNewTrail value - updateNewTrail = ghost_historys.updateNewTrail; - - break; } } } diff --git a/src/util/meter_reward.ts b/src/util/games/meter_reward.ts similarity index 97% rename from src/util/meter_reward.ts rename to src/util/games/meter_reward.ts index e51c26e..c144334 100644 --- a/src/util/meter_reward.ts +++ b/src/util/games/meter_reward.ts @@ -1,7 +1,7 @@ -import { prisma } from ".."; +import { prisma } from "../.."; // Import Proto -import { wm } from "../wmmt/wm.proto"; +import { wm } from "../../wmmt/wm.proto"; // Save story result diff --git a/src/util/games/games_util/ghost_history.ts b/src/util/ghost/ghost_history.ts similarity index 50% rename from src/util/games/games_util/ghost_history.ts rename to src/util/ghost/ghost_history.ts index d841b72..9b417ac 100644 --- a/src/util/games/games_util/ghost_history.ts +++ b/src/util/ghost/ghost_history.ts @@ -1,7 +1,12 @@ // Import Proto -import { prisma } from "../../.."; -import { Config } from "../../../config"; -import { wm } from "../../../wmmt/wm.proto"; +import { prisma } from "../.."; +import { Config } from "../../config"; +import { wm } from "../../wmmt/wm.proto"; + +// Import Util +import * as common from "../../util/common"; +import * as ghost_stamp from "../ghost/ghost_stamp"; +import * as ghost_get_area_from_path from "../ghost/ghost_util/ghost_get_area_from_path"; // Save ghost history battle @@ -11,129 +16,97 @@ export async function saveGhostHistory(body: wm.protobuf.SaveGameResultRequest) let updateNewTrail: boolean = true; let saveExGhostHistory: any = {}; - - if (body.car?.carId !== null && body.car?.carId !== undefined) { - saveExGhostHistory.carId = body.car?.carId!; - } - if (body.car?.tunePower !== null && body.car?.tunePower !== undefined) { - saveExGhostHistory.tunePower = body.car?.tunePower!; - } - if (body.car?.tuneHandling !== null && body.car?.tuneHandling !== undefined) { - saveExGhostHistory.tuneHandling = body.car?.tuneHandling!; - } - if (body.playedAt !== null && body.playedAt !== undefined){ - saveExGhostHistory.playedAt = body.playedAt!; - } - // Get shop name - saveExGhostHistory.playedShopName = Config.getConfig().shopName; + // Get the car result for the car + let car = body?.car; - // Get how many opponents available - for(let i=0; i= 0 && body.rgResult?.path <= 9){ // GID_PATH_C1 - saveExGhostHistory.area = Number(0); - } - else if(body.rgResult?.path >= 10 && body.rgResult?.path <= 15){ // GID_PATH_N9 - saveExGhostHistory.area = Number(1); - } - else if(body.rgResult?.path >= 16 && body.rgResult?.path <= 17){ // GID_PATH_WTEAST - saveExGhostHistory.area = Number(2); - } - else if(body.rgResult?.path >= 18 && body.rgResult?.path <= 19){ // GID_PATH_WT_UP_DOWN - saveExGhostHistory.area = Number(3); - } - else if(body.rgResult?.path >= 20 && body.rgResult?.path <= 26){ // GID_PATH_WG - saveExGhostHistory.area = Number(4); - } - else if(body.rgResult?.path >= 27 && body.rgResult?.path <= 33){ // GID_PATH_KG - saveExGhostHistory.area = Number(5); - } - else if(body.rgResult?.path >= 34 && body.rgResult?.path <= 37){ // GID_PATH_YS - saveExGhostHistory.area = Number(6); - } - else if(body.rgResult?.path >= 38 && body.rgResult?.path <= 48){ // GID_PATH_KG_SHINYAMASHITA_MINATOMIRAI - saveExGhostHistory.area = Number(7); - } - else if(body.rgResult?.path === 49){ // GID_PATH_NGR - saveExGhostHistory.area = Number(8); - } - else if(body.rgResult?.path >= 50 && body.rgResult?.path <= 53){ // GID_PATH_OS - saveExGhostHistory.area = Number(9); - } - else if(body.rgResult?.path >= 54 && body.rgResult?.path <= 55){ // GID_PATH_KB - saveExGhostHistory.area = Number(10); - } - else if(body.rgResult?.path >= 58 && body.rgResult?.path <= 61){ // GID_PATH_FK - saveExGhostHistory.area = Number(11); - } - else if(body.rgResult?.path >= 62 && body.rgResult?.path <= 63){ // GID_PATH_HK - saveExGhostHistory.area = Number(12); - } - else if(body.rgResult?.path >= 64 && body.rgResult?.path <= 65){ // GID_PATH_TP - saveExGhostHistory.area = Number(13); - } - else if(body.rgResult?.path >= 56 && body.rgResult?.path <= 57){ // GID_PATH_HS - saveExGhostHistory.area = Number(18); + saveExGhostHistory = { + carId: common.sanitizeInput(car.carId), + tunePower: common.sanitizeInput(car.tunePower), + tuneHandling: common.sanitizeInput(car.tuneHandling), + playedAt: common.sanitizeInputNotZero(body.playedAt), + playedShopName: Config.getConfig().shopName } } - + + // Get the rg result for the car + let rgResult = body?.rgResult; + + if(rgResult) + { + if(rgResult.opponents) + { + // Get how many opponents available + for(let i=0; i= 0 && body.rgResult?.path <= 9){ // GID_PATH_C1 - saveExGhostHistory.area = Number(0); + saveExGhostHistory = { + carId: common.sanitizeInput(car.carId), + tunePower: common.sanitizeInput(car.tunePower), + tuneHandling: common.sanitizeInput(car.tuneHandling), + playedAt: common.sanitizeInputNotZero(body.playedAt), + playedShopName: Config.getConfig().shopName } - else if(body.rgResult?.path >= 10 && body.rgResult?.path <= 15){ // GID_PATH_N9 - saveExGhostHistory.area = Number(1); + } + + // Get the rg result for the car + let rgResult = body?.rgResult; + + if(rgResult) + { + if(rgResult.opponents) + { + // Get the advantage distance between first opponent and user + saveExGhostHistory.result = rgResult.opponents[0].result; } - else if(body.rgResult?.path >= 16 && body.rgResult?.path <= 17){ // GID_PATH_WTEAST - saveExGhostHistory.area = Number(2); - } - else if(body.rgResult?.path >= 18 && body.rgResult?.path <= 19){ // GID_PATH_WT_UP_DOWN - saveExGhostHistory.area = Number(3); - } - else if(body.rgResult?.path >= 20 && body.rgResult?.path <= 26){ // GID_PATH_WG - saveExGhostHistory.area = Number(4); - } - else if(body.rgResult?.path >= 27 && body.rgResult?.path <= 33){ // GID_PATH_KG - saveExGhostHistory.area = Number(5); - } - else if(body.rgResult?.path >= 34 && body.rgResult?.path <= 37){ // GID_PATH_YS - saveExGhostHistory.area = Number(6); - } - else if(body.rgResult?.path >= 38 && body.rgResult?.path <= 48){ // GID_PATH_KG_SHINYAMASHITA_MINATOMIRAI - saveExGhostHistory.area = Number(7); - } - else if(body.rgResult?.path === 49){ // GID_PATH_NGR - saveExGhostHistory.area = Number(8); - } - else if(body.rgResult?.path >= 50 && body.rgResult?.path <= 53){ // GID_PATH_OS - saveExGhostHistory.area = Number(9); - } - else if(body.rgResult?.path >= 54 && body.rgResult?.path <= 55){ // GID_PATH_KB - saveExGhostHistory.area = Number(10); - } - else if(body.rgResult?.path >= 58 && body.rgResult?.path <= 61){ // GID_PATH_FK - saveExGhostHistory.area = Number(11); - } - else if(body.rgResult?.path >= 62 && body.rgResult?.path <= 63){ // GID_PATH_HK - saveExGhostHistory.area = Number(12); - } - else if(body.rgResult?.path >= 64 && body.rgResult?.path <= 65){ // GID_PATH_TP - saveExGhostHistory.area = Number(13); - } - else if(body.rgResult?.path >= 56 && body.rgResult?.path <= 57){ // GID_PATH_HS - saveExGhostHistory.area = Number(18); + + // Get played Area + if(common.sanitizeInput(rgResult.path)) + { + let getArea = await ghost_get_area_from_path.getArea(rgResult.path); + + saveExGhostHistory.area = getArea.area } } @@ -219,29 +157,11 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques // Get currently active OCM event let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, }, orderBy:{ dbId: 'desc' diff --git a/src/util/games/ghost_ocm.ts b/src/util/ghost/ghost_ocm.ts similarity index 100% rename from src/util/games/ghost_ocm.ts rename to src/util/ghost/ghost_ocm.ts diff --git a/src/util/games/games_util/ghost_ocm_area.ts b/src/util/ghost/ghost_ocm_area.ts similarity index 98% rename from src/util/games/games_util/ghost_ocm_area.ts rename to src/util/ghost/ghost_ocm_area.ts index f831f0f..1fdf434 100644 --- a/src/util/games/games_util/ghost_ocm_area.ts +++ b/src/util/ghost/ghost_ocm_area.ts @@ -1,5 +1,4 @@ - -// Save ghost battle result +// OCM Area export async function OCMArea(competition_id: number) { let areaVal = 0; diff --git a/src/util/games/ghost_save_trail.ts b/src/util/ghost/ghost_save_trail.ts similarity index 90% rename from src/util/games/ghost_save_trail.ts rename to src/util/ghost/ghost_save_trail.ts index 0b893eb..c0f861c 100644 --- a/src/util/games/ghost_save_trail.ts +++ b/src/util/ghost/ghost_save_trail.ts @@ -15,29 +15,11 @@ export async function saveOCMGhostTrail(body: wm.protobuf.RegisterGhostTrailRequ // Get current active OCM Event let ocmEventDate = await prisma.oCMEvent.findFirst({ where: { - OR: [ - { - // qualifyingPeriodStartAt is less than current date - qualifyingPeriodStartAt: { lte: date }, + // qualifyingPeriodStartAt is less than current date + qualifyingPeriodStartAt: { lte: date }, - // qualifyingPeriodCloseAt is greater than current date - qualifyingPeriodCloseAt: { gte: date }, - }, - { - // competitionStartAt is less than current date - competitionStartAt: { lte: date }, - - // competitionCloseAt is greater than current date - competitionCloseAt: { gte: date }, - }, - { - // competitionCloseAt is less than current date - competitionCloseAt: { lte: date }, - - // competitionEndAt is greater than current date - competitionEndAt: {gte: date }, - } - ], + // competitionEndAt is greater than current date + competitionEndAt: { gte: date }, }, orderBy:{ dbId: 'desc' @@ -49,21 +31,20 @@ export async function saveOCMGhostTrail(body: wm.protobuf.RegisterGhostTrailRequ // Get OCM Period ID let OCM_periodId = await prisma.oCMPeriod.findFirst({ where:{ - competitionDbId: ocmEventDate!.dbId, - competitionId: ocmEventDate!.competitionId, - startAt: - { - lte: date, // competitionStartAt is less than current date - }, - closeAt: - { - gte: date, // competitionCloseAt is greater than current date - } + competitionDbId: ocmEventDate.dbId, + competitionId: ocmEventDate.competitionId, + + // StartAt is less than current date + startAt: { lte: date }, + + // CloseAt is greater than current date + closeAt: { gte: date } }, select:{ periodId: true } }); + let ocmMainDraws: boolean = false; let periodId = 0; @@ -92,6 +73,7 @@ export async function saveOCMGhostTrail(body: wm.protobuf.RegisterGhostTrailRequ let grArea: number = 0; let grRamp: number = 0; let grPath: number = 0; + if(ghostResult.area) { grArea = ghostResult.area; @@ -184,6 +166,7 @@ export async function saveCrownGhostTrail(body: wm.protobuf.RegisterGhostTrailRe let grArea: number = 0; let grRamp: number = 0; let grPath: number = 0; + if(ghostResult.area) { grArea = ghostResult.area; diff --git a/src/util/ghost/ghost_stamp.ts b/src/util/ghost/ghost_stamp.ts new file mode 100644 index 0000000..bf568d3 --- /dev/null +++ b/src/util/ghost/ghost_stamp.ts @@ -0,0 +1,239 @@ +import { prisma } from "../.."; + +// Import Proto +import { wm } from "../../wmmt/wm.proto"; + +// Import Util +import * as ghost_get_area_from_path from "../ghost/ghost_util/ghost_get_area_from_path"; + + +export async function sendStamp(body: wm.protobuf.SaveGameResultRequest) +{ + let consoleLog = 0; // stupid stuff for console log notice + + let rgResult = body.rgResult; + + // Get current date + let date = Math.floor(new Date().getTime() / 1000); + + if(rgResult) + { + // Stamp must bigger than 0 + if(rgResult.rgStamp === 0) + { + rgResult.rgStamp = 1; + } + + // Get the area + let area; + if(rgResult.path) + { + let getArea = await ghost_get_area_from_path.getArea(rgResult.path); + + area = getArea.area; + } + + // Check how many opponents available + for(let i=0; i= 0 && path <= 9){ // GID_PATH_C1 + area = Number(0); + } + else if(path >= 10 && path <= 15){ // GID_PATH_N9 + area = Number(1); + } + else if(path >= 16 && path <= 17){ // GID_PATH_WTEAST + area = Number(2); + } + else if(path >= 18 && path <= 19){ // GID_PATH_WT_UP_DOWN + area = Number(3); + } + else if(path >= 20 && path <= 26){ // GID_PATH_WG + area = Number(4); + } + else if(path >= 27 && path <= 33){ // GID_PATH_KG + area = Number(5); + } + else if(path >= 34 && path <= 37){ // GID_PATH_YS + area = Number(6); + } + else if(path >= 38 && path <= 48){ // GID_PATH_KG_SHINYAMASHITA_MINATOMIRAI + area = Number(7); + } + else if(path === 49){ // GID_PATH_NGR + area = Number(8); + } + else if(path >= 50 && path <= 53){ // GID_PATH_OS + area = Number(9); + } + else if(path >= 54 && path <= 55){ // GID_PATH_KB + area = Number(10); + } + else if(path >= 58 && path <= 61){ // GID_PATH_FK + area = Number(11); + } + else if(path >= 62 && path <= 63){ // GID_PATH_HK + area = Number(12); + } + else if(path >= 64 && path <= 65){ // GID_PATH_TP + area = Number(13); + } + else if(path >= 56 && path <= 57){ // GID_PATH_HS + area = Number(18); + } + + return { area } +} \ No newline at end of file