Skip to content

Commit

Permalink
Merge pull request #517 from hanshino/fix/world_boss
Browse files Browse the repository at this point in the history
Fix lodash import issue in WorldBossController
  • Loading branch information
hanshino authored Sep 7, 2024
2 parents 82dd346 + 110fe5d commit f336636
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/src/controller/application/WorldBossController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { DefaultLogger } = require("../../util/Logger");
const { delay, random } = require("../../util/index");
const LineClient = getClient("line");
const config = require("config");
const { get, sample, sortBy } = require("lodash");
const { get, sample, sortBy, isNull } = require("lodash");
const humanNumber = require("human-number");
const { format } = require("util");
const { table, getBorderCharacters } = require("table");
Expand Down Expand Up @@ -226,14 +226,16 @@ async function myStatus(context) {
const character = makeCharacter(job_key, { level });

// 取得今日已經攻擊的次數
const [{ totalCost = 0 }, sumLogs, { max: maxDamage = 0 }, { count: attendTimes = 0 }] =
const [costResult, sumLogs, { max: maxDamage = 0 }, { count: attendTimes = 0 }] =
await Promise.all([
worldBossEventLogService.getTodayCost(id),
worldBossLogModel.getBossLogs(id, { limit: 2 }),
worldBossLogModel.getUserMaxDamage(id),
worldBossLogModel.getUserAttendance(id),
]);

const totalCost = isNull(costResult.totalCost) ? 0 : costResult.totalCost;

const data = {
level,
expPercentage,
Expand Down Expand Up @@ -637,7 +639,7 @@ async function isUserCanAttack(userId) {

// 取得今日紀錄
const result = await worldBossEventLogService.getTodayCost(userId);
const totalCost = parseInt(get(result, "totalCost", 0));
const totalCost = isNull(result.totalCost) ? 0 : parseInt(result.totalCost);
// 如果完全沒有紀錄,代表可以攻擊
if (totalCost === 0) {
await redis.set(key, 1, {
Expand Down

0 comments on commit f336636

Please sign in to comment.