MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / enterGame

Method enterGame

wxapp/nissin.js:271–313  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

269 }
270
271 async enterGame() {
272 try {
273 const beforeTasks = await this.getTaskList();
274 const gameTask = beforeTasks.find((item) => item?.ruleType === "PLAY_GAME");
275 if (gameTask) {
276 $.log(`账号[${this.index}] 玩游戏任务: ${gameTask.complete ? "已完成" : "未完成"}`);
277 }
278
279 const gameConfig = await this.request({ apiPath: "/game/config" });
280 await this.request({
281 method: "POST",
282 apiPath: "/game/login",
283 data: {
284 loginIp: "",
285 loginLocation: "",
286 },
287 });
288 const playCount = await this.request({ apiPath: "/game/count" });
289 const gameUrl = `https://foodhall-prod.nissinfoodium.com.cn/game/index.html?version=${Date.now()}&token=${encodeURIComponent(this.token)}&user_id=${encodeURIComponent(this.userId || this.user.id || "")}&webViewHeight=800`;
290 const page = await axios.get(gameUrl, {
291 headers: {
292 "User-Agent": USER_AGENT,
293 "Referer": `https://servicewechat.com/${MINI_APP_ID}/${PAGE_VERSION}/page-frame.html`,
294 },
295 timeout: 15000,
296 validateStatus: () => true,
297 });
298 if (page.status >= 200 && page.status < 400) {
299 $.log(`账号[${this.index}] 已进入游戏: ${gameConfig?.shareTitle || "日清消消乐"} 剩余次数=${playCount ?? "未知"}`);
300 } else {
301 $.log(`账号[${this.index}] 进入游戏页面异常: HTTP ${page.status}`);
302 }
303
304 const afterTasks = await this.getTaskList();
305 const updatedGameTask = afterTasks.find((item) => item?.ruleType === "PLAY_GAME");
306 if (updatedGameTask) {
307 $.log(`账号[${this.index}] 玩游戏任务更新: ${updatedGameTask.complete ? "已完成" : "未完成"}`);
308 }
309 } catch (e) {
310 $.log(`账号[${this.index}] 进入游戏失败: ${e.message || e}`);
311 if (isTokenError(e)) this.removeCachedToken();
312 }
313 }
314}
315
316!(async () => {

Callers 1

runMethod · 0.95

Calls 6

getTaskListMethod · 0.95
requestMethod · 0.95
removeCachedTokenMethod · 0.95
isTokenErrorFunction · 0.70
logMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected