|
@@ -158,50 +158,64 @@ async function SaveLevelResult(runtime)
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
console.log("Calling SaveLevelResult...");
|
|
console.log("Calling SaveLevelResult...");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const body = {
|
|
const body = {
|
|
|
- token: runtime.globalVars.token,
|
|
|
|
|
- msisdn: runtime.globalVars.msisdn,
|
|
|
|
|
- transId: runtime.globalVars.transId,
|
|
|
|
|
- level: runtime.globalVars.cur_level,
|
|
|
|
|
- score: runtime.globalVars.score,
|
|
|
|
|
- gameType: runtime.globalVars.gameType,
|
|
|
|
|
- gameOver: 0
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ token: runtime.globalVars.token,
|
|
|
|
|
+ msisdn: runtime.globalVars.msisdn,
|
|
|
|
|
+ transId: runtime.globalVars.transId,
|
|
|
|
|
+ level: runtime.globalVars.cur_level,
|
|
|
|
|
+ score: runtime.globalVars.score,
|
|
|
|
|
+ gameType: runtime.globalVars.gameType,
|
|
|
|
|
+ gameOver: 0
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
console.log("Request Body:", body);
|
|
console.log("Request Body:", body);
|
|
|
- console.log("JSON:", JSON.stringify(body));
|
|
|
|
|
|
|
|
|
|
- const response = await fetch(runtime.globalVars.root+"/Game/SaveLevelResult",
|
|
|
|
|
- {
|
|
|
|
|
- method: "POST",
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "application/json"
|
|
|
|
|
- },
|
|
|
|
|
- body: JSON.stringify(body)
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const response = await fetch(
|
|
|
|
|
+ runtime.globalVars.root + "/Game/SaveLevelResult",
|
|
|
|
|
+ {
|
|
|
|
|
+ method: "POST",
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Content-Type": "application/json"
|
|
|
|
|
+ },
|
|
|
|
|
+ body: JSON.stringify(body)
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const result = await response.json();
|
|
const result = await response.json();
|
|
|
|
|
|
|
|
console.log("Level Result:", result);
|
|
console.log("Level Result:", result);
|
|
|
|
|
|
|
|
- // Ví dụ dữ liệu trả về
|
|
|
|
|
- runtime.globalVars.point =
|
|
|
|
|
- result.point ?? "";
|
|
|
|
|
|
|
+ // Lưu dữ liệu gốc
|
|
|
|
|
+ runtime.globalVars.point = Number(result.point ?? 0);
|
|
|
|
|
+ runtime.globalVars.data = Number(result.data ?? 0);
|
|
|
|
|
+ runtime.globalVars.score = Number(result.score ?? 0);
|
|
|
|
|
+ runtime.globalVars.transId = result.transId ?? "";
|
|
|
|
|
|
|
|
- runtime.globalVars.data =
|
|
|
|
|
- result.data ?? "";
|
|
|
|
|
|
|
+ // Xác định phần thưởng
|
|
|
|
|
+ runtime.globalVars.gGiftValues = 0;
|
|
|
|
|
+ runtime.globalVars.gGiftText = "";
|
|
|
|
|
|
|
|
- runtime.globalVars.score =
|
|
|
|
|
- result.score ?? "";
|
|
|
|
|
-
|
|
|
|
|
- runtime.globalVars.transId =
|
|
|
|
|
- result.transId ?? "";
|
|
|
|
|
|
|
+ if (runtime.globalVars.point > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ runtime.globalVars.gGiftValues = runtime.globalVars.point;
|
|
|
|
|
+ runtime.globalVars.gGiftText = "POINTS";
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (runtime.globalVars.data > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ runtime.globalVars.gGiftValues = runtime.globalVars.data;
|
|
|
|
|
+ runtime.globalVars.gGiftText = "DATA";
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (runtime.globalVars.score > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ runtime.globalVars.gGiftValues = runtime.globalVars.score;
|
|
|
|
|
+ runtime.globalVars.gGiftText = "SCORE";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
runtime.globalVars.showPrizePopup = 1;
|
|
runtime.globalVars.showPrizePopup = 1;
|
|
|
- console.log("Chuẩn bị gọi vào function trong event sheet:");
|
|
|
|
|
- //runtime.callFunction("Quangbh");
|
|
|
|
|
- console.log("Da goi goi vao function event sheet xong nhe!!!");
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ console.log("Gift Type:", runtime.globalVars.gGiftText);
|
|
|
|
|
+ console.log("Gift Value:", runtime.globalVars.gGiftValues);
|
|
|
}
|
|
}
|
|
|
catch (error)
|
|
catch (error)
|
|
|
{
|
|
{
|
|
@@ -213,7 +227,6 @@ async function SaveLevelResult(runtime)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// Khi muốn thoát game về MVC
|
|
// Khi muốn thoát game về MVC
|
|
|
function SaveExitGame(runtime)
|
|
function SaveExitGame(runtime)
|
|
|
{
|
|
{
|