Commit 1ad5a620 authored by limingzhe's avatar limingzhe

fix: 上报成绩 ai成绩

parent 73e22e84
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":{}}
\ No newline at end of file
{
"ver": "1.1.2",
"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
......@@ -2,12 +2,13 @@ import { onHomeworkFinish, RandomInt, playAudio, playDragonBoneAnimation, getSpr
import { defaultData } from "../script/defaultData";
import { GameServer } from "../script/server";
import { NetworkHelper } from "../script/NetworkHelper";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
cc.Class({
extends: MyCocosSceneComponent,//cc.Component,
extends: cc.Component,
properties: {
paint: {
......@@ -632,7 +633,7 @@ cc.Class({
return;
case 'send_result':
console.log('in send_result ~ ');
console.log('in send_result ~ ', JSON.stringify(res.data));
this.setPlayerResult(res.data);
return;
......@@ -873,7 +874,7 @@ cc.Class({
const arr = this.serverAllUser;
for (let i = 0; i < arr.length; i++) {
console.log('this.serverAllUser[i].id: ', this.serverAllUser[i]);
console.log('this.serverAllUser[i]: ', JSON.stringify( this.serverAllUser[i]) );
console.log('uuid: ', uuid);
if (this.serverAllUser[i].playerId == uuid) {
return this.serverAllUser[i].name;
......@@ -1097,7 +1098,7 @@ cc.Class({
const token = cc.sys.localStorage.getItem('token');
const url = "/api/oxford/courseware/v1/" + coursewareid + "/getanswer"
mScript.callNetworkApiGet(url, {coursewareid, token, count: aiArr.length}, (res)=> {
mScript.callNetworkApiGet(url, {coursewareid, token, count: aiArr.length}, async (res)=> {
console.log("res~: ", res);
if (typeof(res) == "string") {
......@@ -1110,7 +1111,7 @@ cc.Class({
// OP12.rank.inst.onShow(rankArr);
const rows = res.data?.rows || [];
const rows = res?.rows || [];
await this.addAiResult(rows, aiArr);
......@@ -1168,8 +1169,8 @@ cc.Class({
for (let i = 0; i < aiArr.length; i++) {
if (!randomResultArr[i]) {
console.log(' break ');
break;
console.log(' continue ~ ');
continue;
}
const resultStr = randomResultArr[i]?.result;
if (!resultStr) {
......@@ -1183,10 +1184,10 @@ cc.Class({
const result = JSON.parse(resultStr);
const aiUser = aiArr[i];
if (aiUser && result) {
const resultData = { teethDataArr: result.teethDataArr, uuid: aiUser.id, isAi: true }
const resultData = { teethDataArr: result.teethDataArr, uuid: aiUser.playerId, isAi: true }
this.sendServerEvent('send_result', resultData);
await asyncDelay(0.02);
// await asyncDelay(0.02);
}
}
......@@ -1300,6 +1301,9 @@ cc.Class({
isGoodEnd: null,
countDownEnd() {
this.isGoodEnd = true;
const rank = this.getRank();
if (this.selfScore == 0) {
this.sendServerEvent('get_good', this.playerId)
}
......@@ -1309,15 +1313,36 @@ cc.Class({
id = 1;
}
const data = { teethDataArr: this.teethDataArr, uuid: this.playerId, rank: rank };
console.log('send data: ', JSON.stringify(data));
playDragonBoneAnimation(this.coolcat, 'begin', -1);
this.playAudioByName('result_' + id, () => {
playDragonBoneAnimation(this.coolcat, 'normal');
onHomeworkFinish(null, null, false);
onHomeworkFinish(data);
});
},
getRank() {
let maxScore = 0;
for (let i = 0; i < this.resultItemArr.length; i++) {
const item = this.resultItemArr[i];
const score = Number(item.scoreLabel.string);
// item.score = score;
if (maxScore < score) {
maxScore = score;
}
}
const rank = maxScore - this.selfScore + 1;
return rank;
},
getCountDownLabel() {
const label = this.getScoreLabel();
return label;
......@@ -1369,6 +1394,9 @@ cc.Class({
this.log(teethDataArr.length+"_endData:"+JSON.stringify(teethDataArr));
console.log('key: ', id);
console.log("itemData: ", JSON.stringify(itemData));
const item = await this.getOneItem(teethDataArr, id);
item.x=(item.width+50)*a[s][0];
item.y=(item.height+50)*a[s][1];
......@@ -1969,6 +1997,16 @@ cc.Class({
// }
},
log (str) {
const node = cc.find('middleLayer');
if(node){
node.getComponent('middleLayer').log(str);
}else{
cc.log(str);
}
},
update(dt) {
this.updateTimer(dt)
},
......
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