新建项目
This commit is contained in:
41
utils/constants.js
Normal file
41
utils/constants.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const GAME_MODES = {
|
||||
classic: {
|
||||
id: "classic",
|
||||
name: "经典模式",
|
||||
description: "寻找者在时间结束前抓到全部躲藏者。",
|
||||
icon: "◎"
|
||||
},
|
||||
infection: {
|
||||
id: "infection",
|
||||
name: "感染模式",
|
||||
description: "被抓的躲藏者会转化为寻找者,继续参与追捕。",
|
||||
icon: "↗"
|
||||
}
|
||||
};
|
||||
|
||||
const DEFAULT_SETTINGS = {
|
||||
mode: "infection",
|
||||
durationMinutes: 30,
|
||||
prepareMinutes: 3,
|
||||
maxPlayers: 8,
|
||||
seekerCount: 2,
|
||||
clueIntervalMinutes: 5,
|
||||
radiusMeters: 500,
|
||||
skillsEnabled: true
|
||||
};
|
||||
|
||||
const BOT_NAMES = ["阿树", "小满", "木木", "大川", "橘子", "青禾", "野原"];
|
||||
const AREA_CLUES = [
|
||||
"目标可能在西北侧树林附近",
|
||||
"南侧入口附近检测到活动",
|
||||
"中心草坪周边出现模糊信号",
|
||||
"东侧步道附近有人移动",
|
||||
"目标可能靠近北侧边界"
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
GAME_MODES,
|
||||
DEFAULT_SETTINGS,
|
||||
BOT_NAMES,
|
||||
AREA_CLUES
|
||||
};
|
||||
30
utils/format.js
Normal file
30
utils/format.js
Normal file
@@ -0,0 +1,30 @@
|
||||
function pad(value) {
|
||||
return String(value).padStart(2, "0");
|
||||
}
|
||||
|
||||
function formatCountdown(totalSeconds) {
|
||||
const safe = Math.max(0, Math.floor(totalSeconds || 0));
|
||||
const minutes = Math.floor(safe / 60);
|
||||
const seconds = safe % 60;
|
||||
return `${pad(minutes)}:${pad(seconds)}`;
|
||||
}
|
||||
|
||||
function formatTime(timestamp) {
|
||||
const date = new Date(timestamp);
|
||||
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||
}
|
||||
|
||||
function randomCode() {
|
||||
return String(Math.floor(100000 + Math.random() * 900000));
|
||||
}
|
||||
|
||||
function clone(value) {
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatCountdown,
|
||||
formatTime,
|
||||
randomCode,
|
||||
clone
|
||||
};
|
||||
Reference in New Issue
Block a user