1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2024-12-03 19:47:17 +01:00

fix custom color and discarded card item reward every n*100 plays

This commit is contained in:
ghkkk090 2022-07-23 16:40:17 +07:00
parent f471add716
commit b076fff40c

View File

@ -21,7 +21,6 @@ export default class GameModule extends Module {
carId: body.carId carId: body.carId
} }
}); });
console.log(body);
let storyLose: boolean = false; let storyLose: boolean = false;
switch (body.gameMode) { switch (body.gameMode) {
case wm.wm.protobuf.GameMode.MODE_STORY: case wm.wm.protobuf.GameMode.MODE_STORY:
@ -92,20 +91,6 @@ export default class GameModule extends Module {
}); });
console.log('-------'); console.log('-------');
console.log(c); console.log(c);
if(body.earnedItems.length !== 0){
console.log('Game reward available, continuing ...');
for(let i=0; i<body.earnedItems.length; i++){
await prisma.carItem.create({
data: {
carId: body.carId,
category: body.earnedItems[i].category,
itemId: body.earnedItems[i].itemId,
amount: 1
}
});
}
}
} }
break; break;
} }
@ -278,24 +263,41 @@ export default class GameModule extends Module {
}, },
data: saveEx data: saveEx
}); });
if(body.earnedItems.length !== 0){
console.log('Game reward available, continuing ...');
for(let i=0; i<body.earnedItems.length; i++){
await prisma.carItem.create({
data: {
carId: body.carId,
category: body.earnedItems[i].category,
itemId: body.earnedItems[i].itemId,
amount: 1
}
});
}
}
} }
} }
} }
// Get car item
if(body.earnedItems.length !== 0){
console.log('Car Item reward available, continuing ...');
for(let i=0; i<body.earnedItems.length; i++){
await prisma.carItem.create({
data: {
carId: body.carId,
category: body.earnedItems[i].category,
itemId: body.earnedItems[i].itemId,
amount: 1
}
});
}
}
// Get user item
if(body.earnedUserItems.length !== 0){
console.log('User Item reward available, continuing ...');
for(let i=0; i<body.earnedUserItems.length; i++){
await prisma.userItem.create({
data: {
category: body.earnedUserItems[i].category,
itemId: body.earnedUserItems[i].itemId,
userId: body.car!.userId!,
earnedAt: 0,
type: 0
}
});
}
}
// Update car // Update car
await prisma.car.update({ await prisma.car.update({
where: { where: {
@ -311,6 +313,7 @@ export default class GameModule extends Module {
tunePower: body.car!.tunePower!, tunePower: body.car!.tunePower!,
tuneHandling: body.car!.tuneHandling!, tuneHandling: body.car!.tuneHandling!,
windowSticker: body.car!.windowSticker!, windowSticker: body.car!.windowSticker!,
earnedCustomColor: body.earnedCustomColor!
} }
}) })
@ -386,11 +389,8 @@ export default class GameModule extends Module {
}) })
app.post('/method/load_user', async (req, res) => { app.post('/method/load_user', async (req, res) => {
let body = wm.wm.protobuf.LoadUserRequest.decode(req.body); let body = wm.wm.protobuf.LoadUserRequest.decode(req.body);
let user = await prisma.user.findFirst({ let user = await prisma.user.findFirst({
where: { where: {
chipId: body.cardChipId, chipId: body.cardChipId,
@ -407,7 +407,6 @@ export default class GameModule extends Module {
// 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,
@ -1231,9 +1230,7 @@ export default class GameModule extends Module {
}) })
app.post('/method/update_car', async (req, res) => { app.post('/method/update_car', async (req, res) => {
let body = wm.wm.protobuf.UpdateCarRequest.decode(req.body); let body = wm.wm.protobuf.UpdateCarRequest.decode(req.body);
let car = await prisma.car.findFirst({ let car = await prisma.car.findFirst({
where: { where: {
carId: body.carId carId: body.carId
@ -1280,6 +1277,21 @@ export default class GameModule extends Module {
} }
}); });
// Get car item
if(body.earnedItems.length !== 0){
console.log('Car Item reward available, continuing ...');
for(let i=0; i<body.earnedItems.length; i++){
await prisma.carItem.create({
data: {
carId: body.carId,
category: body.earnedItems[i].category,
itemId: body.earnedItems[i].itemId,
amount: 1
}
});
}
}
let msg = { let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
} }
@ -1739,7 +1751,6 @@ export default class GameModule extends Module {
}) })
app.post('/method/update_user_session', (req, res) => { app.post('/method/update_user_session', (req, res) => {
// Get the request body // Get the request body
// let body = wm.wm.protobuf.UpdateUserSessionRequest.decode(req.body); // let body = wm.wm.protobuf.UpdateUserSessionRequest.decode(req.body);
@ -1776,8 +1787,7 @@ export default class GameModule extends Module {
app.post('/method/search_cars_by_level', async (req, res) => { app.post('/method/search_cars_by_level', async (req, res) => {
let body = wm.wm.protobuf.SearchCarsByLevelRequest.decode(req.body); let body = wm.wm.protobuf.SearchCarsByLevelRequest.decode(req.body);
console.log(body); //---------------MAYBE NOT CORRECT---------------
//---------------MAYBE NOT CORRECT---------------
let rampVal = 0; let rampVal = 0;
let pathVal = 0; let pathVal = 0;
if(body.area === 0){ //GID_RUNAREA_C1 if(body.area === 0){ //GID_RUNAREA_C1