feat: complete playtest parity improvements
This commit is contained in:
@@ -63,7 +63,7 @@ if [[ -z "${DISPLAY:-}" ]]; then
|
||||
echo "build-linux: X11 smoke unavailable: DISPLAY is unset and xvfb-run is not installed." >&2
|
||||
exit 2
|
||||
fi
|
||||
runner=(xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24")
|
||||
runner=(xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24")
|
||||
fi
|
||||
|
||||
smoke_log="build/linux/smoke.log"
|
||||
|
||||
@@ -13,9 +13,11 @@ import sys
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
WIDTH = 1280
|
||||
HEIGHT = 720
|
||||
VIEWPORT = (256, 40, 1024, 678)
|
||||
WIDTH = 1920
|
||||
HEIGHT = 1080
|
||||
# Central dungeon measurement region, proportionally equivalent to the former
|
||||
# 16:9 reference crop while excluding the anchored HUD panels.
|
||||
VIEWPORT = (384, 60, 1536, 1017)
|
||||
UNKNOWN = (1, 2, 5)
|
||||
# Captured explored tiles are texture modulated, so classify their blue-black
|
||||
# pixels by palette range rather than expecting one flat overlay color.
|
||||
@@ -140,8 +142,15 @@ def luminance(rgb: tuple[int, int, int]) -> float:
|
||||
|
||||
|
||||
def is_visible(pixel: tuple[int, int, int]) -> bool:
|
||||
# The unmodulated grayscale floor texture includes these neutral bright texels.
|
||||
return max(pixel) - min(pixel) <= 3 and max(pixel) >= 112
|
||||
# Visible terrain can be either the neutral wall texture or the brown floor
|
||||
# texture. The authored surface begins in a large open room, so a capture is
|
||||
# not required to include a wall inside the central measurement crop.
|
||||
neutral_wall = max(pixel) - min(pixel) <= 3 and max(pixel) >= 112
|
||||
unmodulated_floor = pixel in {
|
||||
(23, 4, 0), (23, 7, 0), (10, 10, 0), (30, 13, 0),
|
||||
(4, 4, 0), (41, 23, 1), (30, 9, 0), (66, 36, 6),
|
||||
}
|
||||
return neutral_wall or unmodulated_floor
|
||||
|
||||
|
||||
def is_explored(pixel: tuple[int, int, int]) -> bool:
|
||||
|
||||
@@ -3,33 +3,40 @@ extends RefCounted
|
||||
|
||||
const CompanionStateType = preload("res://scripts/domain/entities/companion_state.gd")
|
||||
const PathfindingType = preload("res://scripts/domain/ai/pathfinding.gd")
|
||||
const SUPPORT_HEAL_THRESHOLD := 0.5
|
||||
const SUPPORT_HEAL_RANGE := 4
|
||||
const SUPPORT_HEAL_AMOUNT := 2
|
||||
|
||||
static func decide(companion: CompanionState, player: ActorState, enemies: Dictionary[StringName, ActorState], map: GridMapState, blocked_cells: Dictionary[Vector2i, bool] = {}) -> Dictionary:
|
||||
static func decide(companion: CompanionState, player: ActorState, enemies: Dictionary[StringName, ActorState], map: GridMapState, blocked_cells: Dictionary[Vector2i, bool] = {}, detected_cells: Dictionary[Vector2i, bool] = {}) -> Dictionary:
|
||||
if companion == null or not companion.is_alive():
|
||||
return {"kind": &"idle"}
|
||||
match companion.stance:
|
||||
CompanionStateType.Stance.FOLLOW:
|
||||
match CompanionStateType.normalize_stance(companion.stance):
|
||||
CompanionStateType.Stance.STAY_BACK:
|
||||
return _follow(companion.actor, player, map, blocked_cells)
|
||||
CompanionStateType.Stance.DEFEND:
|
||||
CompanionStateType.Stance.DEFEND_ME:
|
||||
return _defend(companion.actor, player, enemies, map, blocked_cells)
|
||||
CompanionStateType.Stance.SUPPORT:
|
||||
return {"kind": &"idle"}
|
||||
CompanionStateType.Stance.ATTACK_ON_SIGHT:
|
||||
return _aggressive(companion.actor, player, enemies, map, blocked_cells, detected_cells)
|
||||
_:
|
||||
return {"kind": &"idle"}
|
||||
|
||||
static func _aggressive(actor: ActorState, player: ActorState, enemies: Dictionary[StringName, ActorState], map: GridMapState, blocked_cells: Dictionary[Vector2i, bool], detected_cells: Dictionary[Vector2i, bool]) -> Dictionary:
|
||||
var target := _nearest_enemy(actor.cell, enemies, detected_cells)
|
||||
if target == null:
|
||||
return _follow(actor, player, map, blocked_cells)
|
||||
if actor.cell.distance_to(target.cell) <= 1.5:
|
||||
return {"kind": &"melee", "target_id": target.id}
|
||||
return _move_toward(actor, target.cell, player.cell, map, blocked_cells)
|
||||
|
||||
static func _support(actor: ActorState, player: ActorState, map: GridMapState, blocked_cells: Dictionary[Vector2i, bool]) -> Dictionary:
|
||||
if player.is_alive() and float(player.hit_points) / float(maxi(1, player.effective_max_hit_points())) < SUPPORT_HEAL_THRESHOLD and actor.cell.distance_to(player.cell) <= SUPPORT_HEAL_RANGE:
|
||||
return {"kind": &"heal_player", "amount": SUPPORT_HEAL_AMOUNT}
|
||||
return _follow(actor, player, map, blocked_cells)
|
||||
|
||||
static func _follow(actor: ActorState, player: ActorState, map: GridMapState, blocked_cells: Dictionary[Vector2i, bool]) -> Dictionary:
|
||||
if actor.cell.distance_to(player.cell) <= 1.5:
|
||||
return {"kind": &"idle"}
|
||||
var occupied := blocked_cells.duplicate()
|
||||
occupied.erase(actor.cell)
|
||||
occupied[player.cell] = true
|
||||
var goals: Array[Vector2i] = []
|
||||
for direction: Vector2i in PathfindingType.CARDINAL_DIRECTIONS:
|
||||
var cell := player.cell + direction
|
||||
if map.is_walkable(cell) and not occupied.has(cell):
|
||||
goals.append(cell)
|
||||
var path := PathfindingType.find_path_to_any(map, actor.cell, goals, occupied)
|
||||
return {"kind": &"move", "to_cell": path.front()} if not path.is_empty() else {"kind": &"idle"}
|
||||
return _move_toward(actor, player.cell, player.cell, map, blocked_cells)
|
||||
|
||||
static func _defend(actor: ActorState, player: ActorState, enemies: Dictionary[StringName, ActorState], map: GridMapState, blocked_cells: Dictionary[Vector2i, bool]) -> Dictionary:
|
||||
var targets: Array[ActorState] = []
|
||||
@@ -37,6 +44,33 @@ static func _defend(actor: ActorState, player: ActorState, enemies: Dictionary[S
|
||||
if enemy.is_alive() and enemy.cell.distance_to(player.cell) <= 1.5:
|
||||
targets.append(enemy)
|
||||
targets.sort_custom(func(first: ActorState, second: ActorState) -> bool: return String(first.id) < String(second.id))
|
||||
if not targets.is_empty() and actor.cell.distance_to(targets[0].cell) <= 1.5:
|
||||
return {"kind": &"melee", "target_id": targets[0].id}
|
||||
if not targets.is_empty():
|
||||
if actor.cell.distance_to(targets[0].cell) <= 1.5:
|
||||
return {"kind": &"melee", "target_id": targets[0].id}
|
||||
return _move_toward(actor, targets[0].cell, player.cell, map, blocked_cells)
|
||||
return _follow(actor, player, map, blocked_cells)
|
||||
|
||||
static func _move_toward(actor: ActorState, destination: Vector2i, player_cell: Vector2i, map: GridMapState, blocked_cells: Dictionary[Vector2i, bool]) -> Dictionary:
|
||||
var occupied := blocked_cells.duplicate()
|
||||
occupied.erase(actor.cell)
|
||||
occupied[player_cell] = true
|
||||
occupied[destination] = true
|
||||
var goals: Array[Vector2i] = []
|
||||
for direction: Vector2i in PathfindingType.CARDINAL_DIRECTIONS:
|
||||
var cell := destination + direction
|
||||
if map.is_walkable(cell) and not occupied.has(cell):
|
||||
goals.append(cell)
|
||||
var path := PathfindingType.find_path_to_any(map, actor.cell, goals, occupied)
|
||||
return {"kind": &"move", "to_cell": path.front()} if not path.is_empty() else {"kind": &"idle"}
|
||||
|
||||
static func _nearest_enemy(origin: Vector2i, enemies: Dictionary[StringName, ActorState], detected_cells: Dictionary[Vector2i, bool]) -> ActorState:
|
||||
var candidates: Array[ActorState] = []
|
||||
for enemy: ActorState in enemies.values():
|
||||
if enemy.is_alive() and detected_cells.has(enemy.cell):
|
||||
candidates.append(enemy)
|
||||
candidates.sort_custom(func(first: ActorState, second: ActorState) -> bool:
|
||||
var first_distance := origin.distance_squared_to(first.cell)
|
||||
var second_distance := origin.distance_squared_to(second.cell)
|
||||
return String(first.id) < String(second.id) if first_distance == second_distance else first_distance < second_distance
|
||||
)
|
||||
return candidates[0] if not candidates.is_empty() else null
|
||||
|
||||
@@ -15,7 +15,8 @@ func _init(scripted_rolls: Array[float] = []) -> void:
|
||||
_rolls.assign(scripted_rolls)
|
||||
|
||||
func resolve_attack(attacker: ActorState, defender: ActorState, grant_xp: bool = true) -> Dictionary:
|
||||
var events: Array[Dictionary] = [_event(&"attack_started", attacker, defender, {"stance": String(attacker.stance)})]
|
||||
var attack_method := String(attacker.metadata.get("melee_weapon_name", "mains nues" if attacker.id == &"player" else "attaque naturelle"))
|
||||
var events: Array[Dictionary] = [_event(&"attack_started", attacker, defender, {"stance": String(attacker.stance), "attack_method": attack_method})]
|
||||
var attack_score := attacker.accuracy - attacker.wound_severity(&"arms") * ARM_WOUND_PENALTY
|
||||
var defense_score := defender.defense * 3 - defender.wound_severity(&"legs") * LEG_WOUND_PENALTY
|
||||
if defender.stance == &"dodge":
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
class_name HealthRegeneration
|
||||
extends RefCounted
|
||||
|
||||
const ENDURANCE_DIVISOR := 3
|
||||
const SKILL_AMPLIFIER := 0.15
|
||||
const DIFFICULTY_MULTIPLIERS := {
|
||||
&"touriste": 1.5,
|
||||
&"crawler": 1.0,
|
||||
&"veteran": 0.75,
|
||||
&"masochiste": 0.5,
|
||||
}
|
||||
|
||||
static func amount(endurance: int, regeneration_skill: int = 1, perk_bonus: int = 0, difficulty_id: StringName = &"crawler") -> int:
|
||||
var base := maxi(1, endurance / ENDURANCE_DIVISOR)
|
||||
var skill_bonus := maxi(0, regeneration_skill - 1)
|
||||
var total := float(base + maxi(0, perk_bonus)) * (1.0 + float(skill_bonus) * SKILL_AMPLIFIER)
|
||||
return maxi(0, int(total * float(DIFFICULTY_MULTIPLIERS.get(difficulty_id, 1.0))))
|
||||
|
||||
static func apply(actor: ActorState, endurance: int, regeneration_skill: int = 1, perk_bonus: int = 0, difficulty_id: StringName = &"crawler") -> int:
|
||||
if actor == null or not actor.is_alive():
|
||||
return 0
|
||||
var before := actor.hit_points
|
||||
actor.hit_points = mini(actor.effective_max_hit_points(), actor.hit_points + amount(endurance, regeneration_skill, perk_bonus, difficulty_id))
|
||||
return actor.hit_points - before
|
||||
@@ -0,0 +1 @@
|
||||
uid://3ccnf6g0ily8
|
||||
@@ -37,6 +37,9 @@ func resolve(map: GridMapState, attacker: ActorState, target: ActorState) -> Dic
|
||||
"events": events,
|
||||
}
|
||||
|
||||
func validation_reason(map: GridMapState, attacker: ActorState, target: ActorState) -> StringName:
|
||||
return _validation_reason(map, attacker, target)
|
||||
|
||||
func _validation_reason(map: GridMapState, attacker: ActorState, target: ActorState) -> StringName:
|
||||
if attacker == null or target == null or attacker == target or attacker.id == target.id or not target.is_alive():
|
||||
return &"invalid_target"
|
||||
|
||||
@@ -4,36 +4,70 @@ extends RefCounted
|
||||
# E4 deliberately owns only the companion's earned-XP ledger. F1 remains the
|
||||
# sole owner of level thresholds and character progression.
|
||||
class Stance:
|
||||
const STAY_BACK: StringName = &"stay_back"
|
||||
const DEFEND_ME: StringName = &"defend_me"
|
||||
const ATTACK_ON_SIGHT: StringName = &"attack_on_sight"
|
||||
# Legacy identifiers remain readable for code and saves created before the
|
||||
# player-facing behavior names were introduced.
|
||||
const FOLLOW: StringName = &"follow"
|
||||
const DEFEND: StringName = &"defend"
|
||||
const SUPPORT: StringName = &"support"
|
||||
|
||||
const ActorStateType = preload("res://scripts/domain/actor_state.gd")
|
||||
const ExperienceType = preload("res://scripts/domain/progression/experience.gd")
|
||||
const VALID_STANCES: Array[StringName] = [Stance.FOLLOW, Stance.DEFEND, Stance.SUPPORT]
|
||||
const VALID_STANCES: Array[StringName] = [Stance.STAY_BACK, Stance.DEFEND_ME, Stance.ATTACK_ON_SIGHT]
|
||||
|
||||
var choice_id: StringName
|
||||
var actor: ActorState
|
||||
var stance: StringName = Stance.FOLLOW
|
||||
var stance: StringName = Stance.STAY_BACK
|
||||
var name := "Familier"
|
||||
var species := "Animal"
|
||||
var endurance := 4
|
||||
var regeneration_skill := 1
|
||||
var regeneration_perk_bonus := 0
|
||||
|
||||
func _init(new_choice_id: StringName, new_actor: ActorState) -> void:
|
||||
choice_id = new_choice_id
|
||||
actor = new_actor
|
||||
|
||||
static func from_choice(new_choice_id: StringName, cell: Vector2i, hit_points: int = 8) -> CompanionState:
|
||||
static func from_choice(new_choice_id: StringName, cell: Vector2i, hit_points: int = 8, new_name: String = "Familier", new_species: String = "Animal") -> CompanionState:
|
||||
var id := new_choice_id if not new_choice_id.is_empty() else &"moth"
|
||||
var companion_actor := ActorStateType.new(&"companion", cell, maxi(1, hit_points), 3, id, {"accuracy": 30, "xp": 0})
|
||||
return CompanionState.new(id, companion_actor)
|
||||
var companion := CompanionState.new(id, companion_actor)
|
||||
companion.name = new_name.strip_edges() if not new_name.strip_edges().is_empty() else "Familier"
|
||||
companion.species = new_species.strip_edges() if not new_species.strip_edges().is_empty() else "Animal"
|
||||
return companion
|
||||
|
||||
func is_alive() -> bool:
|
||||
return actor != null and actor.is_alive()
|
||||
|
||||
func set_stance(new_stance: StringName) -> bool:
|
||||
if not new_stance in VALID_STANCES:
|
||||
var normalized := normalize_stance(new_stance)
|
||||
if not normalized in VALID_STANCES:
|
||||
return false
|
||||
stance = new_stance
|
||||
stance = normalized
|
||||
return true
|
||||
|
||||
static func normalize_stance(value: StringName) -> StringName:
|
||||
match value:
|
||||
Stance.FOLLOW, &"aggressif": return Stance.ATTACK_ON_SIGHT
|
||||
Stance.DEFEND, Stance.SUPPORT, &"defensif", &"soutien": return Stance.DEFEND_ME
|
||||
return value
|
||||
|
||||
static func stance_label(value: StringName) -> String:
|
||||
match normalize_stance(value):
|
||||
Stance.STAY_BACK: return "Reste en arrière"
|
||||
Stance.DEFEND_ME: return "Défends-moi"
|
||||
Stance.ATTACK_ON_SIGHT: return "Attaque à vue"
|
||||
return "Inconnu"
|
||||
|
||||
static func stance_description(value: StringName) -> String:
|
||||
match normalize_stance(value):
|
||||
Stance.STAY_BACK: return "Suit le joueur sans engager les ennemis."
|
||||
Stance.DEFEND_ME: return "Intercepte et attaque les ennemis qui menacent le joueur."
|
||||
Stance.ATTACK_ON_SIGHT: return "Poursuit et attaque l’ennemi visible le plus proche."
|
||||
return ""
|
||||
|
||||
# This is intentionally a neutral allocation seam: it records earned XP only
|
||||
# and neither reads nor changes levels, thresholds, attributes, or skills.
|
||||
func share_xp(player: ActorState, amount: int) -> Dictionary:
|
||||
|
||||
@@ -7,6 +7,7 @@ const TrapEngineType = preload("res://scripts/domain/world/trap_engine.gd")
|
||||
const SpecialInteractionsType = preload("res://scripts/domain/world/special_interactions.gd")
|
||||
const CompanionStateType = preload("res://scripts/domain/entities/companion_state.gd")
|
||||
const PartyStateType = preload("res://scripts/domain/entities/party_state.gd")
|
||||
const PLAYER_VISION_RADIUS := 6
|
||||
|
||||
var player: ActorState
|
||||
# E4 keeps the selected pet run-scoped rather than making it a floor entity.
|
||||
@@ -109,7 +110,7 @@ func compute_visible_cells(game_map: GridMapState, origin: Vector2i, radius: int
|
||||
return visible
|
||||
|
||||
func update_exploration() -> void:
|
||||
visible_cells = compute_visible_cells(map, player.cell, 6)
|
||||
visible_cells = compute_visible_cells(map, player.cell, PLAYER_VISION_RADIUS)
|
||||
for cell in visible_cells:
|
||||
explored_cells[cell] = true
|
||||
|
||||
|
||||
@@ -71,6 +71,11 @@ func recompute_player(player) -> void:
|
||||
player.normalize_resources()
|
||||
elif player is ActorState:
|
||||
player.recompute_equipment_modifiers(attributes, skills, combat)
|
||||
var main_hand := item_in_slot(&"main_hand")
|
||||
if main_hand != null and main_hand.definition != null and StringName(main_hand.definition.raw.get("weapon_kind", "")) != &"ranged":
|
||||
player.metadata["melee_weapon_name"] = main_hand.definition.name
|
||||
else:
|
||||
player.metadata.erase("melee_weapon_name")
|
||||
|
||||
func _accumulate_combat_modifiers(item: ItemInstance, combat: Dictionary[StringName, Variant]) -> void:
|
||||
var raw := item.definition.raw
|
||||
|
||||
@@ -92,6 +92,8 @@ func use_item(instance_id: StringName, default_target, identification: ItemIdent
|
||||
var status := StringName(effect_data.get("status", ""))
|
||||
recipient.apply_status(StatusEffect.new(status, int(effect_data.get("duration", -1)), int(effect_data.get("magnitude", 0)), item.definition.id))
|
||||
effects.append({"type": effect_type, "status": status})
|
||||
&"learn_spell":
|
||||
effects.append({"type": effect_type, "spell": StringName(effect_data.get("spell", ""))})
|
||||
_:
|
||||
effects.append({"type": effect_type})
|
||||
var consumed := remove_item(instance_id)
|
||||
|
||||
@@ -10,15 +10,21 @@ static func resolve(table: Dictionary, seed: String, context: String = "") -> Di
|
||||
var items: Array[Dictionary] = []
|
||||
var gold := 0
|
||||
var entries: Array = table.get("entries", [])
|
||||
var selected_item_ids: Dictionary[StringName, bool] = {}
|
||||
var rolls := maxi(0, int(table.get("rolls", 0)))
|
||||
for _roll in range(rolls):
|
||||
var entry := _choose_entry(entries, rng)
|
||||
var eligible_entries := entries.filter(func(value) -> bool:
|
||||
return not (value is Dictionary and value.has("item") and selected_item_ids.has(StringName(value.item)))
|
||||
)
|
||||
var entry := _choose_entry(eligible_entries, rng)
|
||||
if entry.is_empty():
|
||||
continue
|
||||
if bool(entry.get("gold", false)):
|
||||
gold += _range_value(entry, "min_gold", "max_gold", rng)
|
||||
elif entry.has("item"):
|
||||
_append_item(items, StringName(entry.item), _range_value(entry, "min_qty", "max_qty", rng, 1))
|
||||
var item_id := StringName(entry.item)
|
||||
selected_item_ids[item_id] = true
|
||||
_append_item(items, item_id, _range_value(entry, "min_qty", "max_qty", rng, 1))
|
||||
return {
|
||||
"items": items,
|
||||
"gold": gold,
|
||||
|
||||
@@ -33,6 +33,17 @@ func resolve(map: GridMapState, caster: ActorState, target: ActorState, spell: D
|
||||
var xp_event := _event(&"xp_granted", caster, target, spell, {})
|
||||
xp_event.payload = xp_payload
|
||||
events.append(xp_event)
|
||||
events.append({
|
||||
"kind": &"loot_dropped",
|
||||
"actor_id": target.id,
|
||||
"target_id": caster.id,
|
||||
"cell": target.cell,
|
||||
"payload": {
|
||||
"loot_table": String(target.loot_table),
|
||||
"actor_content_id": target.content_id,
|
||||
"target_content_id": caster.content_id,
|
||||
},
|
||||
})
|
||||
return {"valid": true, "reason": &"", "damage": damage, "events": events}
|
||||
|
||||
func valid_targets(map: GridMapState, caster: ActorState, enemies: Dictionary[StringName, ActorState], spell: Dictionary, spells: SpellState) -> Dictionary[StringName, Vector2i]:
|
||||
|
||||
@@ -33,7 +33,15 @@ 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))
|
||||
definitions.sort_custom(func(a: Dictionary, b: Dictionary) -> bool: return String(a.get("name", a.id)) < String(b.get("name", b.id)))
|
||||
return definitions
|
||||
|
||||
func class_definitions(race_id: StringName = &"") -> Array[Dictionary]:
|
||||
var definitions: Array[Dictionary] = []
|
||||
for id: StringName in _classes:
|
||||
if race_id.is_empty() or is_compatible(race_id, id):
|
||||
definitions.append(_classes[id].duplicate(true))
|
||||
definitions.sort_custom(func(a: Dictionary, b: Dictionary) -> bool: return String(a.get("name", a.id)) < String(b.get("name", b.id)))
|
||||
return definitions
|
||||
|
||||
func is_compatible(race_id: StringName, class_id: StringName) -> bool:
|
||||
@@ -75,12 +83,32 @@ func apply_creation(player: PlayerState, race_id: StringName, class_id: StringNa
|
||||
var choice := creation_choice(race_id, class_id)
|
||||
if not bool(choice.get("accepted", false)):
|
||||
return choice
|
||||
var race := _races[race_id]
|
||||
var race_result := choose_race(player, race_id)
|
||||
if not bool(race_result.get("accepted", false)):
|
||||
return race_result
|
||||
return choose_class(player, class_id)
|
||||
|
||||
func choose_race(player: PlayerState, race_id: StringName) -> Dictionary:
|
||||
if player == null or not player.race.is_empty():
|
||||
return {"accepted": false, "reason": &"already_chosen"}
|
||||
if not _races.has(race_id):
|
||||
return {"accepted": false, "reason": &"unknown_race"}
|
||||
player.race = race_id
|
||||
_apply_bonuses(player, _races[race_id])
|
||||
return {"accepted": true, "race_id": race_id}
|
||||
|
||||
func choose_class(player: PlayerState, class_id: StringName) -> Dictionary:
|
||||
if player == null or not player.archetype.is_empty():
|
||||
return {"accepted": false, "reason": &"already_chosen"}
|
||||
if player.race.is_empty():
|
||||
return {"accepted": false, "reason": &"race_required"}
|
||||
if not _classes.has(class_id):
|
||||
return {"accepted": false, "reason": &"unknown_class"}
|
||||
if not is_compatible(player.race, class_id):
|
||||
return {"accepted": false, "reason": &"incompatible"}
|
||||
player.archetype = class_id
|
||||
_apply_bonuses(player, race)
|
||||
_apply_bonuses(player, _classes[class_id])
|
||||
return choice
|
||||
return {"accepted": true, "race_id": player.race, "class_id": class_id}
|
||||
|
||||
func eligible_evolutions(player: PlayerState) -> Array[Dictionary]:
|
||||
var eligible: Array[Dictionary] = []
|
||||
|
||||
@@ -7,17 +7,23 @@ var seed: String
|
||||
var difficulty_id: StringName
|
||||
var permadeath: bool
|
||||
var pet_enabled: bool
|
||||
var pet_name: String
|
||||
var pet_species: String
|
||||
|
||||
func _init(
|
||||
new_seed: String = "",
|
||||
new_difficulty_id: StringName = &"crawler",
|
||||
new_permadeath: bool = false,
|
||||
new_pet_enabled: bool = false
|
||||
new_pet_enabled: bool = false,
|
||||
new_pet_name: String = "Familier",
|
||||
new_pet_species: String = "Animal"
|
||||
) -> void:
|
||||
seed = new_seed.strip_edges()
|
||||
difficulty_id = new_difficulty_id
|
||||
permadeath = new_permadeath
|
||||
pet_enabled = new_pet_enabled
|
||||
pet_name = new_pet_name.strip_edges() if not new_pet_name.strip_edges().is_empty() else "Familier"
|
||||
pet_species = new_pet_species.strip_edges() if not new_pet_species.strip_edges().is_empty() else "Animal"
|
||||
|
||||
func is_valid() -> bool:
|
||||
return not seed.is_empty() and difficulty_id in DIFFICULTY_IDS
|
||||
|
||||
@@ -4,7 +4,7 @@ extends RefCounted
|
||||
var seed: String
|
||||
var settings: RunSettings
|
||||
var player_name := "Sans-Nom"
|
||||
var base_archetype: StringName = &"vanguard"
|
||||
var base_archetype: StringName = &""
|
||||
var current_floor := 0
|
||||
var floors: Dictionary[int, FloorState] = {}
|
||||
# Deadline records are intentionally independent from generated FloorState so
|
||||
|
||||
@@ -13,6 +13,15 @@ static func resolve_player_action(state: GameState, direction: Vector2i) -> Arra
|
||||
return results
|
||||
var player: ActorState = state.player
|
||||
var destination: Vector2i = player.cell + direction
|
||||
if abs(direction.x) == 1 and abs(direction.y) == 1:
|
||||
# Diagonal movement cannot squeeze between blocking cardinal cells. A
|
||||
# closed door must therefore gate the room instead of being bypassable at
|
||||
# either corner; walls and chests obey the same geometry.
|
||||
var horizontal := player.cell + Vector2i(direction.x, 0)
|
||||
var vertical := player.cell + Vector2i(0, direction.y)
|
||||
if not state.map.is_walkable(horizontal) or not state.map.is_walkable(vertical):
|
||||
results.append(TurnResultType.new(player.id, &"blocked", player.cell, destination, &"", 0, "Your way is blocked."))
|
||||
return results
|
||||
var enemy: ActorState = _enemy_at(state, destination)
|
||||
if enemy != null:
|
||||
# A companion-owning run takes the neutral shared-XP seam. Combat must
|
||||
@@ -89,7 +98,8 @@ static func append_enemy_response(state: GameState, results: Array[TurnResult])
|
||||
var enemy: ActorState = state.enemies.get(enemy_id)
|
||||
if enemy == null or not enemy.is_alive():
|
||||
continue
|
||||
var decision: Dictionary = EnemyBehaviorsType.decide(enemy, state.player, state.map, occupied)
|
||||
var target := _enemy_target(state, enemy)
|
||||
var decision: Dictionary = EnemyBehaviorsType.decide(enemy, target, state.map, occupied)
|
||||
if decision.has("diagnostic"):
|
||||
results.append(TurnResultType.new(
|
||||
enemy.id,
|
||||
@@ -103,25 +113,33 @@ static func append_enemy_response(state: GameState, results: Array[TurnResult])
|
||||
))
|
||||
match decision.get("kind", &"idle"):
|
||||
&"melee":
|
||||
if _support_companion_intercepts(state, enemy, results):
|
||||
if target == state.player and _support_companion_intercepts(state, enemy, results):
|
||||
continue
|
||||
_append_combat_results(results, CombatEngineType.new().resolve_attack(enemy, state.player), enemy.cell, state.player.cell)
|
||||
if not state.player.is_alive():
|
||||
_append_combat_results(results, CombatEngineType.new().resolve_attack(enemy, target), enemy.cell, target.cell)
|
||||
if target == state.player and not state.player.is_alive():
|
||||
return
|
||||
&"move":
|
||||
var target: Vector2i = decision.get("to_cell", enemy.cell)
|
||||
var move_target: Vector2i = decision.get("to_cell", enemy.cell)
|
||||
# The behavior contract has already rejected these cells; retain the
|
||||
# resolver guard as the authoritative state mutation boundary.
|
||||
if state.map.is_walkable(target) and target != state.player.cell and not occupied.has(target):
|
||||
if state.map.is_walkable(move_target) and move_target != target.cell and not occupied.has(move_target):
|
||||
var from: Vector2i = enemy.cell
|
||||
occupied.erase(from)
|
||||
enemy.cell = target
|
||||
occupied[target] = true
|
||||
results.append(TurnResultType.new(enemy.id, &"enemy_moved", from, target, &"", 0, "%s moves." % _actor_label(enemy.id)))
|
||||
enemy.cell = move_target
|
||||
occupied[move_target] = true
|
||||
results.append(TurnResultType.new(enemy.id, &"enemy_moved", from, move_target, &"", 0, "%s moves." % _actor_label(enemy.id)))
|
||||
|
||||
static func _enemy_target(state: GameState, enemy: ActorState) -> ActorState:
|
||||
var companion: CompanionState = state.companion
|
||||
if companion == null or not companion.is_alive():
|
||||
return state.player
|
||||
var player_distance := enemy.cell.distance_squared_to(state.player.cell)
|
||||
var companion_distance := enemy.cell.distance_squared_to(companion.actor.cell)
|
||||
return companion.actor if companion_distance <= player_distance else state.player
|
||||
|
||||
static func _support_companion_intercepts(state: GameState, enemy: ActorState, results: Array[TurnResult]) -> bool:
|
||||
var companion: CompanionState = state.companion
|
||||
if companion == null or not companion.is_alive() or companion.stance != CompanionStateType.Stance.SUPPORT:
|
||||
if companion == null or not companion.is_alive() or CompanionStateType.normalize_stance(companion.stance) != CompanionStateType.Stance.DEFEND_ME:
|
||||
return false
|
||||
if companion.actor.cell.distance_to(state.player.cell) > 1.5:
|
||||
return false
|
||||
@@ -143,7 +161,8 @@ static func _append_companion_response(state: GameState, results: Array[TurnResu
|
||||
return
|
||||
var occupied := _occupied_enemy_cells(state)
|
||||
occupied[companion.actor.cell] = true
|
||||
var decision := CompanionBehaviorsType.decide(companion, state.player, state.enemies, state.map, occupied)
|
||||
var detected_cells := state.compute_visible_cells(state.map, state.player.cell, state.PLAYER_VISION_RADIUS)
|
||||
var decision := CompanionBehaviorsType.decide(companion, state.player, state.enemies, state.map, occupied, detected_cells)
|
||||
match decision.get("kind", &"idle"):
|
||||
&"move":
|
||||
var target: Vector2i = decision.get("to_cell", companion.actor.cell)
|
||||
@@ -156,9 +175,15 @@ static func _append_companion_response(state: GameState, results: Array[TurnResu
|
||||
if enemy != null and enemy.is_alive() and companion.actor.cell.distance_to(enemy.cell) <= 1.5:
|
||||
_append_combat_results(results, CombatEngineType.new().resolve_attack(companion.actor, enemy), companion.actor.cell, enemy.cell)
|
||||
results.back().kind = &"companion_melee"
|
||||
results.back().message = "Your companion defends you."
|
||||
results.back().message = "%s attacks." % companion.name
|
||||
if not enemy.is_alive():
|
||||
state.enemies.erase(enemy.id)
|
||||
&"heal_player":
|
||||
var before := state.player.hit_points
|
||||
state.player.hit_points = mini(state.player.effective_max_hit_points(), before + int(decision.get("amount", 0)))
|
||||
var healed := state.player.hit_points - before
|
||||
if healed > 0:
|
||||
results.append(TurnResultType.new(companion.actor.id, &"companion_healed_player", companion.actor.cell, state.player.cell, state.player.id, -healed, "%s restores %d PV." % [companion.name, healed], {"healing": healed}))
|
||||
|
||||
static func _occupied_enemy_cells(state: GameState) -> Dictionary[Vector2i, bool]:
|
||||
var occupied: Dictionary[Vector2i, bool] = {state.player.cell: true}
|
||||
@@ -176,10 +201,11 @@ static func _append_combat_results(results: Array[TurnResult], outcome: Dictiona
|
||||
var target_id := StringName(first.target_id)
|
||||
var legacy_kind := &"melee" if actor_id == &"player" else &"enemy_melee"
|
||||
var damage := int(outcome.damage)
|
||||
var message := "You strike the goblin for %d." % damage if actor_id == &"player" else "%s hits you for %d." % [_actor_label(actor_id), damage]
|
||||
results.append(TurnResultType.new(actor_id, legacy_kind, from_cell, to_cell, target_id, damage, message, {"domain_events": descriptors}))
|
||||
var attack_method := String(first.payload.get("attack_method", "mains nues" if actor_id == &"player" else "attaque naturelle"))
|
||||
var message := "You strike the goblin with %s for %d." % [attack_method, damage] if actor_id == &"player" else "%s hits you with %s for %d." % [_actor_label(actor_id), attack_method, damage]
|
||||
results.append(TurnResultType.new(actor_id, legacy_kind, from_cell, to_cell, target_id, damage, message, {"domain_events": descriptors, "attack_method": attack_method}))
|
||||
if not bool(outcome.hit):
|
||||
results.back().message = "You miss the goblin." if actor_id == &"player" else "%s misses you." % _actor_label(actor_id)
|
||||
results.back().message = "You miss the goblin with %s." % attack_method if actor_id == &"player" else "%s misses you with %s." % [_actor_label(actor_id), attack_method]
|
||||
if not (results.back().payload.domain_events as Array).filter(func(event: Dictionary) -> bool: return event.kind == &"actor_died").is_empty():
|
||||
var defeated := target_id if actor_id == &"player" else actor_id
|
||||
results.append(TurnResultType.new(defeated, &"enemy_defeated", to_cell, to_cell, actor_id, 0, "%s is defeated." % _actor_label(defeated)))
|
||||
|
||||
@@ -3,8 +3,6 @@ extends RefCounted
|
||||
|
||||
const MAX_MAP_SIZE := Vector2i(700, 350)
|
||||
const MAX_ROOM_COUNT := 500
|
||||
const SHALLOW_ROOM_MIN_SIZE := Vector2i(5, 4)
|
||||
const SHALLOW_ROOM_MAX_SIZE := Vector2i(10, 8)
|
||||
const DEEP_ROOM_MIN_SIZE := Vector2i(4, 3)
|
||||
const DEEP_ROOM_MAX_SIZE := Vector2i(6, 5)
|
||||
const ROOM_PADDING := 2
|
||||
@@ -38,13 +36,6 @@ const EconomyType = preload("res://scripts/domain/items/economy.gd")
|
||||
# impractical. It is also the sole sizing input to generation, making a seed
|
||||
# and floor number reproduce exactly the same layout.
|
||||
static func generation_profile(floor_number: int) -> Dictionary:
|
||||
if floor_number <= 1:
|
||||
return {
|
||||
"map_size": Vector2i(80, 50),
|
||||
"target_room_count": 8,
|
||||
"room_min_size": SHALLOW_ROOM_MIN_SIZE,
|
||||
"room_max_size": SHALLOW_ROOM_MAX_SIZE,
|
||||
}
|
||||
var normalized_floor := maxi(1, floor_number)
|
||||
return {
|
||||
"map_size": Vector2i(
|
||||
@@ -75,6 +66,7 @@ static func generate(seed: String, floor_number: int, catalog: ContentCatalog) -
|
||||
graph.add_local_loops(rooms, rng)
|
||||
for edge in graph.loop_edges:
|
||||
_carve_l_corridor_preserving_doors(map, _room_center(rooms[edge.from].bounds), _room_center(rooms[edge.to].bounds))
|
||||
tree_door_cells = _remove_nonfunctional_doors(map, tree_door_cells)
|
||||
for serialized_door in tree_door_cells:
|
||||
map.set_cell(Vector2i(int(serialized_door[0]), int(serialized_door[1])), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
|
||||
@@ -176,6 +168,24 @@ static func _place_tree_boundary_doors(map: GridMapState, path: Array[Vector2i],
|
||||
break
|
||||
return serialized_cells
|
||||
|
||||
static func _remove_nonfunctional_doors(map: GridMapState, serialized_doors: Array[Array]) -> Array[Array]:
|
||||
var functional: Array[Array] = []
|
||||
for serialized_door: Array in serialized_doors:
|
||||
var cell := Vector2i(int(serialized_door[0]), int(serialized_door[1]))
|
||||
var walkable_directions: Array[Vector2i] = []
|
||||
for direction: Vector2i in [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]:
|
||||
if map.is_walkable(cell + direction):
|
||||
walkable_directions.append(direction)
|
||||
var controls_straight_passage := walkable_directions.size() == 2 and (
|
||||
(walkable_directions.has(Vector2i.LEFT) and walkable_directions.has(Vector2i.RIGHT))
|
||||
or (walkable_directions.has(Vector2i.UP) and walkable_directions.has(Vector2i.DOWN))
|
||||
)
|
||||
if controls_straight_passage:
|
||||
functional.append(serialized_door)
|
||||
else:
|
||||
map.set_cell(cell, GridMapStateType.CellKind.FLOOR)
|
||||
return functional
|
||||
|
||||
static func _is_adjacent_to_serialized_door(cell: Vector2i, serialized_doors: Array[Array]) -> bool:
|
||||
for serialized_door in serialized_doors:
|
||||
var door_cell := Vector2i(int(serialized_door[0]), int(serialized_door[1]))
|
||||
|
||||
@@ -55,11 +55,10 @@ static func _spawn_enemy(floor: FloorState, catalog: ContentCatalog, room: RoomS
|
||||
return serial + 1
|
||||
|
||||
static func _spawn_chest(floor: FloorState, catalog: ContentCatalog, room: RoomState, rng: DeterministicRng, occupied: Dictionary[Vector2i, bool]) -> void:
|
||||
var definitions := SpawnRulesType.loot_tables(catalog)
|
||||
var definition := catalog.get_loot_table(&"floor_treasure")
|
||||
var cell := _available_cell(floor, room, rng, occupied)
|
||||
if definitions.is_empty() or cell == Vector2i(-1, -1):
|
||||
if definition.is_empty() or cell == Vector2i(-1, -1):
|
||||
return
|
||||
var definition: Dictionary = definitions[rng.next_int() % definitions.size()]
|
||||
floor.chests[cell] = {
|
||||
"loot_table_id": definition["id"],
|
||||
"opened": false,
|
||||
|
||||
@@ -3,44 +3,36 @@ extends RefCounted
|
||||
|
||||
const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd")
|
||||
const FloorStateType = preload("res://scripts/domain/world/floor_state.gd")
|
||||
const ActorStateType = preload("res://scripts/domain/actor_state.gd")
|
||||
const RoomStateType = preload("res://scripts/domain/world/room_state.gd")
|
||||
|
||||
# Floor zero deliberately remains an authored tutorial surface. Its geometry is
|
||||
# not derived from the run seed; RunState supplies persistence by caching it.
|
||||
const SURFACE_SIZE := Vector2i(42, 16)
|
||||
const ENTRANCE := Vector2i(4, 7)
|
||||
const DOOR := Vector2i(36, 7)
|
||||
const EXIT := Vector2i(39, 7)
|
||||
|
||||
# The surface mirrors DCWASCII's current floor-zero contract: an empty authored
|
||||
# staging area, a straight corridor, one door, and the stairs to the procedural
|
||||
# dungeon. It intentionally contains no enemies, chest, deadline content, or
|
||||
# seed-dependent population.
|
||||
static func generate(_seed: String = "") -> FloorState:
|
||||
var map := GridMapStateType.new(Vector2i(30, 20), GridMapStateType.CellKind.WALL)
|
||||
_carve_room(map, Rect2i(2, 12, 6, 5))
|
||||
_carve_room(map, Rect2i(2, 4, 7, 7))
|
||||
_carve_room(map, Rect2i(10, 2, 10, 6))
|
||||
_carve_room(map, Rect2i(21, 5, 7, 8))
|
||||
_carve_vertical_corridor(map, 4, 10, 12)
|
||||
_carve_horizontal_corridor(map, 8, 10, 6)
|
||||
_carve_horizontal_corridor(map, 18, 21, 6)
|
||||
_carve_vertical_corridor(map, 18, 4, 6)
|
||||
map.set_cell(Vector2i(4, 11), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.CHEST)
|
||||
map.set_cell(Vector2i(18, 4), GridMapStateType.CellKind.STAIRS)
|
||||
var map := GridMapStateType.new(SURFACE_SIZE, GridMapStateType.CellKind.WALL)
|
||||
var entrance_room := RoomStateType.new(&"surface_entrance", Rect2i(2, 2, 18, 11), &"entrance")
|
||||
var landing := RoomStateType.new(&"surface_landing", Rect2i(37, 6, 4, 3), &"open")
|
||||
_carve_room(map, entrance_room.bounds)
|
||||
for x in range(20, DOOR.x):
|
||||
map.set_cell(Vector2i(x, ENTRANCE.y), GridMapStateType.CellKind.FLOOR)
|
||||
map.set_cell(DOOR, GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
_carve_room(map, landing.bounds)
|
||||
map.set_cell(EXIT, GridMapStateType.CellKind.STAIRS)
|
||||
|
||||
var floor := FloorStateType.new(map, 0, 0)
|
||||
floor.entrance = Vector2i(4, 12)
|
||||
floor.exit = Vector2i(18, 4)
|
||||
floor.enemies[&"goblin"] = ActorStateType.new(&"goblin", Vector2i(24, 8), 6, 2)
|
||||
floor.chests[Vector2i(4, 7)] = {
|
||||
"loot_table_id": &"floor1_reward",
|
||||
"opened": false,
|
||||
}
|
||||
floor.rooms = [entrance_room, landing]
|
||||
floor.entrance = ENTRANCE
|
||||
floor.exit = EXIT
|
||||
floor.metadata = {"hand_authored": true, "theme": "surface"}
|
||||
return floor
|
||||
|
||||
static func _carve_room(map: GridMapState, room: Rect2i) -> void:
|
||||
for y in range(room.position.y, room.end.y):
|
||||
for x in range(room.position.x, room.end.x):
|
||||
static func _carve_room(map: GridMapState, bounds: Rect2i) -> void:
|
||||
for y in range(bounds.position.y, bounds.end.y):
|
||||
for x in range(bounds.position.x, bounds.end.x):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
static func _carve_horizontal_corridor(map: GridMapState, from_x: int, to_x: int, y: int) -> void:
|
||||
for x in range(from_x, to_x + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
static func _carve_vertical_corridor(map: GridMapState, x: int, from_y: int, to_y: int) -> void:
|
||||
for y in range(from_y, to_y + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
@@ -50,12 +50,24 @@ static func trigger(floor: FloorState, player: ActorState, cell: Vector2i, catal
|
||||
trap["discovered"] = true
|
||||
floor.traps[cell] = trap
|
||||
var payload := {"trap_id": StringName(trap.get("trap_id", "")), "damage": actual_damage}
|
||||
var events: Array[Dictionary] = [{"kind": &"trap_triggered", "payload": payload}]
|
||||
var events: Array[Dictionary] = [_event(&"trap_triggered", player, cell, payload)]
|
||||
# Content chance remains deterministic in this turn-based seam: a declared
|
||||
# majority chance applies, while lower chances are safely represented as no
|
||||
# status until a future RNG-owned rules slice supplies a roll stream.
|
||||
var status := StringName(definition.get("status", ""))
|
||||
# JSON `null` is a valid declaration for traps without a status effect.
|
||||
# Convert only textual IDs; StringName(null) is not a valid constructor.
|
||||
var status_value: Variant = definition.get("status")
|
||||
var status := StringName(status_value) if status_value is String else &""
|
||||
if not status.is_empty() and float(definition.get("status_chance", 0.0)) >= 0.5:
|
||||
player.apply_status(StatusEffectType.new(status, int(definition.get("status_duration", -1)), 0, StringName(trap.get("trap_id", ""))))
|
||||
events.append({"kind": &"trap_status_applied", "payload": {"trap_id": StringName(trap.get("trap_id", "")), "status": status}})
|
||||
events.append(_event(&"trap_status_applied", player, cell, {"trap_id": StringName(trap.get("trap_id", "")), "status": status}))
|
||||
return {"triggered": true, "damage": actual_damage, "trap_id": StringName(trap.get("trap_id", "")), "message": String(definition.get("message", "A trap triggers.")), "events": events}
|
||||
|
||||
static func _event(kind: StringName, player: ActorState, cell: Vector2i, payload: Dictionary) -> Dictionary:
|
||||
return {
|
||||
"kind": kind,
|
||||
"actor_id": player.id,
|
||||
"target_id": player.id,
|
||||
"cell": cell,
|
||||
"payload": payload,
|
||||
}
|
||||
|
||||
+248
-59
@@ -2,8 +2,10 @@ class_name Game
|
||||
extends Node2D
|
||||
|
||||
signal game_started(settings: RunSettings, run_state: RunState)
|
||||
signal death_navigation_requested(action: StringName)
|
||||
signal save_requested
|
||||
|
||||
const REFERENCE_VIEWPORT := Vector2i(1280, 720)
|
||||
const REFERENCE_VIEWPORT := Vector2i(1920, 1080)
|
||||
const TILE_SIZE := Vector2i(32, 32)
|
||||
const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd")
|
||||
const ActorStateType = preload("res://scripts/domain/actor_state.gd")
|
||||
@@ -22,6 +24,8 @@ const SpellStateType = preload("res://scripts/domain/magic/spell_state.gd")
|
||||
const TrapEngine = preload("res://scripts/domain/world/trap_engine.gd")
|
||||
const ItemDefinitionType = preload("res://scripts/domain/items/item_definition.gd")
|
||||
const ItemInstanceType = preload("res://scripts/domain/items/item_instance.gd")
|
||||
const LootResolverType = preload("res://scripts/domain/items/loot_resolver.gd")
|
||||
const TemporaryPlaytestKitType = preload("res://scripts/game/temporary_playtest_kit.gd")
|
||||
const InventoryPanelType = preload("res://scripts/presentation/inventory_panel.gd")
|
||||
const EconomyType = preload("res://scripts/domain/items/economy.gd")
|
||||
const CraftingEngineType = preload("res://scripts/domain/items/crafting_engine.gd")
|
||||
@@ -50,6 +54,7 @@ const SyndicateType = preload("res://scripts/domain/meta/syndicate.gd")
|
||||
const FactionPanelType = preload("res://scripts/presentation/faction_panel.gd")
|
||||
const ModerationPanelType = preload("res://scripts/presentation/moderation_panel.gd")
|
||||
const DeathEngineType = preload("res://scripts/domain/run/death_engine.gd")
|
||||
const HealthRegenerationType = preload("res://scripts/domain/combat/health_regeneration.gd")
|
||||
const TouristServiceType = preload("res://scripts/domain/world/tourist_service.gd")
|
||||
const DeathPanelType = preload("res://scripts/presentation/death_panel.gd")
|
||||
const VictoryPanelType = preload("res://scripts/presentation/victory_panel.gd")
|
||||
@@ -75,6 +80,7 @@ const QuestStateType = preload("res://scripts/domain/narrative/quest_state.gd")
|
||||
@onready var party_panel: PartyPanel = $HUD/PartyPanel
|
||||
@onready var character_panel: CharacterPanel = $HUD/CharacterPanel
|
||||
@onready var progression_choice_panel: ProgressionChoicePanel = $HUD/ProgressionChoicePanel
|
||||
@onready var race_class_choice_panel: RaceClassChoicePanel = $HUD/RaceClassChoicePanel
|
||||
@onready var achievement_panel: AchievementPanel = $HUD/AchievementPanel
|
||||
@onready var audience_panel: AudiencePanel = $HUD/AudiencePanel
|
||||
@onready var recap_panel: RecapPanel = $HUD/RecapPanel
|
||||
@@ -102,8 +108,8 @@ var last_turn_results: Array[TurnResult] = []
|
||||
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 pending_base_archetype: StringName = &""
|
||||
var pending_race: StringName = &""
|
||||
var pending_loaded_run: Dictionary = {}
|
||||
var floor_transition: FloorTransition
|
||||
var spell_catalog: ContentCatalog
|
||||
@@ -124,12 +130,14 @@ var moderation: Moderation
|
||||
var death_engine: DeathEngine
|
||||
var active_dialogue_npc: Dictionary = {}
|
||||
var active_event_index := -1
|
||||
var _turn_start_player_hit_points := -1
|
||||
var _turn_start_companion_hit_points := -1
|
||||
|
||||
func configure_new_run(settings: RunSettings, player_name: String, base_archetype: StringName, race: StringName = &"race_humain_standard") -> void:
|
||||
func configure_new_run(settings: RunSettings, player_name: String) -> void:
|
||||
pending_run_settings = settings
|
||||
pending_player_name = player_name
|
||||
pending_base_archetype = base_archetype
|
||||
pending_race = race
|
||||
pending_base_archetype = &""
|
||||
pending_race = &""
|
||||
|
||||
func configure_loaded_run(loaded: Dictionary) -> void:
|
||||
pending_loaded_run = loaded
|
||||
@@ -147,6 +155,9 @@ func _ready() -> void:
|
||||
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)
|
||||
race_class_choice_panel.race_confirmed.connect(_choose_floor_three_race)
|
||||
race_class_choice_panel.class_confirmed.connect(_choose_floor_three_class)
|
||||
death_panel.navigation_requested.connect(func(action: StringName) -> void: death_navigation_requested.emit(action))
|
||||
map_renderer.set_map(game_state.map)
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
@@ -175,6 +186,8 @@ func _initialize_run_state() -> void:
|
||||
run_state.base_archetype = pending_base_archetype
|
||||
spell_catalog = ContentCatalogType.load_from_directory("res://data/ascii")
|
||||
run_state.content_catalog = spell_catalog
|
||||
if pending_run_settings != null:
|
||||
_initialize_tutorial_kit()
|
||||
crafting_engine = CraftingEngineType.new(spell_catalog)
|
||||
dialogue_engine = DialogueEngineType.new()
|
||||
event_engine = EventEngineType.new()
|
||||
@@ -191,20 +204,24 @@ func _initialize_run_state() -> void:
|
||||
moderation = ModerationType.new(run_state.moderation_state)
|
||||
death_engine = DeathEngineType.new()
|
||||
_refresh_title()
|
||||
# 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)
|
||||
# New runs deliberately remain classless and raceless through dungeon floors
|
||||
# one and two. The floor-three milestone applies both choices later.
|
||||
game_state.content_catalog = spell_catalog
|
||||
spell_state = SpellStateType.new([&"spell_epines_empoisonnees"])
|
||||
floor_transition = FloorTransitionType.new(spell_catalog)
|
||||
var initial_floor := floor_transition.initial_floor(run_state)
|
||||
if pending_run_settings != null:
|
||||
TemporaryPlaytestKitType.apply_to_new_run(initial_floor)
|
||||
game_state.set_floor_state(initial_floor)
|
||||
game_state.player.cell = initial_floor.entrance
|
||||
# Direct Game-scene instantiation is the established automated-test seam.
|
||||
# Production runs are always configured by MainMenu and keep the reference
|
||||
# surface empty; the seam retains one deterministic actor for combat tests.
|
||||
if pending_loaded_run.is_empty() and _is_automated_test_run():
|
||||
game_state.enemies[&"goblin"] = ActorStateType.new(&"goblin", initial_floor.entrance + Vector2i(3, 0), 6, 2)
|
||||
game_state.update_exploration()
|
||||
if settings.pet_enabled:
|
||||
game_state.companion = CompanionStateType.from_choice(&"moth", initial_floor.entrance + Vector2i.RIGHT)
|
||||
game_state.companion = CompanionStateType.from_choice(&"moth", initial_floor.entrance + Vector2i.RIGHT, 8, settings.pet_name, settings.pet_species)
|
||||
if pending_run_settings != null:
|
||||
var game_started := GameEventType.new(
|
||||
run_state.next_turn(),
|
||||
@@ -215,8 +232,11 @@ func _initialize_run_state() -> void:
|
||||
"difficulty_id": settings.difficulty_id,
|
||||
"permadeath": settings.permadeath,
|
||||
"pet_enabled": settings.pet_enabled,
|
||||
"pet_name": settings.pet_name if settings.pet_enabled else "",
|
||||
"pet_species": settings.pet_species if settings.pet_enabled else "",
|
||||
"player_name": run_state.player_name,
|
||||
"base_archetype": run_state.base_archetype,
|
||||
"race": dialogue_player.race,
|
||||
},
|
||||
"%s begins a new run." % run_state.player_name,
|
||||
&"player",
|
||||
@@ -226,6 +246,17 @@ func _initialize_run_state() -> void:
|
||||
run_state.append_events([game_started])
|
||||
_observe_achievements([game_started])
|
||||
|
||||
func _initialize_tutorial_kit() -> void:
|
||||
# Floors one and two use DCWASCII's class-neutral kit so combat is explicit
|
||||
# and playable without pre-empting the floor-three class choice.
|
||||
run_state.gold = 15
|
||||
var knife := ItemInstanceType.new(ItemDefinitionType.from_catalog(spell_catalog, &"weapon_hunting_knife"), 1, &"tutorial-knife")
|
||||
var bandage := ItemInstanceType.new(ItemDefinitionType.from_catalog(spell_catalog, &"consumable_bandage"), 1, &"tutorial-bandage")
|
||||
run_state.inventory.add_item(knife)
|
||||
run_state.inventory.add_item(bandage)
|
||||
run_state.equipment.equip(run_state.inventory, knife.instance_id, game_state.player, run_state.identification)
|
||||
_sync_player_equipment()
|
||||
|
||||
func _apply_loaded_run(loaded: Dictionary) -> void:
|
||||
run_state = loaded.get("run_state")
|
||||
game_state = loaded.get("game_state")
|
||||
@@ -258,6 +289,15 @@ func _apply_loaded_run(loaded: Dictionary) -> void:
|
||||
game_state.update_exploration()
|
||||
_refresh_title()
|
||||
|
||||
func _is_automated_test_run() -> bool:
|
||||
var arguments := OS.get_cmdline_args() + OS.get_cmdline_user_args()
|
||||
if "--test-mode" in arguments:
|
||||
return true
|
||||
for argument in arguments:
|
||||
if argument.begins_with("-g"):
|
||||
return true
|
||||
return false
|
||||
|
||||
func _get_capture_mode() -> String:
|
||||
var arguments := OS.get_cmdline_user_args()
|
||||
if "--capture-exit" in arguments:
|
||||
@@ -280,16 +320,42 @@ func _capture_visual_check(capture_mode: String) -> void:
|
||||
get_tree().quit(0 if result == OK else 1)
|
||||
|
||||
func _prepare_exit_capture_state() -> void:
|
||||
game_state.map.set_cell(Vector2i(4, 10), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = Vector2i(18, 4)
|
||||
# The exit capture represents a reached stair route; make the B6 gate
|
||||
# eligible so the visual fixture remains valid without weakening gameplay.
|
||||
run_state.current_floor_deadline().turns_remaining = FloorDeadline.STAIRS_OPEN_DAYS_BEFORE_COLLAPSE * FloorDeadline.TURNS_PER_DAY
|
||||
_process_interact()
|
||||
# Preserve the entrance exploration, then frame the authored surface exit.
|
||||
# This exercises visible, explored, and unknown rendering without depending
|
||||
# on the removed prototype-map coordinates.
|
||||
game_state.map.set_cell(Vector2i(36, 7), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = game_state.floor_state.exit
|
||||
game_state.update_exploration()
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
player_view.refresh()
|
||||
_sync_camera_to_player()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
# Movement and wait commands belong to gameplay even if a previously opened
|
||||
# Control retained keyboard focus. Handle them before focused UI consumes the
|
||||
# arrow event; modal panels still own navigation and are handled below.
|
||||
if event is InputEventKey and event.is_pressed() and not event.echo and not _has_modal_panel_open():
|
||||
var physical_direction := _physical_movement_direction(event as InputEventKey)
|
||||
if physical_direction != Vector2i.ZERO:
|
||||
action_router.submit(PlayerActionType.new(&"move", physical_direction))
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _has_modal_panel_open() -> bool:
|
||||
return options_panel.visible or help_panel.visible or faction_panel.visible or moderation_panel.visible or audience_panel.visible or recap_panel.visible or achievement_panel.visible or race_class_choice_panel.visible or progression_choice_panel.visible or character_panel.visible or party_panel.visible or companion_panel.visible or quest_panel.visible or event_panel.visible or dialogue_panel.visible or crafting_panel.visible or shop_panel.visible or inventory_panel.visible or loot_panel.visible or targeting_overlay.visible or spell_targeting_overlay.visible
|
||||
|
||||
func _physical_movement_direction(event: InputEventKey) -> Vector2i:
|
||||
match event.physical_keycode:
|
||||
KEY_UP: return Vector2i.UP
|
||||
KEY_DOWN: return Vector2i.DOWN
|
||||
KEY_LEFT: return Vector2i.LEFT
|
||||
KEY_RIGHT: return Vector2i.RIGHT
|
||||
return Vector2i.ZERO
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.echo:
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if run_state != null and run_state.is_game_over:
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
@@ -347,6 +413,15 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
return
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if race_class_choice_panel.visible and event is InputEventKey and event.is_pressed():
|
||||
if event.keycode == KEY_UP:
|
||||
race_class_choice_panel.select_next(-1)
|
||||
elif event.keycode == KEY_DOWN:
|
||||
race_class_choice_panel.select_next(1)
|
||||
elif event.keycode == KEY_ENTER or event.keycode == KEY_SPACE:
|
||||
race_class_choice_panel.confirm()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if progression_choice_panel.visible and event is InputEventKey and event.is_pressed():
|
||||
if event.keycode == KEY_UP:
|
||||
progression_choice_panel.select_next(-1)
|
||||
@@ -535,9 +610,11 @@ func equip_test_ranged_weapon(definition: Dictionary, ammunition: int) -> void:
|
||||
game_state.player.equip_ranged_weapon(definition, ammunition)
|
||||
|
||||
func submit_player_action(action: PlayerAction) -> Array[GameEvent]:
|
||||
if run_state.is_game_over:
|
||||
if run_state.is_game_over or race_class_choice_panel.visible:
|
||||
last_turn_results = []
|
||||
return []
|
||||
_turn_start_player_hit_points = game_state.player.hit_points
|
||||
_turn_start_companion_hit_points = game_state.companion.actor.hit_points if game_state.companion != null else -1
|
||||
match action.kind:
|
||||
&"move":
|
||||
last_turn_results = _process_action(action.direction)
|
||||
@@ -597,6 +674,10 @@ func submit_player_action(action: PlayerAction) -> Array[GameEvent]:
|
||||
last_turn_results = []
|
||||
hud.toggle_log()
|
||||
return []
|
||||
&"save":
|
||||
last_turn_results = []
|
||||
save_requested.emit()
|
||||
return []
|
||||
&"ranged":
|
||||
return _begin_targeting()
|
||||
&"ranged_target":
|
||||
@@ -609,24 +690,25 @@ func submit_player_action(action: PlayerAction) -> Array[GameEvent]:
|
||||
return _record_unavailable_action(action)
|
||||
|
||||
func _begin_targeting() -> Array[GameEvent]:
|
||||
if game_state.player.ranged_weapon.is_empty():
|
||||
return _record_non_turn_event(&"invalid_ranged_target", &"", {"reason": &"no_ranged_weapon", "damage": 0}, "Aucune arme à distance n’est équipée.")
|
||||
var targets: Dictionary[StringName, Vector2i] = {}
|
||||
var ranged_combat := RangedCombatType.new()
|
||||
for enemy_id: StringName in game_state.enemies:
|
||||
var enemy: ActorState = game_state.enemies[enemy_id]
|
||||
if enemy.is_alive():
|
||||
if enemy.is_alive() and ranged_combat.validation_reason(game_state.map, game_state.player, enemy).is_empty():
|
||||
targets[enemy_id] = enemy.cell
|
||||
if game_state.player.ranged_weapon.is_empty():
|
||||
return _record_ranged_event(&"invalid_ranged_target", &"", {"reason": &"no_ranged_weapon", "damage": 0}, "No ranged weapon is equipped.")
|
||||
if targets.is_empty():
|
||||
return _record_ranged_event(&"invalid_ranged_target", &"", {"reason": &"invalid_target", "damage": 0}, "No valid ranged target.")
|
||||
return _record_non_turn_event(&"invalid_ranged_target", &"", {"reason": &"invalid_target", "damage": 0}, "Aucune cible valide à portée et en ligne de vue.")
|
||||
targeting_overlay.begin(targets)
|
||||
return _record_ranged_event(&"targeting_started", &"", {"target_ids": targeting_overlay.get_target_ids()}, "Choose a ranged target.")
|
||||
return _record_non_turn_event(&"targeting_started", &"", {"target_ids": targeting_overlay.get_target_ids()}, "Choisissez une cible à distance.")
|
||||
|
||||
func _on_target_selected(target_id: StringName) -> void:
|
||||
action_router.submit(PlayerActionType.new(&"ranged_target", Vector2i.ZERO, target_id))
|
||||
|
||||
func _cancel_targeting() -> void:
|
||||
targeting_overlay.finish()
|
||||
_record_ranged_event(&"targeting_cancelled", &"", {}, "Ranged targeting cancelled.")
|
||||
_record_non_turn_event(&"targeting_cancelled", &"", {}, "Ciblage à distance annulé.")
|
||||
|
||||
func _begin_spell_targeting() -> Array[GameEvent]:
|
||||
var available: Array[StringName] = []
|
||||
@@ -707,6 +789,15 @@ func _process_ranged_target(target_id: StringName) -> Array[TurnResult]:
|
||||
TurnResolver.append_enemy_response(game_state, results)
|
||||
return _resolve_player_action(results, true)
|
||||
|
||||
func _record_non_turn_event(kind: StringName, target_id: StringName, payload: Dictionary, message: String) -> Array[GameEvent]:
|
||||
var event := GameEventType.new(run_state.current_turn, run_state.current_floor, kind, payload, message, &"player", target_id, game_state.player.cell)
|
||||
var events: Array[GameEvent] = [event]
|
||||
run_state.append_events(events)
|
||||
event_presenter.enqueue(events)
|
||||
event_presenter.present_next()
|
||||
hud.refresh(game_state, run_state.recent_events(run_state.log.size()), run_state)
|
||||
return events
|
||||
|
||||
func _record_ranged_event(kind: StringName, target_id: StringName, payload: Dictionary, message: String) -> Array[GameEvent]:
|
||||
var event := GameEventType.new(run_state.next_turn(), run_state.current_floor, kind, payload, message, &"player", target_id, game_state.player.cell)
|
||||
var events: Array[GameEvent] = [event]
|
||||
@@ -796,7 +887,7 @@ func _process_interact() -> Array[TurnResult]:
|
||||
# behavior and are deliberately not used as item sources in this slice.
|
||||
if game_state.floor_state.ground_items.has(game_state.player.cell):
|
||||
return _process_ground_pickup()
|
||||
if _is_down_stairs() and not run_state.current_floor_deadline().can_descend():
|
||||
if _is_down_stairs() and run_state.current_floor > 0 and not run_state.current_floor_deadline().can_descend():
|
||||
var deadline := run_state.current_floor_deadline()
|
||||
var blocked := _deadline_result(
|
||||
&"stairs_refused",
|
||||
@@ -1369,6 +1460,7 @@ func _use_selected_inventory_item(target = null) -> void:
|
||||
return
|
||||
var result := run_state.inventory.use_item(item.instance_id, game_state.player, run_state.identification, target)
|
||||
if bool(result.accepted):
|
||||
_apply_item_use_effects(result.effects)
|
||||
_record_ranged_event(&"item_used", &"", {"instance_id": item.instance_id, "effects": result.effects, "revealed": result.revealed}, "Used %s." % item.definition.name)
|
||||
elif result.reason == &"target_required":
|
||||
_record_ranged_event(&"item_targeting_started", &"", {"instance_id": item.instance_id, "target_kind": &"ally"}, "Choose an ally target for %s." % item.definition.name)
|
||||
@@ -1376,6 +1468,11 @@ func _use_selected_inventory_item(target = null) -> void:
|
||||
_record_ranged_event(&"item_use_refused", &"", {"instance_id": item.instance_id, "reason": result.reason}, "Cannot use that item.")
|
||||
inventory_panel.refresh()
|
||||
|
||||
func _apply_item_use_effects(effects: Array) -> void:
|
||||
for effect: Dictionary in effects:
|
||||
if StringName(effect.get("type", "")) == &"learn_spell":
|
||||
spell_state.learn(StringName(effect.get("spell", "")))
|
||||
|
||||
# Public hook for the future party selector: it applies the currently selected
|
||||
# ally-target consumable without coupling this D3 slice to a party UI.
|
||||
func submit_inventory_ally_target(target) -> Array[GameEvent]:
|
||||
@@ -1422,15 +1519,19 @@ func _take_all_loot() -> void:
|
||||
else:
|
||||
refused_items.append({"item_id": StringName(item_data.get("item_id", "")), "quantity": int(item_data.get("quantity", 1)), "reason": result.reason})
|
||||
var gold := int(pending_loot.get("gold", 0))
|
||||
var ammunition := maxi(0, int(pending_loot.get("ammunition", 0)))
|
||||
run_state.gold += gold
|
||||
game_state.player.ammunition += ammunition
|
||||
loot_panel.dismiss()
|
||||
var message := "Butin récupéré"
|
||||
if gold > 0:
|
||||
message += " : +%d or" % gold
|
||||
if ammunition > 0:
|
||||
message += " : +%d munitions" % ammunition
|
||||
if not refused_items.is_empty():
|
||||
message += " (inventaire plein pour certains objets)"
|
||||
message += "."
|
||||
_record_ranged_event(&"loot_taken", &"", {"items": accepted_items, "gold": gold, "refused_items": refused_items}, message)
|
||||
_record_ranged_event(&"loot_taken", &"", {"items": accepted_items, "gold": gold, "ammunition": ammunition, "refused_items": refused_items}, message)
|
||||
pending_loot.clear()
|
||||
|
||||
func _process_rest() -> Array[TurnResult]:
|
||||
@@ -1494,14 +1595,59 @@ func _transition_floor(stairs_cell: Vector2i) -> void:
|
||||
game_state.set_floor_state(destination)
|
||||
game_state.content_catalog = spell_catalog
|
||||
game_state.player.cell = transition["arrival"]
|
||||
_place_companion_near_player()
|
||||
game_state.update_exploration()
|
||||
map_renderer.set_map(game_state.map)
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
player_view.set_actor(game_state.player)
|
||||
_sync_camera_to_player()
|
||||
# Camera bounds are map-specific. Recompute them before positioning the
|
||||
# camera whenever a floor transition swaps the active map dimensions.
|
||||
_configure_camera()
|
||||
_sync_enemy_views()
|
||||
hud.refresh(game_state, run_state.recent_events(run_state.log.size()), run_state)
|
||||
_check_floor_three_race_class_milestone()
|
||||
|
||||
func _place_companion_near_player() -> void:
|
||||
if game_state.companion == null or not game_state.companion.is_alive():
|
||||
return
|
||||
var occupied: Dictionary[Vector2i, bool] = {game_state.player.cell: true}
|
||||
for enemy: ActorState in game_state.enemies.values():
|
||||
if enemy.is_alive():
|
||||
occupied[enemy.cell] = true
|
||||
for member: ActorState in game_state.party.living_members():
|
||||
occupied[member.cell] = true
|
||||
for direction: Vector2i in [Vector2i.LEFT, Vector2i.DOWN, Vector2i.RIGHT, Vector2i.UP]:
|
||||
var candidate := game_state.player.cell + direction
|
||||
if game_state.map.is_walkable(candidate) and not occupied.has(candidate):
|
||||
game_state.companion.actor.cell = candidate
|
||||
return
|
||||
|
||||
func _check_floor_three_race_class_milestone() -> void:
|
||||
if run_state.current_floor != 3 or (not dialogue_player.race.is_empty() and not dialogue_player.archetype.is_empty()):
|
||||
return
|
||||
race_class_choice_panel.present_races(class_engine.race_definitions())
|
||||
_record_ranged_event(
|
||||
&"race_class_choice_required",
|
||||
&"",
|
||||
{"floor": run_state.current_floor},
|
||||
"Niveau 3 du Donjon : choisissez votre race, puis votre classe."
|
||||
)
|
||||
|
||||
func _choose_floor_three_race(race_id: StringName) -> void:
|
||||
var result := class_engine.choose_race(dialogue_player, race_id)
|
||||
if not bool(result.get("accepted", false)):
|
||||
return
|
||||
_record_ranged_event(&"race_chosen", race_id, {}, "Race choisie : %s." % race_id)
|
||||
race_class_choice_panel.present_classes(class_engine.class_definitions(dialogue_player.race))
|
||||
|
||||
func _choose_floor_three_class(class_id: StringName) -> void:
|
||||
var result := class_engine.choose_class(dialogue_player, class_id)
|
||||
if not bool(result.get("accepted", false)):
|
||||
return
|
||||
run_state.base_archetype = dialogue_player.archetype
|
||||
race_class_choice_panel.dismiss()
|
||||
_record_ranged_event(&"class_chosen", class_id, {}, "Classe choisie : %s." % class_id)
|
||||
|
||||
func _process_action(direction: Vector2i) -> Array[TurnResult]:
|
||||
var results := game_state.try_player_action(direction)
|
||||
@@ -1532,14 +1678,18 @@ func _append_collapse_damage(results: Array[TurnResult]) -> void:
|
||||
# journal: results from one resolved player action are converted and appended once,
|
||||
# and every resulting GameEvent shares that action's turn number.
|
||||
func _resolve_player_action(results: Array[TurnResult], sync_camera: bool) -> Array[TurnResult]:
|
||||
if _results_consume_turn(results):
|
||||
_apply_passive_health_regeneration(results)
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
player_view.refresh()
|
||||
_sync_companion_view()
|
||||
_sync_party_views()
|
||||
_sync_enemy_views()
|
||||
if sync_camera:
|
||||
_sync_camera_to_player()
|
||||
_dispatch_audio(results)
|
||||
_resolve_enemy_loot(results)
|
||||
var events := _record_events(results)
|
||||
_resolve_player_death_if_needed()
|
||||
_append_level_up_events(events)
|
||||
@@ -1565,6 +1715,39 @@ func _resolve_player_action(results: Array[TurnResult], sync_camera: bool) -> Ar
|
||||
hud.refresh(game_state, run_state.recent_events(run_state.log.size()), run_state)
|
||||
return results
|
||||
|
||||
func _results_consume_turn(results: Array[TurnResult]) -> bool:
|
||||
if results.is_empty():
|
||||
return false
|
||||
return not results.all(func(result: TurnResult) -> bool:
|
||||
return result.kind in [&"blocked", &"nothing_to_interact", &"rest_refused", &"stairs_refused"]
|
||||
)
|
||||
|
||||
func _apply_passive_health_regeneration(results: Array[TurnResult]) -> void:
|
||||
_sync_dialogue_player_progression()
|
||||
var player_took_damage := (_turn_start_player_hit_points >= 0 and game_state.player.hit_points < _turn_start_player_hit_points) or results.any(func(result: TurnResult) -> bool:
|
||||
return result.damage > 0 and (result.target_id == game_state.player.id or result.kind == &"collapse_damage")
|
||||
)
|
||||
var perk_bonus := int(perk_engine.modifiers().get("regen_bonus", 0)) if perk_engine != null else 0
|
||||
if not player_took_damage:
|
||||
HealthRegenerationType.apply(
|
||||
game_state.player,
|
||||
dialogue_player.effective_attribute(&"end"),
|
||||
dialogue_player.effective_skill(&"regeneration"),
|
||||
perk_bonus,
|
||||
run_state.settings.difficulty_id
|
||||
)
|
||||
var companion_took_damage := game_state.companion != null and ((_turn_start_companion_hit_points >= 0 and game_state.companion.actor.hit_points < _turn_start_companion_hit_points) or results.any(func(result: TurnResult) -> bool:
|
||||
return result.damage > 0 and result.target_id == game_state.companion.actor.id
|
||||
))
|
||||
if game_state.companion != null and game_state.companion.is_alive() and not companion_took_damage:
|
||||
HealthRegenerationType.apply(
|
||||
game_state.companion.actor,
|
||||
game_state.companion.endurance,
|
||||
game_state.companion.regeneration_skill,
|
||||
game_state.companion.regeneration_perk_bonus,
|
||||
run_state.settings.difficulty_id
|
||||
)
|
||||
|
||||
func _resolve_player_death_if_needed() -> void:
|
||||
if game_state.player.is_alive() or run_state.is_game_over:
|
||||
return
|
||||
@@ -1708,6 +1891,30 @@ func _append_level_up_events(events: Array[GameEvent]) -> void:
|
||||
run_state.append_events([level_event])
|
||||
_check_progression_choices_and_evolutions()
|
||||
|
||||
func _resolve_enemy_loot(results: Array[TurnResult]) -> void:
|
||||
var resolved_enemy_ids: Dictionary[StringName, bool] = {}
|
||||
for result: TurnResult in results:
|
||||
var descriptors: Array = result.payload.get("domain_events", [])
|
||||
for descriptor: Dictionary in descriptors:
|
||||
if descriptor.kind != &"loot_dropped" or descriptor.actor_id == &"player" or resolved_enemy_ids.has(StringName(descriptor.actor_id)):
|
||||
continue
|
||||
resolved_enemy_ids[StringName(descriptor.actor_id)] = true
|
||||
var table_id := StringName(descriptor.payload.get("loot_table", ""))
|
||||
var table := spell_catalog.get_loot_table(table_id) if spell_catalog != null else {}
|
||||
var reward := LootResolverType.resolve(table, run_state.seed, "enemy:%d:%s" % [run_state.current_floor, descriptor.actor_id])
|
||||
reward["loot_table"] = table_id
|
||||
descriptor.payload = reward
|
||||
var drop_cell: Vector2i = result.to_cell
|
||||
for item_data: Dictionary in reward.items:
|
||||
var definition := ItemDefinitionType.from_catalog(spell_catalog, StringName(item_data.get("item_id", "")))
|
||||
if not definition.is_valid():
|
||||
continue
|
||||
if not game_state.floor_state.ground_items.has(drop_cell):
|
||||
game_state.floor_state.ground_items[drop_cell] = []
|
||||
game_state.floor_state.ground_items[drop_cell].append(ItemInstanceType.new(definition, int(item_data.get("quantity", 1))))
|
||||
run_state.gold += int(reward.gold)
|
||||
_sync_map_renderer_visibility()
|
||||
|
||||
func _record_events(results: Array[TurnResult]) -> Array[GameEvent]:
|
||||
var events: Array[GameEvent] = []
|
||||
if results.is_empty():
|
||||
@@ -1764,34 +1971,12 @@ func _get_actor_view(actor_id: StringName) -> ActorView:
|
||||
return enemy_views.get(actor_id) as ActorView
|
||||
|
||||
func _create_initial_state() -> GameState:
|
||||
var map := GridMapStateType.new(Vector2i(30, 20), GridMapStateType.CellKind.WALL)
|
||||
_carve_room(map, Rect2i(2, 12, 6, 5))
|
||||
_carve_room(map, Rect2i(2, 4, 7, 7))
|
||||
_carve_room(map, Rect2i(10, 2, 10, 6))
|
||||
_carve_room(map, Rect2i(21, 5, 7, 8))
|
||||
_carve_vertical_corridor(map, 4, 10, 12)
|
||||
_carve_horizontal_corridor(map, 8, 10, 6)
|
||||
_carve_horizontal_corridor(map, 18, 21, 6)
|
||||
_carve_vertical_corridor(map, 18, 4, 6)
|
||||
map.set_cell(Vector2i(4, 11), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.CHEST)
|
||||
map.set_cell(Vector2i(18, 4), GridMapStateType.CellKind.STAIRS)
|
||||
var player := ActorStateType.new(&"player", Vector2i(4, 12), 12, 3)
|
||||
var goblin := ActorStateType.new(&"goblin", Vector2i(24, 8), 6, 2)
|
||||
return GameStateType.new(map, player, {&"goblin": goblin})
|
||||
|
||||
func _carve_room(map: GridMapState, room: Rect2i) -> void:
|
||||
for y in range(room.position.y, room.end.y):
|
||||
for x in range(room.position.x, room.end.x):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _carve_horizontal_corridor(map: GridMapState, from_x: int, to_x: int, y: int) -> void:
|
||||
for x in range(from_x, to_x + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _carve_vertical_corridor(map: GridMapState, x: int, from_y: int, to_y: int) -> void:
|
||||
for y in range(from_y, to_y + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
# Run initialization immediately replaces this neutral shell with the authored
|
||||
# surface. Keeping the shell content-free prevents the removed prototype map
|
||||
# from becoming an accidental gameplay source again.
|
||||
var map := GridMapStateType.new(Vector2i.ONE, GridMapStateType.CellKind.FLOOR)
|
||||
var player := ActorStateType.new(&"player", Vector2i.ZERO, 12, 3)
|
||||
return GameStateType.new(map, player, {})
|
||||
|
||||
func _configure_camera() -> void:
|
||||
var map_size := game_state.map.size * TILE_SIZE
|
||||
@@ -1863,4 +2048,8 @@ func _sync_enemy_views() -> void:
|
||||
view.texture = preload("res://assets/dcss/goblin.png")
|
||||
enemies.add_child(view)
|
||||
enemy_views[enemy_id] = view
|
||||
enemy_views[enemy_id].set_actor(game_state.enemies[enemy_id])
|
||||
var enemy: ActorState = game_state.enemies[enemy_id]
|
||||
enemy_views[enemy_id].set_actor(enemy)
|
||||
# Actor sprites must obey the same current-FOV contract as special map
|
||||
# markers. Explored memory never reveals a live enemy.
|
||||
enemy_views[enemy_id].visible = enemy.is_alive() and game_state.visible_cells.has(enemy.cell)
|
||||
|
||||
@@ -4,6 +4,9 @@ extends RefCounted
|
||||
# The Input Map owns physical bindings; this catalog gives every rebindable action
|
||||
# its stable identifier, player command and user-facing French help name.
|
||||
const ACTIONS: Array[StringName] = [
|
||||
# Modifier shortcuts must be checked before their unmodified key (Ctrl+S
|
||||
# before south), otherwise Godot also considers the physical S match.
|
||||
&"save",
|
||||
&"interact",
|
||||
&"move_north",
|
||||
&"move_south",
|
||||
@@ -14,7 +17,6 @@ const ACTIONS: Array[StringName] = [
|
||||
&"move_southwest",
|
||||
&"move_southeast",
|
||||
&"wait",
|
||||
&"attack",
|
||||
&"ranged",
|
||||
&"cast",
|
||||
&"talk",
|
||||
@@ -47,8 +49,8 @@ const HELP_NAMES := {
|
||||
&"move_southeast": "Déplacer vers le sud-est",
|
||||
&"wait": "Attendre",
|
||||
&"interact": "Interagir",
|
||||
&"attack": "Attaquer",
|
||||
&"ranged": "Attaque à distance",
|
||||
&"ranged": "Attaque à distance / choisir une cible",
|
||||
&"save": "Sauvegarder manuellement (V ou Ctrl+S)",
|
||||
&"cast": "Lancer un sort",
|
||||
&"talk": "Parler",
|
||||
&"rest": "Se reposer",
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
class_name TemporaryPlaytestKit
|
||||
extends RefCounted
|
||||
|
||||
## TEMPORARY PLAYTEST FIXTURE
|
||||
##
|
||||
## Remove this file and its single call in Game once normal early-game loot and
|
||||
## encounter balance can exercise melee, ranged, and offensive magic naturally.
|
||||
## It deliberately does not modify procedural generation or authored loot tables.
|
||||
|
||||
const CHESTS := {
|
||||
Vector2i(3, 6): {
|
||||
"label": "MÊLÉE",
|
||||
"items": [{"item_id": &"weapon_rusty_sword", "quantity": 1}],
|
||||
"ammunition": 0,
|
||||
},
|
||||
Vector2i(5, 6): {
|
||||
"label": "DISTANCE",
|
||||
"items": [{"item_id": &"weapon_hand_crossbow", "quantity": 1}],
|
||||
"ammunition": 20,
|
||||
},
|
||||
Vector2i(6, 6): {
|
||||
"label": "MAGIE OFFENSIVE",
|
||||
"items": [{"item_id": &"misc_grimoire_ombre", "quantity": 1}],
|
||||
"ammunition": 0,
|
||||
},
|
||||
}
|
||||
|
||||
static func apply_to_new_run(floor: FloorState) -> void:
|
||||
if floor == null or floor.floor_number != 0:
|
||||
return
|
||||
floor.metadata["temporary_playtest_chests"] = true
|
||||
for cell: Vector2i in CHESTS:
|
||||
var reward: Dictionary = CHESTS[cell]
|
||||
floor.chests[cell] = {
|
||||
"loot_table_id": &"",
|
||||
"opened": false,
|
||||
"temporary_playtest": true,
|
||||
"label": reward.label,
|
||||
"reward": {
|
||||
"items": reward.items.duplicate(true),
|
||||
"gold": 0,
|
||||
"empty": false,
|
||||
"trap": &"",
|
||||
"ammunition": int(reward.ammunition),
|
||||
},
|
||||
}
|
||||
floor.map.set_cell(cell, GridMapState.CellKind.CHEST)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b1f30fl11cbkt
|
||||
@@ -12,6 +12,11 @@ const AMBIENCE_CONTEXTS := [&"exploration", &"combat", &"danger"]
|
||||
const SFX_EVENTS := [&"attack_given", &"attack_received", &"menu_select", &"menu_cancel", &"item_use", &"death"]
|
||||
const USER_AUDIO_DIRECTORY := "user://audio"
|
||||
const USER_MANIFEST_PATH := "user://audio/audio_import_manifest.tres"
|
||||
const BUNDLED_AMBIENCE_PATHS := {
|
||||
&"exploration": "res://assets/audio/dungeon_exploration.wav",
|
||||
&"combat": "res://assets/audio/dungeon_combat.wav",
|
||||
&"danger": "res://assets/audio/dungeon_danger.wav",
|
||||
}
|
||||
|
||||
var ambience_streams: Dictionary = {}
|
||||
var sfx_streams: Dictionary = {}
|
||||
@@ -46,9 +51,23 @@ static func save_user_manifest(manifest: AudioImportManifest) -> Error:
|
||||
return ResourceSaver.save(manifest, USER_MANIFEST_PATH)
|
||||
|
||||
static func load_user_manifest() -> AudioImportManifest:
|
||||
var manifest := load_bundled_manifest()
|
||||
if not FileAccess.file_exists(USER_MANIFEST_PATH):
|
||||
return AudioImportManifest.new()
|
||||
return manifest
|
||||
var resource := ResourceLoader.load(USER_MANIFEST_PATH, "AudioImportManifest", ResourceLoader.CACHE_MODE_IGNORE)
|
||||
if resource is AudioImportManifest:
|
||||
return resource as AudioImportManifest
|
||||
return AudioImportManifest.new()
|
||||
if not resource is AudioImportManifest:
|
||||
return manifest
|
||||
var user_manifest := resource as AudioImportManifest
|
||||
for context: StringName in user_manifest.ambience_streams:
|
||||
manifest.register_ambience(context, user_manifest.ambience_for(context))
|
||||
for event: StringName in user_manifest.sfx_streams:
|
||||
manifest.register_sfx(event, user_manifest.sfx_for(event))
|
||||
return manifest
|
||||
|
||||
static func load_bundled_manifest() -> AudioImportManifest:
|
||||
var manifest := AudioImportManifest.new()
|
||||
for context: StringName in BUNDLED_AMBIENCE_PATHS:
|
||||
var stream := ResourceLoader.load(String(BUNDLED_AMBIENCE_PATHS[context])) as AudioStream
|
||||
if stream != null:
|
||||
manifest.register_ambience(context, stream)
|
||||
return manifest
|
||||
|
||||
@@ -20,12 +20,16 @@ var _last_ambience_path := ""
|
||||
var _last_sfx_path := ""
|
||||
|
||||
func _init(manifest_or_legacy_root: Variant = null) -> void:
|
||||
# The former API accepted an external directory override. Intentionally ignore
|
||||
# it for compatibility: external paths are not a safe playback source.
|
||||
if manifest_or_legacy_root is AudioImportManifest:
|
||||
_manifest = manifest_or_legacy_root as AudioImportManifest
|
||||
else:
|
||||
elif manifest_or_legacy_root == null:
|
||||
# Production instances load bundled music and optionally overlay the safe
|
||||
# Godot-native user manifest.
|
||||
_manifest = AudioImportManifestType.load_user_manifest()
|
||||
else:
|
||||
# The former API accepted an external directory override. Keep explicit
|
||||
# legacy instances isolated and silent: arbitrary files are never decoded.
|
||||
_manifest = AudioImportManifestType.new()
|
||||
|
||||
func _ready() -> void:
|
||||
_ensure_players()
|
||||
@@ -40,9 +44,12 @@ func set_manifest(manifest: AudioImportManifest) -> void:
|
||||
func set_ambience_context(context: String) -> void:
|
||||
if not context in AMBIENCE_CONTEXTS:
|
||||
return
|
||||
var stream := _manifest.ambience_for(StringName(context))
|
||||
if current_ambience_context == context and _ambience_player != null and _ambience_player.stream == stream and _ambience_player.playing:
|
||||
return
|
||||
current_ambience_context = context
|
||||
_last_ambience_path = ""
|
||||
_set_ambience_stream(_manifest.ambience_for(StringName(context)))
|
||||
_last_ambience_path = stream.resource_path if stream != null else ""
|
||||
_set_ambience_stream(stream)
|
||||
|
||||
func play_sfx(event: String) -> void:
|
||||
_last_sfx_path = ""
|
||||
|
||||
@@ -116,7 +116,7 @@ func _serialize(run: RunState, game: GameState, dialogue_player) -> Dictionary:
|
||||
identified.append(String(id))
|
||||
return {
|
||||
"version": SCHEMA_VERSION,
|
||||
"run": {"seed": run.seed, "settings": {"seed": run.settings.seed, "difficulty_id": String(run.settings.difficulty_id), "permadeath": run.settings.permadeath, "pet_enabled": run.settings.pet_enabled}, "player_name": run.player_name, "base_archetype": String(run.base_archetype), "current_floor": run.current_floor, "current_turn": run.current_turn, "gold": run.gold, "floors": floors, "floor_deadlines": deadlines, "inventory": run.inventory.to_dict(), "equipment": equipment, "identified_instance_ids": identified, "quest_records": run.quest_records, "achievement_state": run.achievement_state, "audience_state": run.audience_state, "recap_state": run.recap_state, "faction_war_state": run.faction_war_state, "moderation_state": run.moderation_state, "endgame_state": {"victory": run.endgame_state.victory}, "is_game_over": run.is_game_over, "death_outcome": String(run.death_outcome), "slot_policy": String(run.slot_policy), "log": _events_to_data(run.log), "meta": {}},
|
||||
"run": {"seed": run.seed, "settings": {"seed": run.settings.seed, "difficulty_id": String(run.settings.difficulty_id), "permadeath": run.settings.permadeath, "pet_enabled": run.settings.pet_enabled, "pet_name": run.settings.pet_name, "pet_species": run.settings.pet_species}, "player_name": run.player_name, "base_archetype": String(run.base_archetype), "current_floor": run.current_floor, "current_turn": run.current_turn, "gold": run.gold, "floors": floors, "floor_deadlines": deadlines, "inventory": run.inventory.to_dict(), "equipment": equipment, "identified_instance_ids": identified, "quest_records": run.quest_records, "achievement_state": run.achievement_state, "audience_state": run.audience_state, "recap_state": run.recap_state, "faction_war_state": run.faction_war_state, "moderation_state": run.moderation_state, "endgame_state": {"victory": run.endgame_state.victory}, "is_game_over": run.is_game_over, "death_outcome": String(run.death_outcome), "slot_policy": String(run.slot_policy), "log": _events_to_data(run.log), "meta": {}},
|
||||
"runtime": {"player": _actor_to_data(game.player), "companion": _companion_to_data(game.companion), "party": _actors_to_data(game.party.members), "dialogue_player": _dialogue_to_data(dialogue_player)},
|
||||
"metadata": {"updated_at": Time.get_unix_time_from_system(), "source": "godot"},
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func _serialize(run: RunState, game: GameState, dialogue_player) -> Dictionary:
|
||||
func _deserialize(data: Dictionary, catalog: ContentCatalog) -> Dictionary:
|
||||
var run_data: Dictionary = data.get("run", {})
|
||||
var settings_data: Dictionary = run_data.get("settings", {})
|
||||
var run := RunStateType.new(String(run_data.get("seed", "")), RunSettingsType.new(String(settings_data.get("seed", run_data.get("seed", ""))), StringName(settings_data.get("difficulty_id", "crawler")), bool(settings_data.get("permadeath", false)), bool(settings_data.get("pet_enabled", false))))
|
||||
var run := RunStateType.new(String(run_data.get("seed", "")), RunSettingsType.new(String(settings_data.get("seed", run_data.get("seed", ""))), StringName(settings_data.get("difficulty_id", "crawler")), bool(settings_data.get("permadeath", false)), bool(settings_data.get("pet_enabled", false)), String(settings_data.get("pet_name", "Familier")), String(settings_data.get("pet_species", "Animal"))))
|
||||
run.player_name = String(run_data.get("player_name", "Sans-Nom")); run.base_archetype = StringName(run_data.get("base_archetype", "vanguard")); run.current_floor = int(run_data.get("current_floor", 0)); run.current_turn = int(run_data.get("current_turn", 0)); run.gold = int(run_data.get("gold", 0))
|
||||
for key in (run_data.get("floors", {}) as Dictionary):
|
||||
var floor := _floor_from_data(run_data.floors[key], catalog)
|
||||
@@ -200,12 +200,36 @@ static func _actors_from_data(data: Array) -> Array[ActorState]:
|
||||
|
||||
static func _companion_to_data(companion: CompanionState):
|
||||
if companion == null: return null
|
||||
return {"choice_id": String(companion.choice_id), "stance": String(companion.stance), "actor": _actor_to_data(companion.actor)}
|
||||
return {"choice_id": String(companion.choice_id), "stance": String(companion.stance), "name": companion.name, "species": companion.species, "endurance": companion.endurance, "regeneration_skill": companion.regeneration_skill, "regeneration_perk_bonus": companion.regeneration_perk_bonus, "actor": _actor_to_data(companion.actor)}
|
||||
|
||||
static func _companion_from_data(data) -> CompanionState:
|
||||
if not data is Dictionary or data.is_empty(): return null
|
||||
var actor := _actor_from_data(data.get("actor", {})); if actor == null: return null
|
||||
var companion := CompanionStateType.new(StringName(data.get("choice_id", "moth")), actor); companion.stance = StringName(data.get("stance", "follow")); return companion
|
||||
var actor_data: Dictionary = data.get("actor", {})
|
||||
if actor_data.is_empty() and data.has("id"):
|
||||
actor_data = {
|
||||
"id": String(data.get("id", "companion")),
|
||||
"cell": [int(data.get("x", 0)), int(data.get("y", 0))],
|
||||
"hit_points": int(data.get("hp", 1)),
|
||||
"max_hit_points": int(data.get("max_hp", data.get("hp", 1))),
|
||||
"attack_damage": int(data.get("attack_damage", 3)),
|
||||
"xp": int(data.get("xp", 0)),
|
||||
}
|
||||
var actor := _actor_from_data(actor_data); if actor == null: return null
|
||||
var companion := CompanionStateType.new(StringName(data.get("choice_id", data.get("id", "moth"))), actor)
|
||||
companion.stance = _legacy_companion_stance(StringName(data.get("stance", data.get("behavior", "stay_back"))))
|
||||
companion.name = String(data.get("name", "Familier"))
|
||||
companion.species = String(data.get("species", "Animal"))
|
||||
var attributes: Dictionary = data.get("attributes", {})
|
||||
var skills: Dictionary = data.get("skills", {})
|
||||
var perks: Dictionary = data.get("perks", {})
|
||||
companion.endurance = int(data.get("endurance", attributes.get("end", 4)))
|
||||
companion.regeneration_skill = int(data.get("regeneration_skill", skills.get("regeneration", 1)))
|
||||
companion.regeneration_perk_bonus = int(data.get("regeneration_perk_bonus", perks.get("regen_bonus", 0)))
|
||||
return companion
|
||||
|
||||
static func _legacy_companion_stance(value: StringName) -> StringName:
|
||||
var normalized := CompanionStateType.normalize_stance(value)
|
||||
return normalized if normalized in CompanionStateType.VALID_STANCES else CompanionStateType.Stance.STAY_BACK
|
||||
|
||||
static func _events_to_data(events: Array[GameEvent]) -> Array:
|
||||
var data: Array = []
|
||||
|
||||
@@ -25,13 +25,13 @@ func select_next(delta: int) -> bool:
|
||||
func refresh() -> void:
|
||||
if _companion == null:
|
||||
return
|
||||
title.text = "Companion command"
|
||||
var status := "Alive" if _companion.is_alive() else "Fallen"
|
||||
body.text = "%s — %s\n\n%s\n\n←/→ Change stance Esc Close" % [String(_companion.choice_id).capitalize(), status, _stance_lines()]
|
||||
title.text = _companion.name
|
||||
var status := "En vie" if _companion.is_alive() else "À terre"
|
||||
body.text = "%s — %s\nPV %d/%d\n\nComportement :\n%s\n\n%s\n\n←/→ Changer K ou Échap Fermer" % [_companion.species, status, _companion.actor.hit_points, _companion.actor.effective_max_hit_points(), _stance_lines(), CompanionState.stance_description(_companion.stance)]
|
||||
|
||||
func _stance_lines() -> String:
|
||||
var lines: PackedStringArray = []
|
||||
for stance: StringName in CompanionState.VALID_STANCES:
|
||||
var cursor := "> " if stance == _companion.stance else " "
|
||||
lines.append("%s%s" % [cursor, String(stance).capitalize()])
|
||||
lines.append("%s%s" % [cursor, CompanionState.stance_label(stance)])
|
||||
return "\n".join(lines)
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
class_name DeathPanel
|
||||
extends PanelContainer
|
||||
|
||||
@onready var body: RichTextLabel = $Body
|
||||
signal navigation_requested(action: StringName)
|
||||
|
||||
@onready var body: RichTextLabel = $Layout/Body
|
||||
@onready var hint: Label = $Layout/Hint
|
||||
@onready var load_button: Button = $Layout/Actions/LoadButton
|
||||
|
||||
func _ready() -> void:
|
||||
load_button.pressed.connect(func() -> void: navigation_requested.emit(&"load"))
|
||||
$Layout/Actions/NewRunButton.pressed.connect(func() -> void: navigation_requested.emit(&"new_run"))
|
||||
$Layout/Actions/MenuButton.pressed.connect(func() -> void: navigation_requested.emit(&"menu"))
|
||||
|
||||
func present(outcome: StringName, player_name: String, floor: int, level: int) -> void:
|
||||
visible = true
|
||||
var mode := "Mort permanente : la sauvegarde de cette run est retirée." if outcome == &"permadeath" else "Classique : la sauvegarde de cette run reste disponible."
|
||||
var classic := outcome != &"permadeath"
|
||||
var mode := "Mort permanente : cette run est terminée." if not classic else "Classique : vous pouvez charger une sauvegarde existante."
|
||||
body.text = "%s n'aura pas survécu au donjon.\n\nNiveau atteint : %d Étage : %d\n\n%s\n\nLe donjon, lui, continuera sans vous." % [player_name, level, floor, mode]
|
||||
load_button.visible = classic
|
||||
hint.text = "Choisissez une sauvegarde, une nouvelle partie ou le menu principal." if classic else "Commencez une nouvelle partie ou retournez au menu principal."
|
||||
|
||||
func dismiss() -> void:
|
||||
visible = false
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class_name DialoguePanel
|
||||
extends PanelContainer
|
||||
|
||||
@onready var title: Label = $Title
|
||||
@onready var body: RichTextLabel = $Body
|
||||
@onready var entries: RichTextLabel = $Entries
|
||||
@onready var title: Label = $Layout/Title
|
||||
@onready var body: RichTextLabel = $Layout/Body
|
||||
@onready var entries: RichTextLabel = $Layout/Entries
|
||||
|
||||
var _engine: DialogueEngine
|
||||
var _state: DialogueState
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class_name EventPanel
|
||||
extends PanelContainer
|
||||
|
||||
@onready var title: Label = $Title
|
||||
@onready var body: RichTextLabel = $Body
|
||||
@onready var entries: RichTextLabel = $Entries
|
||||
@onready var title: Label = $Layout/Title
|
||||
@onready var body: RichTextLabel = $Layout/Body
|
||||
@onready var entries: RichTextLabel = $Layout/Entries
|
||||
|
||||
var _engine: EventEngine
|
||||
var _definition: Dictionary = {}
|
||||
|
||||
@@ -20,5 +20,7 @@ func refresh() -> void:
|
||||
if not events.is_empty() and events[0] is InputEventKey:
|
||||
binding = OS.get_keycode_string((events[0] as InputEventKey).physical_keycode)
|
||||
lines.append("%s — %s" % [binding, InputBindingsType.help_name_for(action)])
|
||||
lines.append("\nF1 / ? — fermer")
|
||||
lines.append("\nCiblage : flèches, Entrée pour confirmer, Échap pour annuler")
|
||||
lines.append("Sauvegarde : V (éditeur) ou Ctrl+S (jeu autonome), puis choix d’un emplacement")
|
||||
lines.append("F1 / Échap — fermer")
|
||||
body.text = "\n".join(lines)
|
||||
|
||||
@@ -13,6 +13,8 @@ const QUEST_BOARD_PROMPT := "Espace — Lire le tableau des quêtes"
|
||||
|
||||
@onready var player_health_label: Label = $PlayerHealthLabel
|
||||
@onready var player_focus_label: Label = $PlayerFocusLabel
|
||||
@onready var experience_bar: ProgressBar = $ExperienceBar
|
||||
@onready var experience_label: Label = $ExperienceLabel
|
||||
@onready var spell_label: Label = $SpellLabel
|
||||
@onready var deadline_label: Label = $DeadlineLabel
|
||||
@onready var gold_label: Label = $GoldLabel
|
||||
@@ -38,6 +40,7 @@ func refresh(state: GameState, events: Array[GameEvent] = [], run_state: RunStat
|
||||
_run_state = run_state
|
||||
player_health_label.text = "Player HP: %d/%d" % [state.player.hit_points, state.player.max_hit_points]
|
||||
player_focus_label.text = "Focus: %d/%d" % [state.player.focus, state.player.max_focus]
|
||||
_refresh_experience(state.player.progression)
|
||||
if state.enemies.has(&"goblin"):
|
||||
var goblin: ActorState = state.enemies[&"goblin"]
|
||||
enemy_health_label.text = "Goblin HP: %d/%d" % [goblin.hit_points, goblin.max_hit_points]
|
||||
@@ -55,6 +58,16 @@ func refresh(state: GameState, events: Array[GameEvent] = [], run_state: RunStat
|
||||
for event in events:
|
||||
event_log.append_text(event.message + "\n")
|
||||
|
||||
func _refresh_experience(experience: Experience) -> void:
|
||||
var current_level_start := experience.xp_for_level(experience.level)
|
||||
var next_level_total := experience.next_level_xp()
|
||||
var level_progress := experience.total_xp - current_level_start
|
||||
var level_required := next_level_total - current_level_start
|
||||
experience_bar.min_value = 0
|
||||
experience_bar.max_value = level_required
|
||||
experience_bar.value = level_progress
|
||||
experience_label.text = "Niveau %d — XP %d/%d" % [experience.level, level_progress, level_required]
|
||||
|
||||
func get_context_prompt() -> String:
|
||||
if _state == null:
|
||||
return ""
|
||||
@@ -72,7 +85,7 @@ func get_context_prompt() -> String:
|
||||
&"stairs":
|
||||
if _state.floor_state.floor_number > 0 and _state.player.cell == _state.floor_state.entrance:
|
||||
return STAIRS_UP_PROMPT
|
||||
if _run_state != null:
|
||||
if _run_state != null and _state.floor_state.floor_number > 0:
|
||||
var deadline := _run_state.current_floor_deadline()
|
||||
if not deadline.can_descend():
|
||||
return "Escaliers verrouillés — encore %d jour(s) avant l’ouverture" % deadline.days_until_stairs_open()
|
||||
@@ -101,6 +114,8 @@ func _quest_tracker() -> String:
|
||||
func _deadline_status() -> String:
|
||||
if _run_state == null:
|
||||
return ""
|
||||
if _run_state.current_floor == 0:
|
||||
return "Surface — aucun effondrement"
|
||||
var deadline := _run_state.current_floor_deadline()
|
||||
var status := "Étage %d — %d jour(s) avant l’effondrement" % [_run_state.current_floor, deadline.remaining_days()]
|
||||
if deadline.collapsing:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class_name InventoryPanel
|
||||
extends PanelContainer
|
||||
|
||||
@onready var entries: RichTextLabel = $Entries
|
||||
@onready var details: RichTextLabel = $Details
|
||||
@onready var entries: RichTextLabel = $Layout/Columns/Entries
|
||||
@onready var details: RichTextLabel = $Layout/Columns/Details
|
||||
|
||||
var selected_index := 0
|
||||
var _inventory: InventoryState
|
||||
@@ -53,7 +53,7 @@ func refresh() -> void:
|
||||
var stats := _identification.display_stats(item) if _identification != null else ""
|
||||
var description := String(item.definition.raw.get("description", "")) if _identification == null or _identification.is_identified(item) else "Its properties are not yet known."
|
||||
var comparison := _equipment.comparison_for(item, _identification) if _equipment != null else ""
|
||||
details.text = "%s\n%s\n%s\n\n%s\n\n%s\n↑/↓ Select E Equip U Use D Drop I Close" % [name, stats, description, comparison, equipment_summary]
|
||||
details.text = "%s\n%s\n%s\n\n%s\n\n%s" % [name, stats, description, comparison, equipment_summary]
|
||||
|
||||
func _equipment_summary() -> String:
|
||||
if _equipment == null or _identification == null:
|
||||
|
||||
@@ -49,7 +49,7 @@ func _color_for(presentation_kind: StringName) -> Color:
|
||||
|
||||
func _label_for(event: GameEvent, presentation_kind: StringName) -> String:
|
||||
match presentation_kind:
|
||||
&"loot": return "✦ LOOT SECURED"
|
||||
&"loot": return "✦ BUTIN AU SOL"
|
||||
&"trap": return "! TRAP"
|
||||
&"quest": return "✦ QUEST UPDATED"
|
||||
_: return event.message
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class_name LootPanel
|
||||
extends PanelContainer
|
||||
|
||||
@onready var entries: RichTextLabel = $Entries
|
||||
@onready var entries: RichTextLabel = $Layout/Entries
|
||||
|
||||
func present(reward: Dictionary, catalog: ContentCatalog) -> void:
|
||||
entries.text = _reward_text(reward, catalog)
|
||||
|
||||
@@ -1,49 +1,37 @@
|
||||
class_name CharacterCreation
|
||||
extends Control
|
||||
|
||||
signal run_requested(settings: RunSettings, player_name: String, base_archetype: StringName, race: StringName)
|
||||
signal run_requested(settings: RunSettings, player_name: String)
|
||||
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 pet_details: VBoxContainer = $Panel/Layout/Fields/PetDetails
|
||||
@onready var pet_name_edit: LineEdit = $Panel/Layout/Fields/PetDetails/PetNameEdit
|
||||
@onready var pet_species_edit: LineEdit = $Panel/Layout/Fields/PetDetails/PetSpeciesEdit
|
||||
@onready var seed_edit: LineEdit = $Panel/Layout/Fields/SeedEdit
|
||||
@onready var difficulty_option: OptionButton = $Panel/Layout/Fields/DifficultyOption
|
||||
@onready var permadeath_option: OptionButton = $Panel/Layout/Fields/PermadeathOption
|
||||
@onready var validation_label: Label = $Panel/Layout/ValidationLabel
|
||||
|
||||
func _ready() -> void:
|
||||
_populate_races()
|
||||
race_option.item_selected.connect(_refresh_recommendation)
|
||||
pet_check.toggled.connect(func(enabled: bool) -> void: pet_details.visible = enabled)
|
||||
pet_details.visible = pet_check.button_pressed
|
||||
$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(
|
||||
seed_edit.text,
|
||||
selected_difficulty,
|
||||
permadeath_option.get_selected_id() == 1,
|
||||
pet_check.button_pressed
|
||||
pet_check.button_pressed,
|
||||
pet_name_edit.text,
|
||||
pet_species_edit.text
|
||||
)
|
||||
if not settings.is_valid():
|
||||
validation_label.text = settings.validation_error()
|
||||
@@ -52,10 +40,4 @@ func _on_start_run_pressed() -> void:
|
||||
var player_name := name_edit.text.strip_edges()
|
||||
if player_name.is_empty():
|
||||
player_name = "Sans-Nom"
|
||||
var selected_archetype := ARCHETYPE_IDS[archetype_option.selected]
|
||||
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)
|
||||
run_requested.emit(settings, player_name)
|
||||
|
||||
@@ -29,7 +29,7 @@ func _ready() -> void:
|
||||
save_load_panel.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", &"race_humain_standard")
|
||||
_start_new_run(RunSettings.new("visual-check", &"crawler", false, false), "Visual Check")
|
||||
|
||||
func _get_capture_mode() -> bool:
|
||||
var arguments := OS.get_cmdline_user_args()
|
||||
@@ -94,14 +94,14 @@ func _show_load_slots() -> void:
|
||||
|
||||
func show_save_slots() -> void:
|
||||
_save_load_mode = "save"
|
||||
save_load_panel.present(_save_load_mode, _save_repository.list_slots())
|
||||
save_load_panel.present(_save_load_mode, _save_repository.list_slots(), "La sauvegarde est manuelle. Choisissez un emplacement.")
|
||||
|
||||
func _on_save_load_slot_requested(slot: int) -> void:
|
||||
var result := save_to_slot(slot) if _save_load_mode == "save" else load_slot(slot)
|
||||
if bool(result.get("ok", false)):
|
||||
_show_main_menu() if _save_load_mode == "load" else save_load_panel.set_status("Saved to slot %d." % slot)
|
||||
_show_main_menu() if _save_load_mode == "load" else save_load_panel.set_status("Partie sauvegardée dans l’emplacement %d." % slot)
|
||||
else:
|
||||
save_load_panel.set_status(String(result.get("error", "Save operation failed.")))
|
||||
save_load_panel.set_status(String(result.get("error", "Échec de la sauvegarde.")))
|
||||
|
||||
func save_to_slot(slot: int) -> Dictionary:
|
||||
var game := get_node_or_null("Game") as Game
|
||||
@@ -122,17 +122,33 @@ func load_slot(slot: int) -> Dictionary:
|
||||
game.name = "Game"
|
||||
game.configure_loaded_run(loaded)
|
||||
add_child(game)
|
||||
_connect_game_navigation(game)
|
||||
menu.visible = false
|
||||
character_creation.visible = false
|
||||
return loaded
|
||||
|
||||
func _start_new_run(settings: RunSettings, player_name: String, base_archetype: StringName, race: StringName = &"race_humain_standard") -> void:
|
||||
func _start_new_run(settings: RunSettings, player_name: String) -> void:
|
||||
var game := GameScene.instantiate() as Game
|
||||
game.name = "Game"
|
||||
game.configure_new_run(settings, player_name, base_archetype, race)
|
||||
game.configure_new_run(settings, player_name)
|
||||
add_child(game)
|
||||
_connect_game_navigation(game)
|
||||
menu.visible = false
|
||||
character_creation.visible = false
|
||||
game.game_started.connect(func(started_settings: RunSettings, run_state: RunState) -> void:
|
||||
game_started.emit(started_settings, run_state)
|
||||
)
|
||||
|
||||
func _connect_game_navigation(game: Game) -> void:
|
||||
game.death_navigation_requested.connect(_on_death_navigation_requested.bind(game))
|
||||
game.save_requested.connect(show_save_slots)
|
||||
|
||||
func _on_death_navigation_requested(action: StringName, game: Game) -> void:
|
||||
if not is_instance_valid(game):
|
||||
return
|
||||
game.queue_free()
|
||||
_show_main_menu()
|
||||
if action == &"load":
|
||||
_show_load_slots()
|
||||
elif action == &"new_run":
|
||||
_show_character_creation()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class_name QuestPanel
|
||||
extends PanelContainer
|
||||
|
||||
@onready var title: Label = $Title
|
||||
@onready var body: RichTextLabel = $Body
|
||||
@onready var entries: RichTextLabel = $Entries
|
||||
@onready var title: Label = $Layout/Title
|
||||
@onready var body: RichTextLabel = $Layout/Body
|
||||
@onready var entries: RichTextLabel = $Layout/Entries
|
||||
|
||||
var _manager: QuestManager
|
||||
var _quest_ids: Array[StringName] = []
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
class_name RaceClassChoicePanel
|
||||
extends PanelContainer
|
||||
|
||||
signal race_confirmed(race_id: StringName)
|
||||
signal class_confirmed(class_id: StringName)
|
||||
|
||||
@onready var title: Label = $Layout/Title
|
||||
@onready var intro: Label = $Layout/Intro
|
||||
@onready var options: RichTextLabel = $Layout/Options
|
||||
|
||||
var _stage: StringName = &"race"
|
||||
var _choices: Array[Dictionary] = []
|
||||
var _selected_index := 0
|
||||
|
||||
func present_races(choices: Array[Dictionary]) -> void:
|
||||
_stage = &"race"
|
||||
_present(choices)
|
||||
|
||||
func present_classes(choices: Array[Dictionary]) -> void:
|
||||
_stage = &"class"
|
||||
_present(choices)
|
||||
|
||||
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
|
||||
var choice_id := StringName(_choices[_selected_index].get("id", ""))
|
||||
if _stage == &"race":
|
||||
race_confirmed.emit(choice_id)
|
||||
else:
|
||||
class_confirmed.emit(choice_id)
|
||||
|
||||
func stage() -> StringName:
|
||||
return _stage
|
||||
|
||||
func _present(choices: Array[Dictionary]) -> void:
|
||||
_choices = choices.duplicate(true)
|
||||
_selected_index = 0
|
||||
visible = true
|
||||
refresh()
|
||||
|
||||
func refresh() -> void:
|
||||
title.text = "NIVEAU 3 — CHOIX DE %s" % ("RACE" if _stage == &"race" else "CLASSE")
|
||||
intro.text = "Choisissez votre race, puis votre classe. Ce choix est permanent."
|
||||
var lines := PackedStringArray()
|
||||
for index in _choices.size():
|
||||
var choice := _choices[index]
|
||||
var marker := ">" if index == _selected_index else " "
|
||||
lines.append("%s %s" % [marker, String(choice.get("name", choice.get("id", "")))])
|
||||
var description := String(choice.get("description", ""))
|
||||
if not description.is_empty():
|
||||
lines.append(" %s" % description)
|
||||
options.text = "\n".join(lines) + "\n\nHaut/Bas : sélectionner Entrée : confirmer"
|
||||
@@ -0,0 +1 @@
|
||||
uid://chvjdg03j75dt
|
||||
@@ -18,7 +18,7 @@ func _ready() -> void:
|
||||
func present(mode: String, slot_metas: Array[Dictionary], message: String = "") -> void:
|
||||
_mode = mode
|
||||
visible = true
|
||||
title_label.text = "SAVE RUN" if mode == "save" else "LOAD RUN"
|
||||
title_label.text = "SAUVEGARDER LA PARTIE" if mode == "save" else "CHARGER UNE PARTIE"
|
||||
status_label.text = message
|
||||
for index in range(slots.get_child_count()):
|
||||
var button := slots.get_child(index) as Button
|
||||
@@ -39,5 +39,5 @@ func _request_slot(slot: int) -> void:
|
||||
func _label_for(meta: Dictionary) -> String:
|
||||
var slot := int(meta.get("slot", 0))
|
||||
if not bool(meta.get("exists", false)):
|
||||
return "SLOT %d — EMPTY" % slot
|
||||
return "SLOT %d — %s — FLOOR %d" % [slot, String(meta.get("character_name", "?")), int(meta.get("floor", 0))]
|
||||
return "EMPLACEMENT %d — VIDE" % slot
|
||||
return "EMPLACEMENT %d — %s — ÉTAGE %d" % [slot, String(meta.get("character_name", "?")), int(meta.get("floor", 0))]
|
||||
|
||||
@@ -64,4 +64,4 @@ func _refresh_label() -> void:
|
||||
return
|
||||
var target_id := target_ids[_selected_index]
|
||||
var cell: Vector2i = _targets[target_id]
|
||||
target_label.text = "Cible : %s (%d, %d) — Entrée pour tirer, Échap pour annuler" % [String(target_id).capitalize(), cell.x, cell.y]
|
||||
target_label.text = "Cible : %s (%d, %d) — Flèches : choisir • Entrée : tirer • Échap : annuler" % [String(target_id).capitalize(), cell.x, cell.y]
|
||||
|
||||
@@ -24,7 +24,7 @@ rm -f "$initial_capture_path" "$exit_capture_path"
|
||||
runner=()
|
||||
if [[ -z "${DISPLAY:-}" ]]; then
|
||||
if command -v xvfb-run >/dev/null 2>&1; then
|
||||
runner=(xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24")
|
||||
runner=(xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24")
|
||||
else
|
||||
echo "visual check unavailable: DISPLAY is unset and xvfb-run is not installed" | tee "$log_path" >&2
|
||||
exit 2
|
||||
|
||||
Reference in New Issue
Block a user