Merge pull request #67 from shiroikitsu8/master
trying to fix terminal scratch
This commit is contained in:
commit
da73b2fbce
@ -10,7 +10,7 @@
|
||||
"grantFullTuneTicketToNewUsers": 5,
|
||||
"giftCarsFullyTuned": 0,
|
||||
"scratchEnabled": 1,
|
||||
"scratchType": 1,
|
||||
"scratchType": 0,
|
||||
"giveMeterReward": 0,
|
||||
"newCardsBanned": 0,
|
||||
"enableScreenshot": 0
|
||||
|
@ -482,13 +482,6 @@ export default class TerminalModule extends Module {
|
||||
// Get the current date/time (unix epoch)
|
||||
let date = Math.floor(new Date().getTime() / 1000)
|
||||
|
||||
// Get all of the info for the user
|
||||
let user = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: body.userId
|
||||
}
|
||||
});
|
||||
|
||||
// Get all of the scratch sheets for the user
|
||||
let scratchSheets = await prisma.scratchSheet.findMany({
|
||||
where: {
|
||||
@ -559,11 +552,24 @@ export default class TerminalModule extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
// If the box we uncovered is the car
|
||||
if (scratchSquare.category == 201)
|
||||
// If the box we uncovered is the car... hehe boi
|
||||
if (scratchSquare.category === 201)
|
||||
{
|
||||
// Get user last scratch sheet number
|
||||
let lastUserSheet = await prisma.scratchSheet.findFirst({
|
||||
where:{
|
||||
userId: body.userId
|
||||
},
|
||||
orderBy:{
|
||||
sheetNo: 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
// Last scratch sheet plus 1
|
||||
let targetSheet:number = Number(lastUserSheet?.sheetNo) + 1 || Number(body.targetSheet) + 1;
|
||||
|
||||
// Generate a new scratch sheet for the user
|
||||
await scratch.generateScratchSheet(body.userId, body.targetSheet + 1)
|
||||
await scratch.generateScratchSheet(body.userId, targetSheet);
|
||||
}
|
||||
}
|
||||
catch (error) // Failed to update scratch sheet
|
||||
|
@ -294,13 +294,14 @@ function shuffleScratchSheet (array: number[][])
|
||||
// 1 Random Scratch Car
|
||||
// 25 Random Scratch Stickers
|
||||
// 24 Random Scratch Versus Markers
|
||||
function getRandomScratchSheet (carId: number)
|
||||
function getRandomScratchSheet (sheetNo: number)
|
||||
{
|
||||
// Scratch items list
|
||||
let items : number[][] = [];
|
||||
let sheetNumber:number = Number(sheetNo % scratchCars.length);
|
||||
|
||||
// Add the scratch car for the given index
|
||||
items.push([201, scratchCars[carId % scratchCars.length]]);
|
||||
items.push([201, scratchCars[sheetNumber]]);
|
||||
|
||||
// Add the random scratch stickers
|
||||
|
||||
|
@ -123,9 +123,9 @@ export default class UserModule extends Module {
|
||||
false, // TUTORIAL_ID_UNUSED_17 = 17,
|
||||
false, // TUTORIAL_ID_UNUSED_18 = 18,
|
||||
false, // TUTORIAL_ID_UNUSED_19 = 19,
|
||||
false, // TUTORIAL_ID_GHOST_STAMP = 20,
|
||||
false, // TUTORIAL_ID_GHOST_STAMP_DECLINED = 21,
|
||||
false, // TUTORIAL_ID_GHOST_STAMP_FRIENDS = 22,
|
||||
true, // TUTORIAL_ID_GHOST_STAMP = 20,
|
||||
true, // TUTORIAL_ID_GHOST_STAMP_DECLINED = 21,
|
||||
true, // TUTORIAL_ID_GHOST_STAMP_FRIENDS = 22,
|
||||
false, // TUTORIAL_ID_TERMINAL_SCRATCH = 23,
|
||||
false, // TUTORIAL_ID_TURN_SCRATCH_SHEET = 24,
|
||||
false, // TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN = 25,
|
||||
@ -159,7 +159,7 @@ export default class UserModule extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('user made')
|
||||
console.log('user made');
|
||||
|
||||
if (!user)
|
||||
{
|
||||
@ -179,7 +179,7 @@ export default class UserModule extends Module {
|
||||
userId: user.id,
|
||||
category: wm.wm.protobuf.ItemCategory.CAT_CAR_TICKET_FREE,
|
||||
itemId: 5,
|
||||
type: 0 // Car Ticket
|
||||
type: Number(0) // Car Ticket
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -211,15 +211,15 @@ export default class UserModule extends Module {
|
||||
}
|
||||
})
|
||||
|
||||
console.log("Current sheet count:", scratchSheetCount);
|
||||
console.log("Current sheet count: ", scratchSheetCount);
|
||||
|
||||
// If the user has no scratch sheets
|
||||
if (scratchSheetCount == 0)
|
||||
if (scratchSheetCount === 0)
|
||||
{
|
||||
console.log("Generating first sheet ...");
|
||||
|
||||
// Generate a new scratch sheet for the user
|
||||
await scratch.generateScratchSheet(user!.id, 1);
|
||||
await scratch.generateScratchSheet(user!.id, Number(1));
|
||||
|
||||
// Set the current scratch sheet to 1
|
||||
await prisma.user.update({
|
||||
@ -227,7 +227,7 @@ export default class UserModule extends Module {
|
||||
id: user!.id
|
||||
},
|
||||
data: {
|
||||
currentSheet: 1
|
||||
currentSheet: Number(1)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user