1
0
mirror of synced 2025-01-31 12:13:43 +01:00

Merge pull request #48 from shiroikitsu8/master-asakura

fix crown list order and story nuke bug when clearing story that already cleared
This commit is contained in:
Luna 2022-10-29 14:07:17 +01:00 committed by GitHub
commit fe865bc826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 108 additions and 52 deletions

View File

@ -536,6 +536,8 @@ export default class CarModule extends Module {
// Car update data
data = {
name: common.sanitizeInput(cars.name),
manufacturer: common.sanitizeInput(cars.manufacturer),
model: common.sanitizeInput(cars.model),
visualModel: common.sanitizeInput(cars.visualModel),
customColor: common.sanitizeInput(cars.customColor),
wheel: common.sanitizeInput(cars.wheel),

View File

@ -332,27 +332,28 @@ export default class ResourceModule extends Module {
// Get the crown holder data
let car_crown = await prisma.carCrown.findMany({
orderBy: {
area: 'asc'
}
area: 'asc'
},
distinct: ['area']
});
// Crown holder data available
if(car_crown.length !== 0)
{
let counter = 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)
// After Kobe is Hiroshima then Fukuoka and the rest
if(i > 14)
{
i = 18; // GID_RUNAREA_HIROSHIMA
}
// Crown holder for certain area available
if(car_crown[counter].area === i){
if(car_crown[counter].area === i)
{
// Get user's data
let car = await prisma.car.findFirst({
where: {
@ -364,12 +365,6 @@ export default class ResourceModule extends Module {
}
});
// 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;
@ -394,48 +389,98 @@ export default class ResourceModule extends Module {
}
// 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!
}));
// GID_RUNAREA_HIROSHIMA
if(car_crown[counter].area === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: car_crown[counter].carId,
area: car_crown[counter].area,
unlockAt: car_crown[counter].playedAt,
car: car!
});
if(counter < car_crown.length-1){
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: car_crown[counter].carId,
area: car_crown[counter].area,
unlockAt: car_crown[counter].playedAt,
car: car!
}));
}
if(counter < car_crown.length-1)
{
counter++;
}
}
// Crown holder for certain area not available
else{
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,
}));
// GID_RUNAREA_HIROSHIMA
if(i === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
});
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
}));
}
}
}
}
// There is no user's crown holder data available
else{
else
{
// Loop GID_RUNAREA
for(let i=0; i<19; i++)
for(let i=0; i<14; i++)
{
// 14 - 16 are dummy area, 17 is C1 Closed
if(i >= 14)
// After Kobe is Hiroshima then Fukuoka and the rest
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,
}));
// GID_RUNAREA_HIROSHIMA
if(i === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
});
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
}));
}
}
}

View File

@ -15,9 +15,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
// If the game was not retired / timed out
if (!(body.retired || body.timeup))
{
console.log('Game not retired / timed out, continuing ...')
console.log(body);
// Get the story result for the car
let storyResult = body?.stResult;
let stLoseBits = 0;
let stLoseBits;
// storyResult is set
if (storyResult)
@ -54,6 +57,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
}
}
// Calling check step function (BASE_PATH/src/util/games/games_util/check_step.ts)
let check_steps = await check_step.checkCurrentStep(body);
// Set the ghost level to the correct level
data.ghostLevel = check_steps.ghostLevel;
// Check if clearBits is not null, and not lose the story
if(storyResult.stClearBits !== null && storyResult.stClearBits !== undefined)
{
@ -63,19 +72,19 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
}
}
// Calling check step function (BASE_PATH/src/util/games/games_util/check_step.ts)
let check_steps = await check_step.checkCurrentStep(body);
// Set the ghost level to the correct level
data.ghostLevel = check_steps.ghostLevel;
// Update the car properties
await prisma.car.update({
where: {
carId: body.carId
},
data: data
});
if(data.stClearCount || stLoseBits)
{
console.log('Updating story data');
// Update the car properties
await prisma.car.update({
where: {
carId: body.carId
},
data: data
});
}
}
}
}