Commit 6f300672 authored by haiyoucuv's avatar haiyoucuv

11

parent c6050460
......@@ -52,6 +52,15 @@ export class Game extends Base {
const { levelIndex, levelIdxArr } = gameStore.gameInfo;
if (levelIndex > 0) {
if (levelIndex >= LevelArr.length) {
gameStore.submit(LevelArr.length);
return;
} else {
gameStore.middleSubmit(levelIndex);
}
}
if (levelIndex >= levelIdxArr.length) {
return;
}
......
import { makeAutoObservable, } from 'mobx';
import { LevelArr } from "@/pages/GamePage/Level/LevelConfig.ts";
import API from "@/api";
import { AESEncrypt } from "@/utils/Crypto.ts";
import { PageCtrl } from "@/core/ctrls/PageCtrl.tsx";
import HomePage from "@/pages/HomePage/HomePage.tsx";
import { ModalCtrl } from "@/core/ctrls/ModalCtrl.tsx";
import Settlechance from "@/components/settlechance/settlechance";
import Settlenochance from "@/components/settlenochance/settlenochance";
class GameStore {
......@@ -9,6 +15,7 @@ class GameStore {
}
gameInfo = {
recordId: "",
levelIndex: -1,
levelIdxArr: [],
countdownSeconds: 180,
......@@ -23,16 +30,46 @@ class GameStore {
this.gameInfo.levelIdxArr = LevelArr.map((_, index) => index);
this.gameInfo.levelIdxArr.sort(() => Math.random() - 0.5);
this.gameInfo.levelIndex = -1;
this.gameInfo.recordId = data.recordId;
this.gameInfo.countdownSeconds = data.countdownSeconds;
this.gameInfo.remainTipTimes = data.remainTipTimes
return success;
}
async submit() {
async middleSubmit(score: number) {
console.log(score);
const param = AESEncrypt(JSON.stringify({
recordId: this.gameInfo.recordId,
score,
timestamp: Date.now(),
}), "7A2F4B8D1E6C3905", "cDOiBC1n2QrkAY2P");
const score = this.gameInfo.levelIndex;
const { success, data } = await API.middleSubmit({ param });
return success;
}
async submit(score: number) {
console.log(score);
const param = AESEncrypt(JSON.stringify({
recordId: this.gameInfo.recordId,
score,
timestamp: Date.now(),
}), "7A2F4B8D1E6C3905", "cDOiBC1n2QrkAY2P");
const { success, data } = await API.middleSubmit({ param });
if (!success) {
PageCtrl.changePage(HomePage);
return success;
}
if (data.drawChance) {
ModalCtrl.showModal(Settlechance, { score, ...data });
}else {
ModalCtrl.showModal(Settlenochance, { score, ...data });
}
return success;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment