Commit 73e22e84 authored by limingzhe's avatar limingzhe

fix: debug

parent 2b3c9c8f
No preview for this file type
{ {"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
"ver": "1.1.2", \ No newline at end of file
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
...@@ -742,6 +742,7 @@ cc.Class({ ...@@ -742,6 +742,7 @@ cc.Class({
}, },
setPlayerResult(data) { setPlayerResult(data) {
console.log(' in setPlayerResult');
const { uuid } = data; const { uuid } = data;
this.gameEndData[uuid] = data; this.gameEndData[uuid] = data;
...@@ -1050,7 +1051,7 @@ cc.Class({ ...@@ -1050,7 +1051,7 @@ cc.Class({
} }
const aiArr = this.getAiArr(); const aiArr = this.getAiArr();
if (aiArr.length == 0 || true) { if (aiArr.length == 0) {
this.teacherEnd(); this.teacherEnd();
return; return;
} }
...@@ -1073,45 +1074,116 @@ cc.Class({ ...@@ -1073,45 +1074,116 @@ cc.Class({
// return; // return;
c.getAnswer({ count: aiArr.length }, (res) => { this.getAnswer(aiArr);
console.log('getAnswer res: ', res);
if (res) { // this.teacherEnd();
},
async getAnswer(aiArr) {
if (typeof (res) == 'string') { const node = cc.find('middleLayer');
if (node) {
console.log('node exist');
const mScript = node.getComponent('middleLayer');
const coursewareid = mScript?.courseItem?.id;
if (!coursewareid) {
console.log(" !coursewareid~: ");
this.teacherEnd();
return;
}
console.log('~ coursewareid :' , coursewareid);
const token = cc.sys.localStorage.getItem('token');
const url = "/api/oxford/courseware/v1/" + coursewareid + "/getanswer"
mScript.callNetworkApiGet(url, {coursewareid, token, count: aiArr.length}, (res)=> {
console.log("res~: ", res);
if (typeof(res) == "string") {
res = JSON.parse(res); res = JSON.parse(res);
console.log('objRes: ', res);
}
if(res.code == 200) {
// const rankArr = res.data?.rows || [];
// OP12.rank.inst.onShow(rankArr);
const rows = res.data?.rows || [];
await this.addAiResult(rows, aiArr);
// await this.asyncDelay(1);
console.log("res: ", res);
} }
this.addAiResult(res, aiArr);
this._timeoutIds.push(setTimeout(() => { this._timeoutIds.push(setTimeout(() => {
this.teacherEnd(); this.teacherEnd();
}, 200)); }, 200));
// await this.asyncDelay(1); });
} else { } else {
console.log('node not exist');
this._timeoutIds.push(setTimeout(() => { this._timeoutIds.push(setTimeout(() => {
this.teacherEnd(); this.teacherEnd();
}, 200)); }, 200));
} }
})
// c.getAnswer({ count: aiArr.length }, (res) => {
// console.log('getAnswer res: ', res);
// if (res) {
// if (typeof (res) == 'string') {
// res = JSON.parse(res);
// }
// this.addAiResult(res, aiArr);
// this._timeoutIds.push(setTimeout(() => {
// this.teacherEnd();
// }, 200));
// // await this.asyncDelay(1);
// } else {
// this._timeoutIds.push(setTimeout(() => {
// this.teacherEnd();
// }, 200));
// }
// })
}, },
async addAiResult(data, aiArr) { async addAiResult(data, aiArr) {
console.log(' in addAiResult') console.log(' in addAiResult')
const randomResultArr = data; const randomResultArr = data;
for (let i = 0; i < aiArr.length; i++) { for (let i = 0; i < aiArr.length; i++) {
const resultStr = randomResultArr[i].result; if (!randomResultArr[i]) {
console.log(' break ');
break;
}
const resultStr = randomResultArr[i]?.result;
if (!resultStr) {
console.log(' continue ');
continue;
} else {
console.log('resultStr: ', resultStr);
}
const result = JSON.parse(resultStr); const result = JSON.parse(resultStr);
const aiUser = aiArr[i]; const aiUser = aiArr[i];
if (aiUser && result) { if (aiUser && result) {
const resultData = { teethDataArr: result.teethDataArr, uuid: aiUser.id, isAi: true } const resultData = { teethDataArr: result.teethDataArr, uuid: aiUser.id, isAi: true }
this.sendServerEvent('send_result', resultData); this.sendServerEvent('send_result', resultData);
await asyncDelay(0.02); await asyncDelay(0.02);
...@@ -1124,6 +1196,7 @@ cc.Class({ ...@@ -1124,6 +1196,7 @@ cc.Class({
let aiArr = []; let aiArr = [];
for (let i = 0; i < this.serverAllUser.length; i++) { for (let i = 0; i < this.serverAllUser.length; i++) {
console.log('serverAllUser[i]: ', this.serverAllUser[i]);
if (!this.serverAllUser[i].result) { if (!this.serverAllUser[i].result) {
aiArr.push(this.serverAllUser[i]); aiArr.push(this.serverAllUser[i]);
} }
...@@ -1240,7 +1313,7 @@ cc.Class({ ...@@ -1240,7 +1313,7 @@ cc.Class({
this.playAudioByName('result_' + id, () => { this.playAudioByName('result_' + id, () => {
playDragonBoneAnimation(this.coolcat, 'normal'); playDragonBoneAnimation(this.coolcat, 'normal');
onHomeworkFinish(); onHomeworkFinish(null, null, false);
}); });
}, },
...@@ -1659,6 +1732,7 @@ cc.Class({ ...@@ -1659,6 +1732,7 @@ cc.Class({
} }
this.isGameEnd = true; this.isGameEnd = true;
this.showResultView() this.showResultView()
}, },
// gameEnd(){ // gameEnd(){
...@@ -1856,12 +1930,25 @@ cc.Class({ ...@@ -1856,12 +1930,25 @@ cc.Class({
}, },
sendResult() { sendResult() {
return;
const data = { teethDataArr: this.teethDataArr, uuid: this.playerId }; const data = { teethDataArr: this.teethDataArr, uuid: this.playerId };
if (window && window.courseware) { const node = cc.find('middleLayer');
window.courseware.sendAnswer(data); if (node) {
console.log('node exist');
const mScript = node.getComponent('middleLayer');
console.log(' saveAnswer ~ :', JSON.stringify(data));
mScript.saveAnswer(data, () => {
callback && callback();
})
} }
// if (window && window.courseware) {
// window.courseware.sendAnswer(data);
// }
}, },
sendServerEvent(key, data) { sendServerEvent(key, data) {
......
...@@ -392,12 +392,12 @@ export function showTrebleFirework(baseNode, rabbonList) { ...@@ -392,12 +392,12 @@ export function showTrebleFirework(baseNode, rabbonList) {
showFireworks(right); showFireworks(right);
} }
export function onHomeworkFinish() { export function onHomeworkFinish(cb, data, isSave) {
const middleLayer = cc.find('middleLayer'); const middleLayer = cc.find('middleLayer');
if (middleLayer) { if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer'); const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') { if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { }); middleLayerComponent.onHomeworkFinish(cb, data, isSave);
} }
} else { } else {
console.log('onHomeworkFinish'); console.log('onHomeworkFinish');
......
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