ghost stamp, config.json, etc (i forgot)
This commit is contained in:
parent
87bc26d25d
commit
fed0d55477
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"placeId": "JPN0123",
|
||||||
"shopName": "Bayshore",
|
"shopName": "Bayshore",
|
||||||
"shopNickname": "Bayshore",
|
"shopNickname": "Bayshore",
|
||||||
|
"regionId": "1",
|
||||||
|
"country": "JPN",
|
||||||
"regionName": "JPN0123",
|
"regionName": "JPN0123",
|
||||||
"serverIp": "127.0.0.1",
|
"serverIp": "127.0.0.1",
|
||||||
"gameOptions": {
|
"gameOptions": {
|
||||||
|
35
prisma/migrations/20220824075745_ghost_stamp/migration.sql
Normal file
35
prisma/migrations/20220824075745_ghost_stamp/migration.sql
Normal file
@ -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;
|
@ -0,0 +1,5 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "CarSettings" ALTER COLUMN "volume" SET DEFAULT 2;
|
17
prisma/migrations/20220824085616_place_list/migration.sql
Normal file
17
prisma/migrations/20220824085616_place_list/migration.sql
Normal file
@ -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;
|
17
prisma/migrations/20220824090041_place_list/migration.sql
Normal file
17
prisma/migrations/20220824090041_place_list/migration.sql
Normal file
@ -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;
|
@ -88,8 +88,6 @@ model Car {
|
|||||||
rivalMarker Int @default(0)
|
rivalMarker Int @default(0)
|
||||||
lastPlayedAt Int @default(0)
|
lastPlayedAt Int @default(0)
|
||||||
aura Int @default(0)
|
aura Int @default(0)
|
||||||
auraMotif Int @default(0)
|
|
||||||
ghostLevel Int @default(1)
|
|
||||||
|
|
||||||
// This is more data about the car
|
// This is more data about the car
|
||||||
tuningPoints Int @default(0)
|
tuningPoints Int @default(0)
|
||||||
@ -98,15 +96,20 @@ model Car {
|
|||||||
earnedCustomColor Boolean @default(false)
|
earnedCustomColor Boolean @default(false)
|
||||||
carSettingsDbId Int @unique
|
carSettingsDbId Int @unique
|
||||||
settings CarSettings @relation(fields: [carSettingsDbId], references: [dbId])
|
settings CarSettings @relation(fields: [carSettingsDbId], references: [dbId])
|
||||||
|
|
||||||
|
auraMotif Int @default(0)
|
||||||
vsPlayCount Int @default(0)
|
vsPlayCount Int @default(0)
|
||||||
vsBurstCount Int @default(0)
|
vsBurstCount Int @default(0)
|
||||||
vsStarCount Int @default(0)
|
vsStarCount Int @default(0)
|
||||||
|
vsStarCountMax Int @default(0)
|
||||||
vsCoolOrWild Int @default(0)
|
vsCoolOrWild Int @default(0)
|
||||||
vsSmoothOrRough Int @default(0)
|
vsSmoothOrRough Int @default(0)
|
||||||
vsTripleStarMedals Int @default(0)
|
vsTripleStarMedals Int @default(0)
|
||||||
vsDoubleStarMedals Int @default(0)
|
vsDoubleStarMedals Int @default(0)
|
||||||
vsSingleStarMedals Int @default(0)
|
vsSingleStarMedals Int @default(0)
|
||||||
vsPlainMedals Int @default(0)
|
vsPlainMedals Int @default(0)
|
||||||
|
|
||||||
|
ghostLevel Int @default(1)
|
||||||
rgPlayCount Int @default(0)
|
rgPlayCount Int @default(0)
|
||||||
rgWinCount Int @default(0)
|
rgWinCount Int @default(0)
|
||||||
rgTrophy Int @default(0)
|
rgTrophy Int @default(0)
|
||||||
@ -114,8 +117,12 @@ model Car {
|
|||||||
rgStamp Int @default(0)
|
rgStamp Int @default(0)
|
||||||
rgAcquireAllCrowns Boolean @default(false)
|
rgAcquireAllCrowns Boolean @default(false)
|
||||||
rgRegionMapScore Int[]
|
rgRegionMapScore Int[]
|
||||||
|
stampSheetCount Int @default(0)
|
||||||
|
stampSheet Int[]
|
||||||
|
|
||||||
dressupLevel Int @default(0)
|
dressupLevel Int @default(0)
|
||||||
dressupPoint Int @default(0)
|
dressupPoint Int @default(0)
|
||||||
|
|
||||||
stPlayCount Int @default(0)
|
stPlayCount Int @default(0)
|
||||||
stClearBits Int @default(0)
|
stClearBits Int @default(0)
|
||||||
stClearDivCount Int @default(0)
|
stClearDivCount Int @default(0)
|
||||||
@ -125,24 +132,27 @@ model Car {
|
|||||||
stConsecutiveWinsMax Int @default(0)
|
stConsecutiveWinsMax Int @default(0)
|
||||||
stCompleted100Episodes Boolean @default(false)
|
stCompleted100Episodes Boolean @default(false)
|
||||||
|
|
||||||
|
lastPlayedPlaceId Int?
|
||||||
|
lastPlayedPlace PlaceList? @relation(fields: [lastPlayedPlaceId], references: [id])
|
||||||
|
|
||||||
items CarItem[]
|
items CarItem[]
|
||||||
carGTWingDbId Int @unique
|
carGTWingDbId Int @unique
|
||||||
gtWing CarGTWing @relation(fields: [carGTWingDbId], references: [dbId])
|
gtWing CarGTWing @relation(fields: [carGTWingDbId], references: [dbId])
|
||||||
carStateDbId Int @unique
|
carStateDbId Int @unique
|
||||||
state CarState @relation(fields: [carStateDbId], references: [dbId])
|
state CarState @relation(fields: [carStateDbId], references: [dbId])
|
||||||
TimeAttackRecord TimeAttackRecord[]
|
TimeAttackRecord TimeAttackRecord[]
|
||||||
|
|
||||||
CarCrown CarCrown[]
|
CarCrown CarCrown[]
|
||||||
GhostTrail GhostTrail[]
|
GhostTrail GhostTrail[]
|
||||||
GhostBattleRecord GhostBattleRecord[]
|
GhostBattleRecord GhostBattleRecord[]
|
||||||
CarPathandTuning CarPathandTuning[]
|
CarPathandTuning CarPathandTuning[]
|
||||||
|
|
||||||
OCMGhostBattleRecord OCMGhostBattleRecord[]
|
OCMGhostBattleRecord OCMGhostBattleRecord[]
|
||||||
OCMTally OCMTally[]
|
OCMTally OCMTally[]
|
||||||
OCMTop1Ghost OCMTop1Ghost[]
|
OCMTop1Ghost OCMTop1Ghost[]
|
||||||
OCMGhostTrail OCMGhostTrail[]
|
OCMGhostTrail OCMGhostTrail[]
|
||||||
OCMPlayRecord OCMPlayRecord[]
|
OCMPlayRecord OCMPlayRecord[]
|
||||||
GhostRegisteredFromTerminal GhostRegisteredFromTerminal[]
|
GhostRegisteredFromTerminal GhostRegisteredFromTerminal[]
|
||||||
|
CarStampTarget CarStampTarget[]
|
||||||
|
CarChallenger CarChallenger[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model CarGTWing {
|
model CarGTWing {
|
||||||
@ -175,7 +185,7 @@ model CarSettings {
|
|||||||
retire Boolean @default(false)
|
retire Boolean @default(false)
|
||||||
meter Int @default(0)
|
meter Int @default(0)
|
||||||
navigationMap Boolean @default(true)
|
navigationMap Boolean @default(true)
|
||||||
volume Int @default(1)
|
volume Int @default(2)
|
||||||
bgm Int @default(0)
|
bgm Int @default(0)
|
||||||
nameplate Int @default(0)
|
nameplate Int @default(0)
|
||||||
nameplateColor Int @default(0)
|
nameplateColor Int @default(0)
|
||||||
@ -395,3 +405,34 @@ model GhostRegisteredFromTerminal {
|
|||||||
competitionId Int?
|
competitionId Int?
|
||||||
opponentCarId 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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -1,8 +1,11 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
export interface ConfigFile {
|
export interface ConfigFile {
|
||||||
|
placeId: string;
|
||||||
shopName: string;
|
shopName: string;
|
||||||
shopNickname: string;
|
shopNickname: string;
|
||||||
|
regionId: number;
|
||||||
|
country: string;
|
||||||
regionName: string;
|
regionName: string;
|
||||||
serverIp?: string;
|
serverIp?: string;
|
||||||
gameOptions: GameOptions;
|
gameOptions: GameOptions;
|
||||||
|
@ -30,7 +30,8 @@ export default class CarModule extends Module {
|
|||||||
include: {
|
include: {
|
||||||
settings: true,
|
settings: true,
|
||||||
items: true,
|
items: true,
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,29 +52,11 @@ export default class CarModule extends Module {
|
|||||||
// Get current / previous active OCM Event
|
// Get current / previous active OCM Event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{
|
{
|
||||||
@ -140,18 +123,11 @@ export default class CarModule extends Module {
|
|||||||
carId: carId
|
carId: carId
|
||||||
},
|
},
|
||||||
include:{
|
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
|
// Get Ghost Trail
|
||||||
let ghostTrailNo1 = await prisma.oCMTop1GhostTrail.findFirst({
|
let ghostTrailNo1 = await prisma.oCMTop1GhostTrail.findFirst({
|
||||||
where:{
|
where:{
|
||||||
@ -166,7 +142,6 @@ export default class CarModule extends Module {
|
|||||||
ghostCarsNo1 = wm.wm.protobuf.GhostCar.create({
|
ghostCarsNo1 = wm.wm.protobuf.GhostCar.create({
|
||||||
car: {
|
car: {
|
||||||
...cars!,
|
...cars!,
|
||||||
lastPlayedPlace: playedPlace
|
|
||||||
},
|
},
|
||||||
area: ghostTrailNo1!.area,
|
area: ghostTrailNo1!.area,
|
||||||
ramp: ghostTrailNo1!.ramp,
|
ramp: ghostTrailNo1!.ramp,
|
||||||
@ -180,15 +155,66 @@ 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<opponentTarget.length; i++)
|
||||||
|
{
|
||||||
|
// Get all of the friend cars for the carId provided
|
||||||
|
let challengers = await prisma.carChallenger.findFirst({
|
||||||
|
where: {
|
||||||
|
challengerCarId: body.carId,
|
||||||
|
carId: opponentTarget[0].carId
|
||||||
|
},
|
||||||
|
orderBy:{
|
||||||
|
id: 'desc'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(challengers)
|
||||||
|
{
|
||||||
|
returnCount = opponentTarget[0].returnCount;
|
||||||
|
|
||||||
|
let carTarget = await prisma.car.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: challengers.carId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
carsChallengers.push(
|
||||||
|
wm.wm.protobuf.ChallengerCar.create({
|
||||||
|
car: carTarget!,
|
||||||
|
stamp: challengers.stamp,
|
||||||
|
result: challengers.result,
|
||||||
|
area: challengers.area
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
car: {
|
car: {
|
||||||
...car!
|
...car!,
|
||||||
},
|
},
|
||||||
tuningPoint: car!.tuningPoints,
|
tuningPoint: car!.tuningPoints,
|
||||||
setting: car!.settings,
|
setting: car!.settings,
|
||||||
vsStarCountMax: car!.vsStarCount,
|
|
||||||
rgPreviousVersionPlayCount: 0,
|
rgPreviousVersionPlayCount: 0,
|
||||||
stCompleted_100Episodes: car!.stCompleted100Episodes,
|
stCompleted_100Episodes: car!.stCompleted100Episodes,
|
||||||
auraMotifAutoChange: false,
|
auraMotifAutoChange: false,
|
||||||
@ -199,6 +225,13 @@ export default class CarModule extends Module {
|
|||||||
ownedItems: car!.items,
|
ownedItems: car!.items,
|
||||||
lastPlayedAt: car!.lastPlayedAt,
|
lastPlayedAt: car!.lastPlayedAt,
|
||||||
announceEventModePrize: true,
|
announceEventModePrize: true,
|
||||||
|
|
||||||
|
// Stamp or Challenger
|
||||||
|
challenger: carsChallengers[0] || null,
|
||||||
|
challengerReturnCount: returnCount || null,
|
||||||
|
numOfChallengers: carsChallengers.length || null,
|
||||||
|
|
||||||
|
// OCM Challenge Top 1
|
||||||
opponentGhost: ghostCarsNo1 || null,
|
opponentGhost: ghostCarsNo1 || null,
|
||||||
opponentTrailId: trailIdNo1 || null,
|
opponentTrailId: trailIdNo1 || null,
|
||||||
opponentCompetitionId: ocmEventDate?.competitionId || null
|
opponentCompetitionId: ocmEventDate?.competitionId || null
|
||||||
@ -396,6 +429,7 @@ export default class CarModule extends Module {
|
|||||||
carGTWingDbId: gtWing.dbId,
|
carGTWingDbId: gtWing.dbId,
|
||||||
regionId: randomRegionId,
|
regionId: randomRegionId,
|
||||||
lastPlayedAt: date,
|
lastPlayedAt: date,
|
||||||
|
lastPlayedPlaceId: 1, // Server Default
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if user have more than one cars
|
// Check if user have more than one cars
|
||||||
@ -528,6 +562,9 @@ export default class CarModule extends Module {
|
|||||||
// Car is set
|
// Car is set
|
||||||
if (cars)
|
if (cars)
|
||||||
{
|
{
|
||||||
|
// Get current date
|
||||||
|
let date = Math.floor(new Date().getTime() / 1000);
|
||||||
|
|
||||||
// Car update data
|
// Car update data
|
||||||
data = {
|
data = {
|
||||||
customColor: common.sanitizeInput(cars.customColor),
|
customColor: common.sanitizeInput(cars.customColor),
|
||||||
@ -548,6 +585,7 @@ export default class CarModule extends Module {
|
|||||||
aura: common.sanitizeInput(cars.aura),
|
aura: common.sanitizeInput(cars.aura),
|
||||||
auraMotif: common.sanitizeInput(cars.auraMotif),
|
auraMotif: common.sanitizeInput(cars.auraMotif),
|
||||||
rgStamp: common.sanitizeInput(body.rgStamp),
|
rgStamp: common.sanitizeInput(body.rgStamp),
|
||||||
|
lastPlayed: date
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the car info
|
// Update the car info
|
||||||
@ -566,7 +604,8 @@ export default class CarModule extends Module {
|
|||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
settings: true,
|
settings: true,
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import * as wm from "../wmmt/wm.proto";
|
|||||||
|
|
||||||
// Import Util
|
// Import Util
|
||||||
import * as common from "../util/common";
|
import * as common from "../util/common";
|
||||||
import * as meter_reward from "../util/meter_reward";
|
import * as meter_reward from "../util/games/meter_reward";
|
||||||
import * as story from "../util/games/story";
|
import * as story from "../util/games/story";
|
||||||
import * as time_attack from "../util/games/time_attack";
|
import * as time_attack from "../util/games/time_attack";
|
||||||
import * as ghost from "../util/games/ghost";
|
import * as ghost from "../util/games/ghost";
|
||||||
@ -73,8 +73,9 @@ export default class GameModule extends Module {
|
|||||||
// Set this to tell the server if user is playing ghost battle mode
|
// Set this to tell the server if user is playing ghost battle mode
|
||||||
ghostModePlay = ghostReturn.ghostModePlay;
|
ghostModePlay = ghostReturn.ghostModePlay;
|
||||||
|
|
||||||
// For OCM Ghost Batle Mode
|
// For OCM : Disable update trail if current advantage distance record is not better than previous advantage distance record
|
||||||
// Disable update trail if current advantage distance record is not better than previous advantage distance record
|
// For Crown : Disable update trail if lose
|
||||||
|
// Ghost Battle will return true
|
||||||
updateNewTrail = ghostReturn.updateNewTrail;
|
updateNewTrail = ghostReturn.updateNewTrail;
|
||||||
|
|
||||||
// Check if user playing OCM Ghost Battle Mode
|
// Check if user playing OCM Ghost Battle Mode
|
||||||
@ -88,7 +89,7 @@ export default class GameModule extends Module {
|
|||||||
case wm.wm.protobuf.GameMode.MODE_VS_BATTLE:
|
case wm.wm.protobuf.GameMode.MODE_VS_BATTLE:
|
||||||
{
|
{
|
||||||
// Calling save vs battle result function (BASE_PATH/src/util/games/versus.ts)
|
// Calling save vs battle result function (BASE_PATH/src/util/games/versus.ts)
|
||||||
await versus.saveVersusBattleResult(body);
|
await versus.saveVersusBattleResult(body, car);
|
||||||
|
|
||||||
// Break the switch case
|
// Break the switch case
|
||||||
break;
|
break;
|
||||||
@ -167,7 +168,8 @@ export default class GameModule extends Module {
|
|||||||
tuneHandling: body.car!.tuneHandling!,
|
tuneHandling: body.car!.tuneHandling!,
|
||||||
windowSticker: body.car!.windowSticker!,
|
windowSticker: body.car!.windowSticker!,
|
||||||
lastPlayedAt: timestamps,
|
lastPlayedAt: timestamps,
|
||||||
regionId: body.car!.regionId!
|
regionId: body.car!.regionId!,
|
||||||
|
rgStamp: common.sanitizeInputNotZero(body.rgResult?.rgStamp)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -269,7 +271,7 @@ export default class GameModule extends Module {
|
|||||||
msg = {
|
msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS
|
||||||
|
|
||||||
// No session for saving ghost trail (not playing Ghost Battle Mode)
|
// No session for saving ghost trail (not playing Ghost Battle Mode / Retiring)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,15 +542,19 @@ export default class GameModule extends Module {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get current date
|
||||||
|
let date = Math.floor(new Date().getTime() / 1000);
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
taRecords: ta_records,
|
taRecords: ta_records,
|
||||||
taRankingUpdatedAt: 1,
|
taRankingUpdatedAt: date,
|
||||||
ghostHistory: list_ghostHistoryData,
|
ghostHistory: list_ghostHistoryData,
|
||||||
ghostBattleCount: car!.rgPlayCount,
|
ghostBattleCount: car!.rgPlayCount,
|
||||||
ghostBattleWinCount: car!.rgWinCount,
|
ghostBattleWinCount: car!.rgWinCount,
|
||||||
stampSheetCount: 0,
|
stampSheetCount: car!.stampSheetCount,
|
||||||
|
stampSheet: car!.stampSheet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode the response
|
// Encode the response
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Application } from "express";
|
import { Application } from "express";
|
||||||
import { Module } from "module";
|
import { Module } from "module";
|
||||||
import { prisma } from "..";
|
import { prisma } from "..";
|
||||||
import { CarPathandTuning, GhostTrail } from "@prisma/client";
|
import { CarPathandTuning } from "@prisma/client";
|
||||||
import Long from "long";
|
import Long from "long";
|
||||||
|
import { Config } from "../config";
|
||||||
|
|
||||||
// Import Proto
|
// Import Proto
|
||||||
import * as wm from "../wmmt/wm.proto";
|
import * as wm from "../wmmt/wm.proto";
|
||||||
@ -10,8 +11,8 @@ import * as wmsrv from "../wmmt/service.proto";
|
|||||||
|
|
||||||
// Import Util
|
// Import Util
|
||||||
import * as common from "../util/common";
|
import * as common from "../util/common";
|
||||||
import * as ghost_save_trail from "../util/games/ghost_save_trail";
|
import * as ghost_save_trail from "../util/ghost/ghost_save_trail";
|
||||||
import * as ghost_trail from "../util/games/ghost_trail";
|
import * as ghost_trail from "../util/ghost/ghost_trail";
|
||||||
|
|
||||||
|
|
||||||
export default class GhostModule extends Module {
|
export default class GhostModule extends Module {
|
||||||
@ -20,6 +21,15 @@ export default class GhostModule extends Module {
|
|||||||
// Load Ghost Battle Info
|
// Load Ghost Battle Info
|
||||||
app.post('/method/load_ghost_battle_info', async (req, res) => {
|
app.post('/method/load_ghost_battle_info', async (req, res) => {
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// ---For testing only---
|
// ---For testing only---
|
||||||
let cars = await prisma.car.findMany({
|
let cars = await prisma.car.findMany({
|
||||||
where: {
|
where: {
|
||||||
@ -33,7 +43,8 @@ export default class GhostModule extends Module {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
include:{
|
include:{
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
carId: 'asc'
|
carId: 'asc'
|
||||||
@ -41,21 +52,73 @@ export default class GhostModule extends Module {
|
|||||||
take: 10
|
take: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
for(let i=0; i<cars.length; i++)
|
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: {
|
||||||
|
stampTargetCarId: body.carId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(stampTargets)
|
||||||
{
|
{
|
||||||
// If regionId is 0 or not set, game will crash after defeating the ghost
|
for(let i=0; i<stampTargets.length; i++)
|
||||||
if(cars[i].regionId === 0)
|
|
||||||
{
|
{
|
||||||
let randomRegionId = Math.floor(Math.random() * 47) + 1;
|
let carTarget = await prisma.car.findFirst({
|
||||||
cars[i].regionId = randomRegionId;
|
where:{
|
||||||
|
carId: stampTargets[i].carId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
carsStamp.push(
|
||||||
|
wm.wm.protobuf.StampTargetCar.create({
|
||||||
|
car: carTarget!,
|
||||||
|
returnCount: stampTargets[i].returnCount,
|
||||||
|
locked: stampTargets[i].locked,
|
||||||
|
recommended: stampTargets[i].recommended
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all of the friend cars for the carId provided
|
||||||
|
let challengers = await prisma.carChallenger.findMany({
|
||||||
|
where: {
|
||||||
|
challengerCarId: body.carId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(challengers)
|
||||||
|
{
|
||||||
|
for(let i=0; i<challengers.length; i++)
|
||||||
|
{
|
||||||
|
let carTarget = await prisma.car.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: challengers[i].carId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
carsChallenger.push(
|
||||||
|
wm.wm.protobuf.ChallengerCar.create({
|
||||||
|
car: carTarget!,
|
||||||
|
stamp: challengers[i].stamp,
|
||||||
|
result: challengers[i].result,
|
||||||
|
area: challengers[i].area
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----------------------
|
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
stampSheetCount: 100,
|
stampTargetCars: carsStamp,
|
||||||
|
challengers: carsChallenger,
|
||||||
|
stampSheetCount: car!.stampSheetCount,
|
||||||
|
stampSheet: car?.stampSheet || null,
|
||||||
|
stampReturnStats: car?.stampSheet || null,
|
||||||
history: cars || null,
|
history: cars || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,14 +134,72 @@ export default class GhostModule extends Module {
|
|||||||
app.post('/method/load_stamp_target', async (req, res) => {
|
app.post('/method/load_stamp_target', async (req, res) => {
|
||||||
|
|
||||||
// Get the request body for the load stamp target request
|
// 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
|
let carsStamp: wm.wm.protobuf.StampTargetCar[] = [];
|
||||||
// This is literally just bare-bones
|
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<stampTargets.length; i++)
|
||||||
|
{
|
||||||
|
let carTarget = await prisma.car.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: stampTargets[i].stampTargetCarId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
carsStamp.push(
|
||||||
|
wm.wm.protobuf.StampTargetCar.create({
|
||||||
|
car: carTarget!,
|
||||||
|
returnCount: stampTargets[i].returnCount,
|
||||||
|
locked: stampTargets[i].locked,
|
||||||
|
recommended: stampTargets[i].recommended
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all of the friend cars for the carId provided
|
||||||
|
let challengers = await prisma.carChallenger.findMany({
|
||||||
|
where: {
|
||||||
|
carId: body.carId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(stampTargets)
|
||||||
|
{
|
||||||
|
for(let i=0; i<challengers.length; i++)
|
||||||
|
{
|
||||||
|
let carTarget = await prisma.car.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: challengers[i].challengerCarId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
carsChallenger.push(
|
||||||
|
wm.wm.protobuf.ChallengerCar.create({
|
||||||
|
car: carTarget!,
|
||||||
|
stamp: challengers[i].stamp,
|
||||||
|
result: challengers[i].result,
|
||||||
|
area: challengers[i].area
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
|
cars: carsStamp,
|
||||||
|
challengers: carsChallenger
|
||||||
};
|
};
|
||||||
|
|
||||||
// Encode the response
|
// Encode the response
|
||||||
@ -101,7 +222,8 @@ export default class GhostModule extends Module {
|
|||||||
ghostLevel: body.ghostLevel
|
ghostLevel: body.ghostLevel
|
||||||
},
|
},
|
||||||
include:{
|
include:{
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -185,8 +307,8 @@ export default class GhostModule extends Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Choose the user's car data randomly to appear
|
// Choose the user's car data randomly to appear
|
||||||
while(arr.length < maxNumber){
|
while(arr.length < maxNumber)
|
||||||
|
{
|
||||||
// Pick random car Id
|
// Pick random car Id
|
||||||
let randomNumber: number = Math.floor(Math.random() * car.length);
|
let randomNumber: number = Math.floor(Math.random() * car.length);
|
||||||
if(arr.indexOf(randomNumber) === -1){
|
if(arr.indexOf(randomNumber) === -1){
|
||||||
@ -269,8 +391,8 @@ export default class GhostModule extends Module {
|
|||||||
let lists_ghostcar: wm.wm.protobuf.LoadGhostDriveDataResponse.GhostDriveData[] = [];
|
let lists_ghostcar: wm.wm.protobuf.LoadGhostDriveDataResponse.GhostDriveData[] = [];
|
||||||
|
|
||||||
// Check how many opponent ghost data available (including user data)
|
// Check how many opponent ghost data available (including user data)
|
||||||
for(let i=0; i<body.carTunings.length; i++){
|
for(let i=0; i<body.carTunings.length; i++)
|
||||||
|
{
|
||||||
// Check if opponent ghost have trail
|
// Check if opponent ghost have trail
|
||||||
let ghost_trails = await prisma.ghostTrail.findFirst({
|
let ghost_trails = await prisma.ghostTrail.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@ -568,7 +690,7 @@ export default class GhostModule extends Module {
|
|||||||
carId: body.selectedCars[i],
|
carId: body.selectedCars[i],
|
||||||
tunePower: pathAndTuning!.tunePower,
|
tunePower: pathAndTuning!.tunePower,
|
||||||
tuneHandling: pathAndTuning!.tuneHandling,
|
tuneHandling: pathAndTuning!.tuneHandling,
|
||||||
lastPlayedAt: pathAndTuning!.lastPlayedAt
|
lastPlayedAt: pathAndTuning!.lastPlayedAt,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// Opponent ghost doesn't have path and tuning record for certain area
|
// Opponent ghost doesn't have path and tuning record for certain area
|
||||||
@ -577,7 +699,7 @@ export default class GhostModule extends Module {
|
|||||||
// Get user's car last used tunePower and tuneHandling
|
// Get user's car last used tunePower and tuneHandling
|
||||||
let car = await prisma.car.findFirst({
|
let car = await prisma.car.findFirst({
|
||||||
where: {
|
where: {
|
||||||
carId: body.carId
|
carId: body.selectedCars[i]
|
||||||
},
|
},
|
||||||
select:{
|
select:{
|
||||||
tunePower: true,
|
tunePower: true,
|
||||||
@ -636,37 +758,5 @@ export default class GhostModule extends Module {
|
|||||||
// Send the response to the client
|
// Send the response to the client
|
||||||
common.sendResponse(message, res);
|
common.sendResponse(message, res);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
app.post('/method/lock_stamp_target', async (req, res) => {
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,8 +9,8 @@ import * as wm from "../wmmt/wm.proto";
|
|||||||
|
|
||||||
// Import Util
|
// Import Util
|
||||||
import * as common from "../util/common";
|
import * as common from "../util/common";
|
||||||
import * as ghost_ocm from "../util/games/ghost_ocm";
|
import * as ghost_ocm from "../util/ghost/ghost_ocm";
|
||||||
import * as ghost_ocm_area from "../util/games/games_util/ghost_ocm_area";
|
import * as ghost_ocm_area from "../util/ghost/ghost_ocm_area";
|
||||||
|
|
||||||
|
|
||||||
export default class GhostModule extends Module {
|
export default class GhostModule extends Module {
|
||||||
@ -28,29 +28,11 @@ export default class GhostModule extends Module {
|
|||||||
// Get currently active OCM event (query still not complete)
|
// Get currently active OCM event (query still not complete)
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy:{
|
orderBy:{
|
||||||
dbId: 'desc'
|
dbId: 'desc'
|
||||||
@ -417,35 +399,13 @@ export default class GhostModule extends Module {
|
|||||||
// Get currently active OCM event
|
// Get currently active OCM event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
competitionId: competition_id,
|
competitionId: competition_id,
|
||||||
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy:{
|
orderBy:{
|
||||||
dbId: 'desc'
|
dbId: 'desc'
|
||||||
@ -471,10 +431,10 @@ export default class GhostModule extends Module {
|
|||||||
let ghostTypes;
|
let ghostTypes;
|
||||||
let cars: wm.wm.protobuf.ICar | (Car & { gtWing: CarGTWing; }) | null;
|
let cars: wm.wm.protobuf.ICar | (Car & { gtWing: CarGTWing; }) | null;
|
||||||
let playedPlace = wm.wm.protobuf.Place.create({
|
let playedPlace = wm.wm.protobuf.Place.create({
|
||||||
placeId: 'JPN0123',
|
placeId: Config.getConfig().placeId,
|
||||||
|
regionId: Config.getConfig().regionId,
|
||||||
shopName: Config.getConfig().shopName,
|
shopName: Config.getConfig().shopName,
|
||||||
regionId: 18,
|
country: Config.getConfig().country
|
||||||
country: 'JPN'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get default trail id
|
// Get default trail id
|
||||||
@ -520,7 +480,8 @@ export default class GhostModule extends Module {
|
|||||||
carId: checkGhostTrail!.carId
|
carId: checkGhostTrail!.carId
|
||||||
},
|
},
|
||||||
include:{
|
include:{
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -594,7 +555,8 @@ export default class GhostModule extends Module {
|
|||||||
title: 'Don\'t have S660?',
|
title: 'Don\'t have S660?',
|
||||||
level: 65, // SSSSS
|
level: 65, // SSSSS
|
||||||
lastPlayedAt: checkGhostTrail!.playedAt,
|
lastPlayedAt: checkGhostTrail!.playedAt,
|
||||||
country: 'GLB'
|
country: 'IDN',
|
||||||
|
lastPlayedPlace: playedPlace
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set Ghost stuff Value
|
// Set Ghost stuff Value
|
||||||
@ -603,7 +565,8 @@ export default class GhostModule extends Module {
|
|||||||
}
|
}
|
||||||
else if(ocmEventDate!.competitionCloseAt < date && ocmEventDate!.competitionEndAt > date)
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -644,7 +607,8 @@ export default class GhostModule extends Module {
|
|||||||
carId: checkGhostTrail!.carId
|
carId: checkGhostTrail!.carId
|
||||||
},
|
},
|
||||||
include:{
|
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
|
// Push the Top 1 OCM ghost car data
|
||||||
ghostCars = wm.wm.protobuf.GhostCar.create({
|
ghostCars = wm.wm.protobuf.GhostCar.create({
|
||||||
car: {
|
car: cars!,
|
||||||
...cars!,
|
|
||||||
lastPlayedPlace: playedPlace
|
|
||||||
},
|
|
||||||
area: areaVal,
|
area: areaVal,
|
||||||
ramp: rampVal,
|
ramp: rampVal,
|
||||||
path: pathVal,
|
path: pathVal,
|
||||||
|
495
src/modules/resource.ts
Normal file
495
src/modules/resource.ts
Normal file
@ -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<ta_time.length; j++){
|
||||||
|
|
||||||
|
// Get the car data
|
||||||
|
let car_ta = await prisma.car.findFirst({
|
||||||
|
where: {
|
||||||
|
carId: ta_time[j].carId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Push the data to the ranking data
|
||||||
|
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: ta_time[j].carId,
|
||||||
|
rank: car_ta!.level,
|
||||||
|
result: ta_time[j].time,
|
||||||
|
name: car_ta!.name,
|
||||||
|
regionId: car_ta!.regionId,
|
||||||
|
model: car_ta!.model,
|
||||||
|
visualModel: car_ta!.visualModel,
|
||||||
|
defaultColor: car_ta!.defaultColor,
|
||||||
|
tunePower: ta_time[j].tunePower, // Set the tunePower used when playing TA
|
||||||
|
tuneHandling: ta_time[j].tuneHandling, // Set the tuneHandling used when playing TA
|
||||||
|
title: car_ta!.title,
|
||||||
|
level: car_ta!.level
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the TA time record by user is less than 10 user
|
||||||
|
if(ta_time.length < 11){
|
||||||
|
|
||||||
|
// Take the remaining unfilled
|
||||||
|
for(let j=ta_time.length; j<11; j++){
|
||||||
|
let resultTime = 599999; // 9:59:999 time
|
||||||
|
|
||||||
|
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
|
||||||
|
if(i === 22 || i === 23){
|
||||||
|
resultTime = 1199999; // 19:59:999 time
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push the data to the ranking data
|
||||||
|
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: 0,
|
||||||
|
rank: 0,
|
||||||
|
result: resultTime,
|
||||||
|
name: 'GUEST',
|
||||||
|
regionId: 1, // Hokkaido
|
||||||
|
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
||||||
|
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
||||||
|
defaultColor: 0,
|
||||||
|
tunePower: 0,
|
||||||
|
tuneHandling: 0,
|
||||||
|
title: 'Wangan Beginner', // 湾岸の新人
|
||||||
|
level: 0 // N
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
||||||
|
rankingType: i, // RANKING_TA_*AREA*
|
||||||
|
topRecords: list_ta
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
// There is no user's TA record for certain area
|
||||||
|
else{
|
||||||
|
|
||||||
|
// Empty list of ranking records for GUEST time attack
|
||||||
|
let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = [];
|
||||||
|
|
||||||
|
// Generate the top 10 GUEST TA time data
|
||||||
|
for(let j=0; j<11; j++){
|
||||||
|
let resulttime = 599999; // 9:59:999 time
|
||||||
|
|
||||||
|
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
|
||||||
|
if(i === 22 || i === 23){
|
||||||
|
resulttime = 1199999 // 19:59:999 time
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push the GUEST data to the ranking data
|
||||||
|
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: 0,
|
||||||
|
rank: 0,
|
||||||
|
result: resulttime,
|
||||||
|
name: 'GUEST',
|
||||||
|
regionId: 1, // Hokkaido
|
||||||
|
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
||||||
|
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
||||||
|
defaultColor: 0,
|
||||||
|
tunePower: 0,
|
||||||
|
tuneHandling: 0,
|
||||||
|
title: 'Wangan Beginner', // 湾岸の新人
|
||||||
|
level: 0 // N
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push the certain area ranking data to the list
|
||||||
|
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
||||||
|
rankingType: i, // RANKING_TA_*AREA*
|
||||||
|
topRecords: list_ta // Top 10 TA time record data
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get VS Star Ranking
|
||||||
|
// Get the user's VS Stars data
|
||||||
|
let car_vs = await prisma.car.findMany({
|
||||||
|
orderBy: {
|
||||||
|
vsStarCount: 'desc'
|
||||||
|
},
|
||||||
|
take: 20, // Take top 20
|
||||||
|
});
|
||||||
|
|
||||||
|
// Empty list of ranking records for VS Stars
|
||||||
|
let list_vs: wmsrv.wm.protobuf.Ranking.Entry[] = [];
|
||||||
|
|
||||||
|
// Get the VS stars data
|
||||||
|
for(let i=0; i<car_vs.length; i++){
|
||||||
|
|
||||||
|
// Push the car data to the ranking data
|
||||||
|
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: car_vs[i].carId,
|
||||||
|
rank: car_vs[i].level,
|
||||||
|
result: car_vs[i].vsStarCount,
|
||||||
|
name: car_vs[i].name,
|
||||||
|
regionId: car_vs[i].regionId,
|
||||||
|
model: car_vs[i].model,
|
||||||
|
visualModel: car_vs[i].visualModel,
|
||||||
|
defaultColor: car_vs[i].defaultColor,
|
||||||
|
tunePower: car_vs[i].tunePower,
|
||||||
|
tuneHandling: car_vs[i].tuneHandling,
|
||||||
|
title: car_vs[i].title,
|
||||||
|
level: car_vs[i].level
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the VS stars record by user is less than 20 user
|
||||||
|
if(car_vs.length < 20){
|
||||||
|
|
||||||
|
// Take the remaining unfilled
|
||||||
|
for(let j=car_vs.length; j<21; j++){
|
||||||
|
|
||||||
|
// Push the GUEST data to the ranking data
|
||||||
|
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: 0,
|
||||||
|
rank: 0,
|
||||||
|
result: 0,
|
||||||
|
name: 'GUEST',
|
||||||
|
regionId: 1, // Hokkaido
|
||||||
|
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
||||||
|
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
||||||
|
defaultColor: 0,
|
||||||
|
tunePower: 0,
|
||||||
|
tuneHandling: 0,
|
||||||
|
title: 'Wangan Beginner', // 湾岸の新人
|
||||||
|
level: 0 // N
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push the data
|
||||||
|
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
||||||
|
rankingType: 100, // RANKING_VS_STAR
|
||||||
|
topRecords: list_vs // Top 20 VS stars record data
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
// Get Ghost Defeated Ranking
|
||||||
|
// Get the user's Ghost Win data
|
||||||
|
let car_ghost = await prisma.car.findMany({
|
||||||
|
orderBy: {
|
||||||
|
rgWinCount: 'desc'
|
||||||
|
},
|
||||||
|
take: 20, // Take top 20
|
||||||
|
});
|
||||||
|
|
||||||
|
// Empty list of ranking records for Ghost Battle Win
|
||||||
|
let list_ghost: wmsrv.wm.protobuf.Ranking.Entry[] = [];
|
||||||
|
|
||||||
|
// Get the Ghost Battle Win data
|
||||||
|
for(let i=0; i<car_ghost.length; i++){
|
||||||
|
|
||||||
|
// Push the car data to the ranking data
|
||||||
|
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: car_ghost[i].carId,
|
||||||
|
rank: car_ghost[i].level,
|
||||||
|
result: car_ghost[i].rgWinCount,
|
||||||
|
name: car_ghost[i].name,
|
||||||
|
regionId: car_ghost[i].regionId,
|
||||||
|
model: car_ghost[i].model,
|
||||||
|
visualModel: car_ghost[i].visualModel,
|
||||||
|
defaultColor: car_ghost[i].defaultColor,
|
||||||
|
tunePower: car_ghost[i].tunePower,
|
||||||
|
tuneHandling: car_ghost[i].tuneHandling,
|
||||||
|
title: car_ghost[i].title,
|
||||||
|
level: car_ghost[i].level
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the Ghost Win record by user is less than 20 user
|
||||||
|
if(car_ghost.length < 20){
|
||||||
|
|
||||||
|
// Take the remaining unfilled
|
||||||
|
for(let j=car_ghost.length; j<21; j++){
|
||||||
|
|
||||||
|
// Push the GUEST data to the ranking data
|
||||||
|
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
||||||
|
carId: 0,
|
||||||
|
rank: 0,
|
||||||
|
result: 0,
|
||||||
|
name: 'GUEST',
|
||||||
|
regionId: 1, // Hokkaido
|
||||||
|
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
||||||
|
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
||||||
|
defaultColor: 0,
|
||||||
|
tunePower: 0,
|
||||||
|
tuneHandling: 0,
|
||||||
|
title: 'Wangan Beginner', // 湾岸の新人
|
||||||
|
level: 0 // N
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push the data
|
||||||
|
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
||||||
|
rankingType: 101, // RANKING_GHOST_DEFEATED_COUNT
|
||||||
|
topRecords: list_ghost // Top 20 Ghost Win record data
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Encode the response
|
||||||
|
let message = wmsrv.wm.protobuf.Ranking.encode({lists});
|
||||||
|
|
||||||
|
// Send the response to the client
|
||||||
|
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,
|
||||||
|
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);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,9 @@
|
|||||||
import { Application } from "express";
|
import { Application } from "express";
|
||||||
import {Module} from "module";
|
import {Module} from "module";
|
||||||
import { Config } from "../config";
|
|
||||||
import { prisma } from "..";
|
import { prisma } from "..";
|
||||||
|
|
||||||
// Import Proto
|
// Import Proto
|
||||||
import * as wm from "../wmmt/wm.proto";
|
import * as wm from "../wmmt/wm.proto";
|
||||||
import * as wmsrv from "../wmmt/service.proto";
|
|
||||||
|
|
||||||
// Import Util
|
// Import Util
|
||||||
import * as common from "../util/common";
|
import * as common from "../util/common";
|
||||||
@ -26,29 +24,11 @@ export default class StartupModule extends Module {
|
|||||||
// Get current / previous active OCM Event
|
// Get current / previous active OCM Event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{
|
{
|
||||||
@ -154,295 +134,31 @@ export default class StartupModule extends Module {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// Place List
|
// Update Event Mode Serial
|
||||||
app.get('/resource/place_list', (req, res) => {
|
app.post('/method/update_user_session', (req, res) => {
|
||||||
console.log('place list');
|
|
||||||
|
|
||||||
// Empty list of place records
|
let body = wm.wm.protobuf.UpdateUserSessionRequest.decode(req.body);
|
||||||
let places: wm.wm.protobuf.Place[] = [];
|
|
||||||
|
// TODO: Actual stuff here
|
||||||
|
// This is literally just bare-bones so the shit boots
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
places.push(new wm.wm.protobuf.Place({
|
let msg = {
|
||||||
placeId: "JPN0123",
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
regionId: 1,
|
}
|
||||||
shopName: Config.getConfig().shopName,
|
|
||||||
country: "JPN"
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Encode the response
|
// Generate the response message
|
||||||
let message = wm.wm.protobuf.PlaceList.encode({places});
|
let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg);
|
||||||
|
|
||||||
// Send the response to the client
|
// Send the response to the client
|
||||||
common.sendResponse(message, res);
|
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<ta_time.length; j++){
|
|
||||||
|
|
||||||
// Get the car data
|
|
||||||
let car_ta = await prisma.car.findFirst({
|
|
||||||
where: {
|
|
||||||
carId: ta_time[j].carId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Push the data to the ranking data
|
|
||||||
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: ta_time[j].carId,
|
|
||||||
rank: car_ta!.level,
|
|
||||||
result: ta_time[j].time,
|
|
||||||
name: car_ta!.name,
|
|
||||||
regionId: car_ta!.regionId,
|
|
||||||
model: car_ta!.model,
|
|
||||||
visualModel: car_ta!.visualModel,
|
|
||||||
defaultColor: car_ta!.defaultColor,
|
|
||||||
tunePower: ta_time[j].tunePower, // Set the tunePower used when playing TA
|
|
||||||
tuneHandling: ta_time[j].tuneHandling, // Set the tuneHandling used when playing TA
|
|
||||||
title: car_ta!.title,
|
|
||||||
level: car_ta!.level
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the TA time record by user is less than 10 user
|
|
||||||
if(ta_time.length < 11){
|
|
||||||
|
|
||||||
// Take the remaining unfilled
|
|
||||||
for(let j=ta_time.length; j<11; j++){
|
|
||||||
let resultTime = 599999; // 9:59:999 time
|
|
||||||
|
|
||||||
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
|
|
||||||
if(i === 22 || i === 23){
|
|
||||||
resultTime = 1199999; // 19:59:999 time
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push the data to the ranking data
|
|
||||||
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: 0,
|
|
||||||
rank: 0,
|
|
||||||
result: resultTime,
|
|
||||||
name: 'GUEST',
|
|
||||||
regionId: 1, // Hokkaido
|
|
||||||
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
|
||||||
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
|
||||||
defaultColor: 0,
|
|
||||||
tunePower: 0,
|
|
||||||
tuneHandling: 0,
|
|
||||||
title: 'Wangan Beginner', // 湾岸の新人
|
|
||||||
level: 0 // N
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
|
||||||
rankingType: i, // RANKING_TA_*AREA*
|
|
||||||
topRecords: list_ta
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
// There is no user's TA record for certain area
|
|
||||||
else{
|
|
||||||
|
|
||||||
// Empty list of ranking records for GUEST time attack
|
|
||||||
let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = [];
|
|
||||||
|
|
||||||
// Generate the top 10 GUEST TA time data
|
|
||||||
for(let j=0; j<11; j++){
|
|
||||||
let resulttime = 599999; // 9:59:999 time
|
|
||||||
|
|
||||||
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
|
|
||||||
if(i === 22 || i === 23){
|
|
||||||
resulttime = 1199999 // 19:59:999 time
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push the GUEST data to the ranking data
|
|
||||||
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: 0,
|
|
||||||
rank: 0,
|
|
||||||
result: resulttime,
|
|
||||||
name: 'GUEST',
|
|
||||||
regionId: 1, // Hokkaido
|
|
||||||
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
|
||||||
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
|
||||||
defaultColor: 0,
|
|
||||||
tunePower: 0,
|
|
||||||
tuneHandling: 0,
|
|
||||||
title: 'Wangan Beginner', // 湾岸の新人
|
|
||||||
level: 0 // N
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push the certain area ranking data to the list
|
|
||||||
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
|
||||||
rankingType: i, // RANKING_TA_*AREA*
|
|
||||||
topRecords: list_ta // Top 10 TA time record data
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Get VS Star Ranking
|
|
||||||
// Get the user's VS Stars data
|
|
||||||
let car_vs = await prisma.car.findMany({
|
|
||||||
orderBy: {
|
|
||||||
vsStarCount: 'desc'
|
|
||||||
},
|
|
||||||
take: 20, // Take top 20
|
|
||||||
});
|
|
||||||
|
|
||||||
// Empty list of ranking records for VS Stars
|
|
||||||
let list_vs: wmsrv.wm.protobuf.Ranking.Entry[] = [];
|
|
||||||
|
|
||||||
// Get the VS stars data
|
|
||||||
for(let i=0; i<car_vs.length; i++){
|
|
||||||
|
|
||||||
// Push the car data to the ranking data
|
|
||||||
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: car_vs[i].carId,
|
|
||||||
rank: car_vs[i].level,
|
|
||||||
result: car_vs[i].vsStarCount,
|
|
||||||
name: car_vs[i].name,
|
|
||||||
regionId: car_vs[i].regionId,
|
|
||||||
model: car_vs[i].model,
|
|
||||||
visualModel: car_vs[i].visualModel,
|
|
||||||
defaultColor: car_vs[i].defaultColor,
|
|
||||||
tunePower: car_vs[i].tunePower,
|
|
||||||
tuneHandling: car_vs[i].tuneHandling,
|
|
||||||
title: car_vs[i].title,
|
|
||||||
level: car_vs[i].level
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the VS stars record by user is less than 20 user
|
|
||||||
if(car_vs.length < 20){
|
|
||||||
|
|
||||||
// Take the remaining unfilled
|
|
||||||
for(let j=car_vs.length; j<21; j++){
|
|
||||||
|
|
||||||
// Push the GUEST data to the ranking data
|
|
||||||
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: 0,
|
|
||||||
rank: 0,
|
|
||||||
result: 0,
|
|
||||||
name: 'GUEST',
|
|
||||||
regionId: 1, // Hokkaido
|
|
||||||
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
|
||||||
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
|
||||||
defaultColor: 0,
|
|
||||||
tunePower: 0,
|
|
||||||
tuneHandling: 0,
|
|
||||||
title: 'Wangan Beginner', // 湾岸の新人
|
|
||||||
level: 0 // N
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push the data
|
|
||||||
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
|
||||||
rankingType: 100, // RANKING_VS_STAR
|
|
||||||
topRecords: list_vs // Top 20 VS stars record data
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
// Get Ghost Defeated Ranking
|
|
||||||
// Get the user's Ghost Win data
|
|
||||||
let car_ghost = await prisma.car.findMany({
|
|
||||||
orderBy: {
|
|
||||||
rgWinCount: 'desc'
|
|
||||||
},
|
|
||||||
take: 20, // Take top 20
|
|
||||||
});
|
|
||||||
|
|
||||||
// Empty list of ranking records for Ghost Battle Win
|
|
||||||
let list_ghost: wmsrv.wm.protobuf.Ranking.Entry[] = [];
|
|
||||||
|
|
||||||
// Get the Ghost Battle Win data
|
|
||||||
for(let i=0; i<car_ghost.length; i++){
|
|
||||||
|
|
||||||
// Push the car data to the ranking data
|
|
||||||
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: car_ghost[i].carId,
|
|
||||||
rank: car_ghost[i].level,
|
|
||||||
result: car_ghost[i].rgWinCount,
|
|
||||||
name: car_ghost[i].name,
|
|
||||||
regionId: car_ghost[i].regionId,
|
|
||||||
model: car_ghost[i].model,
|
|
||||||
visualModel: car_ghost[i].visualModel,
|
|
||||||
defaultColor: car_ghost[i].defaultColor,
|
|
||||||
tunePower: car_ghost[i].tunePower,
|
|
||||||
tuneHandling: car_ghost[i].tuneHandling,
|
|
||||||
title: car_ghost[i].title,
|
|
||||||
level: car_ghost[i].level
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the Ghost Win record by user is less than 20 user
|
|
||||||
if(car_ghost.length < 20){
|
|
||||||
|
|
||||||
// Take the remaining unfilled
|
|
||||||
for(let j=car_ghost.length; j<21; j++){
|
|
||||||
|
|
||||||
// Push the GUEST data to the ranking data
|
|
||||||
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
|
|
||||||
carId: 0,
|
|
||||||
rank: 0,
|
|
||||||
result: 0,
|
|
||||||
name: 'GUEST',
|
|
||||||
regionId: 1, // Hokkaido
|
|
||||||
model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data
|
|
||||||
visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data
|
|
||||||
defaultColor: 0,
|
|
||||||
tunePower: 0,
|
|
||||||
tuneHandling: 0,
|
|
||||||
title: 'Wangan Beginner', // 湾岸の新人
|
|
||||||
level: 0 // N
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push the data
|
|
||||||
lists.push(new wmsrv.wm.protobuf.Ranking.List({
|
|
||||||
rankingType: 101, // RANKING_GHOST_DEFEATED_COUNT
|
|
||||||
topRecords: list_ghost // Top 20 Ghost Win record data
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Encode the response
|
|
||||||
let message = wmsrv.wm.protobuf.Ranking.encode({lists});
|
|
||||||
|
|
||||||
// Send the response to the client
|
|
||||||
common.sendResponse(message, res);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Ping
|
// Ping
|
||||||
app.post('/method/ping', (req, res) => {
|
app.post('/method/ping', (req, res) => {
|
||||||
|
|
||||||
console.log('ping');
|
console.log('ping');
|
||||||
|
|
||||||
let body = wm.wm.protobuf.PingRequest.decode(req.body);
|
let body = wm.wm.protobuf.PingRequest.decode(req.body);
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
@ -459,162 +175,13 @@ export default class StartupModule extends Module {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// 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) => {
|
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
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
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) => {
|
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
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
|
serialError: wm.wm.protobuf.EventModeSerialErrorCode.SERIAL_NO_INPUT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode the response
|
// Encode the response
|
||||||
@ -642,8 +215,14 @@ export default class StartupModule extends Module {
|
|||||||
common.sendResponse(message, res);
|
common.sendResponse(message, res);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
app.post('/method/submit_client_log', async (req, 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
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
@ -655,20 +234,5 @@ export default class StartupModule extends Module {
|
|||||||
// Send the response to the client
|
// Send the response to the client
|
||||||
common.sendResponse(message, res);
|
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);
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,8 @@ export default class TerminalModule extends Module {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
include:{
|
include:{
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -532,35 +533,11 @@ export default class TerminalModule extends Module {
|
|||||||
// Get current active OCM Event
|
// Get current active OCM Event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
competitionId: body.competitionId,
|
|
||||||
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy:{
|
orderBy:{
|
||||||
dbId: 'desc'
|
dbId: 'desc'
|
||||||
|
@ -30,15 +30,18 @@ export default class UserModule extends Module {
|
|||||||
cars: {
|
cars: {
|
||||||
include: {
|
include: {
|
||||||
state: true,
|
state: true,
|
||||||
gtWing: true
|
gtWing: true,
|
||||||
|
lastPlayedPlace: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// No user returned
|
// No user returned
|
||||||
if (!user) {
|
if (!user)
|
||||||
|
{
|
||||||
console.log('no such user');
|
console.log('no such user');
|
||||||
|
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
numOfOwnedCars: 0,
|
numOfOwnedCars: 0,
|
||||||
@ -46,75 +49,86 @@ export default class UserModule extends Module {
|
|||||||
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
||||||
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED,
|
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED,
|
||||||
};
|
};
|
||||||
if (!body.cardChipId || !body.accessCode) {
|
|
||||||
|
if (!body.cardChipId || !body.accessCode)
|
||||||
|
{
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_ID_BANNED,
|
error: wm.wm.protobuf.ErrorCode.ERR_ID_BANNED,
|
||||||
numOfOwnedCars: 0,
|
numOfOwnedCars: 0,
|
||||||
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
||||||
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED
|
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED
|
||||||
}
|
}
|
||||||
let resp = wm.wm.protobuf.LoadUserResponse.encode(msg);
|
|
||||||
let end = resp.finish();
|
// Encode the response
|
||||||
let r = res
|
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
|
||||||
.header('Server', 'v388 wangan')
|
|
||||||
.header('Content-Type', 'application/x-protobuf; revision=8053')
|
// Send the response to the client
|
||||||
.header('Content-Length', end.length.toString())
|
common.sendResponse(message, res);
|
||||||
.status(200);
|
|
||||||
r.send(Buffer.from(end));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let user = await prisma.user.create({
|
let user = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
chipId: body.cardChipId,
|
chipId: body.cardChipId,
|
||||||
accessCode: body.accessCode,
|
accessCode: body.accessCode,
|
||||||
tutorials: [
|
tutorials: [
|
||||||
false, //TUTORIAL_ID_STORY
|
false, //TUTORIAL_ID_STORY = 0,
|
||||||
false, //TUTORIAL_ID_TIME_ATTACK
|
false, //TUTORIAL_ID_TIME_ATTACK = 1,
|
||||||
false, //TUTORIAL_ID_GHOST
|
false, //TUTORIAL_ID_GHOST = 2,
|
||||||
false, //TUTORIAL_ID_GHOST_CHALLENGE
|
false, //TUTORIAL_ID_GHOST_CHALLENGE = 3,
|
||||||
false, //TUTORIAL_ID_GHOST_LEVEL
|
false, //TUTORIAL_ID_GHOST_LEVEL = 4,
|
||||||
false, //TUTORIAL_ID_UNUSED_5
|
false, //TUTORIAL_ID_UNUSED_5 = 5,
|
||||||
false, //TUTORIAL_ID_GHOST_SEARCH
|
false, //TUTORIAL_ID_GHOST_SEARCH = 6,
|
||||||
false, //TUTORIAL_ID_GHOST_COMPETITION
|
false, //TUTORIAL_ID_GHOST_COMPETITION = 7,
|
||||||
false, //TUTORIAL_ID_HP600_CARD
|
false, //TUTORIAL_ID_HP600_CARD = 8,
|
||||||
false, //TUTORIAL_ID_UNUSED_9
|
false, //TUTORIAL_ID_UNUSED_9 = 9,
|
||||||
false, //TUTORIAL_ID_COMPETITION_QUALIFIED
|
false, //TUTORIAL_ID_COMPETITION_QUALIFIED = 10,
|
||||||
false, //TUTORIAL_ID_COMPETITION_TERMINAL
|
false, //TUTORIAL_ID_COMPETITION_TERMINAL = 11,
|
||||||
false, //TUTORIAL_ID_COMPETITION_NOTICE
|
false, //TUTORIAL_ID_COMPETITION_NOTICE = 12,
|
||||||
false, //TUTORIAL_ID_COMPETITION_FINISHED
|
false, //TUTORIAL_ID_COMPETITION_FINISHED = 13,
|
||||||
false, //TUTORIAL_ID_UNUSED_14
|
false, //TUTORIAL_ID_UNUSED_14 = 14,
|
||||||
false, //TUTORIAL_ID_UNUSED_15
|
false, //TUTORIAL_ID_UNUSED_15 = 15,
|
||||||
false, //TUTORIAL_ID_UNUSED_16
|
false, //TUTORIAL_ID_UNUSED_16 = 16,
|
||||||
false, //TUTORIAL_ID_UNUSED_17
|
false, //TUTORIAL_ID_UNUSED_17 = 17,
|
||||||
false, //TUTORIAL_ID_UNUSED_18
|
false, //TUTORIAL_ID_UNUSED_18 = 18,
|
||||||
false, //TUTORIAL_ID_UNUSED_19
|
false, //TUTORIAL_ID_UNUSED_19 = 19,
|
||||||
false, //TUTORIAL_ID_GHOST_STAMP
|
true, //TUTORIAL_ID_GHOST_STAMP = 20,
|
||||||
false, //TUTORIAL_ID_GHOST_STAMP_DECLINED
|
true, //TUTORIAL_ID_GHOST_STAMP_DECLINED = 21,
|
||||||
false, //TUTORIAL_ID_GHOST_STAMP_FRIENDS
|
true, //TUTORIAL_ID_GHOST_STAMP_FRIENDS = 22,
|
||||||
true, //TUTORIAL_ID_TERMINAL_SCRATCH
|
true, //TUTORIAL_ID_TERMINAL_SCRATCH = 23,
|
||||||
true, //TUTORIAL_ID_TURN_SCRATCH_SHEET
|
true, //TUTORIAL_ID_TURN_SCRATCH_SHEET = 24,
|
||||||
false, //TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN
|
false, //TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN = 25,
|
||||||
false, //TUTORIAL_ID_CAR_COUPON_FULL_TUNED_RECEIVABLE
|
false, //TUTORIAL_ID_CAR_COUPON_FULL_TUNED_RECEIVABLE = 26,
|
||||||
false, //TUTORIAL_ID_VS_CONTINUE_TICKET
|
false, //TUTORIAL_ID_VS_CONTINUE_TICKET = 27,
|
||||||
false, //TUTORIAL_ID_UNUSED_28
|
false, //TUTORIAL_ID_UNUSED_28 = 28,
|
||||||
false, //TUTORIAL_ID_UNUSED_29
|
false, //TUTORIAL_ID_UNUSED_29 = 29,
|
||||||
false, //TUTORIAL_ID_UNUSED_30
|
false, //TUTORIAL_ID_UNUSED_30 = 30,
|
||||||
false, //TUTORIAL_ID_DRESS_UP
|
false, //TUTORIAL_ID_DRESS_UP = 31,
|
||||||
true, //TUTORIAL_ID_MULTI_GHOST
|
true, //TUTORIAL_ID_MULTI_GHOST = 32,
|
||||||
true, //TUTORIAL_ID_STORY_NEW_FEATURE
|
true, //TUTORIAL_ID_STORY_NEW_FEATURE = 33,
|
||||||
true, //TUTORIAL_ID_GHOST_NEW_FEATURE
|
true, //TUTORIAL_ID_GHOST_NEW_FEATURE = 34,
|
||||||
true, //TUTORIAL_ID_GHOST_REGION_MAP
|
true, //TUTORIAL_ID_GHOST_REGION_MAP = 35
|
||||||
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('user made')
|
console.log('user made')
|
||||||
if (!user) {
|
|
||||||
|
if (!user)
|
||||||
|
{
|
||||||
msg.error = wm.wm.protobuf.ErrorCode.ERR_REQUEST;
|
msg.error = wm.wm.protobuf.ErrorCode.ERR_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ftTicketGrant = Config.getConfig().gameOptions.grantFullTuneTicketToNewUsers;
|
let ftTicketGrant = Config.getConfig().gameOptions.grantFullTuneTicketToNewUsers;
|
||||||
if (ftTicketGrant > 0) {
|
|
||||||
|
if (ftTicketGrant > 0)
|
||||||
|
{
|
||||||
console.log(`Granting Full-Tune Ticket x${ftTicketGrant} to new user...`);
|
console.log(`Granting Full-Tune Ticket x${ftTicketGrant} to new user...`);
|
||||||
for (let i=0; i<ftTicketGrant; i++) {
|
|
||||||
|
for (let i=0; i<ftTicketGrant; i++)
|
||||||
|
{
|
||||||
await prisma.userItem.create({
|
await prisma.userItem.create({
|
||||||
data: {
|
data: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
@ -124,16 +138,16 @@ export default class UserModule extends Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Done!');
|
console.log('Done!');
|
||||||
}
|
}
|
||||||
let resp = wm.wm.protobuf.LoadUserResponse.encode(msg);
|
|
||||||
let end = resp.finish();
|
// Encode the response
|
||||||
let r = res
|
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
|
||||||
.header('Server', 'v388 wangan')
|
|
||||||
.header('Content-Type', 'application/x-protobuf; revision=8053')
|
// Send the response to the client
|
||||||
.header('Content-Length', end.length.toString())
|
common.sendResponse(message, res);
|
||||||
.status(200);
|
|
||||||
r.send(Buffer.from(end));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +247,7 @@ export default class UserModule extends Module {
|
|||||||
let wsFont = 0;
|
let wsFont = 0;
|
||||||
|
|
||||||
// user.cars found
|
// user.cars found
|
||||||
if(user.cars)
|
if(user.cars.length > 0)
|
||||||
{
|
{
|
||||||
// User atleast have 1 car
|
// User atleast have 1 car
|
||||||
if(user.cars[0]?.windowStickerString !== null && user.cars[0]?.windowStickerString !== undefined &&
|
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;
|
wsFont = user.cars[0].windowStickerFont;
|
||||||
}
|
}
|
||||||
// else{} User don't have a car... returning default windowStickerString and windowStickerFont value
|
// 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<user.cars.length; i++)
|
||||||
|
{
|
||||||
|
user.cars[0].lastPlayedPlaceId = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await prisma.car.updateMany({
|
||||||
|
where:{
|
||||||
|
userId: user.id
|
||||||
|
},
|
||||||
|
data:{
|
||||||
|
lastPlayedPlaceId: 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change Ghost Stamp tutorial to true
|
||||||
|
if(user.tutorials[20] === false)
|
||||||
|
{
|
||||||
|
console.log(`Change Ghost Stamp tutorial to true`)
|
||||||
|
for(let i=20; i<25; i++)
|
||||||
|
{
|
||||||
|
user.tutorials[i] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.user.update({
|
||||||
|
where:{
|
||||||
|
chipId: body.cardChipId
|
||||||
|
},
|
||||||
|
data:{
|
||||||
|
tutorials: user.tutorials
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Response data
|
// Response data
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||||
@ -280,41 +331,24 @@ export default class UserModule extends Module {
|
|||||||
// Get current date
|
// Get current date
|
||||||
let date = Math.floor(new Date().getTime() / 1000);
|
let date = Math.floor(new Date().getTime() / 1000);
|
||||||
|
|
||||||
// Check each car record
|
|
||||||
for(let i=0; i<msg.cars.length; i++)
|
|
||||||
{
|
|
||||||
// Get current active OCM Event
|
// Get current active OCM Event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy:{
|
orderBy:{
|
||||||
dbId: 'desc'
|
dbId: 'desc'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check each car record
|
||||||
|
for(let i=0; i<msg.cars.length; i++)
|
||||||
|
{
|
||||||
|
|
||||||
// Check Competition (OCM) Participation, and available OCM event
|
// Check Competition (OCM) Participation, and available OCM event
|
||||||
if(user.cars.length > 0 && ocmEventDate)
|
if(user.cars.length > 0 && ocmEventDate)
|
||||||
{
|
{
|
||||||
@ -333,33 +367,23 @@ export default class UserModule extends Module {
|
|||||||
if(checkParticipation)
|
if(checkParticipation)
|
||||||
{
|
{
|
||||||
ParticipationMainDrawCounter++
|
ParticipationMainDrawCounter++
|
||||||
}
|
|
||||||
|
|
||||||
// Check Car State
|
// Check Car State
|
||||||
// Get OCM Data
|
// Get OCM Data
|
||||||
let ocmTallyRecord = await prisma.oCMTally.findMany({
|
let ocmTallyRecord = await prisma.oCMTally.findFirst({
|
||||||
where:{
|
where:{
|
||||||
|
carId: user.cars[i].carId,
|
||||||
competitionId: ocmEventDate!.competitionId
|
competitionId: ocmEventDate!.competitionId
|
||||||
},
|
}
|
||||||
orderBy: [
|
|
||||||
{
|
|
||||||
competitionId: 'desc',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
periodId: 'desc',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
result: 'desc',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for(let j=0; j<ocmTallyRecord.length; j++)
|
if(ocmTallyRecord)
|
||||||
{
|
{
|
||||||
carStates[i].eventJoined = true;
|
carStates[i].eventJoined = true;
|
||||||
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_QUALIFIED
|
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_QUALIFIED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Current date is OCM qualifying day
|
// Current date is OCM qualifying day
|
||||||
else if(ocmEventDate!.qualifyingPeriodStartAt < date && ocmEventDate!.qualifyingPeriodCloseAt > date)
|
else if(ocmEventDate!.qualifyingPeriodStartAt < date && ocmEventDate!.qualifyingPeriodCloseAt > date)
|
||||||
{
|
{
|
||||||
@ -375,30 +399,18 @@ export default class UserModule extends Module {
|
|||||||
if(checkParticipation)
|
if(checkParticipation)
|
||||||
{
|
{
|
||||||
ParticipationQualifyingCounter++
|
ParticipationQualifyingCounter++
|
||||||
}
|
|
||||||
|
|
||||||
// Check Car State
|
// Check Car State
|
||||||
// Get OCM Data
|
// Get OCM Data
|
||||||
let ocmRecord = await prisma.oCMPlayRecord.findMany({
|
let ocmRecord = await prisma.oCMPlayRecord.findFirst({
|
||||||
where:{
|
where:{
|
||||||
competitionId: ocmEventDate!.competitionId
|
carId: user.cars[i].carId,
|
||||||
|
competitionId: ocmEventDate!.competitionId,
|
||||||
|
periodId: 0
|
||||||
},
|
},
|
||||||
orderBy: [
|
|
||||||
{
|
|
||||||
dbId: 'asc',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
competitionId: 'desc',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
periodId: 'desc',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for(let j=0; j<ocmRecord.length; j++)
|
if(ocmRecord)
|
||||||
{
|
|
||||||
if(carStates[i].dbId === ocmRecord[j].carId)
|
|
||||||
{
|
{
|
||||||
carStates[i].eventJoined = true;
|
carStates[i].eventJoined = true;
|
||||||
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_PARTICIPATED
|
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_PARTICIPATED
|
||||||
@ -420,33 +432,22 @@ export default class UserModule extends Module {
|
|||||||
if(checkParticipation)
|
if(checkParticipation)
|
||||||
{
|
{
|
||||||
ParticipationEndedCounter++
|
ParticipationEndedCounter++
|
||||||
}
|
|
||||||
|
|
||||||
// Check Car State
|
// Check Car State
|
||||||
// Get OCM Data
|
// Get OCM Data
|
||||||
let ocmTallyRecord = await prisma.oCMTally.findMany({
|
let ocmTallyRecord = await prisma.oCMTally.findFirst({
|
||||||
where:{
|
where:{
|
||||||
|
carId: user.cars[i].carId,
|
||||||
competitionId: ocmEventDate!.competitionId,
|
competitionId: ocmEventDate!.competitionId,
|
||||||
periodId: 999999999
|
periodId: 999999999
|
||||||
},
|
},
|
||||||
orderBy: [
|
|
||||||
{
|
|
||||||
result: 'desc',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for(let j=0; j<ocmTallyRecord.length; j++)
|
if(ocmTallyRecord)
|
||||||
{
|
|
||||||
if(carStates[i].dbId === ocmTallyRecord[j].carId)
|
|
||||||
{
|
{
|
||||||
carStates[i].eventJoined = true;
|
carStates[i].eventJoined = true;
|
||||||
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_QUALIFIED
|
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_QUALIFIED
|
||||||
}
|
}
|
||||||
if(carStates[i].dbId === ocmTallyRecord[j].carId && j === 0)
|
|
||||||
{
|
|
||||||
carStates[i].competitionState = wm.wm.protobuf.GhostCompetitionParticipantState.COMPETITION_WON
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -499,13 +500,20 @@ export default class UserModule extends Module {
|
|||||||
else if(ParticipationEndedCounter > 0)
|
else if(ParticipationEndedCounter > 0)
|
||||||
{
|
{
|
||||||
console.log('OCM Participation : '+ParticipationEndedCounter+' car(s) played OCM Event');
|
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');
|
console.log('OCM Participation : Not Participated / Qualified');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('No OCM Event Available');
|
||||||
|
}
|
||||||
|
|
||||||
// Response data if user is banned
|
// Response data if user is banned
|
||||||
if (user.userBanned) {
|
if (user.userBanned)
|
||||||
|
{
|
||||||
msg.error = wm.wm.protobuf.ErrorCode.ERR_ID_BANNED;
|
msg.error = wm.wm.protobuf.ErrorCode.ERR_ID_BANNED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ export function getBigIntFromLong(n: Long)
|
|||||||
return Number(bigInt);
|
return Number(bigInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sanitizeInput(value: any){
|
export function sanitizeInput(value: any)
|
||||||
|
{
|
||||||
return (value == null || value == undefined) ? undefined : value;
|
return (value == null || value == undefined) ? undefined : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ import wmproto from "../../wmmt/wm.proto";
|
|||||||
|
|
||||||
// Import Util
|
// Import Util
|
||||||
import * as common from "../../util/common";
|
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
|
// Save ghost battle result
|
||||||
export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
|
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
|
// Set ghost mode play to true for saving the ghost trail later
|
||||||
ghostModePlay = true;
|
ghostModePlay = true;
|
||||||
|
|
||||||
// Get the ghost result for the car
|
|
||||||
let ghostResult = body?.rgResult;
|
|
||||||
|
|
||||||
// Declare data
|
// Declare data
|
||||||
let dataGhost : any;
|
let dataGhost : any;
|
||||||
let dataCar : 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
|
// Get the ghost result for the car
|
||||||
let cars = body?.car;
|
let cars = body?.car;
|
||||||
|
|
||||||
@ -79,15 +65,31 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the ghost result for the car
|
||||||
|
let ghostResult = body?.rgResult;
|
||||||
|
|
||||||
|
// 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),
|
||||||
|
stampSheet: common.sanitizeInput(ghostResult.stampSheet),
|
||||||
|
stampSheetCount: common.sanitizeInputNotZero(ghostResult.stampSheetCount),
|
||||||
|
}
|
||||||
|
|
||||||
// Count total win based on region map score
|
// Count total win based on region map score
|
||||||
if(body.rgResult?.rgRegionMapScore && body.rgResult?.rgRegionMapScore.length !== 0)
|
if(ghostResult.rgRegionMapScore && ghostResult.rgRegionMapScore.length !== 0)
|
||||||
{
|
{
|
||||||
let winCounter = 0;
|
let winCounter = 0;
|
||||||
|
|
||||||
// Count the total win
|
// Count the total win
|
||||||
for(let i=0; i<body.rgResult.rgRegionMapScore.length; i++)
|
for(let i=0; i<ghostResult.rgRegionMapScore.length; i++)
|
||||||
{
|
{
|
||||||
winCounter += body.rgResult.rgRegionMapScore[i];
|
winCounter += ghostResult.rgRegionMapScore[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the data
|
// Set the data
|
||||||
@ -95,6 +97,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
dataGhost.rgScore = winCounter;
|
dataGhost.rgScore = winCounter;
|
||||||
dataGhost.rgTrophy = winCounter;
|
dataGhost.rgTrophy = winCounter;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the car properties
|
// Update the car properties
|
||||||
await prisma.car.update({
|
await prisma.car.update({
|
||||||
@ -114,7 +117,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
|
|
||||||
switch (body.rgResult!.selectionMethod)
|
switch (body.rgResult!.selectionMethod)
|
||||||
{
|
{
|
||||||
// Ghost Battle by Level
|
// Ghost Battle Select by Level
|
||||||
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_BY_LEVEL:
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_BY_LEVEL:
|
||||||
{
|
{
|
||||||
console.log('Normal Ghost Mode Found - Select by Level');
|
console.log('Normal Ghost Mode Found - Select by Level');
|
||||||
@ -127,7 +130,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ghost Battle by Name
|
// Ghost Battle Search by Name
|
||||||
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_NAME:
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_NAME:
|
||||||
{
|
{
|
||||||
console.log('Normal Ghost Mode Found - Search by Name');
|
console.log('Normal Ghost Mode Found - Search by Name');
|
||||||
@ -140,7 +143,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ghost Battle by Region
|
// Ghost Battle Search by Region
|
||||||
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_REGION:
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_REGION:
|
||||||
{
|
{
|
||||||
console.log('Normal Ghost Mode Found - Search by Region');
|
console.log('Normal Ghost Mode Found - Search by Region');
|
||||||
@ -153,7 +156,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ghost Battle from History
|
// Ghost Battle Select from History
|
||||||
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_HISTORY:
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_HISTORY:
|
||||||
{
|
{
|
||||||
console.log('Normal Ghost Mode Found - Select from History');
|
console.log('Normal Ghost Mode Found - Select from History');
|
||||||
@ -166,7 +169,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ghost Battle by Shop
|
// Ghost Battle Search by Shop
|
||||||
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_SHOP:
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_SHOP:
|
||||||
{
|
{
|
||||||
console.log('Normal Ghost Mode Found - Search by Shop');
|
console.log('Normal Ghost Mode Found - Search by Shop');
|
||||||
@ -179,6 +182,35 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ghost Battle Select Stamp Match
|
||||||
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_STAMP_MATCH:
|
||||||
|
{
|
||||||
|
console.log('Normal Ghost Mode Found - Select Stamp Match');
|
||||||
|
|
||||||
|
ghost_historys = await ghost_history.saveGhostHistory(body);
|
||||||
|
|
||||||
|
// Update the updateNewTrail value
|
||||||
|
updateNewTrail = ghost_historys.updateNewTrail;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ghost Battle Challenger
|
||||||
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_ACCEPT_CHALLENGER:
|
||||||
|
{
|
||||||
|
console.log('Normal Ghost Mode Found - Challenger');
|
||||||
|
|
||||||
|
ghost_historys = await ghost_history.saveGhostHistory(body);
|
||||||
|
|
||||||
|
// Return Stamp (Shuttle Match)
|
||||||
|
await ghost_stamp.shuttleReturnStamp(body);
|
||||||
|
|
||||||
|
// Update the updateNewTrail value
|
||||||
|
updateNewTrail = ghost_historys.updateNewTrail;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Crown Ghost Battle Mode
|
// Crown Ghost Battle Mode
|
||||||
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_CROWN_MATCH:
|
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_CROWN_MATCH:
|
||||||
{
|
{
|
||||||
@ -341,41 +373,25 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
console.log('OCM Ghost Mode Found');
|
console.log('OCM Ghost Mode Found');
|
||||||
|
|
||||||
OCMModePlay = true;
|
OCMModePlay = true;
|
||||||
let saveExOCM: any = {};
|
|
||||||
saveExOCM.carId = body.carId;
|
|
||||||
|
|
||||||
if(body.rgResult?.competitionId)
|
// Get the rg result for the car
|
||||||
{
|
let rgResult = body?.rgResult;
|
||||||
saveExOCM.competitionId = body.rgResult?.competitionId!;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(body.rgResult?.periodId)
|
// rgResult is set
|
||||||
|
if (rgResult)
|
||||||
{
|
{
|
||||||
saveExOCM.periodId = body.rgResult?.periodId!;
|
let data : any = {
|
||||||
}
|
carId: body.carId,
|
||||||
else
|
competitionId: common.sanitizeInput(rgResult.competitionId),
|
||||||
{
|
periodId: common.sanitizeInput(rgResult.periodId) || 0,
|
||||||
saveExOCM.periodId = 0;
|
brakingPoint: common.sanitizeInput(rgResult.brakingPoint) || 0,
|
||||||
}
|
playedAt: common.sanitizeInput(body.playedAt),
|
||||||
|
|
||||||
if(body.rgResult?.brakingPoint)
|
|
||||||
{
|
|
||||||
saveExOCM.brakingPoint = body.rgResult?.brakingPoint!;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
saveExOCM.brakingPoint = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(body?.playedAt)
|
|
||||||
{
|
|
||||||
saveExOCM.playedAt = body?.playedAt!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the user's available OCM Battle data
|
// Get the user's available OCM Battle data
|
||||||
let countOCM = await prisma.oCMPlayRecord.count({
|
let countOCM = await prisma.oCMPlayRecord.count({
|
||||||
where: {
|
where: {
|
||||||
competitionId: saveExOCM.competitionId,
|
competitionId: data.competitionId,
|
||||||
carId: body.carId
|
carId: body.carId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -388,10 +404,10 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
|
|
||||||
await prisma.oCMPlayRecord.updateMany({
|
await prisma.oCMPlayRecord.updateMany({
|
||||||
where:{
|
where:{
|
||||||
carId: saveExOCM.carId,
|
carId: data.carId,
|
||||||
competitionId: saveExOCM.competitionId,
|
competitionId: data.competitionId,
|
||||||
},
|
},
|
||||||
data: saveExOCM
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// First time User playing OCM Battle
|
// First time User playing OCM Battle
|
||||||
@ -401,7 +417,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
console.log('Creating new OCM Play Record entry');
|
console.log('Creating new OCM Play Record entry');
|
||||||
|
|
||||||
await prisma.oCMPlayRecord.create({
|
await prisma.oCMPlayRecord.create({
|
||||||
data: saveExOCM
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,11 +425,121 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
|
|
||||||
// Update the updateNewTrail value
|
// Update the updateNewTrail value
|
||||||
updateNewTrail = ghost_historys.updateNewTrail;
|
updateNewTrail = ghost_historys.updateNewTrail;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Retiring Ghost Battle
|
||||||
|
else if(body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_BY_LEVEL ||
|
||||||
|
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_NAME ||
|
||||||
|
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_REGION ||
|
||||||
|
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_HISTORY ||
|
||||||
|
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_SHOP ||
|
||||||
|
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_STAMP_MATCH ||
|
||||||
|
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_ACCEPT_CHALLENGER)
|
||||||
|
{
|
||||||
|
console.log('Normal Ghost Mode Found but Retiring');
|
||||||
|
|
||||||
|
// Get the ghost result for the car
|
||||||
|
let ghostResult = body?.rgResult;
|
||||||
|
|
||||||
|
// Declare data
|
||||||
|
let dataGhost : any;
|
||||||
|
|
||||||
|
// ghostResult is set
|
||||||
|
if (ghostResult)
|
||||||
|
{
|
||||||
|
// Ghost update data
|
||||||
|
dataGhost = {
|
||||||
|
rgPlayCount: common.sanitizeInput(ghostResult.rgPlayCount),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the car properties
|
||||||
|
await prisma.car.update({
|
||||||
|
where: {
|
||||||
|
carId: body.carId
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
...dataGhost
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Retiring OCM for mini games
|
||||||
|
else if(body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_COMPETITION)
|
||||||
|
{
|
||||||
|
// Get current date
|
||||||
|
let date = Math.floor(new Date().getTime() / 1000);
|
||||||
|
|
||||||
|
// Get currently active OCM event
|
||||||
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
|
where: {
|
||||||
|
// qualifyingPeriodStartAt is less than current date
|
||||||
|
qualifyingPeriodStartAt: { lte: date },
|
||||||
|
|
||||||
|
// competitionEndAt is greater than current date
|
||||||
|
competitionEndAt: { gte: date },
|
||||||
|
},
|
||||||
|
orderBy:{
|
||||||
|
dbId: 'desc'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(ocmEventDate!.qualifyingPeriodStartAt < date && ocmEventDate!.qualifyingPeriodCloseAt > 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: data.competitionId,
|
||||||
|
carId: body.carId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// User's OCM Battle data available
|
||||||
|
if(countOCM !== 0)
|
||||||
|
{
|
||||||
|
console.log('OCM Play Record found');
|
||||||
|
console.log('Updaing OCM Play Record entry');
|
||||||
|
|
||||||
|
await prisma.oCMPlayRecord.updateMany({
|
||||||
|
where:{
|
||||||
|
carId: data.carId,
|
||||||
|
competitionId: data.competitionId,
|
||||||
|
},
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// First time User playing OCM Battle
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('OCM Play Record not found');
|
||||||
|
console.log('Creating new OCM Play Record entry');
|
||||||
|
|
||||||
|
await prisma.oCMPlayRecord.create({
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return the value to 'BASE_PATH/src/modules/game.ts'
|
// Return the value to 'BASE_PATH/src/modules/game.ts'
|
||||||
return { ghostModePlay, updateNewTrail, OCMModePlay }
|
return { ghostModePlay, updateNewTrail, OCMModePlay }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { prisma } from "..";
|
import { prisma } from "../..";
|
||||||
|
|
||||||
// Import Proto
|
// Import Proto
|
||||||
import { wm } from "../wmmt/wm.proto";
|
import { wm } from "../../wmmt/wm.proto";
|
||||||
|
|
||||||
|
|
||||||
// Save story result
|
// Save story result
|
@ -1,7 +1,12 @@
|
|||||||
// Import Proto
|
// Import Proto
|
||||||
import { prisma } from "../../..";
|
import { prisma } from "../..";
|
||||||
import { Config } from "../../../config";
|
import { Config } from "../../config";
|
||||||
import { wm } from "../../../wmmt/wm.proto";
|
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
|
// Save ghost history battle
|
||||||
@ -12,121 +17,86 @@ export async function saveGhostHistory(body: wm.protobuf.SaveGameResultRequest)
|
|||||||
let updateNewTrail: boolean = true;
|
let updateNewTrail: boolean = true;
|
||||||
let saveExGhostHistory: any = {};
|
let saveExGhostHistory: any = {};
|
||||||
|
|
||||||
if (body.car?.carId !== null && body.car?.carId !== undefined) {
|
// Get the car result for the car
|
||||||
saveExGhostHistory.carId = body.car?.carId!;
|
let car = body?.car;
|
||||||
|
|
||||||
|
if(car)
|
||||||
|
{
|
||||||
|
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
|
||||||
}
|
}
|
||||||
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
|
// Get the rg result for the car
|
||||||
saveExGhostHistory.playedShopName = Config.getConfig().shopName;
|
let rgResult = body?.rgResult;
|
||||||
|
|
||||||
|
if(rgResult)
|
||||||
|
{
|
||||||
|
if(rgResult.opponents)
|
||||||
|
{
|
||||||
// Get how many opponents available
|
// Get how many opponents available
|
||||||
for(let i=0; i<body.rgResult!.opponents!.length; i++)
|
for(let i=0; i<rgResult.opponents.length; i++)
|
||||||
{
|
{
|
||||||
// First opponent data
|
// First opponent data
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
{
|
{
|
||||||
// Get first opponent carId
|
// Get first opponent carId
|
||||||
saveExGhostHistory.opponent1CarId = body.rgResult!.opponents![0].carId;
|
saveExGhostHistory.opponent1CarId = rgResult.opponents[0].carId;
|
||||||
|
|
||||||
// Get first opponent tunePower
|
// Get first opponent tunePower
|
||||||
saveExGhostHistory.opponent1TunePower = body.rgResult!.opponents![0].tunePower;
|
saveExGhostHistory.opponent1TunePower = rgResult.opponents[0].tunePower;
|
||||||
|
|
||||||
// Get first opponent tunePower
|
// Get first opponent tunePower
|
||||||
saveExGhostHistory.opponent1TuneHandling = body.rgResult!.opponents![0].tuneHandling;
|
saveExGhostHistory.opponent1TuneHandling = rgResult.opponents[0].tuneHandling;
|
||||||
|
|
||||||
// Get the advantage distance between first opponent and user
|
// Get the advantage distance between first opponent and user
|
||||||
saveExGhostHistory.opponent1Result = body.rgResult!.opponents![0].result;
|
saveExGhostHistory.opponent1Result = rgResult.opponents[0].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second opponent data
|
// Second opponent data
|
||||||
else if(i == 1)
|
else if(i == 1)
|
||||||
{
|
{
|
||||||
// Get second opponent carId
|
// Get second opponent carId
|
||||||
saveExGhostHistory.opponent2CarId = body.rgResult!.opponents![1].carId;
|
saveExGhostHistory.opponent2CarId = rgResult.opponents[1].carId;
|
||||||
|
|
||||||
// Get second opponent tunePower
|
// Get second opponent tunePower
|
||||||
saveExGhostHistory.opponent2TunePower = body.rgResult!.opponents![1].tunePower;
|
saveExGhostHistory.opponent2TunePower = rgResult.opponents[1].tunePower;
|
||||||
|
|
||||||
// Get second opponent tuneHandling
|
// Get second opponent tuneHandling
|
||||||
saveExGhostHistory.opponent2TuneHandling = body.rgResult!.opponents![1].tuneHandling;
|
saveExGhostHistory.opponent2TuneHandling = rgResult.opponents[1].tuneHandling;
|
||||||
|
|
||||||
// Get the advantage distance between second opponent and user
|
// Get the advantage distance between second opponent and user
|
||||||
saveExGhostHistory.opponent2Result = body.rgResult!.opponents![1].result;
|
saveExGhostHistory.opponent2Result = rgResult.opponents[1].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third opponent data
|
// Third opponent data
|
||||||
else if(i == 2)
|
else if(i == 2)
|
||||||
{
|
{
|
||||||
// Get third opponent carId
|
// Get third opponent carId
|
||||||
saveExGhostHistory.opponent3CarId = body.rgResult!.opponents![2].carId;
|
saveExGhostHistory.opponent3CarId = rgResult.opponents[2].carId;
|
||||||
|
|
||||||
// Get third opponent tunePower
|
// Get third opponent tunePower
|
||||||
saveExGhostHistory.opponent3TunePower = body.rgResult!.opponents![2].tunePower;
|
saveExGhostHistory.opponent3TunePower = rgResult.opponents[2].tunePower;
|
||||||
|
|
||||||
// Get third opponent tuneHandling
|
// Get third opponent tuneHandling
|
||||||
saveExGhostHistory.opponent3TuneHandling = body.rgResult!.opponents![2].tuneHandling;
|
saveExGhostHistory.opponent3TuneHandling = rgResult.opponents[2].tuneHandling;
|
||||||
|
|
||||||
// Get the advantage distance between third opponent and user
|
// Get the advantage distance between third opponent and user
|
||||||
saveExGhostHistory.opponent3Result = body.rgResult!.opponents![2].result;
|
saveExGhostHistory.opponent3Result = rgResult.opponents[2].result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get played Area
|
// Get played Area
|
||||||
if(body.rgResult?.path !== null && body.rgResult?.path !== undefined)
|
if(common.sanitizeInput(rgResult.path))
|
||||||
{
|
{
|
||||||
if(body.rgResult?.path >= 0 && body.rgResult?.path <= 9){ // GID_PATH_C1
|
let getArea = await ghost_get_area_from_path.getArea(rgResult.path);
|
||||||
saveExGhostHistory.area = Number(0);
|
|
||||||
}
|
saveExGhostHistory.area = getArea.area
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +104,9 @@ export async function saveGhostHistory(body: wm.protobuf.SaveGameResultRequest)
|
|||||||
data: saveExGhostHistory
|
data: saveExGhostHistory
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Sending stamp to opponents
|
||||||
|
await ghost_stamp.sendStamp(body);
|
||||||
|
|
||||||
// Return the value to 'BASE_PATH/src/util/games/ghost.ts'
|
// Return the value to 'BASE_PATH/src/util/games/ghost.ts'
|
||||||
return { updateNewTrail }
|
return { updateNewTrail }
|
||||||
}
|
}
|
||||||
@ -144,72 +117,37 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
|
|||||||
let updateNewTrail: boolean = true;
|
let updateNewTrail: boolean = true;
|
||||||
let saveExGhostHistory: any = {};
|
let saveExGhostHistory: any = {};
|
||||||
|
|
||||||
if (body.car?.carId !== null && body.car?.carId !== undefined) {
|
// Get the car result for the car
|
||||||
saveExGhostHistory.carId = body.car?.carId!;
|
let car = body?.car;
|
||||||
|
|
||||||
|
if(car)
|
||||||
|
{
|
||||||
|
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
|
||||||
}
|
}
|
||||||
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
|
// Get the rg result for the car
|
||||||
saveExGhostHistory.playedShopName = Config.getConfig().shopName;
|
let rgResult = body?.rgResult;
|
||||||
|
|
||||||
|
if(rgResult)
|
||||||
|
{
|
||||||
|
if(rgResult.opponents)
|
||||||
|
{
|
||||||
// Get the advantage distance between first opponent and user
|
// Get the advantage distance between first opponent and user
|
||||||
saveExGhostHistory.result = body.rgResult!.opponents![0].result;
|
saveExGhostHistory.result = rgResult.opponents[0].result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get played Area
|
// Get played Area
|
||||||
if(body.rgResult?.path !== null && body.rgResult?.path !== undefined)
|
if(common.sanitizeInput(rgResult.path))
|
||||||
{
|
{
|
||||||
if(body.rgResult?.path >= 0 && body.rgResult?.path <= 9){ // GID_PATH_C1
|
let getArea = await ghost_get_area_from_path.getArea(rgResult.path);
|
||||||
saveExGhostHistory.area = Number(0);
|
|
||||||
}
|
saveExGhostHistory.area = getArea.area
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,29 +157,11 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
|
|||||||
// Get currently active OCM event
|
// Get currently active OCM event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy:{
|
orderBy:{
|
||||||
dbId: 'desc'
|
dbId: 'desc'
|
@ -1,5 +1,4 @@
|
|||||||
|
// OCM Area
|
||||||
// Save ghost battle result
|
|
||||||
export async function OCMArea(competition_id: number)
|
export async function OCMArea(competition_id: number)
|
||||||
{
|
{
|
||||||
let areaVal = 0;
|
let areaVal = 0;
|
@ -15,29 +15,11 @@ export async function saveOCMGhostTrail(body: wm.protobuf.RegisterGhostTrailRequ
|
|||||||
// Get current active OCM Event
|
// Get current active OCM Event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy:{
|
orderBy:{
|
||||||
dbId: 'desc'
|
dbId: 'desc'
|
||||||
@ -49,21 +31,20 @@ export async function saveOCMGhostTrail(body: wm.protobuf.RegisterGhostTrailRequ
|
|||||||
// Get OCM Period ID
|
// Get OCM Period ID
|
||||||
let OCM_periodId = await prisma.oCMPeriod.findFirst({
|
let OCM_periodId = await prisma.oCMPeriod.findFirst({
|
||||||
where:{
|
where:{
|
||||||
competitionDbId: ocmEventDate!.dbId,
|
competitionDbId: ocmEventDate.dbId,
|
||||||
competitionId: ocmEventDate!.competitionId,
|
competitionId: ocmEventDate.competitionId,
|
||||||
startAt:
|
|
||||||
{
|
// StartAt is less than current date
|
||||||
lte: date, // competitionStartAt is less than current date
|
startAt: { lte: date },
|
||||||
},
|
|
||||||
closeAt:
|
// CloseAt is greater than current date
|
||||||
{
|
closeAt: { gte: date }
|
||||||
gte: date, // competitionCloseAt is greater than current date
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
select:{
|
select:{
|
||||||
periodId: true
|
periodId: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let ocmMainDraws: boolean = false;
|
let ocmMainDraws: boolean = false;
|
||||||
let periodId = 0;
|
let periodId = 0;
|
||||||
|
|
||||||
@ -92,6 +73,7 @@ export async function saveOCMGhostTrail(body: wm.protobuf.RegisterGhostTrailRequ
|
|||||||
let grArea: number = 0;
|
let grArea: number = 0;
|
||||||
let grRamp: number = 0;
|
let grRamp: number = 0;
|
||||||
let grPath: number = 0;
|
let grPath: number = 0;
|
||||||
|
|
||||||
if(ghostResult.area)
|
if(ghostResult.area)
|
||||||
{
|
{
|
||||||
grArea = ghostResult.area;
|
grArea = ghostResult.area;
|
||||||
@ -184,6 +166,7 @@ export async function saveCrownGhostTrail(body: wm.protobuf.RegisterGhostTrailRe
|
|||||||
let grArea: number = 0;
|
let grArea: number = 0;
|
||||||
let grRamp: number = 0;
|
let grRamp: number = 0;
|
||||||
let grPath: number = 0;
|
let grPath: number = 0;
|
||||||
|
|
||||||
if(ghostResult.area)
|
if(ghostResult.area)
|
||||||
{
|
{
|
||||||
grArea = ghostResult.area;
|
grArea = ghostResult.area;
|
161
src/util/ghost/ghost_stamp.ts
Normal file
161
src/util/ghost/ghost_stamp.ts
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
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)
|
||||||
|
{
|
||||||
|
console.log('Sending Stamp');
|
||||||
|
|
||||||
|
let rgResult = body.rgResult
|
||||||
|
|
||||||
|
if(rgResult)
|
||||||
|
{
|
||||||
|
// Stamp must bigger than 0
|
||||||
|
if(rgResult.rgStamp === 0)
|
||||||
|
{
|
||||||
|
rgResult.rgStamp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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<rgResult.opponents!.length; i++)
|
||||||
|
{
|
||||||
|
let checkCar = await prisma.car.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: rgResult.opponents![i].carId,
|
||||||
|
NOT:{
|
||||||
|
userId: body.car!.userId!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(checkCar)
|
||||||
|
{
|
||||||
|
let returnCounts = 1;
|
||||||
|
|
||||||
|
let dataChallenger: any = {
|
||||||
|
carId: body.carId,
|
||||||
|
challengerCarId: rgResult.opponents![i].carId,
|
||||||
|
stamp: rgResult.rgStamp,
|
||||||
|
result: rgResult.opponents![i].result,
|
||||||
|
area: area
|
||||||
|
}
|
||||||
|
|
||||||
|
let dataStampTarget: any = {
|
||||||
|
carId: body.carId,
|
||||||
|
stampTargetCarId: rgResult.opponents![i].carId,
|
||||||
|
returnCount: returnCounts,
|
||||||
|
locked: false,
|
||||||
|
recommended: true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check available stamp
|
||||||
|
let stampTarget = await prisma.carStampTarget.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: body.carId,
|
||||||
|
stampTargetCarId: rgResult.opponents![i].carId,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(stampTarget)
|
||||||
|
{
|
||||||
|
dataStampTarget.returnCount = stampTarget.returnCount + 1;
|
||||||
|
|
||||||
|
console.log('Updating stamp entry');
|
||||||
|
|
||||||
|
await prisma.carChallenger.update({
|
||||||
|
where:{
|
||||||
|
id: stampTarget.id
|
||||||
|
},
|
||||||
|
data: dataChallenger
|
||||||
|
})
|
||||||
|
|
||||||
|
await prisma.carStampTarget.update({
|
||||||
|
where:{
|
||||||
|
id: stampTarget.id
|
||||||
|
},
|
||||||
|
data: dataStampTarget
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('Creating new stamp entry');
|
||||||
|
|
||||||
|
await prisma.carChallenger.create({
|
||||||
|
data: dataChallenger
|
||||||
|
})
|
||||||
|
|
||||||
|
await prisma.carStampTarget.create({
|
||||||
|
data: dataStampTarget
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest)
|
||||||
|
{
|
||||||
|
console.log('Returning Stamp');
|
||||||
|
|
||||||
|
let rgResult = body.rgResult
|
||||||
|
|
||||||
|
if(rgResult)
|
||||||
|
{
|
||||||
|
// Stamp must bigger than 0
|
||||||
|
if(rgResult.rgStamp === 0)
|
||||||
|
{
|
||||||
|
rgResult.rgStamp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check how many opponents available
|
||||||
|
for(let i=0; i<rgResult.opponents!.length; i++)
|
||||||
|
{
|
||||||
|
let checkCar = await prisma.car.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: rgResult.opponents![i].carId,
|
||||||
|
NOT:{
|
||||||
|
userId: body.car!.userId!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(checkCar)
|
||||||
|
{
|
||||||
|
// Check opponents target
|
||||||
|
let opponentTarget = await prisma.carStampTarget.findFirst({
|
||||||
|
where:{
|
||||||
|
stampTargetCarId: body.carId,
|
||||||
|
carId: rgResult.opponents![i].carId,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(opponentTarget)
|
||||||
|
{
|
||||||
|
await prisma.carStampTarget.update({
|
||||||
|
where: {
|
||||||
|
id: opponentTarget.id
|
||||||
|
},
|
||||||
|
data:{
|
||||||
|
locked: true,
|
||||||
|
recommended: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ import { prisma } from "../..";
|
|||||||
import { OCMTop1GhostTrail } from "@prisma/client";
|
import { OCMTop1GhostTrail } from "@prisma/client";
|
||||||
|
|
||||||
// Import Proto
|
// Import Proto
|
||||||
import * as ghost_ocm_area from "../games/games_util/ghost_ocm_area";
|
import * as ghost_ocm_area from "./ghost_ocm_area";
|
||||||
|
|
||||||
|
|
||||||
// Save ghost battle result
|
// Save ghost battle result
|
||||||
@ -14,29 +14,11 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
|
|||||||
// Get current / previous active OCM Event
|
// Get current / previous active OCM Event
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
// qualifyingPeriodStartAt is less than current date
|
// qualifyingPeriodStartAt is less than current date
|
||||||
qualifyingPeriodStartAt: { lte: 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 is greater than current date
|
||||||
competitionEndAt: { gte: date },
|
competitionEndAt: { gte: date },
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{
|
{
|
52
src/util/ghost/ghost_util/ghost_get_area_from_path.ts
Normal file
52
src/util/ghost/ghost_util/ghost_get_area_from_path.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
export async function getArea(path: number)
|
||||||
|
{
|
||||||
|
let area = 0;
|
||||||
|
|
||||||
|
if(path >= 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 }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user