1
0
mirror of synced 2024-12-04 19:17:58 +01:00

fix lock friend stamp

This commit is contained in:
ghkkk090 2022-08-31 23:31:16 +07:00
parent bd2d615a3e
commit a243e49015
4 changed files with 101 additions and 32 deletions

View File

@ -169,8 +169,10 @@ export default class CarModule extends Module {
let opponentTarget = await prisma.carStampTarget.findMany({
where:{
stampTargetCarId: body.carId,
locked: false,
recommended: true,
},
orderBy:{
locked: 'desc'
}
})
@ -252,7 +254,7 @@ export default class CarModule extends Module {
// Stamp or Challenger
challenger: carsChallengers[0] || null,
challengerReturnCount: returnCount || null,
numOfChallengers: carsChallengers.length || null,
numOfChallengers: carsChallengers.length + 1 || null,
// OCM Challenge Top 1
opponentGhost: ghostCarsNo1 || null,

View File

@ -78,7 +78,10 @@ export default class GhostModule extends Module {
let stampTargets = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: body.carId,
locked: false
recommended: true
},
orderBy:{
locked: 'desc'
}
});
@ -180,7 +183,10 @@ export default class GhostModule extends Module {
let stampTargets = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: body.carId,
locked: false
recommended: true
},
orderBy:{
locked: 'asc'
}
});

View File

@ -188,6 +188,7 @@ export default class TerminalModule extends Module {
// Get the query from the request
let query = req.query;
let cars;
// Check the query limit
let queryLimit = 10
@ -197,9 +198,9 @@ export default class TerminalModule extends Module {
}
// Check the last played place id
let queryLastPlayedPlaceId = 1;
if(query.limit)
if(query.last_played_place_id)
{
let queryLastPlayedPlaceId = 1;
let getLastPlayedPlaceId = await prisma.placeList.findFirst({
where:{
placeId: String(query.last_played_place_id)
@ -208,12 +209,24 @@ export default class TerminalModule extends Module {
if(getLastPlayedPlaceId)
{
queryLastPlayedPlaceId = getLastPlayedPlaceId.id
}
queryLastPlayedPlaceId = getLastPlayedPlaceId.id;
}
cars = await prisma.car.findMany({
take: queryLimit,
where: {
lastPlayedPlaceId: queryLastPlayedPlaceId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
});
}
else
{
// Get all of the cars matching the query
let cars = await prisma.car.findMany({
cars = await prisma.car.findMany({
take: queryLimit,
where: {
OR:[
@ -223,15 +236,19 @@ export default class TerminalModule extends Module {
}
},
{
lastPlayedPlaceId: queryLastPlayedPlaceId
name: {
endsWith: String(query.name)
}
}
]
},
include:{
gtWing: true,
lastPlayedPlace: true
}
});
}
for(let i=0; i<cars.length; i++)
{
@ -995,6 +1012,50 @@ export default class TerminalModule extends Module {
})
// Lock Stamp Target
app.post('/method/lock_stamp_target', async (req, res) => {
// car_id, target_cars[]
let body = wm.wm.protobuf.LockStampTargetRequest.decode(req.body);
// Unlock all of the stamp targets for the car
await prisma.carStampTarget.updateMany({
where: {
stampTargetCarId: body.carId
},
data: {
locked: false
}
});
// Loop over all of the locked stamp targets
for(let targetCar of body.targetCars)
{
// Lock the stamp target for the given car
// This should only occur once, however
// the relationship is not strictly 1:1
await prisma.carStampTarget.updateMany({
where: {
carId: targetCar,
stampTargetCarId: body.carId
},
data: {
locked: true
}
});
}
// Encode the response
let message = wm.wm.protobuf.LoadStampTargetResponse.encode({
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
});
// Send the response to the client
common.sendResponse(message, res);
});
/*
app.post('/method/load_unreceived_user_items', async (req, res) => {

View File

@ -165,11 +165,11 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
carId: rgResult.opponents![i].carId,
stampTargetCarId: body.carId,
returnCount: returnCount,
locked: true,
locked: false,
recommended: false
}
console.log(`Updating car ${rgResult.opponents![i].carId} vs ${body.carId} stamp entry and locking it`);
console.log(`Updating car ${rgResult.opponents![i].carId} vs ${body.carId} stamp entry and remove it from your recommendation`);
await prisma.carStampTarget.update({
where:{
@ -217,7 +217,7 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
if(stampReturned)
{
console.log(`Stamp returned to ${rgResult.opponents![i].carId}, unlocking it so opponents can fight your ghost`);
console.log(`Stamp returned to ${rgResult.opponents![i].carId}, recommend it so opponents can fight your ghost`);
await prisma.carStampTarget.update({
where:{