Commit bede2e03 authored by 俞嘉婷's avatar 俞嘉婷

游戏。。。

parent 72058707
...@@ -10,49 +10,33 @@ export default [ ...@@ -10,49 +10,33 @@ export default [
message: "message", message: "message",
data: AESEncrypt(JSON.stringify({ data: AESEncrypt(JSON.stringify({
recordId: "recordId", recordId: "recordId",
countdownSeconds: 110, countdownSeconds: 26,
remainTipTimes: 3, targetConfig: {
}), "7A2F4B8D1E6C3905", "cDOiBC1n2QrkAY2P"), target1: 10, // 背包数量
target2: 23, // 飞机数量
},
}), "4fe20bdefdd4804f", "cDOiBC1n2QrkAY2P"),
// data: "TtL6pvFMpXEajymGe7uOoiD0iaAnxxtuOFqvG+Vo0R4qzJQlb+eQneEkPKv+nNsXKJHVe/hfKTQAMj6FuC2Ltg==" // data: "TtL6pvFMpXEajymGe7uOoiD0iaAnxxtuOFqvG+Vo0R4qzJQlb+eQneEkPKv+nNsXKJHVe/hfKTQAMj6FuC2Ltg=="
} }
}, },
}, },
{
url: '/game/suggest.do',
response: ({ query }) => {
return {
code: "123",
success: true,
message: "message",
data: null
}
},
},
{
url: '/game/middleSubmit.do',
response: ({ query }) => {
return {
code: "123",
success: true,
message: "message",
data: null
}
},
},
{ {
url: '/game/submit.do', url: '/game/submit.do',
response: ({ query }) => { response: ({ query }) => {
return { return {
code: "123", "success": true,
success: true, "code": "",
message: "message", "message": "",
data: { "data": {
drawChance: 3, "gotSpInfo": {
title: "5555", "spId": "sp_landmark1",
desc: "123123123", "name": "北京",
score: 10, "icon": "https://www.baidu.com/tiananmen.png"
},
"rewardDrawTimes": 1,
"leftGameTimes": 2
} }
} }
}, }
}, },
] ]
...@@ -149,14 +149,6 @@ const API = generateAPI({ ...@@ -149,14 +149,6 @@ const API = generateAPI({
uri: `game/start.do`, uri: `game/start.do`,
withToken: true, withToken: true,
}, },
suggest: {
uri: `game/suggest.do`,
withToken: true,
},
middleSubmit: {
uri: `game/middleSubmit.do`,
withToken: true,
},
submit: { submit: {
uri: `game/submit.do`, uri: `game/submit.do`,
withToken: true, withToken: true,
......
...@@ -19,8 +19,6 @@ import { _throttle } from "@/utils/utils.ts"; ...@@ -19,8 +19,6 @@ import { _throttle } from "@/utils/utils.ts";
import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts"; import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts";
import { LOG_KEY, pageView, sensorLog } from "@/utils/sensors"; import { LOG_KEY, pageView, sensorLog } from "@/utils/sensors";
import { ModalCtrl } from "@/core/ctrls/ModalCtrl"; import { ModalCtrl } from "@/core/ctrls/ModalCtrl";
import FailPopup from '@/panels/FailPopup/index.jsx'
import VictoryPopup from '@/panels/VictoryPopup/index.jsx'
import "./js/output"; import "./js/output";
...@@ -55,9 +53,9 @@ class GamePage extends React.Component<any, any> { ...@@ -55,9 +53,9 @@ class GamePage extends React.Component<any, any> {
window.addEventListener('resize', function () { store.game.stage.resize() }); window.addEventListener('resize', function () { store.game.stage.resize() });
//展示游戏,传入数据 //展示游戏,传入数据
store.game.showGame({ store.game.showGame({
targetStudy: 1,//背包数量 targetStudy: gameStore.gameInfo.targetConfig.target1,//背包数量
targetTravel: 1,//飞机数量 targetTravel: gameStore.gameInfo.targetConfig.target2,//飞机数量
time: 120,//时间,秒计 time: gameStore.gameInfo.countdownSeconds,//时间,秒计
needGuide: store.indexData?.newGuideFlag == 1, needGuide: store.indexData?.newGuideFlag == 1,
}) })
if (store.indexData?.newGuideFlag == 1) { if (store.indexData?.newGuideFlag == 1) {
...@@ -68,11 +66,12 @@ class GamePage extends React.Component<any, any> { ...@@ -68,11 +66,12 @@ class GamePage extends React.Component<any, any> {
console.log(e)//成功 console.log(e)//成功
if (e.data === true) { if (e.data === true) {
//成功 //成功
let param = { "recordId": 1234, "score": 507, "success": true, "timestamp": 1749800591737 } // 得分【1个背包100分,1个飞机1分】
this.submitGame(param) const score = 0; // TODO
gameStore.submit(score, true)
} else { } else {
console.log(e.data) const score = 0; // TODO
ModalCtrl.showModal(FailPopup, e.data); gameStore.submit(score, false, e.data)
// { // {
// targetStudy: 1,//还差合成数量 // targetStudy: 1,//还差合成数量
// targetTravel: 2, // targetTravel: 2,
...@@ -103,29 +102,6 @@ class GamePage extends React.Component<any, any> { ...@@ -103,29 +102,6 @@ class GamePage extends React.Component<any, any> {
} }
//提交游戏
submitGame = async (param) => {
let gameData: any = await API.submitGame({ param: param })
gameData = {
"success": true,
"code": "",
"message": "",
"data": {
"gotSpInfo": {
"spId": "sp_landmark1",
"name": "北京",
"icon": "https://www.baidu.com/tiananmen.png"
},
"rewardDrawTimes": 1,
"leftGameTimes": 2
}
}
if (gameData.data?.gotSpInfo) {
ModalCtrl.showModal(VictoryPopup, gameData.data);
}
}
render() { render() {
return <div className={styles.root} ref={(el) => this.gameDiv = el}> return <div className={styles.root} ref={(el) => this.gameDiv = el}>
......
...@@ -29,10 +29,13 @@ class FailPopup extends React.Component { ...@@ -29,10 +29,13 @@ class FailPopup extends React.Component {
//再玩一次 //再玩一次
onReceive = () => { onReceive = () => {
ModalCtrl.closeModal(); ModalCtrl.closeModal();
PageCtrl.changePage(HomePage);//回到首页
/*
//重玩游戏 //重玩游戏
if (store.game) { if (store.game) {
store.game.dispatchGlobalEvent("restartGame", { targetStudy: 1, targetTravel: 1, time: 120 }) store.game.dispatchGlobalEvent("restartGame", { targetStudy: 1, targetTravel: 1, time: 120 })
} }
*/
} }
render() { render() {
......
...@@ -4,8 +4,8 @@ import { AESDecrypt, AESEncrypt } from "@/utils/Crypto.ts"; ...@@ -4,8 +4,8 @@ import { AESDecrypt, AESEncrypt } from "@/utils/Crypto.ts";
import { PageCtrl } from "@/core/ctrls/PageCtrl.tsx"; import { PageCtrl } from "@/core/ctrls/PageCtrl.tsx";
import HomePage from "@/pages/HomePage/HomePage.tsx"; import HomePage from "@/pages/HomePage/HomePage.tsx";
import { ModalCtrl } from "@/core/ctrls/ModalCtrl.tsx"; import { ModalCtrl } from "@/core/ctrls/ModalCtrl.tsx";
import Settlechance from "@/components/settlechance/settlechance"; import FailPopup from '@/panels/FailPopup/index.jsx'
import Settlenochance from "@/components/settlenochance/settlenochance"; import VictoryPopup from '@/panels/VictoryPopup/index.jsx'
class GameStore { class GameStore {
...@@ -15,11 +15,11 @@ class GameStore { ...@@ -15,11 +15,11 @@ class GameStore {
gameInfo = { gameInfo = {
recordId: "", recordId: "",
levelIndex: -1,
levelIdxArr: [],
countdownSeconds: 180, countdownSeconds: 180,
remainTipTimes: 0, targetConfig: {
cd: 180, target1: 0, // 背包数量
target2: 0, // 飞机数量
},
isSubmit: false, isSubmit: false,
} }
...@@ -28,41 +28,31 @@ class GameStore { ...@@ -28,41 +28,31 @@ class GameStore {
const { success, data: d } = await API.start(); const { success, data: d } = await API.start();
if (!success) return false; if (!success) return false;
const data = JSON.parse(AESDecrypt(d, "7A2F4B8D1E6C3905", "cDOiBC1n2QrkAY2P")) as any; const data = JSON.parse(AESDecrypt(d, "4fe20bdefdd4804f", "cDOiBC1n2QrkAY2P")) as any;
this.gameInfo.levelIdxArr.sort(() => Math.random() - 0.5);
this.gameInfo.levelIndex = -1;
this.gameInfo.isSubmit = false; this.gameInfo.isSubmit = false;
this.gameInfo.recordId = data.recordId; this.gameInfo.recordId = data.recordId;
this.gameInfo.countdownSeconds = data.countdownSeconds; this.gameInfo.countdownSeconds = data.countdownSeconds;
this.gameInfo.remainTipTimes = data.remainTipTimes this.gameInfo.targetConfig = data.targetConfig
return success; return success;
} }
async suggest() {
const { success, data } = await API.suggest();
return success;
}
async middleSubmit(score: number) { async submitGame(score: number) {
if (this.gameInfo.isSubmit) { if (this.gameInfo.isSubmit) {
return; return;
} }
const d = { const d = {
recordId: this.gameInfo.recordId,
score,
timestamp: Date.now(),
}; };
console.log(1, d); const param = AESEncrypt(JSON.stringify(d), "4fe20bdefdd4804f", "cDOiBC1n2QrkAY2P");
const param = AESEncrypt(JSON.stringify(d), "7A2F4B8D1E6C3905", "cDOiBC1n2QrkAY2P");
const { success, data } = await API.middleSubmit({ param }); const { success, data } = await API.submit({ param });
return success; return success;
} }
async submit(score: number) { async submit(score: number, suc: boolean, gameData?: any) {
if (this.gameInfo.isSubmit) { if (this.gameInfo.isSubmit) {
return; return;
} }
...@@ -72,10 +62,11 @@ class GameStore { ...@@ -72,10 +62,11 @@ class GameStore {
const d = { const d = {
recordId: this.gameInfo.recordId, recordId: this.gameInfo.recordId,
score, score,
success: suc,
timestamp: Date.now(), timestamp: Date.now(),
}; };
console.log(2, d); console.log(2, d);
const param = AESEncrypt(JSON.stringify(d), "7A2F4B8D1E6C3905", "cDOiBC1n2QrkAY2P"); const param = AESEncrypt(JSON.stringify(d), "4fe20bdefdd4804f", "cDOiBC1n2QrkAY2P");
const { success, data } = await API.submit({ param }); const { success, data } = await API.submit({ param });
if (!success) { if (!success) {
...@@ -83,12 +74,11 @@ class GameStore { ...@@ -83,12 +74,11 @@ class GameStore {
return success; return success;
} }
if (data.drawChance) { if (suc) {
ModalCtrl.showModal(Settlechance, { data }); ModalCtrl.showModal(VictoryPopup, data);
}else { } else {
ModalCtrl.showModal(Settlenochance, { data }); ModalCtrl.showModal(FailPopup, gameData);
} }
return success; 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