Features: - Combat system with AP/EP hit calculation and three-layer defense - Auto-combat/farming mode - Item system with stacking support - Skill system with levels, milestones, and parent skill sync - Shop system with dynamic pricing - Inventory management with bulk selling - Event system - Game loop with offline earnings - Save/Load system Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
93 lines
2.0 KiB
JavaScript
93 lines
2.0 KiB
JavaScript
/**
|
|
* Game Store 测试夹具
|
|
*/
|
|
|
|
/**
|
|
* 创建模拟游戏数据
|
|
* @param {Object} overrides - 覆盖的属性
|
|
* @returns {Object} 模拟游戏对象
|
|
*/
|
|
export function createMockGame(overrides = {}) {
|
|
return {
|
|
currentTab: 'status',
|
|
drawerState: {
|
|
inventory: false,
|
|
event: false,
|
|
...overrides.drawerState
|
|
},
|
|
logs: overrides.logs || [],
|
|
gameTime: {
|
|
day: 1,
|
|
hour: 8,
|
|
minute: 0,
|
|
totalMinutes: 480,
|
|
...overrides.gameTime
|
|
},
|
|
inCombat: overrides.inCombat || false,
|
|
combatState: overrides.combatState || null,
|
|
activeTasks: overrides.activeTasks || [],
|
|
negativeStatus: overrides.negativeStatus || [],
|
|
marketPrices: overrides.marketPrices || {
|
|
lastRefreshDay: 1,
|
|
prices: {}
|
|
},
|
|
currentEvent: overrides.currentEvent || null,
|
|
scheduledEvents: overrides.scheduledEvents || []
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 创建战斗中的游戏状态
|
|
* @param {Object} enemy - 敌人对象
|
|
* @returns {Object} 模拟游戏对象
|
|
*/
|
|
export function createGameInCombat(enemy) {
|
|
return createMockGame({
|
|
inCombat: true,
|
|
combatState: {
|
|
enemyId: enemy.id,
|
|
enemy,
|
|
stance: 'balance',
|
|
environment: 'normal',
|
|
startTime: Date.now(),
|
|
ticks: 0
|
|
}
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 创建有活动任务的游戏状态
|
|
* @param {Array} tasks - 任务数组
|
|
* @returns {Object} 模拟游戏对象
|
|
*/
|
|
export function createGameWithTasks(tasks) {
|
|
return createMockGame({
|
|
activeTasks: tasks.map(task => ({
|
|
id: Date.now() + Math.random(),
|
|
type: task.type,
|
|
data: task.data || {},
|
|
startTime: Date.now(),
|
|
progress: 0,
|
|
totalDuration: task.duration || 0,
|
|
lastTickTime: Date.now(),
|
|
...task
|
|
}))
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 创建有日志的游戏状态
|
|
* @param {Array} logs - 日志数组
|
|
* @returns {Object} 模拟游戏对象
|
|
*/
|
|
export function createGameWithLogs(logs) {
|
|
return createMockGame({
|
|
logs: logs.map((log, index) => ({
|
|
id: Date.now() + index,
|
|
time: '08:00',
|
|
message: log,
|
|
type: 'info'
|
|
}))
|
|
})
|
|
}
|