From fa9d751a886fb8c32a74bf8d36a5f3fa7dde66f9 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:25:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A2=E7=B4=A2=E5=A5=96?= =?UTF-8?q?=E5=8A=B1=E8=8E=B7=E5=8F=96=E6=9C=BA=E5=88=B6=E5=8F=8A=E6=95=B0?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/Constants.ts | 6 +++--- src/controllers/game.controller.ts | 22 +++++++++++----------- src/services/game.svr.ts | 12 ++++++++++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/common/Constants.ts b/src/common/Constants.ts index a9e6472..421aeb1 100644 --- a/src/common/Constants.ts +++ b/src/common/Constants.ts @@ -18,11 +18,11 @@ export const CONFIRM_MAIL_HTML = ` export const MANUAL_OPEN_GAME = false // 每一步能获得的最小分数 -export const STEP_SCORE_MIN = 1 +export const STEP_SCORE_MIN = 50 // 每一步能获得的最大分数 -export const STEP_SCORE_MAX = 5 +export const STEP_SCORE_MAX = 50 // 每一步能获得的宝箱的概率 -export const STEP_CHEST_RATE = 0.1 +export const STEP_CHEST_RATE = 0.3 // 宝箱各等级的概率 export const STEP_CHEST_LEVEL = [70, 85, 95, 100] // 低保步数 diff --git a/src/controllers/game.controller.ts b/src/controllers/game.controller.ts index ac7f9c6..24d837b 100644 --- a/src/controllers/game.controller.ts +++ b/src/controllers/game.controller.ts @@ -355,17 +355,17 @@ class GameController extends BaseController { $inc: { tickets: -step }, } let { score, chests } = generateStepReward(user.id, user.activity, step) - if (chests.length > 0) { - updateData.maxNoChestCount = 0 - } else { - if (record.maxNoChestCount + step >= RESET_STEP) { - updateData.maxNoChestCount = 0 - const level = generateChestLevel() - chests.push(generateNewChest(user.id, user.activity, level, ChestStatusEnum.NORMAL)) - } else { - updateData['$inc']['maxNoChestCount'] = step - } - } + // if (chests.length > 0) { + // updateData.maxNoChestCount = 0 + // } else { + // if (record.maxNoChestCount + step >= RESET_STEP) { + // updateData.maxNoChestCount = 0 + // const level = generateChestLevel() + // chests.push(generateNewChest(user.id, user.activity, level, ChestStatusEnum.NORMAL)) + // } else { + // updateData['$inc']['maxNoChestCount'] = step + // } + // } await ActivityGame.updateOne({ user: user.id, activity: user.activity }, updateData) await updateRankScore({ user: user.id, diff --git a/src/services/game.svr.ts b/src/services/game.svr.ts index 582d6e7..aca0c6d 100644 --- a/src/services/game.svr.ts +++ b/src/services/game.svr.ts @@ -39,16 +39,24 @@ export const generateChestLevel = function (): number { } return level } - +/** + * 生成步数奖励 + * // TODO:: 增加白名单和特殊种类nft的奖励 + * @param uid + * @param activity + * @param step + * @returns + */ export const generateStepReward = (uid: string, activity: string, step: number) => { let score = 0 let chests = [] for (let i = 0; i < step; i++) { - score += Math.floor(Math.random() * (STEP_SCORE_MAX - STEP_SCORE_MIN + 1) + STEP_SCORE_MIN) if (Math.random() < STEP_CHEST_RATE) { let randomLevel = generateChestLevel() let chest = generateNewChest(uid, activity, randomLevel, ChestStatusEnum.NORMAL) chests.push(chest) + } else { + score += Math.floor(Math.random() * (STEP_SCORE_MAX - STEP_SCORE_MIN + 1) + STEP_SCORE_MIN) } } return { score, chests }