commit
7f9ad527c7
4
.gitignore
vendored
4
.gitignore
vendored
@ -7,4 +7,6 @@ dist/
|
|||||||
cert.pfx
|
cert.pfx
|
||||||
key.pem
|
key.pem
|
||||||
config.json
|
config.json
|
||||||
ecosystem.config.js
|
package-lock.json
|
||||||
|
ecosystem.config.js
|
||||||
|
prisma/public.sql
|
9
prisma/migrations/20220720050238_caritem/migration.sql
Normal file
9
prisma/migrations/20220720050238_caritem/migration.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "CarItem_carId_key";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "CarItem" ADD COLUMN "dbId" SERIAL NOT NULL,
|
||||||
|
ADD CONSTRAINT "CarItem_pkey" PRIMARY KEY ("dbId");
|
@ -106,8 +106,8 @@ model Car {
|
|||||||
|
|
||||||
model CarItem {
|
model CarItem {
|
||||||
Car Car? @relation(fields: [carId], references: [carId])
|
Car Car? @relation(fields: [carId], references: [carId])
|
||||||
carId Int @unique
|
dbId Int @id @default(autoincrement())
|
||||||
|
carId Int
|
||||||
category Int
|
category Int
|
||||||
itemId Int
|
itemId Int
|
||||||
amount Int
|
amount Int
|
||||||
|
@ -16,71 +16,88 @@ export default class GameModule extends Module {
|
|||||||
carId: body.carId
|
carId: body.carId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let storyLose: boolean = false;
|
||||||
switch (body.gameMode) {
|
switch (body.gameMode) {
|
||||||
case wm.wm.protobuf.GameMode.MODE_STORY:
|
case wm.wm.protobuf.GameMode.MODE_STORY:
|
||||||
{
|
{
|
||||||
let maxConsecutiveWins = car!.stConsecutiveWinsMax;
|
if (!(body.retired)) {
|
||||||
if (maxConsecutiveWins < body.stResult!.stConsecutiveWins!) {
|
let maxConsecutiveWins = car!.stConsecutiveWinsMax;
|
||||||
maxConsecutiveWins = body.stResult!.stConsecutiveWins!;
|
if (maxConsecutiveWins < body.stResult!.stConsecutiveWins!) {
|
||||||
}
|
maxConsecutiveWins = body.stResult!.stConsecutiveWins!;
|
||||||
let divcount = body.stResult?.stClearDivCount;
|
}
|
||||||
let saveEx: any = {};
|
let divcount = body.stResult?.stClearDivCount;
|
||||||
if (divcount !== null && divcount !== undefined && divcount !== 0) {
|
let saveEx: any = {};
|
||||||
console.log(body.stResult?.stClearDivCount);
|
if (body.stResult?.stLoseBits !== null && body.stResult?.stLoseBits !== undefined) {
|
||||||
saveEx.stClearDivCount = divcount;
|
let actualLoseBits = BigInt(0);
|
||||||
} else {
|
if (body.stResult?.stLoseBits! instanceof Long) {
|
||||||
saveEx.stClearDivCount = car?.stClearDivCount;
|
actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.high);
|
||||||
}
|
actualLoseBits = actualLoseBits << BigInt(32);
|
||||||
if (body.stResult?.stClearBits !== null && body.stResult?.stClearBits !== undefined) {
|
actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.low);
|
||||||
saveEx.stClearBits = body.stResult?.stClearBits;
|
saveEx.stLoseBits = Number(actualLoseBits);
|
||||||
} else {
|
if(saveEx.stLoseBits > 0){
|
||||||
saveEx.stClearBits = car?.stClearBits;
|
storyLose = true;
|
||||||
}
|
}
|
||||||
if (body.stResult?.stPlayCount !== null && body.stResult?.stPlayCount !== undefined) {
|
}
|
||||||
saveEx.stPlayCount = body.stResult?.stPlayCount!;
|
} else {
|
||||||
} else {
|
saveEx.stLoseBits = car?.stLoseBits;
|
||||||
saveEx.stPlayCount = car?.stPlayCount;
|
}
|
||||||
}
|
if (divcount !== null && divcount !== undefined && divcount !== 0) {
|
||||||
if (body.stResult?.stClearCount !== null && body.stResult?.stClearCount !== undefined) {
|
console.log(body.stResult?.stClearDivCount);
|
||||||
saveEx.stClearCount = body.stResult?.stClearCount!;
|
saveEx.stClearDivCount = divcount;
|
||||||
} else {
|
} else {
|
||||||
saveEx.stClearCount = car?.stClearCount;
|
saveEx.stClearDivCount = car?.stClearDivCount;
|
||||||
}
|
}
|
||||||
if (body.stResult?.stLoseBits !== null && body.stResult?.stLoseBits !== undefined) {
|
if (body.stResult?.stClearBits !== null && body.stResult?.stClearBits !== undefined && storyLose !== true) {
|
||||||
let actualLoseBits = BigInt(0);
|
saveEx.stClearBits = body.stResult?.stClearBits;
|
||||||
if (body.stResult?.stLoseBits! instanceof Long) {
|
} else {
|
||||||
actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.high);
|
saveEx.stClearBits = car?.stClearBits;
|
||||||
actualLoseBits = actualLoseBits << BigInt(32);
|
}
|
||||||
actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.low);
|
if (body.stResult?.stPlayCount !== null && body.stResult?.stPlayCount !== undefined) {
|
||||||
saveEx.stLoseBits = actualLoseBits;
|
saveEx.stPlayCount = body.stResult?.stPlayCount!;
|
||||||
|
} else {
|
||||||
|
saveEx.stPlayCount = car?.stPlayCount;
|
||||||
|
}
|
||||||
|
if (body.stResult?.stClearCount !== null && body.stResult?.stClearCount !== undefined && body.stResult?.stClearCount !== 0) {
|
||||||
|
saveEx.stClearCount = body.stResult?.stClearCount!;
|
||||||
|
} else {
|
||||||
|
saveEx.stClearCount = car?.stClearCount;
|
||||||
|
}
|
||||||
|
if (body.stResult?.stConsecutiveWins !== null && body.stResult?.stConsecutiveWins !== undefined) {
|
||||||
|
saveEx.stConsecutiveWins = body.stResult?.stConsecutiveWins!;
|
||||||
|
} else {
|
||||||
|
saveEx.stConsecutiveWins = car?.stConsecutiveWins;
|
||||||
|
}
|
||||||
|
if (body.stResult?.tuningPoint !== null && body.stResult?.tuningPoint !== undefined) {
|
||||||
|
saveEx.tuningPoints = body.stResult?.tuningPoint!;
|
||||||
|
} else {
|
||||||
|
saveEx.tuningPoints = car?.tuningPoints;
|
||||||
|
}
|
||||||
|
if (body.stResult?.stCompleted_100Episodes !== null && body.stResult?.stCompleted_100Episodes !== undefined) {
|
||||||
|
saveEx.stCompleted100Episodes = body.stResult?.stCompleted_100Episodes!;
|
||||||
|
} else {
|
||||||
|
saveEx.stCompleted100Episodes = car?.stCompleted100Episodes;
|
||||||
|
}
|
||||||
|
console.log(saveEx);
|
||||||
|
let c = await prisma.car.update({
|
||||||
|
where: {
|
||||||
|
carId: body.carId
|
||||||
|
},
|
||||||
|
data: saveEx
|
||||||
|
});
|
||||||
|
console.log('-------');
|
||||||
|
console.log(c);
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
saveEx.stLoseBits = car?.stLoseBits;
|
|
||||||
}
|
}
|
||||||
if (body.stResult?.stConsecutiveWins !== null && body.stResult?.stConsecutiveWins !== undefined) {
|
|
||||||
saveEx.stConsecutiveWins = body.stResult?.stConsecutiveWins!;
|
|
||||||
} else {
|
|
||||||
saveEx.stConsecutiveWins = car?.stConsecutiveWins;
|
|
||||||
}
|
|
||||||
if (body.stResult?.tuningPoint !== null && body.stResult?.tuningPoint !== undefined) {
|
|
||||||
saveEx.tuningPoints = body.stResult?.tuningPoint!;
|
|
||||||
} else {
|
|
||||||
saveEx.tuningPoints = car?.tuningPoints;
|
|
||||||
}
|
|
||||||
if (body.stResult?.stCompleted_100Episodes !== null && body.stResult?.stCompleted_100Episodes !== undefined) {
|
|
||||||
saveEx.stCompleted100Episodes = body.stResult?.stCompleted_100Episodes!;
|
|
||||||
} else {
|
|
||||||
saveEx.stCompleted100Episodes = car?.stCompleted100Episodes;
|
|
||||||
}
|
|
||||||
console.log(body);
|
|
||||||
console.log(saveEx);
|
|
||||||
let c = await prisma.car.update({
|
|
||||||
where: {
|
|
||||||
carId: body.carId
|
|
||||||
},
|
|
||||||
data: saveEx
|
|
||||||
});
|
|
||||||
console.log(c);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wm.wm.protobuf.GameMode.MODE_TIME_ATTACK:
|
case wm.wm.protobuf.GameMode.MODE_TIME_ATTACK:
|
||||||
@ -814,6 +831,7 @@ export default class GameModule extends Module {
|
|||||||
transferred: false,
|
transferred: false,
|
||||||
...car!,
|
...car!,
|
||||||
stLoseBits: longLoseBits,
|
stLoseBits: longLoseBits,
|
||||||
|
ownedItems: car!.items
|
||||||
};
|
};
|
||||||
let resp = wm.wm.protobuf.LoadCarResponse.encode(msg);
|
let resp = wm.wm.protobuf.LoadCarResponse.encode(msg);
|
||||||
let end = resp.finish();
|
let end = resp.finish();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user