Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c64d623f9 | ||
|
|
47907f2f68 | ||
|
|
337588e11c |
@@ -20,6 +20,7 @@
|
||||
[ext_resource type="PackedScene" path="res://scenes/ui/CompanionPanel.tscn" id="18_companion"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/ui/PartyPanel.tscn" id="19_party"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/ui/CharacterPanel.tscn" id="20_character"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/ui/ProgressionChoicePanel.tscn" id="21_progression_choice"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBox_hud_panel"]
|
||||
bg_color = Color(0.035, 0.055, 0.09, 0.9)
|
||||
@@ -111,6 +112,8 @@ script = ExtResource("4_hud")
|
||||
|
||||
[node name="CharacterPanel" parent="HUD" instance=ExtResource("20_character")]
|
||||
|
||||
[node name="ProgressionChoicePanel" parent="HUD" instance=ExtResource("21_progression_choice")]
|
||||
|
||||
[node name="ResponsiveLayout" type="Control" parent="HUD"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
||||
@@ -35,9 +35,9 @@ anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -270.0
|
||||
offset_top = -295.0
|
||||
offset_top = -350.0
|
||||
offset_right = 270.0
|
||||
offset_bottom = 295.0
|
||||
offset_bottom = 350.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBox_panel")
|
||||
@@ -87,6 +87,19 @@ popup/item_2/text = "Scout"
|
||||
popup/item_2/id = 2
|
||||
popup/item_2/metadata = "scout"
|
||||
|
||||
[node name="RaceLabel" type="Label" parent="Panel/Layout/Fields"]
|
||||
layout_mode = 2
|
||||
text = "Race"
|
||||
|
||||
[node name="RaceOption" type="OptionButton" parent="Panel/Layout/Fields"]
|
||||
custom_minimum_size = Vector2(0, 31)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="RecommendationLabel" type="Label" parent="Panel/Layout/Fields"]
|
||||
layout_mode = 2
|
||||
autowrap_mode = 2
|
||||
theme_override_colors/font_color = Color(0.72, 0.8, 0.92, 1)
|
||||
|
||||
[node name="PetCheck" type="CheckBox" parent="Panel/Layout/Fields"]
|
||||
custom_minimum_size = Vector2(0, 27)
|
||||
layout_mode = 2
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/presentation/progression_choice_panel.gd" id="1_panel"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBox_panel"]
|
||||
bg_color = Color(0.035, 0.055, 0.09, 0.98)
|
||||
border_width_left = 3
|
||||
border_width_top = 3
|
||||
border_width_right = 3
|
||||
border_width_bottom = 3
|
||||
border_color = Color(0.96, 0.76, 0.28, 0.95)
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
|
||||
[node name="ProgressionChoicePanel" type="PanelContainer"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -360.0
|
||||
offset_top = -220.0
|
||||
offset_right = 360.0
|
||||
offset_bottom = 220.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBox_panel")
|
||||
script = ExtResource("1_panel")
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -320.0
|
||||
offset_top = 18.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 48.0
|
||||
grow_horizontal = 2
|
||||
theme_override_colors/font_color = Color(0.96, 0.82, 0.42, 1)
|
||||
theme_override_font_sizes/font_size = 21
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Body" type="RichTextLabel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 28.0
|
||||
offset_top = 62.0
|
||||
offset_right = -28.0
|
||||
offset_bottom = -20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/default_color = Color(0.92, 0.95, 1, 1)
|
||||
theme_override_font_sizes/normal_font_size = 16
|
||||
@@ -14,6 +14,9 @@ var hit_points := 1
|
||||
var focus := 0
|
||||
var equipment_attribute_modifiers: Dictionary[StringName, int] = {}
|
||||
var equipment_skill_modifiers: Dictionary[StringName, int] = {}
|
||||
# Perks are character-level modifiers, independent from swappable equipment.
|
||||
var perk_attribute_modifiers: Dictionary[StringName, int] = {}
|
||||
var perk_skill_modifiers: Dictionary[StringName, int] = {}
|
||||
var flags: Dictionary[StringName, Variant] = {}
|
||||
var reputation: Dictionary[StringName, int] = {}
|
||||
var archetype: StringName = &""
|
||||
@@ -42,13 +45,13 @@ func max_focus() -> int:
|
||||
return maxi(0, 15 + attributes.get_attribute(&"wil") * 5 + (level - 1) * 3)
|
||||
|
||||
func effective_attribute(key: StringName) -> int:
|
||||
var value: int = attributes.get_attribute(key) + equipment_attribute_modifiers.get(key, 0)
|
||||
var value: int = attributes.get_attribute(key) + equipment_attribute_modifiers.get(key, 0) + perk_attribute_modifiers.get(key, 0)
|
||||
for effect in status_effects:
|
||||
value += effect.attribute_modifier().get(key, 0)
|
||||
return value
|
||||
|
||||
func effective_skill(key: StringName) -> int:
|
||||
return skills.get(key, 0) + equipment_skill_modifiers.get(key, 0)
|
||||
return skills.get(key, 0) + equipment_skill_modifiers.get(key, 0) + perk_skill_modifiers.get(key, 0)
|
||||
|
||||
func modify_attribute(key: StringName, amount: int) -> void:
|
||||
attributes.modify_attribute(key, amount)
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
class_name ClassEngine
|
||||
extends RefCounted
|
||||
|
||||
const RACES_PATH := "res://data/ascii/races.json"
|
||||
const HERO_CLASSES_PATH := "res://data/ascii/hero_classes.json"
|
||||
const BASE_CLASSES := [
|
||||
{"id": "vanguard", "name": "Vanguard", "style_tags": ["melee"]},
|
||||
{"id": "mystic", "name": "Mystic", "style_tags": ["spell"]},
|
||||
{"id": "scout", "name": "Scout", "style_tags": ["ranged", "stealth"]},
|
||||
]
|
||||
const HERO_BASE_ARCHETYPE_ALIASES := {
|
||||
&"vanguard": &"combattant",
|
||||
&"mystic": &"occultiste",
|
||||
&"scout": &"eclaireur",
|
||||
}
|
||||
|
||||
var _races: Dictionary[StringName, Dictionary] = {}
|
||||
var _classes: Dictionary[StringName, Dictionary] = {}
|
||||
var _heroes: Array[Dictionary] = []
|
||||
var _notified: Dictionary[StringName, bool] = {}
|
||||
|
||||
func _init(races: Array = [], classes: Array = [], heroes: Array = []) -> void:
|
||||
_register_all(_races, races)
|
||||
_register_all(_classes, classes)
|
||||
for entry: Variant in heroes:
|
||||
if entry is Dictionary and not StringName(entry.get("id", "")).is_empty():
|
||||
_heroes.append(entry.duplicate(true))
|
||||
|
||||
static func load_default() -> ClassEngine:
|
||||
return ClassEngine.new(_load_array(RACES_PATH), BASE_CLASSES, _load_array(HERO_CLASSES_PATH))
|
||||
|
||||
func race_definitions() -> Array[Dictionary]:
|
||||
var definitions: Array[Dictionary] = []
|
||||
for id: StringName in _races:
|
||||
definitions.append(_races[id].duplicate(true))
|
||||
definitions.sort_custom(func(a: Dictionary, b: Dictionary) -> bool: return String(a.id) < String(b.id))
|
||||
return definitions
|
||||
|
||||
func is_compatible(race_id: StringName, class_id: StringName) -> bool:
|
||||
if not _races.has(race_id) or not _classes.has(class_id):
|
||||
return false
|
||||
var excluded: Array = _races[race_id].get("excludes_class_tags", [])
|
||||
var class_tags: Array = _classes[class_id].get("tags", [])
|
||||
for tag: Variant in excluded:
|
||||
if class_tags.has(tag):
|
||||
return false
|
||||
return true
|
||||
|
||||
func recommendations_for(race_id: StringName) -> Array[StringName]:
|
||||
var recommendations: Array[StringName] = []
|
||||
if not _races.has(race_id):
|
||||
return recommendations
|
||||
var affinity: Array = _races[race_id].get("style_affinity", [])
|
||||
for id: StringName in _classes:
|
||||
if not is_compatible(race_id, id):
|
||||
continue
|
||||
var styles: Array = _classes[id].get("style_tags", [])
|
||||
if styles.any(func(style: Variant) -> bool: return affinity.has(style)):
|
||||
recommendations.append(id)
|
||||
recommendations.sort()
|
||||
return recommendations
|
||||
|
||||
func creation_choice(race_id: StringName, class_id: StringName) -> Dictionary:
|
||||
if race_id.is_empty() or class_id.is_empty():
|
||||
return {"accepted": false, "reason": &"choice_required"}
|
||||
if not _races.has(race_id):
|
||||
return {"accepted": false, "reason": &"unknown_race"}
|
||||
if not _classes.has(class_id):
|
||||
return {"accepted": false, "reason": &"unknown_class"}
|
||||
if not is_compatible(race_id, class_id):
|
||||
return {"accepted": false, "reason": &"incompatible"}
|
||||
return {"accepted": true, "race_id": race_id, "class_id": class_id}
|
||||
|
||||
func apply_creation(player: PlayerState, race_id: StringName, class_id: StringName) -> Dictionary:
|
||||
var choice := creation_choice(race_id, class_id)
|
||||
if not bool(choice.get("accepted", false)):
|
||||
return choice
|
||||
var race := _races[race_id]
|
||||
player.race = race_id
|
||||
player.archetype = class_id
|
||||
_apply_bonuses(player, race)
|
||||
_apply_bonuses(player, _classes[class_id])
|
||||
return choice
|
||||
|
||||
func eligible_evolutions(player: PlayerState) -> Array[Dictionary]:
|
||||
var eligible: Array[Dictionary] = []
|
||||
for definition in _heroes:
|
||||
var base: Variant = definition.get("base_archetype")
|
||||
if base != null and StringName(base) != player.archetype and StringName(base) != _hero_base_archetype_for(player.archetype):
|
||||
continue
|
||||
if _conditions_met(definition.get("conditions", []), player):
|
||||
eligible.append(definition.duplicate(true))
|
||||
eligible.sort_custom(func(a: Dictionary, b: Dictionary) -> bool: return String(a.id) < String(b.id))
|
||||
return eligible
|
||||
|
||||
func evolution_notifications(player: PlayerState) -> Array[Dictionary]:
|
||||
var notifications: Array[Dictionary] = []
|
||||
for definition in eligible_evolutions(player):
|
||||
var id := StringName(definition.id)
|
||||
if not _notified.has(id):
|
||||
_notified[id] = true
|
||||
notifications.append(definition)
|
||||
return notifications
|
||||
|
||||
func _hero_base_archetype_for(class_id: StringName) -> StringName:
|
||||
# Preserve custom/test class IDs while translating only production aliases.
|
||||
return HERO_BASE_ARCHETYPE_ALIASES.get(class_id, class_id)
|
||||
|
||||
func _conditions_met(conditions: Array, player: PlayerState) -> bool:
|
||||
for condition: Variant in conditions:
|
||||
if not condition is Dictionary:
|
||||
return false
|
||||
match StringName(condition.get("type", "")):
|
||||
&"level":
|
||||
if player.level < int(condition.get("min", 1)): return false
|
||||
&"flag":
|
||||
if player.flags.get(StringName(condition.get("flag", "")), false) != condition.get("equals", true): return false
|
||||
&"reputation":
|
||||
if player.reputation.get(StringName(condition.get("faction", "")), 0) < int(condition.get("min", 0)): return false
|
||||
&"skill":
|
||||
if player.effective_skill(StringName(condition.get("skill", ""))) < int(condition.get("min", 0)): return false
|
||||
_:
|
||||
return false
|
||||
return true
|
||||
|
||||
func _apply_bonuses(player: PlayerState, definition: Dictionary) -> void:
|
||||
for key in definition.get("attr_bonus", {}):
|
||||
player.modify_attribute(StringName(key), int(definition.attr_bonus[key]))
|
||||
for key in definition.get("skill_bonus", {}):
|
||||
player.modify_skill(StringName(key), int(definition.skill_bonus[key]))
|
||||
|
||||
func _register_all(destination: Dictionary[StringName, Dictionary], definitions: Array) -> void:
|
||||
for entry: Variant in definitions:
|
||||
if entry is Dictionary:
|
||||
var id := StringName(entry.get("id", ""))
|
||||
if not id.is_empty() and not destination.has(id):
|
||||
destination[id] = entry.duplicate(true)
|
||||
|
||||
static func _load_array(path: String) -> Array:
|
||||
var file := FileAccess.open(path, FileAccess.READ)
|
||||
if file == null:
|
||||
push_error("Unable to load progression catalog: %s" % path)
|
||||
return []
|
||||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||||
return parsed if parsed is Array else []
|
||||
@@ -0,0 +1 @@
|
||||
uid://bd4vbukk0rapw
|
||||
@@ -0,0 +1,90 @@
|
||||
class_name PerkEngine
|
||||
extends RefCounted
|
||||
|
||||
const PERKS_PATH := "res://data/ascii/perks.json"
|
||||
|
||||
var _definitions: Dictionary[StringName, Dictionary] = {}
|
||||
var _order: Array[StringName] = []
|
||||
var _ranks: Dictionary[StringName, int] = {}
|
||||
var _level_three_choice_made := false
|
||||
|
||||
func _init(definitions: Array = []) -> void:
|
||||
for entry: Variant in definitions:
|
||||
if not entry is Dictionary:
|
||||
continue
|
||||
var id := StringName(entry.get("id", ""))
|
||||
if id.is_empty() or _definitions.has(id):
|
||||
continue
|
||||
_definitions[id] = entry.duplicate(true)
|
||||
_order.append(id)
|
||||
|
||||
static func load_default() -> PerkEngine:
|
||||
var file := FileAccess.open(PERKS_PATH, FileAccess.READ)
|
||||
if file == null:
|
||||
push_error("Unable to load perk catalog: %s" % PERKS_PATH)
|
||||
return PerkEngine.new()
|
||||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||||
return PerkEngine.new(parsed if parsed is Array else [])
|
||||
|
||||
func choices_for_level(level: int) -> Array[Dictionary]:
|
||||
var choices: Array[Dictionary] = []
|
||||
for id in _order:
|
||||
var definition := _definitions[id]
|
||||
if int(definition.get("min_level", 1)) <= level and rank_for(id) < int(definition.get("max_rank", 1)):
|
||||
choices.append(definition.duplicate(true))
|
||||
return choices
|
||||
|
||||
func level_three_choices() -> Array[Dictionary]:
|
||||
var choices: Array[Dictionary] = []
|
||||
for id in _order:
|
||||
var definition := _definitions[id]
|
||||
if int(definition.get("min_level", 1)) == 3 and rank_for(id) < int(definition.get("max_rank", 1)):
|
||||
choices.append(definition.duplicate(true))
|
||||
return choices
|
||||
|
||||
func requires_level_three_choice(level: int) -> bool:
|
||||
return level >= 3 and not _level_three_choice_made and not level_three_choices().is_empty()
|
||||
|
||||
func choose_level_three(id: StringName, level: int) -> Dictionary:
|
||||
if not requires_level_three_choice(level):
|
||||
return {"accepted": false, "reason": &"choice_not_required"}
|
||||
if not level_three_choices().any(func(choice: Dictionary) -> bool: return StringName(choice.get("id", "")) == id):
|
||||
return {"accepted": false, "reason": &"not_level_three_choice"}
|
||||
var result := rank_up(id, level)
|
||||
if bool(result.get("accepted", false)):
|
||||
_level_three_choice_made = true
|
||||
return result
|
||||
|
||||
func rank_up(id: StringName, level: int) -> Dictionary:
|
||||
if not _definitions.has(id):
|
||||
return {"accepted": false, "reason": &"unknown_perk"}
|
||||
var definition := _definitions[id]
|
||||
if level < int(definition.get("min_level", 1)):
|
||||
return {"accepted": false, "reason": &"level_too_low"}
|
||||
var rank := rank_for(id)
|
||||
if rank >= int(definition.get("max_rank", 1)):
|
||||
return {"accepted": false, "reason": &"rank_maxed"}
|
||||
_ranks[id] = rank + 1
|
||||
return {"accepted": true, "perk_id": id, "rank": _ranks[id], "definition": definition.duplicate(true)}
|
||||
|
||||
func rank_for(id: StringName) -> int:
|
||||
return _ranks.get(id, 0)
|
||||
|
||||
func modifiers() -> Dictionary:
|
||||
var totals := {}
|
||||
for id in _ranks:
|
||||
var per_rank: Dictionary = _definitions[id].get("per_rank", {})
|
||||
for key in per_rank:
|
||||
totals[key] = totals.get(key, 0) + per_rank[key] * _ranks[id]
|
||||
return totals
|
||||
|
||||
func apply_to_player(player: PlayerState) -> void:
|
||||
player.perk_attribute_modifiers.clear()
|
||||
player.perk_skill_modifiers.clear()
|
||||
for key: StringName in modifiers():
|
||||
var value: Variant = modifiers()[key]
|
||||
if String(key).begins_with("attr_"):
|
||||
player.perk_attribute_modifiers[StringName(String(key).trim_prefix("attr_"))] = int(value)
|
||||
elif String(key).begins_with("skill_"):
|
||||
player.perk_skill_modifiers[StringName(String(key).trim_prefix("skill_"))] = int(value)
|
||||
player.normalize_resources()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bahscsrai708a
|
||||
+49
-1
@@ -34,6 +34,9 @@ const CompanionStateType = preload("res://scripts/domain/entities/companion_stat
|
||||
const PartyTurnEngineType = preload("res://scripts/domain/ai/party_turn_engine.gd")
|
||||
const PartyPanelType = preload("res://scripts/presentation/party_panel.gd")
|
||||
const CharacterPanelType = preload("res://scripts/presentation/character_panel.gd")
|
||||
const PerkEngineType = preload("res://scripts/domain/progression/perk_engine.gd")
|
||||
const ClassEngineType = preload("res://scripts/domain/progression/class_engine.gd")
|
||||
const ProgressionChoicePanelType = preload("res://scripts/presentation/progression_choice_panel.gd")
|
||||
@onready var event_presenter: EventPresenter = $EventPresenter
|
||||
@onready var map_renderer: MapRenderer = $World/MapRenderer
|
||||
@onready var player_view: ActorView = $World/Player
|
||||
@@ -52,6 +55,7 @@ const CharacterPanelType = preload("res://scripts/presentation/character_panel.g
|
||||
@onready var companion_panel: CompanionPanel = $HUD/CompanionPanel
|
||||
@onready var party_panel: PartyPanel = $HUD/PartyPanel
|
||||
@onready var character_panel: CharacterPanel = $HUD/CharacterPanel
|
||||
@onready var progression_choice_panel: ProgressionChoicePanel = $HUD/ProgressionChoicePanel
|
||||
@onready var companion_view: ActorView = $World/Companion
|
||||
@onready var party_views: Node2D = $World/Party
|
||||
var pending_loot: Dictionary = {}
|
||||
@@ -66,6 +70,7 @@ var action_router: ActionRouter
|
||||
var pending_run_settings: RunSettings
|
||||
var pending_player_name := "Sans-Nom"
|
||||
var pending_base_archetype: StringName = &"vanguard"
|
||||
var pending_race: StringName = &"race_humain_standard"
|
||||
var floor_transition: FloorTransition
|
||||
var spell_catalog: ContentCatalog
|
||||
var spell_state: SpellState
|
||||
@@ -74,13 +79,16 @@ var dialogue_engine: DialogueEngine
|
||||
var event_engine: EventEngine
|
||||
var quest_manager: QuestManager
|
||||
var dialogue_player: PlayerState
|
||||
var perk_engine: PerkEngine
|
||||
var class_engine: ClassEngine
|
||||
var active_dialogue_npc: Dictionary = {}
|
||||
var active_event_index := -1
|
||||
|
||||
func configure_new_run(settings: RunSettings, player_name: String, base_archetype: StringName) -> void:
|
||||
func configure_new_run(settings: RunSettings, player_name: String, base_archetype: StringName, race: StringName = &"race_humain_standard") -> void:
|
||||
pending_run_settings = settings
|
||||
pending_player_name = player_name
|
||||
pending_base_archetype = base_archetype
|
||||
pending_race = race
|
||||
|
||||
func _ready() -> void:
|
||||
game_state = _create_initial_state()
|
||||
@@ -92,6 +100,7 @@ func _ready() -> void:
|
||||
targeting_overlay.targeting_cancelled.connect(_cancel_targeting)
|
||||
spell_targeting_overlay.target_selected.connect(_on_spell_target_selected)
|
||||
spell_targeting_overlay.targeting_cancelled.connect(_cancel_spell_targeting)
|
||||
progression_choice_panel.choice_confirmed.connect(_choose_level_three_perk)
|
||||
map_renderer.set_map(game_state.map)
|
||||
_sync_map_renderer_visibility()
|
||||
player_view.set_actor(game_state.player)
|
||||
@@ -124,6 +133,14 @@ func _initialize_run_state() -> void:
|
||||
quest_manager = QuestManagerType.new(spell_catalog)
|
||||
run_state.quest_manager = quest_manager
|
||||
dialogue_player = PlayerStateType.new({"id": game_state.player.id, "level": game_state.player.progression.level})
|
||||
perk_engine = PerkEngineType.load_default()
|
||||
class_engine = ClassEngineType.load_default()
|
||||
# The existing base-archetype menu is now the mandatory class choice. Race
|
||||
# defaults to the neutral human until the creation UI submits its selection.
|
||||
# Preserve the no-class initial state used by dialogue gates in existing runs;
|
||||
# menu creation assigns its explicit base class immediately after launch.
|
||||
if pending_run_settings != null:
|
||||
class_engine.apply_creation(dialogue_player, pending_race, run_state.base_archetype)
|
||||
game_state.content_catalog = spell_catalog
|
||||
spell_state = SpellStateType.new([&"spell_epines_empoisonnees"])
|
||||
floor_transition = FloorTransitionType.new(spell_catalog)
|
||||
@@ -184,6 +201,15 @@ func _prepare_exit_capture_state() -> void:
|
||||
_sync_camera_to_player()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if progression_choice_panel.visible and event is InputEventKey and event.is_pressed():
|
||||
if event.keycode == KEY_UP:
|
||||
progression_choice_panel.select_next(-1)
|
||||
elif event.keycode == KEY_DOWN:
|
||||
progression_choice_panel.select_next(1)
|
||||
elif event.keycode == KEY_ENTER or event.keycode == KEY_SPACE:
|
||||
progression_choice_panel.confirm()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if character_panel.visible and event is InputEventKey and event.is_pressed():
|
||||
if event.keycode == KEY_A:
|
||||
_spend_character_attribute(&"str_")
|
||||
@@ -533,6 +559,9 @@ func get_run_state() -> RunState:
|
||||
func get_dialogue_player() -> PlayerState:
|
||||
return dialogue_player
|
||||
|
||||
func get_perk_engine() -> PerkEngine:
|
||||
return perk_engine
|
||||
|
||||
func get_actor_cell_rect(actor_id: StringName) -> Rect2:
|
||||
if actor_id == &"player":
|
||||
return player_view.get_cell_rect()
|
||||
@@ -684,12 +713,30 @@ func _append_context_level_up_event(previous_level: int) -> void:
|
||||
var levels_gained := game_state.player.progression.level - previous_level
|
||||
if levels_gained <= 0:
|
||||
return
|
||||
_sync_dialogue_player_progression()
|
||||
_record_ranged_event(
|
||||
&"level_up",
|
||||
&"",
|
||||
{"level": game_state.player.progression.level, "levels_gained": levels_gained},
|
||||
"You reached level %d." % game_state.player.progression.level
|
||||
)
|
||||
_check_progression_choices_and_evolutions()
|
||||
|
||||
func _check_progression_choices_and_evolutions() -> void:
|
||||
if perk_engine.requires_level_three_choice(game_state.player.progression.level):
|
||||
progression_choice_panel.present(perk_engine.level_three_choices())
|
||||
_record_ranged_event(&"level_three_choice_required", &"", {"level": game_state.player.progression.level}, "Choose a level 3 perk.")
|
||||
for evolution in class_engine.evolution_notifications(dialogue_player):
|
||||
_record_ranged_event(&"%s_available" % String(evolution.get("tier", "hero")), StringName(evolution.get("id", "")), {"tier": evolution.get("tier", "hero")}, "%s evolution available." % String(evolution.get("name", evolution.get("id", ""))))
|
||||
|
||||
func _choose_level_three_perk(perk_id: StringName) -> void:
|
||||
var result := perk_engine.choose_level_three(perk_id, game_state.player.progression.level)
|
||||
if not bool(result.get("accepted", false)):
|
||||
return
|
||||
perk_engine.apply_to_player(dialogue_player)
|
||||
progression_choice_panel.dismiss()
|
||||
_record_ranged_event(&"perk_chosen", perk_id, {"rank": result.get("rank", 0)}, "%s chosen." % String(result.get("definition", {}).get("name", perk_id)))
|
||||
_check_progression_choices_and_evolutions()
|
||||
|
||||
func _toggle_companion_panel() -> Array[GameEvent]:
|
||||
if game_state.companion == null:
|
||||
@@ -1209,6 +1256,7 @@ func _append_level_up_events(events: Array[GameEvent]) -> void:
|
||||
)
|
||||
events.append(level_event)
|
||||
run_state.append_events([level_event])
|
||||
_check_progression_choices_and_evolutions()
|
||||
|
||||
func _record_events(results: Array[TurnResult]) -> Array[GameEvent]:
|
||||
var events: Array[GameEvent] = []
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
class_name CharacterCreation
|
||||
extends Control
|
||||
|
||||
signal run_requested(settings: RunSettings, player_name: String, base_archetype: StringName)
|
||||
signal run_requested(settings: RunSettings, player_name: String, base_archetype: StringName, race: StringName)
|
||||
signal cancelled
|
||||
|
||||
const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd")
|
||||
const ClassEngineType = preload("res://scripts/domain/progression/class_engine.gd")
|
||||
const DIFFICULTY_IDS: Array[StringName] = [&"touriste", &"crawler", &"veteran", &"masochiste"]
|
||||
const ARCHETYPE_IDS: Array[StringName] = [&"vanguard", &"mystic", &"scout"]
|
||||
|
||||
@onready var name_edit: LineEdit = $Panel/Layout/Fields/NameEdit
|
||||
@onready var archetype_option: OptionButton = $Panel/Layout/Fields/ArchetypeOption
|
||||
@onready var race_option: OptionButton = $Panel/Layout/Fields/RaceOption
|
||||
@onready var recommendation_label: Label = $Panel/Layout/Fields/RecommendationLabel
|
||||
@onready var pet_check: CheckBox = $Panel/Layout/Fields/PetCheck
|
||||
@onready var seed_edit: LineEdit = $Panel/Layout/Fields/SeedEdit
|
||||
@onready var difficulty_option: OptionButton = $Panel/Layout/Fields/DifficultyOption
|
||||
@@ -17,9 +20,23 @@ const ARCHETYPE_IDS: Array[StringName] = [&"vanguard", &"mystic", &"scout"]
|
||||
@onready var validation_label: Label = $Panel/Layout/ValidationLabel
|
||||
|
||||
func _ready() -> void:
|
||||
_populate_races()
|
||||
race_option.item_selected.connect(_refresh_recommendation)
|
||||
$Panel/Layout/Actions/StartRunButton.pressed.connect(_on_start_run_pressed)
|
||||
$Panel/Layout/Actions/CancelButton.pressed.connect(func() -> void: cancelled.emit())
|
||||
|
||||
func _populate_races() -> void:
|
||||
var engine := ClassEngineType.load_default()
|
||||
for race in engine.race_definitions():
|
||||
race_option.add_item(String(race.get("name", race.get("id", ""))))
|
||||
race_option.set_item_metadata(race_option.item_count - 1, StringName(race.get("id", "")))
|
||||
_refresh_recommendation(race_option.selected)
|
||||
|
||||
func _refresh_recommendation(_selected: int) -> void:
|
||||
var race_id := StringName(race_option.get_item_metadata(race_option.selected))
|
||||
var recommendations := ClassEngineType.load_default().recommendations_for(race_id)
|
||||
recommendation_label.text = "Recommended: %s" % (", ".join(PackedStringArray(recommendations.map(func(id: StringName) -> String: return String(id).capitalize()))) if not recommendations.is_empty() else "Recommended: any base class")
|
||||
|
||||
func _on_start_run_pressed() -> void:
|
||||
var selected_difficulty := DIFFICULTY_IDS[difficulty_option.selected]
|
||||
var settings := RunSettingsType.new(
|
||||
@@ -36,4 +53,9 @@ func _on_start_run_pressed() -> void:
|
||||
if player_name.is_empty():
|
||||
player_name = "Sans-Nom"
|
||||
var selected_archetype := ARCHETYPE_IDS[archetype_option.selected]
|
||||
run_requested.emit(settings, player_name, selected_archetype)
|
||||
var selected_race := StringName(race_option.get_item_metadata(race_option.selected))
|
||||
var choice := ClassEngineType.load_default().creation_choice(selected_race, selected_archetype)
|
||||
if not bool(choice.get("accepted", false)):
|
||||
validation_label.text = "Choose a compatible race and base archetype."
|
||||
return
|
||||
run_requested.emit(settings, player_name, selected_archetype, selected_race)
|
||||
|
||||
@@ -23,7 +23,7 @@ func _ready() -> void:
|
||||
character_creation.cancelled.connect(_show_main_menu)
|
||||
_show_main_menu()
|
||||
if _get_capture_mode():
|
||||
_start_new_run(RunSettings.new("visual-check", &"crawler", false, false), "Visual Check", &"vanguard")
|
||||
_start_new_run(RunSettings.new("visual-check", &"crawler", false, false), "Visual Check", &"vanguard", &"race_humain_standard")
|
||||
|
||||
func _get_capture_mode() -> bool:
|
||||
var arguments := OS.get_cmdline_user_args()
|
||||
@@ -69,10 +69,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
func _show_unavailable(action_name: String) -> void:
|
||||
status_label.text = "%s will be available when save slots arrive." % action_name
|
||||
|
||||
func _start_new_run(settings: RunSettings, player_name: String, base_archetype: StringName) -> void:
|
||||
func _start_new_run(settings: RunSettings, player_name: String, base_archetype: StringName, race: StringName = &"race_humain_standard") -> void:
|
||||
var game := GameScene.instantiate() as Game
|
||||
game.name = "Game"
|
||||
game.configure_new_run(settings, player_name, base_archetype)
|
||||
game.configure_new_run(settings, player_name, base_archetype, race)
|
||||
add_child(game)
|
||||
menu.visible = false
|
||||
character_creation.visible = false
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
class_name ProgressionChoicePanel
|
||||
extends PanelContainer
|
||||
|
||||
signal choice_confirmed(perk_id: StringName)
|
||||
|
||||
@onready var title: Label = $Title
|
||||
@onready var body: RichTextLabel = $Body
|
||||
|
||||
var _choices: Array[Dictionary] = []
|
||||
var _selected_index := 0
|
||||
|
||||
func present(choices: Array[Dictionary]) -> void:
|
||||
_choices = choices.duplicate(true)
|
||||
_selected_index = 0
|
||||
visible = true
|
||||
refresh()
|
||||
|
||||
func dismiss() -> void:
|
||||
visible = false
|
||||
_choices.clear()
|
||||
_selected_index = 0
|
||||
|
||||
func select_next(delta: int) -> void:
|
||||
if _choices.is_empty():
|
||||
return
|
||||
_selected_index = posmod(_selected_index + delta, _choices.size())
|
||||
refresh()
|
||||
|
||||
func confirm() -> void:
|
||||
if _choices.is_empty():
|
||||
return
|
||||
choice_confirmed.emit(StringName(_choices[_selected_index].get("id", "")))
|
||||
|
||||
func refresh() -> void:
|
||||
title.text = "LEVEL 3 — CHOOSE A PERK"
|
||||
var lines := PackedStringArray(["A perk is required before continuing.", ""])
|
||||
for index in _choices.size():
|
||||
var choice := _choices[index]
|
||||
var marker := ">" if index == _selected_index else " "
|
||||
lines.append("%s %s — %s" % [marker, String(choice.get("name", choice.get("id", ""))), String(choice.get("description", ""))])
|
||||
body.text = "\n".join(lines) + "\n\nUp/Down Select Enter Confirm"
|
||||
@@ -0,0 +1 @@
|
||||
uid://cq1mhoffrvq3p
|
||||
@@ -0,0 +1,42 @@
|
||||
# Task F2 — Perks, Races, Classes, and Hero Evolution
|
||||
|
||||
## Scope
|
||||
|
||||
Implemented only F2 progression behavior:
|
||||
|
||||
- Data-backed race/class validation, compatibility checks, affinity recommendations, and creation bonuses.
|
||||
- Character-creation race selection and recommendation display, with the selected race passed into a new run.
|
||||
- Data-backed perk ranks, level/rank gates, accumulated modifiers, and mandatory level-3 perk selection.
|
||||
- A modal level-3 choice panel that captures navigation/confirmation input until a perk is selected and journals both the requirement and selection.
|
||||
- Data-backed hero/elite eligibility checks and one-time availability notifications, including mapping the current creation archetypes to the ASCII hero definitions' canonical base-archetype IDs.
|
||||
- Unit coverage for perks, race/class contracts, and hero/elite conditions; real-scene E2E coverage for the floor-three modal flow.
|
||||
|
||||
No F3 achievement, title, reward, or achievement UI behavior was added or changed.
|
||||
|
||||
## Verification fix
|
||||
|
||||
The initial full verification run failed one existing layout test because `character_creation.gd` had been updated to require `RaceOption` and `RecommendationLabel`, but the corresponding scene controls had not been added. This produced null-node script errors while instantiating the creation scene.
|
||||
|
||||
The root fix added the missing race controls to `CharacterCreation.tscn`, increased the panel height to accommodate them, wired the selected race through the menu's run-start signal, and validated the submitted race/class pair. The rerun then exposed a hero test regression from applying production archetype aliases to a test-defined `vanguard` hero; eligibility now accepts the exact class ID first and uses aliases only for canonical ASCII definitions.
|
||||
|
||||
## Final verification and capture
|
||||
|
||||
`git diff --check` passed.
|
||||
|
||||
`./scripts/verify.sh` passed with Godot 4.5.0:
|
||||
|
||||
- Unit: **164 / 164** tests, **1,243** assertions
|
||||
- Integration: **10 / 10** tests, **59,462** assertions
|
||||
- E2E: **48 / 48** tests, **484** assertions
|
||||
- Visual: passed both Xvfb captures
|
||||
|
||||
Captured and validated artifacts (ignored by Git):
|
||||
|
||||
- `artifacts/visual-check.png`: `dungeon_non_black_pixels=489308`, `visible_pixels=17524`, `explored_pixels=10438`, `unknown_pixels=366284`
|
||||
- `artifacts/visual-check-exit.png`: `dungeon_non_black_pixels=489252`, `visible_pixels=17404`, `explored_pixels=17146`, `unknown_pixels=440456`
|
||||
|
||||
The runner emitted existing third-party GUT invalid-UID warnings plus Godot resource-cleanup warnings. No application `SCRIPT ERROR` or parse error occurred in the successful final verification.
|
||||
|
||||
## Git
|
||||
|
||||
This report and all F2 implementation, scene, test, and UID files are included in the local F2 commit. No push and no PR were created.
|
||||
@@ -0,0 +1,46 @@
|
||||
extends GutTest
|
||||
|
||||
const ExperienceType = preload("res://scripts/domain/progression/experience.gd")
|
||||
const GameScene = preload("res://scenes/Game.tscn")
|
||||
|
||||
var game: Game
|
||||
|
||||
func before_each() -> void:
|
||||
game = GameScene.instantiate()
|
||||
add_child_autofree(game)
|
||||
await get_tree().process_frame
|
||||
|
||||
func test_level_three_open_choice_blocks_actions_until_a_perk_is_chosen_and_journals_choice() -> void:
|
||||
var state := game.get_game_state()
|
||||
state.player.progression = ExperienceType.new(299)
|
||||
state.player.xp = 299
|
||||
state.enemies[&"goblin"].cell = state.player.cell + Vector2i.RIGHT
|
||||
state.enemies[&"goblin"].hit_points = 1
|
||||
state.enemies[&"goblin"].xp_reward = 1
|
||||
state.player.weapon_damage = 12
|
||||
|
||||
await _dispatch_key(KEY_RIGHT)
|
||||
var panel := game.get_node("HUD/ProgressionChoicePanel") as PanelContainer
|
||||
assert_eq(state.player.progression.level, 3)
|
||||
assert_true(panel.visible)
|
||||
assert_true(game.get_run_state().recent_events(8).any(func(event: GameEvent) -> bool: return event.kind == &"level_three_choice_required"))
|
||||
|
||||
await _dispatch_key(KEY_RIGHT)
|
||||
assert_eq(state.player.cell, Vector2i(4, 12))
|
||||
await _dispatch_key(KEY_ENTER)
|
||||
assert_false(panel.visible)
|
||||
assert_eq(game.get_perk_engine().rank_for(&"increvable"), 1)
|
||||
assert_true(game.get_run_state().recent_events(8).any(func(event: GameEvent) -> bool: return event.kind == &"perk_chosen"))
|
||||
|
||||
func _dispatch_key(keycode: Key) -> void:
|
||||
Input.parse_input_event(_key_event(keycode, true))
|
||||
await get_tree().process_frame
|
||||
Input.parse_input_event(_key_event(keycode, false))
|
||||
await get_tree().process_frame
|
||||
|
||||
func _key_event(keycode: Key, pressed: bool) -> InputEventKey:
|
||||
var event := InputEventKey.new()
|
||||
event.keycode = keycode
|
||||
event.physical_keycode = keycode
|
||||
event.pressed = pressed
|
||||
return event
|
||||
@@ -0,0 +1 @@
|
||||
uid://b6shxonyn1tal
|
||||
@@ -0,0 +1,14 @@
|
||||
extends GutTest
|
||||
|
||||
const ClassEngineType = preload("res://scripts/domain/progression/class_engine.gd")
|
||||
|
||||
func test_hero_conditions_report_eligible_hero_and_elite_notifications_once() -> void:
|
||||
var engine := ClassEngineType.new([], [], [
|
||||
{"id": "hero_vanguard", "tier": "hero", "base_archetype": "vanguard", "conditions": [{"type": "level", "min": 3}]},
|
||||
{"id": "elite_any", "tier": "elite", "base_archetype": null, "conditions": [{"type": "flag", "flag": "floor_3", "equals": true}]},
|
||||
])
|
||||
var player := PlayerState.new({"archetype": "vanguard", "level": 3, "flags": {"floor_3": true}})
|
||||
|
||||
assert_eq(engine.eligible_evolutions(player).map(func(entry: Dictionary) -> StringName: return entry.id), [&"elite_any", &"hero_vanguard"])
|
||||
assert_eq(engine.evolution_notifications(player).map(func(entry: Dictionary) -> StringName: return entry.id), [&"elite_any", &"hero_vanguard"])
|
||||
assert_eq(engine.evolution_notifications(player), [])
|
||||
@@ -0,0 +1 @@
|
||||
uid://dcq6fiwqxequ7
|
||||
@@ -0,0 +1,24 @@
|
||||
extends GutTest
|
||||
|
||||
const PerkEngineType = preload("res://scripts/domain/progression/perk_engine.gd")
|
||||
|
||||
func test_level_three_perk_choice_is_required_once_and_obeys_level_and_rank_gates() -> void:
|
||||
var engine := PerkEngineType.load_default()
|
||||
|
||||
assert_true(engine.requires_level_three_choice(3))
|
||||
assert_false(engine.choose_level_three(&"increvable", 2).accepted)
|
||||
assert_false(engine.choose_level_three(&"does_not_exist", 3).accepted)
|
||||
assert_true(engine.choose_level_three(&"increvable", 3).accepted)
|
||||
assert_eq(engine.rank_for(&"increvable"), 1)
|
||||
assert_false(engine.requires_level_three_choice(3))
|
||||
assert_false(engine.choose_level_three(&"sang_froid", 3).accepted)
|
||||
|
||||
func test_perk_rank_effects_accumulate_and_stop_at_the_catalog_rank_cap() -> void:
|
||||
var engine := PerkEngineType.new([
|
||||
{"id": "dur", "min_level": 1, "max_rank": 2, "per_rank": {"hp_pct": 0.1, "carry_capacity": 5}},
|
||||
])
|
||||
|
||||
assert_true(engine.rank_up(&"dur", 1).accepted)
|
||||
assert_true(engine.rank_up(&"dur", 1).accepted)
|
||||
assert_false(engine.rank_up(&"dur", 1).accepted)
|
||||
assert_eq(engine.modifiers(), {"hp_pct": 0.2, "carry_capacity": 10})
|
||||
@@ -0,0 +1 @@
|
||||
uid://bh446pwn6cqln
|
||||
@@ -0,0 +1,36 @@
|
||||
extends GutTest
|
||||
|
||||
const ClassEngineType = preload("res://scripts/domain/progression/class_engine.gd")
|
||||
|
||||
func test_race_class_compatibility_and_affinity_recommendations_are_data_driven() -> void:
|
||||
var engine := ClassEngineType.new(
|
||||
[
|
||||
{"id": "insurge", "style_affinity": ["melee"], "excludes_class_tags": ["faction_bienpensants"]},
|
||||
{"id": "drone", "style_affinity": ["ranged", "traps"]},
|
||||
],
|
||||
[
|
||||
{"id": "guardian", "tags": ["faction_bienpensants"], "style_tags": ["melee"]},
|
||||
{"id": "demineur", "tags": [], "style_tags": ["traps"]},
|
||||
]
|
||||
)
|
||||
|
||||
assert_false(engine.is_compatible(&"insurge", &"guardian"))
|
||||
assert_true(engine.is_compatible(&"insurge", &"demineur"))
|
||||
assert_eq(engine.recommendations_for(&"drone"), [&"demineur"])
|
||||
|
||||
func test_creation_requires_valid_compatible_race_and_base_class_before_apply() -> void:
|
||||
var engine := ClassEngineType.new(
|
||||
[{"id": "human", "attr_bonus": {"end": 2}, "skill_bonus": {"survival": 1}}],
|
||||
[{"id": "vanguard", "style_tags": ["melee"]}]
|
||||
)
|
||||
|
||||
assert_false(engine.creation_choice(&"", &"vanguard").accepted)
|
||||
assert_false(engine.creation_choice(&"human", &"unknown").accepted)
|
||||
assert_true(engine.creation_choice(&"human", &"vanguard").accepted)
|
||||
var player := PlayerState.new()
|
||||
var applied := engine.apply_creation(player, &"human", &"vanguard")
|
||||
assert_true(applied.accepted)
|
||||
assert_eq(player.race, &"human")
|
||||
assert_eq(player.archetype, &"vanguard")
|
||||
assert_eq(player.attributes.get_attribute(&"end"), 6)
|
||||
assert_eq(player.effective_skill(&"survival"), 2)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dtd6grleut7tm
|
||||
Reference in New Issue
Block a user