diff --git a/README.md b/README.md index eb40f89..272ca69 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Godot 4 tactical RPG prototype inspired by classic turn-based Romance of the Thr - Destination-style victory conditions with objective map markers. - Protected-unit defeat conditions for escort battles. - Turn-limit defeat conditions with turn-limit HUD display. -- Live objective progress in the active HUD and briefing tracker, including gated objective unlocks, destination markers, defeated enemy counts, named protected-unit safety, and turns remaining. +- Live objective panels in the active HUD and briefing split objective, progress, and risk details, including gated unlocks, destination markers, defeated enemy counts, named protected-unit safety, and turns remaining. - Next-battle flow after victory. - Campaign completion screen. - New campaign save reset. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 7344004..513c536 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -59,6 +59,6 @@ Joined officers gate whether `requires_joined` player deployments are loaded at Inventory and campaign flags are copied from `CampaignState` into `BattleState` when a scenario starts. The pre-battle Chapters overview reads `CampaignState` chapter progress and can load completed or current battles without mutating the save. Briefings preview first-clear rewards and show completed replay rewards as already claimed. The pre-battle Save menu can write the current campaign state to `user://campaign_manual_save.json`, and loading that checkpoint restores it into `user://campaign_save.json` before re-entering the same pending-choice, completion, or current-briefing branch as startup. Pre-battle shop stock comes from the loaded scenario's `shop.items` list plus matching `shop.conditional_items` blocks, with optional finite limits from item entries or `stock` maps. Shop purchases and 50% sell-back are campaign transactions: they update saved gold, unequipped inventory, and finite-stock purchase counts immediately, write the save file, and refresh the already-loaded battle inventory before the player begins the battle. Pre-battle Armory equipment changes use the same equipment rules as battle HUD equipment changes, then immediately save merged roster equipment/stat snapshots and inventory stock. Pre-battle Roster uses scenario `roster.max_units`, `roster.required_officers`, and `roster.required_units` to mark optional player deployments as sortie or reserve; reserve units remain in the candidate list but are excluded from board occupancy, drawing, selection, AI targeting, and living-unit victory checks. Non-controllable player units can act as protected escort targets: enemies can attack them and conditions can reference them, but they are skipped by player selection, Armory, Formation, counterattacks, and campaign roster progression snapshots when `persist_progression` is false. Scenario `ai_target_priority` nudges enemy movement and damage-skill scoring toward important targets such as envoys without overriding defeat bonuses or range checks. Pre-battle Formation uses the loaded scenario's `formation.cells` and only mutates current battle unit positions before battle-begin events fire. Destination victory cells from `unit_reaches_tile` conditions are exposed to the scene for objective overlays and tile info. Movement-triggered `unit_reaches_tile` events receive the unit that just moved, so ambushes and pickup events fire on entry rather than from units already standing on a marker. Briefing data can append matching `briefing.conditional_lines`, and scenario events can use `when.campaign_flags` to branch dialogue, objective changes, item pickups, and reinforcements from saved campaign choices. Consumable use can restore HP or MP or cure matching poison/seal/snare/disarm statuses, and in-battle item use, event pickup grants, plus equipment swaps mutate only the battle copy until victory; defeats and restarts do not spend saved items, keep picked-up items, or preserve in-battle gear changes. Post-battle choices write campaign `flags` only after the result-panel button is pressed; if the player reloads after rewards are saved but before selecting, the pending scenario id restores the victory choice panel without replaying rewards. The next battle button stays locked until the campaign choice save succeeds. Equipment rewards share the same `item_id -> count` inventory stock, cover weapon, armor, and accessory slots, can be equipped from the side HUD before the selected unit moves or acts, and do not appear in the consumable action menu. Named equipment currently uses the same stock model with a presentation-only rarity tag rather than unique item instances. Already completed scenarios can be replayed without granting duplicate rewards, choices, replay inventory consumption, save writes, current-scenario advancement, or finite-stock purchases; pre-battle Shop, Armory, Roster, Formation, and Save are disabled on completed-scenario replays to avoid side effects. -The battle scene owns presentation feedback: briefing and result states use menu BGM, briefing headers combine `CampaignState` chapter ranges, campaign order, and title data with `BattleState` briefing, objective text, and condition-progress tracker, active battles use battle BGM and show live objective progress from `BattleState`, dialogue lines can show optional cached portrait textures or speaker-initial fallback panels in an expanded visual-novel-style panel, can place the portrait on the left or right side of that panel, and expose progress plus previous-line controls while a sequence is open, the side HUD reuses cached officer portrait textures for the selected unit or hovered unit, board units render low-HP warning rings, HP bar color states, and active support/debuff/poison/seal/snare/disarm status pips from battle state fields, hover previews are rendered as target badges from existing `BattleState` forecast APIs, hover unit info shows class, movement type, AGI, movement, range, and equipped gear, equipment option menus show stat/range/effect deltas, result and inventory summaries show named equipment with compact rarity tags, selected area tactics highlight their affected cells, the Threat toggle overlays enemy physical and hostile tactic reach while tile info names threat sources, estimates physical damage, and summarizes hostile tactic damage or status effects against occupied cells, log/result hooks trigger placeholder SFX, support, debuff, poison, seal, snare, disarm, and item pickup effects use distinct floating feedback colors, `BattleState.unit_motion_requested` asks the scene to interpolate a unit's draw position during movement, and `BattleState.combat_feedback_requested` asks the scene to draw transient floating combat text without changing battle rules. +The battle scene owns presentation feedback: briefing and result states use menu BGM, briefing headers combine `CampaignState` chapter ranges, campaign order, and title data with `BattleState` briefing, objective text, condition-progress text, and defeat-risk text, active battles use battle BGM and show an objective/progress/risk panel fed by `BattleState`, dialogue lines can show optional cached portrait textures or speaker-initial fallback panels in an expanded visual-novel-style panel, can place the portrait on the left or right side of that panel, and expose progress plus previous-line controls while a sequence is open, the side HUD reuses cached officer portrait textures for the selected unit or hovered unit, board units render low-HP warning rings, HP bar color states, and active support/debuff/poison/seal/snare/disarm status pips from battle state fields, hover previews are rendered as target badges from existing `BattleState` forecast APIs, hover unit info shows class, movement type, AGI, movement, range, and equipped gear, equipment option menus show stat/range/effect deltas, result and inventory summaries show named equipment with compact rarity tags, selected area tactics highlight their affected cells, the Threat toggle overlays enemy physical and hostile tactic reach while tile info names threat sources, estimates physical damage, and summarizes hostile tactic damage or status effects against occupied cells, log/result hooks trigger placeholder SFX, support, debuff, poison, seal, snare, disarm, and item pickup effects use distinct floating feedback colors, `BattleState.unit_motion_requested` asks the scene to interpolate a unit's draw position during movement, and `BattleState.combat_feedback_requested` asks the scene to draw transient floating combat text without changing battle rules. The `New Campaign` button clears `user://campaign_save.json`, resets campaign state to the first scenario, and reloads the opening briefing. diff --git a/docs/DATA_MODEL.md b/docs/DATA_MODEL.md index 05f89a0..2273397 100644 --- a/docs/DATA_MODEL.md +++ b/docs/DATA_MODEL.md @@ -436,7 +436,7 @@ Scenario deployments may override `move_type` for special units. For example, a `objectives` are display text. `conditions` drive the actual victory and defeat checks. Defeat is evaluated before victory, matching Cao Cao Zhuan-style commander-loss rules. If `conditions` is omitted, battles fall back to defeating all enemies for victory and losing all player units for defeat. -`BattleState` also exposes condition progress text for presentation. The active HUD and briefing tracker can show defeated enemy counts, destination reach status, named commander or protected-unit safety, and turns remaining from the same `conditions` data. Conditions gated by `after_event` stay marked as pending; when the referenced event is a `unit_reaches_tile` or `turn_start` trigger, the tracker can surface that prerequisite as the next visible objective. +`BattleState` also exposes condition progress and defeat-risk text for presentation. The active HUD and briefing panels split objective, progress, and risk details while showing defeated enemy counts, destination reach status, named commander or protected-unit safety, and turns remaining from the same `conditions` data. Conditions gated by `after_event` stay marked as pending; when the referenced event is a `unit_reaches_tile` or `turn_start` trigger, the tracker can surface that prerequisite as the next visible objective. Player deployments may set `requires_joined: true`; those units are only loaded if their `officer_id` is in campaign `joined_officers`. Scenario rewards can add officers through `rewards.join_officers` and remove them through `rewards.leave_officers`. Post-battle choices can also use `join_officers` and `leave_officers` for branch-specific membership changes. `data/campaign/campaign.json` seeds a new campaign with `initial_joined_officers`. diff --git a/docs/GODOT_4_6_MIGRATION.md b/docs/GODOT_4_6_MIGRATION.md index 17d7186..c7968ee 100644 --- a/docs/GODOT_4_6_MIGRATION.md +++ b/docs/GODOT_4_6_MIGRATION.md @@ -48,7 +48,7 @@ powershell -NoProfile -ExecutionPolicy Bypass -File tools\check_godot46_readines - A player unit can move, attack, wait, use a tactic, use an item, and equip compatible gear; weapon effectiveness appears in forecasts and equipment/shop text when applicable, and equipment options show stat/range change hints. - Named equipment rewards such as Yitian Sword and Dragon Spear validate, appear with compact rarity tags in reward/inventory/equipment text, and remain ordinary stackable inventory stock until unique item instances are implemented. - Hovering an occupied tile shows the unit's class, movement type, AGI, movement, range, equipped weapon/armor/accessory, and a HUD portrait thumbnail when no unit is selected, with empty gear slots shown as `-`. -- The battle HUD and briefing tracker show live objective progress, including pending unlocks, destination reach status, defeated enemy counts, named protected-unit or commander safety, and turns remaining. +- The battle HUD and briefing objective panels split objective, progress, and risk details, including pending unlocks, destination reach status, defeated enemy counts, named protected-unit or commander safety, and turns remaining. - Movement-triggered supply cache events grant battle inventory items with pickup feedback, and the items persist only after victory. - The Threat toggle or `Y` key shows enemy physical and hostile tactic reach, hovered threatened tiles name the threatening units, and occupied player tiles show physical damage/hit estimates plus hostile tactic damage or status hints. - Area tactics such as Blaze, Great Mend, and Poison Mist highlight affected cells, apply only to valid targets in the area, and spend MP once per cast. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 6b33b65..7ebcd61 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -21,7 +21,7 @@ - Scenario-defined victory and defeat conditions exist. - Destination victory conditions and objective map markers exist. - Turn-limit conditions and HUD turn-limit display exist. -- Active HUD and briefing objective trackers show live condition progress, including gated unlocks, destinations, defeated enemies, protected-unit safety, and turns remaining. +- Active HUD and briefing objective panels split objective, progress, and risk details, including gated unlocks, destinations, defeated enemies, protected-unit safety, and turns remaining. - Victory reward summary is visible. - Next-battle flow exists across the current sixty-seven-scenario campaign. - Campaign completion and new-campaign reset exist. @@ -137,7 +137,7 @@ - Unit sprites and animations. Board movement now has a short slide animation, and board units show low-HP warning rings plus small status pips for active support, debuff, poison, seal, snare, and disarm effects. - Battle effects. First floating combat text now covers damage, recovery, misses, support effects, poison ticks, item pickups, level-ups, and promotions. Hover target preview badges summarize attacks, tactics, and items, and the board can overlay enemy threat ranges with physical damage and hostile tactic hints. - Music and sound. Basic placeholder BGM and SFX now play for menus, battle flow, unit actions, tactics, items, and result states. -- Chapter UI, objective presentation, and visual novel scenes. Pre-battle briefing now uses campaign chapter ranges for chapter-aware numbering, has a chapter progress/replay overview plus objective tracker, active battle HUD shows live objective progress, and dialogue lines can choose left or right portrait placement in an expanded portrait dialogue panel with progress and previous-line controls. +- Chapter UI, objective presentation, and visual novel scenes. Pre-battle briefing now uses campaign chapter ranges for chapter-aware numbering, has a chapter progress/replay overview plus objective/progress/risk tracker, active battle HUD shows the same live objective panel, and dialogue lines can choose left or right portrait placement in an expanded portrait dialogue panel with progress and previous-line controls. ## Milestone 6: Content Expansion diff --git a/scripts/core/battle_state.gd b/scripts/core/battle_state.gd index f6ed5a2..e3c717f 100644 --- a/scripts/core/battle_state.gd +++ b/scripts/core/battle_state.gd @@ -1423,18 +1423,28 @@ func get_objective_cells() -> Array[Vector2i]: return result -func get_objective_progress_lines(include_defeat_risks := false) -> Array[String]: +func get_objective_progress_lines(include_defeat_risks := false, include_turn_limit := true) -> Array[String]: var result: Array[String] = [] _append_condition_progress_lines(battle_conditions.get("victory", {}), result, "victory") if include_defeat_risks: _append_condition_progress_lines(battle_conditions.get("defeat", {}), result, "defeat") - else: + elif include_turn_limit: _append_turn_limit_progress_line(result) return result -func get_objective_progress_text(include_defeat_risks := false) -> String: - return _join_strings(get_objective_progress_lines(include_defeat_risks), " | ") +func get_objective_progress_text(include_defeat_risks := false, include_turn_limit := true) -> String: + return _join_strings(get_objective_progress_lines(include_defeat_risks, include_turn_limit), " | ") + + +func get_defeat_progress_lines() -> Array[String]: + var result: Array[String] = [] + _append_condition_progress_lines(battle_conditions.get("defeat", {}), result, "defeat") + return result + + +func get_defeat_progress_text() -> String: + return _join_strings(get_defeat_progress_lines(), " | ") func get_first_skill_id(unit_id: String) -> String: diff --git a/scripts/scenes/battle_scene.gd b/scripts/scenes/battle_scene.gd index a92be29..e52d690 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -72,6 +72,8 @@ var campaign_complete_screen := false var status_label: Label var objective_label: Label var campaign_status_label: Label +var mission_title_label: Label +var mission_detail_label: Label var hud_unit_portrait_panel: PanelContainer var hud_unit_portrait_texture: TextureRect var hud_unit_portrait_label: Label @@ -252,11 +254,11 @@ func _create_hud() -> void: var side_panel := PanelContainer.new() side_panel.position = Vector2(760, 104) - side_panel.size = Vector2(480, 580) + side_panel.size = Vector2(480, 610) root.add_child(side_panel) var side_column := VBoxContainer.new() - side_column.add_theme_constant_override("separation", 10) + side_column.add_theme_constant_override("separation", 6) side_panel.add_child(side_column) var selected_row := HBoxContainer.new() @@ -292,19 +294,29 @@ func _create_hud() -> void: selected_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL selected_row.add_child(selected_label) + mission_title_label = Label.new() + mission_title_label.text = "Objective" + mission_title_label.add_theme_font_size_override("font_size", 14) + side_column.add_child(mission_title_label) + + mission_detail_label = Label.new() + mission_detail_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART + mission_detail_label.custom_minimum_size = Vector2(420, 126) + side_column.add_child(mission_detail_label) + cell_info_label = Label.new() cell_info_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - cell_info_label.custom_minimum_size = Vector2(420, 126) + cell_info_label.custom_minimum_size = Vector2(420, 90) side_column.add_child(cell_info_label) forecast_label = Label.new() forecast_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - forecast_label.custom_minimum_size = Vector2(420, 84) + forecast_label.custom_minimum_size = Vector2(420, 60) side_column.add_child(forecast_label) inventory_label = Label.new() inventory_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - inventory_label.custom_minimum_size = Vector2(420, 40) + inventory_label.custom_minimum_size = Vector2(420, 34) side_column.add_child(inventory_label) var button_row := HBoxContainer.new() @@ -382,7 +394,7 @@ func _create_hud() -> void: equip_menu.add_child(equip_list) log_box = RichTextLabel.new() - log_box.custom_minimum_size = Vector2(420, 150) + log_box.custom_minimum_size = Vector2(420, 70) log_box.fit_content = false side_column.add_child(log_box) @@ -1462,6 +1474,7 @@ func _update_hud() -> void: status_label.text = state.get_status_text() objective_label.text = _format_objective_hud_text() campaign_status_label.text = campaign_state.get_progress_text() + _update_mission_panel() _update_cell_info() _update_forecast() _update_result_panel() @@ -1535,12 +1548,35 @@ func _update_hud() -> void: func _format_objective_hud_text() -> String: var text := String(state.objectives.get("victory", "Defeat all enemies.")) - var progress_text := state.get_objective_progress_text() - if progress_text.is_empty(): - return text if text.is_empty(): - return progress_text - return "%s\n%s" % [text, progress_text] + return "Objective" + return "Objective: %s" % text + + +func _update_mission_panel() -> void: + if mission_detail_label == null: + return + mission_detail_label.text = _format_mission_panel_text() + + +func _format_mission_panel_text() -> String: + var lines := [] + var victory := str(state.objectives.get("victory", "")) + if not victory.is_empty(): + lines.append("Win: %s" % victory) + var progress_lines := state.get_objective_progress_lines(false, false) + if not progress_lines.is_empty(): + lines.append("Progress:") + for progress_line in progress_lines: + lines.append(" %s" % progress_line) + var risk_lines := state.get_defeat_progress_lines() + if not risk_lines.is_empty(): + lines.append("Risk:") + for risk_line in risk_lines: + lines.append(" %s" % risk_line) + if lines.is_empty(): + return "No objective data." + return _join_strings(lines, "\n") func _hovered_unit_for_hud_portrait() -> Dictionary: @@ -2441,11 +2477,16 @@ func _format_briefing_objectives() -> String: if not text.is_empty(): text += "\n" text += "Defeat: %s" % defeat - var tracker_text := state.get_objective_progress_text(true) - if not tracker_text.is_empty(): + var progress_lines := state.get_objective_progress_lines(false, false) + if not progress_lines.is_empty(): if not text.is_empty(): text += "\n" - text += "Tracker: %s" % tracker_text + text += "Progress: %s" % _join_strings(progress_lines, ", ") + var risk_lines := state.get_defeat_progress_lines() + if not risk_lines.is_empty(): + if not text.is_empty(): + text += "\n" + text += "Risk: %s" % _join_strings(risk_lines, ", ") var rewards_text := _format_briefing_rewards() if not rewards_text.is_empty(): if not text.is_empty(): diff --git a/tools/smoke_objective_progress.gd b/tools/smoke_objective_progress.gd index 3174bbc..b4e16bc 100644 --- a/tools/smoke_objective_progress.gd +++ b/tools/smoke_objective_progress.gd @@ -15,7 +15,7 @@ func _init() -> void: _check_contains( failures, "001 briefing progress", - _progress_text("res://data/scenarios/001_yellow_turbans.json", true), + _defeat_text("res://data/scenarios/001_yellow_turbans.json"), "Allies remaining" ) _check_contains( @@ -39,7 +39,7 @@ func _init() -> void: _check_contains( failures, "007 protected-unit risk progress", - _progress_text("res://data/scenarios/007_xian_emperor_escort.json", true), + _defeat_text("res://data/scenarios/007_xian_emperor_escort.json"), "Imperial Envoy safe" ) _check_contains( @@ -66,6 +66,13 @@ func _progress_text(path: String, include_defeat_risks: bool) -> String: return state.get_objective_progress_text(include_defeat_risks) +func _defeat_text(path: String) -> String: + var state = BattleStateScript.new() + if not state.load_battle(path): + return "" % path + return state.get_defeat_progress_text() + + func _check_contains(failures: Array[String], label: String, text: String, expected: String) -> void: if text.contains(expected): return