MCPcopy Create free account
hub / github.com/Semporia/Scripts / getUserElectricity

Function getUserElectricity

jd_dreamFactory.js:291–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

289
290// 获得用户电力情况
291function getUserElectricity() {
292 return new Promise(async resolve => {
293 // const url = `/dreamfactory/generator/QueryCurrentElectricityQuantity?zone=dream_factory&factoryid=${$.factoryId}&sceneval=2&g_login_type=1`
294 $.get(taskurl(`generator/QueryCurrentElectricityQuantity`, `factoryid=${$.factoryId}`, `_time,factoryid,zone`), async (err, resp, data) => {
295 try {
296 if (err) {
297 console.log(`${JSON.stringify(err)}`)
298 console.log(`${$.name} API请求失败,请检查网路重试`)
299 } else {
300 if (safeGet(data)) {
301 data = JSON.parse(data);
302 if (data['ret'] === 0) {
303 console.log(`发电机:当前 ${data.data.currentElectricityQuantity} 电力,最大值 ${data.data.maxElectricityQuantity} 电力`)
304 if (data.data.currentElectricityQuantity < data.data.maxElectricityQuantity) {
305 $.log(`\n本次发电机电力集满分享后${data.data.nextCollectDoubleFlag === 1 ? '可' : '不可'}获得双倍电力,${data.data.nextCollectDoubleFlag === 1 ? '故目前不收取电力' : '故现在收取电力'}\n`)
306 }
307 if (data.data.nextCollectDoubleFlag === 1) {
308 if (data.data.currentElectricityQuantity === data.data.maxElectricityQuantity && data.data.doubleElectricityFlag) {
309 console.log(`发电机:电力可翻倍并收获`)
310 // await shareReport();
311 await collectElectricity()
312 } else {
313 message += `【发电机电力】当前 ${data.data.currentElectricityQuantity} 电力,未达到收获标准\n`
314 }
315 } else {
316 //再收取双倍电力达到上限时,直接收取,不再等到满级
317 await collectElectricity()
318 }
319 }
320 }
321 }
322 } catch (e) {
323 $.logErr(e, resp)
324 } finally {
325 resolve();
326 }
327 })
328 })
329}
330
331//查询有多少的招工电力可收取
332function QueryHireReward() {

Callers 1

jdDreamFactoryFunction · 0.85

Calls 6

collectElectricityFunction · 0.85
taskurlFunction · 0.70
safeGetFunction · 0.70
getMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected