1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2024-11-12 02:01:02 +01:00

rg regions

This commit is contained in:
Shiroi Kitsu 2024-06-24 19:41:39 +07:00
parent 8275339913
commit 2223e88b85
4 changed files with 296 additions and 229 deletions

View File

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Car" ADD COLUMN "rgRegions" INTEGER[],
ALTER COLUMN "stLoseBits" SET DEFAULT 0;

View File

@ -119,6 +119,7 @@ model Car {
rgStamp Int @default(1)
rgAcquireAllCrowns Boolean @default(false)
rgRegionMapScore Int[]
rgRegions Int[]
stampSheetCount Int @default(0)
stampSheet Int[]

View File

@ -109,6 +109,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
stampSheet: stampSheet,
stampSheetCount: common.sanitizeInputNotZero(ghostResult.stampSheetCount),
rgTrophy: common.sanitizeInputNotZero(ghostResult.rgTrophy),
rgRegions: []
}
// Count total win based on region map score
@ -126,6 +127,24 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
dataGhost.rgWinCount = winCounter;
dataGhost.rgScore = winCounter;
}
let ghostResults = common.sanitizeInput(ghostResult)
let rgRegionsScore = await opponentsRegion(ghostResults);
let rgRegions: number[] = car.rgRegions || [];
if(rgRegions.length !== (dataGhost.rgWinCount % 100) - rgRegionsScore.length)
{
rgRegions = new Array((dataGhost.rgWinCount % 100) - rgRegionsScore.length - rgRegions.length).fill(18)
}
let mergedRegion = [...rgRegions, ...rgRegionsScore];
// More than 100
if(mergedRegion.length > 100)
{
const excess = mergedRegion.length - 100;
mergedRegion = mergedRegion.slice(-excess);
}
}
// Get the ghost result for the car
@ -744,4 +763,29 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
// Return the value to 'BASE_PATH/src/modules/game.ts'
return { ghostModePlay, updateNewTrail, OCMModePlay }
}
}
// Opponent Region
async function opponentsRegion(ghostResults: wm.protobuf.SaveGameResultRequest.GhostBattleResult)
{
let regionIdArray = [];
for(const ghostResult of ghostResults.opponents)
{
let getRegionId = await prisma.car.findFirst({
where:{
carId: ghostResult.carId
},
select:{
regionId: true
}
});
if(getRegionId)
{
regionIdArray.push(getRegionId.regionId);
}
}
return regionIdArray;
}

475
yarn.lock

File diff suppressed because it is too large Load Diff