| 272 | }) |
| 273 | } |
| 274 | function startGame() { |
| 275 | return new Promise(resolve => { |
| 276 | $.get(taskUrl('startGame'), async (err, resp, data) => { |
| 277 | try { |
| 278 | if (err) { |
| 279 | console.log(`${JSON.stringify(err)}`) |
| 280 | console.log(`${$.name} API请求失败,请检查网路重试`) |
| 281 | } else { |
| 282 | if (safeGet(data)) { |
| 283 | data = JSON.parse(data); |
| 284 | if (data.retCode === '200') { |
| 285 | console.log(`游戏开始成功`) |
| 286 | await $.wait(10*1000) |
| 287 | await reportGame(data.result.passScore + 2) |
| 288 | } else { |
| 289 | // if (data.retCode === '1102') $.canDo = false |
| 290 | console.log(`游戏开始失败`, JSON.stringify(data)) |
| 291 | $.canDo = false |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | } catch (e) { |
| 296 | $.logErr(e, resp) |
| 297 | } finally { |
| 298 | resolve(); |
| 299 | } |
| 300 | }) |
| 301 | }) |
| 302 | } |
| 303 | function reportGame(score) { |
| 304 | return new Promise(resolve => { |
| 305 | $.get(taskUrl('reportGame',{score:score}), async (err, resp, data) => { |