正文
增加 27 行删除 27 行
1234567848 行未改动5758596061626364656648 行未改动11511611711811912012112212330 行未改动1541551561571581591601611629 行未改动17217317417517617717817918013 行未改动194195196197198199200201202203278 行未改动全部展开482483484485486487488489490205 行未改动全部展开696697698699700701702703704705706707708709710711712216 行未改动全部展开92993093193293393493593693777 行未改动10151016101710181019102010211022102342 行未改动1066106710681069107010711072107310741075107610771078107910801081108239 行未改动11221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156434 行未改动全部展开159115921593159415951596159715981599160054 行未改动165516561657165816591660166116621663674 行未改动全部展开23382339234023412342234323442345234662 行未改动# Slay the Spire 完整架构文档(中文)> **用途:** 本文档描述游戏的所有架构细节,用于指导 CLI 版重构。重构原则:绝不修改游戏逻辑,仅删除/替换纯 GUI 代码,用帧步进模型替代连续渲染循环。>> **最后更新:** 经过 3 个 subagent 独立审查验证。{">"} 标记为已纠正的错误。### 已验证的关键纠正(第二轮审查补充)48 行未改动→ CardCrawlGame.create()├── 加载 Prefs(save slot, player settings)├── Settings.initialize(false) — 读取所有配置├── 加载 LocalizedStrings(从 localization/{lang}/ JSON)├── 初始化各子系统:MusicMaster, SoundMaster, AbstractCreature,│ AbstractCard, GameDictionary, ImageMaster, AbstractPower,│ FontHelper, UnlockTracker, CardLibrary, RelicLibrary,│ InputHelper, TipTracker, ModHelper, ShaderHelper├── 创建 SplashScreen└── mode = GameMode.SPLASH48 行未改动if (完成): 清除过渡, getDungeon() 加载地牢else if (dungeon != null):dungeon.update() ←←← 这是最重要的调用else: log "Eh-?"if (isDungeonBeaten && fadeColor.a == 1.0F):清除 dungeon, 创建下个幕的 transitionSPLASH: splashScreen.update()30 行未改动8. ★★★ switch(screen) — 唯一的分派 switch ★★★★ 屏幕关闭时(2 个 case,通过 ordinal 0/1 映射):case 0 (原 RenderScene.NORMAL/CAMPFIRE 场景):dungeonMapScreen.update()room.update() ← 房间每帧更新scene.update() ← 场景背景9 行未改动GRID:gridSelectScreen.update()if (PeekButton.isPeeking): room.update() ★ BOSS_REWARD 和 HAND_SELECT 无条件调 room.update()CARD_REWARD:cardRewardScreen.update()if (PeekButton.isPeeking): room.update()13 行未改动MAP:dungeonMapScreen.update() ★ 不调用 room.update()其他 screen (SETTINGS, INPUT_SETTINGS, MASTER_DECK_VIEW,GAME_DECK_VIEW, DISCARD_VIEW, EXHAUST_VIEW,DEATH, VICTORY, UNLOCK, DOOR_UNLOCK, CREDITS, NEOW_UNLOCK):只调用对应 screen.update() ★ 不调用 room.update()9. ★ 效果处理278 行未改动全部展开#### EventRoom```java// onPlayerEntry():this.event = AbstractDungeon.generateEvent(eventRngDuplicate);this.event.onEnterRoom();// update():205 行未改动全部展开public void update() {if (!this.combatTime) {this.hasFocus = true;// 随机粒子效果if (this.waitTimer > 0.0F) {this.waitTimer -= delta;if (this.waitTimer < 0.0F) {imageEventText.show(title, body);this.waitTimer = 0.0F;}}if (!GenericEventDialog.waitForInput) {buttonEffect(GenericEventDialog.getSelectedOption());}}216 行未改动全部展开updatePotions():每帧遍历玩家药水:p.hb.update()if (hovered && clicked): potionUi.open(slot, potion)PotionPopUp.open():显示两个按钮:USE / DISCARDUSE: 如果 potion.canUse():- 无需目标: potion.use(null) + destroyPotion(slot)77 行未改动✅ scene.update() // 删除(纯渲染)✅ dungeonMapScreen.update() // 删除(地图 GUI)✅ 效果处理 // 删除(纯视觉)✅ overlayMenu.update() // 大部分可删除,仅保留核心逻辑if (needInput): break // 需要玩家输入时停止```### 13.2 各场景的 break 条件42 行未改动AbstractGameEffect e = it.next();e.update();if (e.isDone) it.remove();}// effectList: 标准效果it = AbstractDungeon.effectList.iterator();while (it.hasNext()) {AbstractGameEffect e = it.next();e.update();if (e.isDone) it.remove();}// 转移排队的效果AbstractDungeon.effectList.addAll(AbstractDungeon.effectsQueue);AbstractDungeon.effectsQueue.clear();AbstractDungeon.topLevelEffects.addAll(AbstractDungeon.topLevelEffectsQueue);39 行未改动// 模拟 AbstractDungeon.update() 的一帧:AbstractDungeon.topPanel.update();AbstractDungeon.updateFading();room.updateObjects();// 根据 screen 决定是否调用 room.update()if (shouldUpdateRoom()) {room.update();}// 更新活跃 screen(如果有)updateActiveScreen();// 处理效果processEffects();// 处理 SoulGroup + 其他 OverlayMenu 逻辑processOverlayLogic();// 检查是否需要输入scene = detectScene();if (scene != null) break;}// ========== 序列化状态 / 获取输入 ==========String json = serializeState(scene);String action = getInput(json);// ========== 应用输入 ==========applyAction(scene, action);// ========== 检查房间切换 ==========if (room.phase == COMPLETE) {AbstractDungeon.dungeonMapScreen.open(false);roomEntered = false;434 行未改动全部展开monsterRng=X, eventRng=Y, cardRng=Z, ...:rng set {rngName} {counter}:通过反射设置 AbstractDungeon.{rngName}.counter = value支持: monsterRng, mapRng, eventRng, cardRng, treasureRng,relicRng, potionRng, miscRng, aiRng, shuffleRng,cardRandomRng, monsterHpRng```安全约束:54 行未改动"card_reward" → AbstractDungeon.cardRewardScreen.open(...)"combat_reward" → AbstractDungeon.combatRewardScreen.open()"boss_relic" → AbstractDungeon.bossRelicScreen.open(...)"shop" → 强制 screen=SHOP, isScreenUp=true2. 对于需要参数的 screen,使用默认参数:gridSelectScreen: 从 masterDeck 选 1 张handCardSelectScreen: 选 1 张cardRewardScreen: 3 张随机卡674 行未改动全部展开// Calling Bell FTUE 检查(可能提前 return 中断过渡)int relicCount = 0;for (RewardItem i : AbstractDungeon.combatRewardScreen.rewards) { ... }if (relicCount == 3 && this.callingBellCheck) { ... return; } // 逻辑:CallingBell 提示CardCrawlGame.music.fadeOutBGM(); // 纯音效CardCrawlGame.music.fadeOutTempBGM(); // 纯音效AbstractDungeon.fadeOut(); // 逻辑:开始 0.8s 渐黑AbstractDungeon.isDungeonBeaten = true; // 逻辑:标志位62 行未改动1234567848 行未改动5758596061626364656648 行未改动11511611711811912012112212330 行未改动1541551561571581591601611629 行未改动17217317417517617717817918013 行未改动194195196197198199200201202203278 行未改动全部展开482483484485486487488489490205 行未改动全部展开696697698699700701702703704705706707708709710711712216 行未改动全部展开92993093193293393493593693777 行未改动10151016101710181019102010211022102342 行未改动1066106710681069107010711072107310741075107610771078107910801081108239 行未改动11221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156434 行未改动全部展开159115921593159415951596159715981599160054 行未改动165516561657165816591660166116621663674 行未改动全部展开23382339234023412342234323442345234662 行未改动# Slay the Spire 完整架构文档(中文)> **用途:** 本文档描述游戏的所有架构细节,用于指导 CLI 版重构。重构原则:绝不修改游戏逻辑,仅删除/替换纯 GUI 代码,用帧步进模型替代连续渲染循环。>> **最后更新:** 经过 3 个 subagent 独立审查验证。{">"} 标记为已纠正的错误。### 已验证的关键纠正(第二轮审查补充)48 行未改动→ CardCrawlGame.create()├── 加载 Prefs(save slot, player settings)├── Settings.initialize(false) — 读取所有配置├── 加载 LocalizedStrings(从 localization/{lang}/ JSON)├── 初始化各子系统:MusicMaster, SoundMaster, AbstractCreature,│ AbstractCard, GameDictionary, ImageMaster, AbstractPower,│ FontHelper, UnlockTracker, CardLibrary, RelicLibrary,│ InputHelper, TipTracker, ModHelper, ShaderHelper├── 创建 SplashScreen└── mode = GameMode.SPLASH48 行未改动if (完成): 清除过渡, getDungeon() 加载地牢else if (dungeon != null):dungeon.update() ←←← 这是最重要的调用else: log "Eh-?"if (isDungeonBeaten && fadeColor.a == 1.0F):清除 dungeon, 创建下个幕的 transitionSPLASH: splashScreen.update()30 行未改动8. ★★★ switch(screen) — 唯一的分派 switch ★★★★ 屏幕关闭时(2 个 case,通过 ordinal 0/1 映射):case 0 (原 RenderScene.NORMAL/CAMPFIRE 场景):dungeonMapScreen.update()room.update() ← 房间每帧更新scene.update() ← 场景背景9 行未改动GRID:gridSelectScreen.update()if (PeekButton.isPeeking): room.update() ★ BOSS_REWARD 和 HAND_SELECT 无条件调 room.update()CARD_REWARD:cardRewardScreen.update()if (PeekButton.isPeeking): room.update()13 行未改动MAP:dungeonMapScreen.update() ★ 不调用 room.update()其他 screen (SETTINGS, INPUT_SETTINGS, MASTER_DECK_VIEW,GAME_DECK_VIEW, DISCARD_VIEW, EXHAUST_VIEW,DEATH, VICTORY, UNLOCK, DOOR_UNLOCK, CREDITS, NEOW_UNLOCK):只调用对应 screen.update() ★ 不调用 room.update()9. ★ 效果处理278 行未改动全部展开#### EventRoom```java// onPlayerEntry():this.event = AbstractDungeon.generateEvent(eventRngDuplicate);this.event.onEnterRoom();// update():205 行未改动全部展开public void update() {if (!this.combatTime) {this.hasFocus = true;// 随机粒子效果if (this.waitTimer > 0.0F) {this.waitTimer -= delta;if (this.waitTimer < 0.0F) {imageEventText.show(title, body);this.waitTimer = 0.0F;}}if (!GenericEventDialog.waitForInput) {buttonEffect(GenericEventDialog.getSelectedOption());}}216 行未改动全部展开updatePotions():每帧遍历玩家药水:p.hb.update()if (hovered && clicked): potionUi.open(slot, potion)PotionPopUp.open():显示两个按钮:USE / DISCARDUSE: 如果 potion.canUse():- 无需目标: potion.use(null) + destroyPotion(slot)77 行未改动✅ scene.update() // 删除(纯渲染)✅ dungeonMapScreen.update() // 删除(地图 GUI)✅ 效果处理 // 删除(纯视觉)✅ overlayMenu.update() // 大部分可删除,仅保留核心逻辑if (needInput): break // 需要玩家输入时停止```### 13.2 各场景的 break 条件42 行未改动AbstractGameEffect e = it.next();e.update();if (e.isDone) it.remove();}// effectList: 标准效果it = AbstractDungeon.effectList.iterator();while (it.hasNext()) {AbstractGameEffect e = it.next();e.update();if (e.isDone) it.remove();}// 转移排队的效果AbstractDungeon.effectList.addAll(AbstractDungeon.effectsQueue);AbstractDungeon.effectsQueue.clear();AbstractDungeon.topLevelEffects.addAll(AbstractDungeon.topLevelEffectsQueue);39 行未改动// 模拟 AbstractDungeon.update() 的一帧:AbstractDungeon.topPanel.update();AbstractDungeon.updateFading();room.updateObjects();// 根据 screen 决定是否调用 room.update()if (shouldUpdateRoom()) {room.update();}// 更新活跃 screen(如果有)updateActiveScreen();// 处理效果processEffects();// 处理 SoulGroup + 其他 OverlayMenu 逻辑processOverlayLogic();// 检查是否需要输入scene = detectScene();if (scene != null) break;}// ========== 序列化状态 / 获取输入 ==========String json = serializeState(scene);String action = getInput(json);// ========== 应用输入 ==========applyAction(scene, action);// ========== 检查房间切换 ==========if (room.phase == COMPLETE) {AbstractDungeon.dungeonMapScreen.open(false);roomEntered = false;434 行未改动全部展开monsterRng=X, eventRng=Y, cardRng=Z, ...:rng set {rngName} {counter}:通过反射设置 AbstractDungeon.{rngName}.counter = value支持: monsterRng, mapRng, eventRng, cardRng, treasureRng,relicRng, potionRng, miscRng, aiRng, shuffleRng,cardRandomRng, monsterHpRng```安全约束:54 行未改动"card_reward" → AbstractDungeon.cardRewardScreen.open(...)"combat_reward" → AbstractDungeon.combatRewardScreen.open()"boss_relic" → AbstractDungeon.bossRelicScreen.open(...)"shop" → 强制 screen=SHOP, isScreenUp=true2. 对于需要参数的 screen,使用默认参数:gridSelectScreen: 从 masterDeck 选 1 张handCardSelectScreen: 选 1 张cardRewardScreen: 3 张随机卡674 行未改动全部展开// Calling Bell FTUE 检查(可能提前 return 中断过渡)int relicCount = 0;for (RewardItem i : AbstractDungeon.combatRewardScreen.rewards) { ... }if (relicCount == 3 && this.callingBellCheck) { ... return; } // 逻辑:CallingBell 提示CardCrawlGame.music.fadeOutBGM(); // 纯音效CardCrawlGame.music.fadeOutTempBGM(); // 纯音效AbstractDungeon.fadeOut(); // 逻辑:开始 0.8s 渐黑AbstractDungeon.isDungeonBeaten = true; // 逻辑:标志位62 行未改动