diff --git a/assets/ASSET_REGISTRY.md b/assets/ASSET_REGISTRY.md index 287c9ea..a742714 100644 --- a/assets/ASSET_REGISTRY.md +++ b/assets/ASSET_REGISTRY.md @@ -13,3 +13,7 @@ All binary art below is an unmodified 32×32 PNG copied from the local **Dungeon | `assets/dcss/stairs.png` | `dungeon/gateways/stone_stairs_up.png` | Dungeon Crawl Stone Soup Full | CC0 1.0 | none | | `assets/dcss/player.png` | `player/base/kobold_female_new.png` | Dungeon Crawl Stone Soup Full | CC0 1.0 | none | | `assets/dcss/goblin.png` | `monster/goblin_new.png` | Dungeon Crawl Stone Soup Full | CC0 1.0 | none | +| `assets/dcss/war_dog.png` | `monster/animals/war_dog.png` | Dungeon Crawl Stone Soup Full | CC0 1.0 | none | +| `assets/audio/dungeon_exploration.wav` | generated specifically for this project | Dungeon Crawler World project | original project asset | procedural synthesis, 2026-10-08 | +| `assets/audio/dungeon_combat.wav` | generated specifically for this project | Dungeon Crawler World project | original project asset | procedural synthesis, 2026-10-08 | +| `assets/audio/dungeon_danger.wav` | generated specifically for this project | Dungeon Crawler World project | original project asset | procedural synthesis, 2026-10-08 | diff --git a/assets/audio/dungeon_combat.wav b/assets/audio/dungeon_combat.wav new file mode 100644 index 0000000..ec1dd7d Binary files /dev/null and b/assets/audio/dungeon_combat.wav differ diff --git a/assets/audio/dungeon_danger.wav b/assets/audio/dungeon_danger.wav new file mode 100644 index 0000000..9145830 Binary files /dev/null and b/assets/audio/dungeon_danger.wav differ diff --git a/assets/audio/dungeon_exploration.wav b/assets/audio/dungeon_exploration.wav new file mode 100644 index 0000000..929a5fc Binary files /dev/null and b/assets/audio/dungeon_exploration.wav differ diff --git a/assets/dcss/war_dog.png b/assets/dcss/war_dog.png new file mode 100644 index 0000000..6250f83 Binary files /dev/null and b/assets/dcss/war_dog.png differ diff --git a/docs/PLAYING.md b/docs/PLAYING.md index a5feca0..df1c7b0 100644 --- a/docs/PLAYING.md +++ b/docs/PLAYING.md @@ -1,6 +1,6 @@ # Playing Dungeon Crawler World -Dungeon Crawler World is a desktop Godot prototype. It supports Linux x86_64 and Windows x86_64 exports. The reference display is 1280×720, but the window is resizable. +Dungeon Crawler World is a desktop Godot prototype. It supports Linux x86_64 and Windows x86_64 exports. The reference display is 1920×1080, but the window is resizable. ## Install or run @@ -38,7 +38,7 @@ The Linux script exports `build/linux/DungeonCrawlerWorld.x86_64` and smoke-laun Choose **NEW RUN** at the main menu, choose a character, then enter the dungeon. **CONTINUE** loads the most recently updated occupied slot; **LOAD SLOT** opens a specific slot. -The main menu exposes **CONTINUE** and **LOAD SLOT**. During an active run, the game API provides the five-slot Save/Load panel; builds that do not expose that command in the current UI should be treated as prototype builds and should not be represented as offering a player-facing manual-save shortcut. Saves are versioned JSON files below Godot's `user://saves` directory, named `slot1.json` through `slot5.json`. The exact native location is platform-dependent. To find it in a running build, open the Godot editor for the same project and use its user-data path, or inspect `ProjectSettings.globalize_path("user://")` from a debug tool. Copy the whole `saves` directory to back up a run; do not edit a save while the game is writing it. +La sauvegarde est **manuelle** : pendant une partie, appuyez sur **V** (fonctionne aussi dans le jeu lancé depuis l’éditeur Godot) ou sur **Ctrl+S** dans une version autonome, puis choisissez l’un des cinq emplacements. Un message confirme l’emplacement écrit. Il n’est pas nécessaire d’avoir un menu Échap et le ciblage ou l’ouverture du panneau de sauvegarde ne consomme aucun tour. Le menu principal expose **CONTINUE** et **LOAD SLOT** pour reprendre la sauvegarde la plus récente ou choisir un emplacement. Les sauvegardes sont des fichiers JSON versionnés dans `user://saves`, nommés `slot1.json` à `slot5.json`. Leur chemin natif dépend de la plateforme. Copiez le dossier `saves` complet pour sauvegarder vos parties hors jeu; ne modifiez pas un fichier pendant son écriture. The game recognizes its current schema and can migrate the supported parts of the supplied ASCII save shape. Unsupported legacy keys are reported rather than silently claimed as preserved. @@ -52,7 +52,9 @@ Press **F1** in a run for the current in-game control list. It is generated from | Move north-west / north-east / south-west / south-east | **Q / keypad 9 / Z / C** | | Interact, open doors/chests, use stairs | **Space** or **E** | | Wait | **.** | -| Melee / ranged / cast | **F / R / X** | +| Attaque de mêlée | Se déplacer vers la case d’un ennemi adjacent | +| Attaque à distance / lancer un sort | **F / X** | +| Sauvegarder manuellement | **V** dans le debug Godot, ou **Ctrl+S** en version autonome, puis choisir un emplacement | | Talk / rest | **T / H** | | Inventory / crafting | **I / B** | | Character / quests | **P / J** | @@ -63,13 +65,13 @@ Press **F1** in a run for the current in-game control list. It is generated from | Options / help | **O / F1** | | Expand journal | **L** (shares the achievements default) | -Several commands open contextual panels. Within selection panels, use arrows to select, **Enter** or **Space** to confirm, and **Esc** to close. In the inventory, use **E** to equip, **U** to use, and **D** to drop the selected item. In the shop, **Tab** changes buy/sell mode. The Options panel supports UI scaling, a high-contrast/color-blind marker mode, and remapping the Inventory control; its displayed keys control ambience and effects volume. +Plusieurs commandes ouvrent des panneaux contextuels. Dans les panneaux de sélection, utilisez les flèches pour choisir, **Entrée** ou **Espace** pour confirmer et **Échap** pour annuler. Avec une arme à distance équipée, **F** ouvre les cibles actuellement à portée et en ligne de vue; confirmer le tir consomme immédiatement un tour et les adversaires survivants se déplacent ou attaquent. **K** ouvre les ordres du familier : **Reste en arrière**, **Défends-moi** ou **Attaque à vue**. Dans l’inventaire, utilisez **E** pour équiper, **U** pour utiliser et **D** pour déposer. Dans la boutique, **Tab** change le mode achat/vente. -## Audio (optional) +## Musique et audio -The game works silently with no audio files. Playback only uses `AudioStream` resources registered in `user://audio/audio_import_manifest.tres`; it does not scan or decode arbitrary files from a directory. The manifest accepts these ambience contexts: `exploration`, `combat`, `danger`; and these SFX events: `attack_given`, `attack_received`, `menu_select`, `menu_cancel`, `item_use`, `death`. +Le jeu contient trois ambiances originales intégrées : exploration, combat et danger. L’exploration démarre automatiquement avec la partie et le contexte passe à la musique de combat lors d’un affrontement. Le panneau Options contrôle séparément les volumes Ambiance et Effets. -This is intentionally a safe, Godot-native setup boundary. A setup/modding tool must import a supported sound into Godot and register the resulting `AudioStream` in the manifest. The Options panel changes separate Ambience and SFX bus volumes; missing, invalid, or unregistered audio remains silent and never blocks gameplay. +La personnalisation reste sécurisée : le jeu ne parcourt et ne décode jamais des fichiers arbitraires. Un manifeste Godot optionnel dans `user://audio/audio_import_manifest.tres` peut remplacer individuellement les ressources intégrées avec des `AudioStream` déjà importés. Il reconnaît les contextes `exploration`, `combat`, `danger` et les effets `attack_given`, `attack_received`, `menu_select`, `menu_cancel`, `item_use`, `death`. Une entrée absente du manifeste utilisateur conserve la ressource intégrée correspondante. ## Known limitations diff --git a/docs/superpowers/plans/2026-10-07-playtest-parity-fixes.md b/docs/superpowers/plans/2026-10-07-playtest-parity-fixes.md new file mode 100644 index 0000000..0f8baf0 --- /dev/null +++ b/docs/superpowers/plans/2026-10-07-playtest-parity-fixes.md @@ -0,0 +1,116 @@ +# Playtest Parity Fixes Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Corriger les quatre écarts constatés en playtest concernant le jalon race/classe, la lisibilité de l’interface, la représentation du combat et le niveau principal. + +**Architecture:** Conserver les domaines existants et corriger les branchements qui les exposent. La création de partie reste limitée aux paramètres de run; un panneau modal dédié consomme `ClassEngine` à l’entrée de l’étage 3. Le monde affiché reste piloté par `FloorState`, mais la surface et le profil de l’étage 1 sont alignés sur `DCWASCII`. + +**Tech Stack:** Godot 4, GDScript, GUT 9.5. + +**Spec:** Retours de playtest du 2026-10-07 et projet de référence `../DCWASCII` (`dcw/game.py`, `dcw/world/surface.py`, `dcw/world/generator.py`). + +## Global Constraints + +- Préserver la modification locale préexistante de `project.godot`. +- Ne pas confondre le niveau principal avec la minimap. +- Les choix de race puis de classe sont obligatoires à l’entrée de l’étage 3 du Donjon, pas à la création ni au niveau de personnage 3. +- Une attaque de mêlée reste déclenchée uniquement en tentant d’entrer dans la case adjacente occupée. +- Les noms techniques et le code restent en anglais. + +--- + +### Task 1: Jalon race et classe de l’étage 3 + +**Files:** +- Modify: `scenes/menu/CharacterCreation.tscn` +- Modify: `scripts/presentation/menu/character_creation.gd` +- Modify: `scripts/presentation/menu/main_menu.gd` +- Modify: `scripts/game/game.gd` +- Modify: `scripts/domain/progression/class_engine.gd` +- Modify: `scripts/domain/run/run_state.gd` +- Create: `scenes/ui/RaceClassChoicePanel.tscn` +- Create: `scripts/presentation/race_class_choice_panel.gd` +- Test: `tests/e2e/test_new_run_creation_e2e.gd` +- Test: `tests/e2e/test_floor_three_race_class_e2e.gd` + +**Interfaces:** +- Consumes: `ClassEngine.race_definitions()`, compatibility rules, `FloorTransition.transition()`. +- Produces: a mandatory `RaceClassChoicePanel`, an initially empty race/archetype, and a persisted `RunState.base_archetype` after confirmation. + +- [ ] Add a failing creation-flow test proving there are no race/class controls and the new player has empty choices. +- [ ] Remove race/class fields and arguments from the creation flow. +- [ ] Add a failing floor-transition test proving entry to floor 3 opens a mandatory race-first modal. +- [ ] Add separate race and class application methods to `ClassEngine` and implement the modal sequence. +- [ ] Verify both focused E2E tests. + +### Task 2: HUD and chest layout + +**Files:** +- Modify: `scenes/Game.tscn` +- Modify: `scenes/ui/LootPanel.tscn` +- Test: `tests/unit/test_hud_layout.gd` +- Test: `tests/unit/test_loot_panel_layout.gd` + +**Interfaces:** +- Consumes: existing HUD node paths retained for compatibility. +- Produces: non-overlapping visible rectangles at 1280×720. + +- [ ] Add failing rectangle-intersection assertions for all visible HUD labels and chest panel sections. +- [ ] Give each visible HUD datum a distinct row and sufficient wrapping space. +- [ ] Put chest title, entries and action inside a vertical layout container. +- [ ] Verify focused layout tests. + +### Task 3: Combat presentation and action wording + +**Files:** +- Modify: `scripts/game/game.gd` +- Modify: `scripts/domain/turn_resolver.gd` +- Test: `tests/e2e/test_enemy_ai_e2e.gd` +- Test: `tests/unit/test_turn_resolver.gd` + +**Interfaces:** +- Consumes: authoritative `ActorState.cell` positions and equipped main-hand metadata when available. +- Produces: synchronized enemy sprites after every resolved turn and melee messages that name the attack method. + +- [ ] Add a failing E2E assertion that an enemy view follows the enemy state after movement. +- [ ] Resynchronize enemy views during player-action presentation updates. +- [ ] Add failing assertions that melee messages identify bare hands, equipped weapon, or natural attack while retaining damage wording. +- [ ] Add attack-method metadata to result messages without changing melee range rules. +- [ ] Verify focused combat tests. + +### Task 4: Surface and procedural dungeon + +**Files:** +- Modify: `scripts/domain/world/surface_generator.gd` +- Modify: `scripts/domain/world/floor_generator.gd` +- Modify: `scripts/game/game.gd` +- Modify: `tests/unit/test_surface_floor_transition.gd` +- Modify: `tests/unit/test_floor_generator_rooms.gd` +- Replace: `tests/unit/test_demo_map.gd` +- Replace: `tests/e2e/test_demo_map_chest_e2e.gd` + +**Interfaces:** +- Consumes: reference surface contract (42×16, empty zone, corridor, door, stairs) and regular procedural formula `180 + floor*30`, `90 + floor*15`, `150 + floor*20`. +- Produces: the true reference surface at floor 0 and a 210×105, 170-room procedural floor 1. + +- [ ] Add failing surface assertions for dimensions, empty population, entrance, door and stairs. +- [ ] Port the reference surface geometry. +- [ ] Add failing floor-1 profile assertions for map size and room target. +- [ ] Remove the obsolete shallow floor-1 profile and dead duplicate POC construction. +- [ ] Replace POC route tests with surface-to-generated-dungeon behavior tests. +- [ ] Verify world unit, integration and E2E tests. + +### Task 5: Regression verification + +**Files:** +- Modify only tests whose old expectations explicitly encoded the removed POC or creation-time class choice. + +**Interfaces:** +- Consumes: `scripts/verify.sh` and focused GUT runners. +- Produces: passing unit, integration, E2E and visual verification without modifying `project.godot`. + +- [ ] Run focused suites after every red/green cycle. +- [ ] Run `git diff --check`. +- [ ] Run `./scripts/verify.sh`. +- [ ] Inspect the regenerated visual captures for the main level, HUD and chest panel. diff --git a/docs/superpowers/plans/2026-10-08-health-regeneration-and-pets.md b/docs/superpowers/plans/2026-10-08-health-regeneration-and-pets.md new file mode 100644 index 0000000..d67d659 --- /dev/null +++ b/docs/superpowers/plans/2026-10-08-health-regeneration-and-pets.md @@ -0,0 +1,107 @@ +# Health Regeneration and Pets Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Porter dans le jeu Godot la régénération passive automatique des PV et rendre le familier créé avec la partie réellement configurable, persistant et utile en exploration/combat, conformément aux comportements de référence de DCWASCII. + +**Architecture:** La formule de régénération reste une règle de domaine pure, appelée une seule fois à la fin de chaque tour résolu et appliquée silencieusement au joueur puis au familier vivant. Le familier reste l’agrégat `CompanionState` existant, enrichi avec son identité, ses caractéristiques de régénération et une IA agressive/défensive/soutien; la création, les transitions d’étage, l’UI et la sauvegarde consomment cet agrégat sans dupliquer les règles. + +**Tech Stack:** Godot 4.7, GDScript, GUT 9.5, scènes `.tscn`, sauvegardes JSON. + +**Spec:** Référence fonctionnelle `../DCWASCII/README.md` sections « Familier jouable » et « Système de soins », ainsi que `../DCWASCII/dcw/entities/{player,companion}.py`, `../DCWASCII/dcw/game.py`, `../DCWASCII/dcw/ai/companion_behaviors.py`. + +## Global Constraints + +- Préserver tous les changements locaux déjà présents; ne pas réinitialiser ni réécrire les modifications non liées. +- Régénération ASCII: `max(1, Endurance / 3)`, bonus `regen_bonus`, amplification de 15 % par rang de compétence Régénération au-delà du rang de base 1, puis multiplicateur de difficulté (1,5 / 1 / 0,75 / 0,5). +- La régénération est silencieuse, plafonnée aux PV max, active dès le niveau 1, une fois par tour consommé, et ne ranime jamais une entité morte. +- Le familier est optionnel, autonome, persistant, suit le joueur entre les étages et sa mort ne termine pas la partie. +- Conserver les coutures publiques et les sauvegardes existantes compatibles. + +--- + +### Task 1: Passive health regeneration rule + +**Files:** +- Create: `scripts/domain/combat/health_regeneration.gd` +- Test: `tests/unit/test_health_regeneration.gd` + +**Interfaces:** +- Produces: `HealthRegeneration.amount(endurance: int, regeneration_skill: int, perk_bonus: int, difficulty_id: StringName) -> int` +- Produces: `HealthRegeneration.apply(actor: ActorState, endurance: int, regeneration_skill: int, perk_bonus: int, difficulty_id: StringName) -> int` + +- [ ] **Step 1: Write the failing formula and cap/death tests** +- [ ] **Step 2: Run the focused test and confirm RED because the rule does not exist** +- [ ] **Step 3: Implement the exact ASCII formula and difficulty multipliers** +- [ ] **Step 4: Run the focused test and confirm GREEN** + +### Task 2: End-of-turn regeneration integration + +**Files:** +- Modify: `scripts/game/game.gd` +- Modify: `scripts/domain/entities/companion_state.gd` +- Test: `tests/e2e/test_health_regeneration_e2e.gd` + +**Interfaces:** +- Consumes: `HealthRegeneration.apply(...)` +- Produces: automatic, silent player/pet healing through normal `submit_player_action` gameplay turns. + +- [ ] **Step 1: Add an E2E test that damages the player, consumes real movement turns and observes exact healing without a regeneration journal event** +- [ ] **Step 2: Run it and confirm RED because completed turns do not heal** +- [ ] **Step 3: Add one centralized end-of-turn hook using the character model’s effective Endurance/skill/perk values and the run difficulty** +- [ ] **Step 4: Extend the test to a living pet and confirm dead actors remain at zero** +- [ ] **Step 5: Run focused unit/E2E tests and confirm GREEN** + +### Task 3: Configurable pet identity and persistence + +**Files:** +- Modify: `scripts/domain/run/run_settings.gd` +- Modify: `scripts/domain/entities/companion_state.gd` +- Modify: `scripts/presentation/menu/character_creation.gd` +- Modify: `scenes/menu/CharacterCreation.tscn` +- Modify: `scripts/infrastructure/save/save_repository.gd` +- Modify: `scripts/presentation/companion_panel.gd` +- Test: `tests/unit/test_companion.gd` +- Test: `tests/unit/test_save_repository.gd` +- Test: `tests/e2e/test_new_run_creation_e2e.gd` + +**Interfaces:** +- Produces: optional `RunSettings.pet_name` and `RunSettings.pet_species`, with backward-compatible defaults. +- Produces: `CompanionState.name`, `species`, Endurance/skill/perk regeneration fields serialized with the companion. + +- [ ] **Step 1: Add failing tests for identity defaults/custom values and save/load round-trip** +- [ ] **Step 2: Run focused tests and confirm RED** +- [ ] **Step 3: Add name/species fields shown only when the pet checkbox is enabled and pass them through `RunSettings`** +- [ ] **Step 4: Persist the complete companion record while accepting legacy companion records** +- [ ] **Step 5: Show name, species and PV in the companion panel** +- [ ] **Step 6: Run focused tests and confirm GREEN** + +### Task 4: Functional autonomous pet behavior and floor following + +**Files:** +- Modify: `scripts/domain/ai/companion_behaviors.gd` +- Modify: `scripts/domain/turn_resolver.gd` +- Modify: `scripts/game/game.gd` +- Test: `tests/unit/test_companion.gd` +- Test: `tests/e2e/test_pet_companion_e2e.gd` + +**Interfaces:** +- Consumes: existing stances `FOLLOW`, `DEFEND`, `SUPPORT` as backward-compatible storage identifiers. +- Produces: aggressive chase/attack for `FOLLOW`, threat interception for `DEFEND`, low-PV player healing for `SUPPORT`, nearest-target enemy attacks, and adjacent pet placement after floor changes. + +- [ ] **Step 1: Add one failing behavior test for aggressive chase and one for support healing** +- [ ] **Step 2: Run focused tests and confirm RED for the missing decisions** +- [ ] **Step 3: Implement deterministic nearest-enemy pursuit and a bounded support-heal action** +- [ ] **Step 4: Resolve heal actions and make enemies pursue/attack the nearer living player or pet, with ties favoring the pet** +- [ ] **Step 5: Add an E2E floor-transition assertion that the pet is placed next to the player** +- [ ] **Step 6: Run pet unit/integration/E2E tests and confirm GREEN** + +### Task 5: Verification and parity evidence + +**Files:** +- Modify: `docs/parity/ASCII_TEST_MATRIX.md` only if a new explicit mapping row/note is required. + +- [ ] **Step 1: Run unit tests for regeneration, companions, settings and saves** +- [ ] **Step 2: Run pet/new-run/regeneration E2E tests** +- [ ] **Step 3: Run the project verification script and inspect failures** +- [ ] **Step 4: Confirm `git diff --check` and review the final diff for unrelated changes** diff --git a/docs/superpowers/plans/2026-10-08-save-ranged-pet-controls.md b/docs/superpowers/plans/2026-10-08-save-ranged-pet-controls.md new file mode 100644 index 0000000..74ee7a4 --- /dev/null +++ b/docs/superpowers/plans/2026-10-08-save-ranged-pet-controls.md @@ -0,0 +1,103 @@ +# Save, Ranged Combat, and Pet Controls Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Rendre la sauvegarde accessible sans menu Échap, déplacer l’attaque à distance sur `F` avec sélection de cible et tour ennemi immédiat, puis exposer trois comportements de familier en français avec un sprite temporaire de chien. + +**Architecture:** Le menu principal reste le propriétaire du `SaveRepository`, mais le jeu actif lui demande d’ouvrir le panneau de sauvegarde par signal afin d’éviter un second dépôt et de conserver les cinq emplacements existants. Le ciblage à distance continue d’utiliser `RangedCombat` et `TargetingOverlay`; seules la touche, la validation des cibles et la résolution complète du tour sont renforcées. Les identifiants persistés des postures du familier restent compatibles, tandis que leurs libellés et règles deviennent « reste en arrière », « défends-moi » et « attaque à vue ». + +**Tech Stack:** Godot 4.7, GDScript, GUT 9.5, scènes `.tscn`, sauvegardes JSON. + +**Spec:** Retour de playtest utilisateur du 2026-10-08. + +## Global Constraints + +- Préserver tous les changements locaux déjà présents; ne pas réinitialiser ni réécrire les modifications non liées. +- L’attaque à distance se déclenche sur `F` seulement si une arme à distance est équipée; `Entrée` confirme et `Échap` annule la cible sans consommer de tour. +- Une attaque à distance valide consomme exactement un tour et fait immédiatement résoudre le déplacement ou l’attaque des adversaires survivants. +- Les trois comportements visibles du familier sont « Reste en arrière », « Défends-moi » et « Attaque à vue ». +- Le familier utilise temporairement un sprite animal de type chien compatible avec la licence CC0 existante. +- Conserver la lecture des anciennes sauvegardes et des anciennes valeurs de posture. + +--- + +### Task 1: Sauvegarde accessible et explicite + +**Files:** +- Modify: `project.godot` +- Modify: `scripts/game/input_bindings.gd` +- Modify: `scripts/game/game.gd` +- Modify: `scripts/presentation/menu/main_menu.gd` +- Modify: `scripts/presentation/save_load_panel.gd` +- Modify: `scenes/ui/SaveLoadPanel.tscn` +- Modify: `tests/unit/test_action_router.gd` +- Modify: `tests/e2e/test_save_load_e2e.gd` +- Modify: `docs/PLAYING.md` + +**Interfaces:** +- Produces: input action `save` on `Ctrl+S`, routed as `PlayerAction(&"save")`. +- Produces: `Game.save_requested` connected by `MainMenu` to `show_save_slots()`. +- Produces: French save-panel feedback that states that saves are manual and confirms the slot written. + +- [ ] Add a failing action-router assertion for `save` and an E2E test that `Ctrl+S` opens the save-slot panel during a run. +- [ ] Add the input binding/help label and the `Game.save_requested` signal branch. +- [ ] Connect the game signal in `MainMenu` and keep repository ownership there. +- [ ] Translate/clarify save-panel labels and update the player documentation. +- [ ] Run focused action-router and save/load tests. + +### Task 2: Attaque à distance sur F et tour ennemi + +**Files:** +- Modify: `project.godot` +- Modify: `scripts/game/input_bindings.gd` +- Modify: `scripts/game/game.gd` +- Modify: `scripts/presentation/targeting_overlay.gd` +- Modify: `tests/e2e/test_ranged_targeting_e2e.gd` +- Modify: `tests/e2e/test_input_action_router_e2e.gd` +- Modify: `docs/PLAYING.md` + +**Interfaces:** +- Produces: `F` bound to `ranged`; the obsolete standalone `attack` input is removed because melee remains movement into an adjacent enemy. +- Produces: targeting candidates filtered by weapon range and line of sight. +- Consumes: `TurnResolver.append_enemy_response(...)` for every valid shot against a surviving enemy. + +- [ ] Add failing E2E assertions proving `F` opens targeting, invalid/no-weapon input does not consume a turn, cancellation does not consume a turn, and a valid shot advances exactly one turn while the enemy approaches. +- [ ] Move `ranged` from `R` to `F` and remove the conflicting unused `attack` action from the input catalog/map. +- [ ] Filter displayed targets through `RangedCombat` validation without consuming ammunition. +- [ ] Keep confirmation/cancellation explicit in French and resolve one enemy response after a valid shot. +- [ ] Run focused ranged, input, turn-resolver, and combat tests. + +### Task 3: Comportements du familier et sprite chien + +**Files:** +- Modify: `scripts/domain/entities/companion_state.gd` +- Modify: `scripts/domain/ai/companion_behaviors.gd` +- Modify: `scripts/domain/turn_resolver.gd` +- Modify: `scripts/infrastructure/save/save_repository.gd` +- Modify: `scripts/presentation/companion_panel.gd` +- Modify: `scenes/Game.tscn` +- Create: `assets/dcss/war_dog.png` +- Modify: `assets/ASSET_REGISTRY.md` +- Modify: `tests/unit/test_companion.gd` +- Modify: `tests/e2e/test_pet_companion_e2e.gd` + +**Interfaces:** +- Produces: persistent stances `stay_back`, `defend`, `attack_on_sight`, while mapping legacy `follow`, `defend`, `support` values. +- Produces: behavior rules where `stay_back` follows without engaging, `defend` attacks threats adjacent to the player, and `attack_on_sight` pursues the nearest living enemy. +- Produces: French UI labels/descriptions and `assets/dcss/war_dog.png` on `$World/Companion`. + +- [ ] Add failing deterministic unit tests for the three named policies and an E2E panel-selection test for their French labels. +- [ ] Define the new stance identifiers and compatibility aliases/migration. +- [ ] Implement passive following, player defense, and nearest-enemy aggression. +- [ ] Replace support-only interception checks with the defend stance and update journal wording. +- [ ] Copy the local CC0 DCSS war-dog tile, wire it to the companion sprite, and register its source/license. +- [ ] Run focused companion, support-compatibility, save, and pet E2E tests. + +### Task 4: Vérification + +**Files:** +- Modify: `docs/parity/ASCII_TEST_MATRIX.md` only if a mapped contract needs an explicit note. + +- [ ] Run all unit, integration, and E2E suites. +- [ ] Run the visual check and inspect the companion sprite and new HUD/help wording. +- [ ] Run `git diff --check` and inspect the final diff for unrelated changes. diff --git a/docs/superpowers/plans/2026-10-08-temporary-starting-playtest-chests.md b/docs/superpowers/plans/2026-10-08-temporary-starting-playtest-chests.md new file mode 100644 index 0000000..8d648da --- /dev/null +++ b/docs/superpowers/plans/2026-10-08-temporary-starting-playtest-chests.md @@ -0,0 +1,57 @@ +# Temporary Starting Playtest Chests Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Garantir temporairement trois coffres dans la salle de départ d’une nouvelle partie pour tester la mêlée, la distance et un sort offensif. + +**Architecture:** Un module `TemporaryPlaytestKit` isolé place trois coffres à récompense fixe sur l’étage de surface. `Game` l’appelle uniquement lors d’une nouvelle partie configurée, jamais lors du chargement d’une sauvegarde ni dans le générateur procédural. Les récompenses utilisent le flux normal des coffres; le payload de distance ajoute des munitions et le grimoire utilise l’effet normal `learn_spell`. + +**Tech Stack:** Godot 4.5, GDScript, GUT. + +**Spec:** Retour de playtest du 2026-10-08. + +## Global Constraints + +- Code explicitement temporaire et supprimable dans un fichier autonome. +- Exactement trois coffres de playtest sur une nouvelle surface. +- Aucun changement aux tables de loot ou aux étages procéduraux. +- Les sauvegardes chargées ne recréent pas les coffres. +- Récompenses fixes : mêlée, distance avec munitions, grimoire offensif. + +--- + +### Task 1: Fixture temporaire de coffres + +**Files:** +- Create: `scripts/game/temporary_playtest_kit.gd` +- Modify: `scripts/game/game.gd` +- Create: `tests/e2e/test_temporary_playtest_chests_e2e.gd` + +**Interfaces:** +- Produces: `TemporaryPlaytestKit.apply_to_new_run(floor: FloorState) -> void`. + +- [ ] Écrire un test E2E rouge instanciant une nouvelle partie et exigeant trois coffres fixes accessibles. +- [ ] Créer le module isolé avec trois cellules, trois récompenses et un marqueur metadata temporaire. +- [ ] Appeler le module seulement dans le chemin de nouvelle partie configurée. +- [ ] Vérifier qu’un chargement ne recrée aucun coffre. + +### Task 2: Récompenses réellement testables + +**Files:** +- Modify: `scripts/game/game.gd` +- Modify: `tests/e2e/test_temporary_playtest_chests_e2e.gd` + +**Interfaces:** +- Consumes: payload coffre `ammunition` et effet d’objet `learn_spell`. +- Produces: munitions ajoutées lors de la récupération; `SpellState.learn(spell_id)` lors de l’utilisation du grimoire. + +- [ ] Tester l’ouverture/récupération normale de chaque coffre. +- [ ] Ajouter les munitions du payload à `ActorState.ammunition` dans `_take_all_loot`. +- [ ] Après `InventoryState.use_item`, appliquer les effets `learn_spell` acceptés à `spell_state`. +- [ ] Vérifier qu’on peut équiper l’arme à distance, cibler avec F, et sélectionner le sort avec X après lecture. + +### Task 3: Vérification + +- [ ] Exécuter les tests ciblés coffre/inventaire/distance/magie. +- [ ] Exécuter les suites unitaires et E2E. +- [ ] Exécuter `git diff --check` et vérifier que le code temporaire reste contenu dans son module. diff --git a/docs/superpowers/plans/2026-10-08-ui-input-loot-1080p-fixes.md b/docs/superpowers/plans/2026-10-08-ui-input-loot-1080p-fixes.md new file mode 100644 index 0000000..c0cbc90 --- /dev/null +++ b/docs/superpowers/plans/2026-10-08-ui-input-loot-1080p-fixes.md @@ -0,0 +1,144 @@ +# UI, Input, Loot, and 1080p Fixes Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Corriger les panneaux à choix illisibles, rendre la sauvegarde accessible depuis le jeu embarqué dans l’éditeur, fiabiliser les flèches de déplacement, diversifier les coffres, matérialiser le butin des ennemis et migrer l’affichage de référence vers 1920×1080. + +**Architecture:** Les panneaux modaux utilisent des conteneurs de mise en page plutôt que des offsets concurrents. Le routeur d’entrée conserve l’InputMap, mais expose une touche de sauvegarde sans modificateur qui n’est pas interceptée par l’éditeur et verrouille un seul déplacement par pression physique. Le résolveur de butin interdit de sélectionner deux fois le même objet pendant une résolution, tandis qu’une étape post-combat unique dans `Game` matérialise les tables de butin sur la cellule de mort pour toutes les voies létales. La résolution de référence devient un contrat 1920×1080 partagé par le projet, les tests et la capture visuelle. + +**Tech Stack:** Godot 4.5, GDScript, GUT 9.5, scènes `.tscn`, JSON de contenu, scripts Bash/Python de vérification visuelle. + +**Spec:** Retours de playtest et capture fournis le 2026-10-08. + +## Global Constraints + +- Préserver les nombreuses modifications locales déjà présentes et ne pas réinitialiser les fichiers hors périmètre. +- Les PNJ ne sont jamais des cibles de combat ou des sources de butin ennemi. +- Les corrections restent déterministes pour un seed et un contexte identiques. +- Les objets d’ennemis doivent être visibles au sol et passer par le flux de ramassage existant. +- Le viewport, la fenêtre de référence et les captures deviennent exactement 1920×1080. +- Les panneaux ne doivent plus superposer le récit, les choix et l’aide, y compris avec du texte long. + +--- + +### Task 1: Résolution de référence 1920×1080 + +**Files:** +- Modify: `project.godot` +- Modify: `scripts/game/game.gd` +- Modify: `scripts/check-visual-capture.py` +- Modify: `scripts/run-visual-check.sh` +- Modify: `scripts/build-linux.sh` +- Modify: `tests/scripts/test_godot_import_runners.sh` +- Modify: `tests/unit/test_display_layout.gd` +- Modify: `tests/e2e/test_display_camera_grid_e2e.gd` +- Modify: `tests/unit/test_hud_layout.gd` +- Modify: `docs/PLAYING.md` + +**Interfaces:** +- Produces: `Game.REFERENCE_VIEWPORT == Vector2i(1920, 1080)`. +- Produces: exact 1920×1080 PNG visual captures and smoke displays. + +- [ ] Add failing assertions for the new project and `Game` reference dimensions. +- [ ] Change project viewport/window overrides and the public game constant. +- [ ] Update Xvfb, fake PNG and PNG validation dimensions; derive the measured dungeon crop from the new dimensions. +- [ ] Re-express the central HUD clearance area relative to `REFERENCE_VIEWPORT`. +- [ ] Run display, HUD, E2E camera and script-runner tests. + +### Task 2: Panneaux de choix adaptatifs et non chevauchants + +**Files:** +- Modify: `scenes/ui/EventPanel.tscn` +- Modify: `scenes/ui/DialoguePanel.tscn` +- Modify: `scenes/ui/QuestPanel.tscn` +- Modify: `scripts/presentation/event_panel.gd` +- Modify: `scripts/presentation/dialogue_panel.gd` +- Modify: `scripts/presentation/quest_panel.gd` +- Modify: affected E2E node paths +- Create: `tests/unit/test_choice_panel_layout.gd` + +**Interfaces:** +- Produces: each modal as `PanelContainer > VBoxContainer Layout > Title, Body, Entries, Help`. +- Produces: distinct, contained narrative, choice and help rectangles at 1920×1080. + +- [ ] Write a failing rectangle test with representative multiline narrative and choices for Event, Dialogue and Quest. +- [ ] Replace direct children and absolute offsets with one `VBoxContainer`, content margins and explicit vertical allocation. +- [ ] Update scripts and E2E paths from `$Body`/`$Entries` to `$Layout/Body`/`$Layout/Entries`. +- [ ] Verify at least 12 px logical separation and containment after two layout frames. +- [ ] Run choice-panel, dialogue, event and quest tests. + +### Task 3: Sauvegarde utilisable depuis le debug embarqué et entrée fiable + +**Files:** +- Modify: `project.godot` +- Modify: `scripts/game/input_bindings.gd` +- Modify: `scripts/game/action_router.gd` +- Modify: `scripts/game/game.gd` +- Modify: `scenes/Game.tscn` +- Modify: `tests/unit/test_action_router.gd` +- Modify: `tests/e2e/test_save_load_e2e.gd` +- Modify: `tests/e2e/test_input_action_router_e2e.gd` +- Modify: `docs/PLAYING.md` + +**Interfaces:** +- Consumes: existing `save` player action and `Game.save_requested` signal. +- Produces: `V` as editor-safe save shortcut while retaining `Ctrl+S` for standalone/exported builds. +- Produces: one movement action per non-echo physical arrow press. + +- [ ] Add a failing E2E test that opens save slots with plain `V` through real input. +- [ ] Add `V` as a second `save` binding and document why `Ctrl+S` is intercepted by the Godot editor’s own Save command in embedded play. +- [ ] Add a repeated alternating Up/Down E2E test proving every press is routed once and echo events do not create or swallow actions. +- [ ] Handle arrow physical keycodes deterministically before ambiguous action matching and ignore `InputEventKey.echo` for turn commands. +- [ ] Update the HUD/help text and run action/input/save tests. + +### Task 4: Coffres sans objets répétés + +**Files:** +- Modify: `scripts/domain/items/loot_resolver.gd` +- Modify: `scripts/domain/world/floor_populator.gd` +- Modify: `tests/unit/test_loot_resolver.gd` +- Modify: `tests/unit/test_floor_populator.gd` +- Modify: `tests/e2e/test_world_chest_loot_e2e.gd` + +**Interfaces:** +- Produces: `LootResolver.resolve(...)` selects each `item_id` at most once per reward; explicit `min_qty/max_qty` remains the sole source of quantity. +- Produces: ordinary treasure rooms use `floor_treasure`, not arbitrary enemy or boss tables. + +- [ ] Add a failing dominant-weight multi-roll test showing the same item is currently selected twice. +- [ ] Filter already-selected item IDs from subsequent weighted rolls while leaving gold/empty repeatable. +- [ ] Assert that generated treasure chests use the floor treasure table. +- [ ] Run resolver, chest, population and deterministic-generation tests. + +### Task 5: Butin ennemi matérialisé et ramassable + +**Files:** +- Modify: `scripts/game/game.gd` +- Modify: `scripts/domain/magic/magic_engine.gd` +- Modify: `scripts/presentation/loot_feedback.gd` +- Modify: `tests/e2e/test_melee_feedback_e2e.gd` +- Modify: `tests/e2e/test_ranged_targeting_e2e.gd` +- Modify: `tests/e2e/test_spell_casting_e2e.gd` +- Modify: `tests/unit/test_save_repository.gd` + +**Interfaces:** +- Produces: one post-combat materialization step that resolves each `loot_dropped` descriptor exactly once. +- Produces: valid `ItemInstance` entries in `FloorState.ground_items[death_cell]` and immediate run gold credit. +- Produces: resolved `loot_dropped` payload containing `loot_table`, `items`, `gold`, and `empty`. + +- [ ] Add a failing melee E2E assertion that a catalog-backed killed enemy leaves a ground item at its death cell. +- [ ] Resolve the enemy loot table using a stable `enemy::` context before event journaling, create item instances, add them to `ground_items`, and credit gold. +- [ ] Add the missing loot descriptor to lethal spell outcomes so magic shares the same post-combat pipeline. +- [ ] Verify melee, ranged, companion and spell deaths each materialize once, and the existing interaction picks the item up. +- [ ] Verify save/load round-trips the generated drop and update feedback wording from “secured” to “dropped”. + +### Task 6: Verification complète + +**Files:** +- Modify: no production files unless a verified regression requires it. + +- [ ] Run all unit tests. +- [ ] Run all integration tests. +- [ ] Run all E2E tests. +- [ ] Run visual capture and inspect both 1920×1080 images. +- [ ] Run matrix parity gate and `git diff --check`. +- [ ] Review the final diff for unrelated or generated temporary files. diff --git a/project.godot b/project.godot index ce50b8d..2147165 100644 --- a/project.godot +++ b/project.godot @@ -1,56 +1,192 @@ ; Engine configuration file. -; GUT 9.5.0 is pinned under addons/gut. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + config_version=5 [application] + config/name="Dungeon Crawler World" run/main_scene="res://scenes/menu/MainMenu.tscn" +config/features=PackedStringArray("4.7") [display] -window/size/viewport_width=1280 -window/size/viewport_height=720 -window/size/window_width_override=1280 -window/size/window_height_override=720 -window/size/resizable=true + +window/size/viewport_width=1920 +window/size/viewport_height=1080 +window/size/window_width_override=1920 +window/size/window_height_override=1080 window/stretch/mode="canvas_items" -[rendering] -renderer/rendering_method="gl_compatibility" -renderer/rendering_method.mobile="gl_compatibility" -textures/default_filters/use_nearest_mipmap_filter=false -textures/canvas_textures/default_texture_filter=0 - [editor_plugins] + enabled=PackedStringArray("res://addons/gut/plugin.cfg") [input] -interact={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":32),Object(InputEventKey,"physical_keycode":69)]} -move_north={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":87),Object(InputEventKey,"physical_keycode":4194320)]} -move_south={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":83),Object(InputEventKey,"physical_keycode":4194322)]} -move_west={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":65),Object(InputEventKey,"physical_keycode":4194319)]} -move_east={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":68),Object(InputEventKey,"physical_keycode":4194321)]} -move_northwest={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":81)]} -move_northeast={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":4194447)]} -move_southwest={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":90)]} -move_southeast={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":67)]} -wait={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":46)]} -attack={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":70)]} -ranged={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":82)]} -cast={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":88)]} -talk={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":84)]} -rest={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":72)]} -inventory={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":73)]} -crafting={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":66)]} -character={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":80)]} -quest={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":74)]} -companion={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":75)]} -party={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":71)]} -achievements={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":76)]} -audience={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":85)]} -recap={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":89)]} -factions={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":77)]} -moderation={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":78)]} -map={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":4194308)]} -help={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":4194332)]} -toggle_log={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":76)]} -options={"deadzone":0.5,"events":[Object(InputEventKey,"physical_keycode":79)]} + +interact={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_north={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_south={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_west={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_east={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_northwest={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_northeast={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194447,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_southwest={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +move_southeast={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +wait={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":46,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +ranged={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +save={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +cast={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +talk={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":84,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +rest={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":72,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +inventory={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +crafting={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +character={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +quest={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":74,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +companion={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":75,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +party={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":71,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +achievements={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +audience={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +recap={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":89,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +factions={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +moderation={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":78,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +map={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194308,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +help={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194332,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +toggle_log={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +options={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} + +[rendering] + +textures/canvas_textures/default_texture_filter=0 +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/scenes/Game.tscn b/scenes/Game.tscn index bf1a67e..083adc3 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=20 format=3] +[gd_scene load_steps=24 format=3] [ext_resource type="Script" path="res://scripts/game/game.gd" id="1_game"] [ext_resource type="Script" path="res://scripts/presentation/map_renderer.gd" id="2_map"] [ext_resource type="Script" path="res://scripts/presentation/actor_view.gd" id="3_actor"] [ext_resource type="Script" path="res://scripts/presentation/hud.gd" id="4_hud"] [ext_resource type="Texture2D" path="res://assets/dcss/player.png" id="5_player"] +[ext_resource type="Texture2D" path="res://assets/dcss/war_dog.png" id="35_companion"] [ext_resource type="Script" path="res://scripts/infrastructure/audio_library.gd" id="6_audio"] [ext_resource type="Script" path="res://scripts/presentation/event_presenter.gd" id="7_presenter"] [ext_resource type="PackedScene" path="res://scenes/overlays/CombatFeedback.tscn" id="8_feedback"] @@ -23,6 +24,7 @@ [ext_resource type="PackedScene" path="res://scenes/ui/PartyPanel.tscn" id="19_party"] [ext_resource type="PackedScene" path="res://scenes/ui/CharacterPanel.tscn" id="20_character"] [ext_resource type="PackedScene" path="res://scenes/ui/ProgressionChoicePanel.tscn" id="21_progression_choice"] +[ext_resource type="PackedScene" path="res://scenes/ui/RaceClassChoicePanel.tscn" id="34_race_class_choice"] [ext_resource type="PackedScene" path="res://scenes/ui/AchievementPanel.tscn" id="22_achievement"] [ext_resource type="PackedScene" path="res://scenes/ui/AudiencePanel.tscn" id="23_audience"] [ext_resource type="PackedScene" path="res://scenes/ui/RecapPanel.tscn" id="24_recap"] @@ -50,6 +52,25 @@ content_margin_top = 8.0 content_margin_right = 12.0 content_margin_bottom = 8.0 +[sub_resource type="StyleBoxFlat" id="StyleBox_xp_background"] +bg_color = Color(0.025, 0.055, 0.075, 1) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.35, 0.48, 0.62, 1) +corner_radius_top_left = 4 +corner_radius_top_right = 4 +corner_radius_bottom_right = 4 +corner_radius_bottom_left = 4 + +[sub_resource type="StyleBoxFlat" id="StyleBox_xp_fill"] +bg_color = Color(0.35, 0.72, 1, 1) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 + [sub_resource type="StyleBoxFlat" id="StyleBox_prompt_panel"] bg_color = Color(0.08, 0.12, 0.16, 0.94) border_width_left = 2 @@ -92,8 +113,7 @@ script = ExtResource("3_actor") [node name="Enemies" type="Node2D" parent="World"] [node name="Companion" type="Sprite2D" parent="World"] -texture = ExtResource("5_player") -modulate = Color(0.62, 0.87, 1, 1) +texture = ExtResource("35_companion") script = ExtResource("3_actor") [node name="Party" type="Node2D" parent="World"] @@ -132,6 +152,8 @@ script = ExtResource("4_hud") [node name="ProgressionChoicePanel" parent="HUD" instance=ExtResource("21_progression_choice")] +[node name="RaceClassChoicePanel" parent="HUD" instance=ExtResource("34_race_class_choice")] + [node name="AchievementPanel" parent="HUD" instance=ExtResource("22_achievement")] [node name="AudiencePanel" parent="HUD" instance=ExtResource("23_audience")] @@ -153,19 +175,29 @@ script = ExtResource("4_hud") [node name="HelpPanel" parent="HUD" instance=ExtResource("30_help")] [node name="AchievementToast" type="Label" parent="HUD"] -offset_left = 390.0 +layout_mode = 1 +anchors_preset = 10 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -360.0 offset_top = 18.0 -offset_right = 890.0 +offset_right = 360.0 offset_bottom = 48.0 +grow_horizontal = 2 theme_override_colors/font_color = Color(1, 0.82, 0.42, 1) theme_override_font_sizes/font_size = 18 horizontal_alignment = 1 [node name="TitleLabel" type="Label" parent="HUD"] -offset_left = 390.0 +layout_mode = 1 +anchors_preset = 10 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -360.0 offset_top = 48.0 -offset_right = 890.0 +offset_right = 360.0 offset_bottom = 74.0 +grow_horizontal = 2 theme_override_colors/font_color = Color(0.75, 0.94, 0.55, 1) theme_override_font_sizes/font_size = 16 horizontal_alignment = 1 @@ -184,8 +216,8 @@ layout_mode = 1 anchors_preset = 0 offset_left = 12.0 offset_top = 12.0 -offset_right = 248.0 -offset_bottom = 170.0 +offset_right = 298.0 +offset_bottom = 250.0 grow_horizontal = 0 grow_vertical = 0 theme_override_styles/panel = SubResource("StyleBox_hud_panel") @@ -237,7 +269,7 @@ layout_mode = 1 anchors_preset = 0 offset_left = 26.0 offset_top = 26.0 -offset_right = 236.0 +offset_right = 286.0 offset_bottom = 46.0 grow_horizontal = 0 grow_vertical = 0 @@ -248,21 +280,54 @@ theme_override_font_sizes/font_size = 18 layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 48.0 -offset_right = 236.0 -offset_bottom = 68.0 +offset_top = 47.0 +offset_right = 286.0 +offset_bottom = 73.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(0.7, 0.8, 1, 1) theme_override_font_sizes/font_size = 18 +[node name="ExperienceBar" type="ProgressBar" parent="HUD"] +layout_mode = 1 +anchors_preset = 0 +offset_left = 26.0 +offset_top = 74.0 +offset_right = 286.0 +offset_bottom = 94.0 +grow_horizontal = 0 +grow_vertical = 0 +mouse_filter = 2 +theme_override_styles/background = SubResource("StyleBox_xp_background") +theme_override_styles/fill = SubResource("StyleBox_xp_fill") +show_percentage = false + +[node name="ExperienceLabel" type="Label" parent="HUD"] +layout_mode = 1 +anchors_preset = 0 +offset_left = 30.0 +offset_top = 74.0 +offset_right = 282.0 +offset_bottom = 94.0 +grow_horizontal = 0 +grow_vertical = 0 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.92, 0.97, 1, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9) +theme_override_constants/shadow_offset_x = 1 +theme_override_constants/shadow_offset_y = 1 +theme_override_font_sizes/font_size = 14 +text = "Niveau 1 — XP 0/100" +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="GoldLabel" type="Label" parent="HUD"] layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 70.0 -offset_right = 236.0 -offset_bottom = 90.0 +offset_top = 96.0 +offset_right = 286.0 +offset_bottom = 122.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(1, 0.84, 0.35, 1) @@ -273,9 +338,9 @@ text = "Or: 0" layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 92.0 -offset_right = 360.0 -offset_bottom = 112.0 +offset_top = 123.0 +offset_right = 286.0 +offset_bottom = 143.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(0.65, 1, 0.72, 1) @@ -286,9 +351,9 @@ text = "Quêtes : aucune" layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 92.0 -offset_right = 360.0 -offset_bottom = 112.0 +offset_top = 144.0 +offset_right = 286.0 +offset_bottom = 164.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(0.82, 0.7, 1, 1) @@ -298,9 +363,9 @@ theme_override_font_sizes/font_size = 14 layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 114.0 -offset_right = 236.0 -offset_bottom = 134.0 +offset_top = 165.0 +offset_right = 286.0 +offset_bottom = 191.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(1, 0.8, 0.7, 1) @@ -310,9 +375,9 @@ theme_override_font_sizes/font_size = 18 layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 114.0 -offset_right = 236.0 -offset_bottom = 134.0 +offset_top = 192.0 +offset_right = 286.0 +offset_bottom = 215.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(1, 0.9, 0.5, 1) @@ -322,13 +387,15 @@ theme_override_font_sizes/font_size = 16 layout_mode = 1 anchors_preset = 0 offset_left = 26.0 -offset_top = 138.0 -offset_right = 360.0 -offset_bottom = 158.0 +offset_top = 216.0 +offset_right = 286.0 +offset_bottom = 246.0 grow_horizontal = 0 grow_vertical = 0 theme_override_colors/font_color = Color(1, 0.76, 0.4, 1) theme_override_font_sizes/font_size = 14 +autowrap_mode = 2 +clip_text = true [node name="EventLog" type="RichTextLabel" parent="HUD"] layout_mode = 1 @@ -378,6 +445,6 @@ grow_horizontal = 2 grow_vertical = 0 theme_override_colors/font_color = Color(0.82, 0.9, 1, 1) theme_override_font_sizes/font_size = 14 -text = "Déplacer : ZQSD / Flèches (nord-est : pavé num. 9) • Interagir : Espace ou E" +text = "Déplacer : ZQSD / Flèches (nord-est : pavé num. 9) • Interagir : Espace ou E • Distance : F • Familier : K • Sauvegarder : V / Ctrl+S • Aide : F1" horizontal_alignment = 1 vertical_alignment = 1 diff --git a/scenes/menu/CharacterCreation.tscn b/scenes/menu/CharacterCreation.tscn index 8f41a87..dc2447e 100644 --- a/scenes/menu/CharacterCreation.tscn +++ b/scenes/menu/CharacterCreation.tscn @@ -35,9 +35,9 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 offset_left = -270.0 -offset_top = -350.0 +offset_top = -310.0 offset_right = 270.0 -offset_bottom = 350.0 +offset_bottom = 310.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_panel") @@ -68,43 +68,26 @@ custom_minimum_size = Vector2(0, 31) layout_mode = 2 placeholder_text = "Sans-Nom" -[node name="ArchetypeLabel" type="Label" parent="Panel/Layout/Fields"] -layout_mode = 2 -text = "Base archetype" - -[node name="ArchetypeOption" type="OptionButton" parent="Panel/Layout/Fields"] -custom_minimum_size = Vector2(0, 31) -layout_mode = 2 -item_count = 3 -selected = 0 -popup/item_0/text = "Vanguard" -popup/item_0/id = 0 -popup/item_0/metadata = "vanguard" -popup/item_1/text = "Mystic" -popup/item_1/id = 1 -popup/item_1/metadata = "mystic" -popup/item_2/text = "Scout" -popup/item_2/id = 2 -popup/item_2/metadata = "scout" - -[node name="RaceLabel" type="Label" parent="Panel/Layout/Fields"] -layout_mode = 2 -text = "Race" - -[node name="RaceOption" type="OptionButton" parent="Panel/Layout/Fields"] -custom_minimum_size = Vector2(0, 31) -layout_mode = 2 - -[node name="RecommendationLabel" type="Label" parent="Panel/Layout/Fields"] -layout_mode = 2 -autowrap_mode = 2 -theme_override_colors/font_color = Color(0.72, 0.8, 0.92, 1) - [node name="PetCheck" type="CheckBox" parent="Panel/Layout/Fields"] custom_minimum_size = Vector2(0, 27) layout_mode = 2 text = "Bring a pet companion" +[node name="PetDetails" type="VBoxContainer" parent="Panel/Layout/Fields"] +visible = false +layout_mode = 2 +theme_override_constants/separation = 4 + +[node name="PetNameEdit" type="LineEdit" parent="Panel/Layout/Fields/PetDetails"] +custom_minimum_size = Vector2(0, 31) +layout_mode = 2 +placeholder_text = "Pet name (Familier)" + +[node name="PetSpeciesEdit" type="LineEdit" parent="Panel/Layout/Fields/PetDetails"] +custom_minimum_size = Vector2(0, 31) +layout_mode = 2 +placeholder_text = "Nature / species (Animal)" + [node name="SeedLabel" type="Label" parent="Panel/Layout/Fields"] layout_mode = 2 text = "Generation seed" diff --git a/scenes/ui/DeathPanel.tscn b/scenes/ui/DeathPanel.tscn index 18b56fb..6bf89f1 100644 --- a/scenes/ui/DeathPanel.tscn +++ b/scenes/ui/DeathPanel.tscn @@ -13,6 +13,10 @@ corner_radius_top_left = 8 corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 +content_margin_left = 32.0 +content_margin_top = 22.0 +content_margin_right = 32.0 +content_margin_bottom = 22.0 [node name="DeathPanel" type="PanelContainer"] visible = false @@ -22,40 +26,57 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -310.0 -offset_top = -190.0 -offset_right = 310.0 -offset_bottom = 190.0 +offset_left = -340.0 +offset_top = -230.0 +offset_right = 340.0 +offset_bottom = 230.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_death_panel") script = ExtResource("1_death") -[node name="Title" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -260.0 -offset_top = 22.0 -offset_right = 260.0 -offset_bottom = 54.0 -grow_horizontal = 2 +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 16 + +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 42) +layout_mode = 2 theme_override_colors/font_color = Color(1, 0.38, 0.34, 1) theme_override_font_sizes/font_size = 27 text = "VOUS ÊTES MORT" horizontal_alignment = 1 +vertical_alignment = 1 -[node name="Body" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 40.0 -offset_top = 75.0 -offset_right = -40.0 -offset_bottom = -34.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Body" type="RichTextLabel" parent="Layout"] +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(1, 0.91, 0.9, 1) theme_override_font_sizes/normal_font_size = 18 + +[node name="Hint" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 24) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 0.78, 0.72, 1) +theme_override_font_sizes/font_size = 15 +horizontal_alignment = 1 + +[node name="Actions" type="HBoxContainer" parent="Layout"] +layout_mode = 2 +theme_override_constants/separation = 12 +alignment = 1 + +[node name="LoadButton" type="Button" parent="Layout/Actions"] +custom_minimum_size = Vector2(170, 42) +layout_mode = 2 +text = "CHARGER" + +[node name="NewRunButton" type="Button" parent="Layout/Actions"] +custom_minimum_size = Vector2(190, 42) +layout_mode = 2 +text = "NOUVELLE PARTIE" + +[node name="MenuButton" type="Button" parent="Layout/Actions"] +custom_minimum_size = Vector2(150, 42) +layout_mode = 2 +text = "MENU PRINCIPAL" diff --git a/scenes/ui/DialoguePanel.tscn b/scenes/ui/DialoguePanel.tscn index 58725f8..ea74ec2 100644 --- a/scenes/ui/DialoguePanel.tscn +++ b/scenes/ui/DialoguePanel.tscn @@ -13,6 +13,10 @@ corner_radius_top_left = 8 corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 +content_margin_left = 36.0 +content_margin_top = 28.0 +content_margin_right = 36.0 +content_margin_bottom = 28.0 [node name="DialoguePanel" type="PanelContainer"] visible = false @@ -22,70 +26,46 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -300.0 -offset_top = -205.0 -offset_right = 300.0 -offset_bottom = 205.0 +offset_left = -480.0 +offset_top = -360.0 +offset_right = 480.0 +offset_bottom = 360.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_dialogue_panel") script = ExtResource("1_dialogue") -[node name="Title" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -270.0 -offset_top = 18.0 -offset_right = 270.0 -offset_bottom = 46.0 -grow_horizontal = 2 -theme_override_colors/font_color = Color(0.55, 0.9, 1, 1) -theme_override_font_sizes/font_size = 21 -horizontal_alignment = 1 +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 16 -[node name="Body" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 58.0 -offset_right = -30.0 -offset_bottom = -175.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 42) +layout_mode = 2 +theme_override_colors/font_color = Color(0.55, 0.9, 1, 1) +theme_override_font_sizes/font_size = 24 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Body" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 300) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) -theme_override_font_sizes/normal_font_size = 18 +theme_override_font_sizes/normal_font_size = 20 -[node name="Entries" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 238.0 -offset_right = -30.0 -offset_bottom = -48.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Entries" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 190) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(1, 0.9, 0.5, 1) -theme_override_font_sizes/normal_font_size = 17 +theme_override_font_sizes/normal_font_size = 19 -[node name="Help" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -270.0 -offset_top = -42.0 -offset_right = 270.0 -offset_bottom = -18.0 -grow_horizontal = 2 +[node name="Help" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 theme_override_colors/font_color = Color(0.55, 0.9, 1, 1) -theme_override_font_sizes/font_size = 16 -text = "↑/↓ Choisir Entrée Confirmer Échap Partir" +theme_override_font_sizes/font_size = 17 +text = "↑/↓ Choisir Entrée Confirmer Échap Partir" horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/scenes/ui/EventPanel.tscn b/scenes/ui/EventPanel.tscn index 9bacb38..1d7417f 100644 --- a/scenes/ui/EventPanel.tscn +++ b/scenes/ui/EventPanel.tscn @@ -13,6 +13,10 @@ corner_radius_top_left = 8 corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 +content_margin_left = 36.0 +content_margin_top = 28.0 +content_margin_right = 36.0 +content_margin_bottom = 28.0 [node name="EventPanel" type="PanelContainer"] visible = false @@ -22,70 +26,46 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -300.0 -offset_top = -205.0 -offset_right = 300.0 -offset_bottom = 205.0 +offset_left = -480.0 +offset_top = -360.0 +offset_right = 480.0 +offset_bottom = 360.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_event_panel") script = ExtResource("1_event") -[node name="Title" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -270.0 -offset_top = 18.0 -offset_right = 270.0 -offset_bottom = 46.0 -grow_horizontal = 2 -theme_override_colors/font_color = Color(1, 0.84, 0.42, 1) -theme_override_font_sizes/font_size = 21 -horizontal_alignment = 1 +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 16 -[node name="Body" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 58.0 -offset_right = -30.0 -offset_bottom = -175.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 42) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 0.84, 0.42, 1) +theme_override_font_sizes/font_size = 24 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Body" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 300) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) -theme_override_font_sizes/normal_font_size = 18 +theme_override_font_sizes/normal_font_size = 20 -[node name="Entries" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 238.0 -offset_right = -30.0 -offset_bottom = -48.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Entries" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 190) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(1, 0.9, 0.5, 1) -theme_override_font_sizes/normal_font_size = 17 +theme_override_font_sizes/normal_font_size = 19 -[node name="Help" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -270.0 -offset_top = -42.0 -offset_right = 270.0 -offset_bottom = -18.0 -grow_horizontal = 2 +[node name="Help" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 theme_override_colors/font_color = Color(1, 0.84, 0.42, 1) -theme_override_font_sizes/font_size = 16 -text = "↑/↓ Choisir Entrée Confirmer Échap Partir" +theme_override_font_sizes/font_size = 17 +text = "↑/↓ Choisir Entrée Confirmer Échap Partir" horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/scenes/ui/InventoryPanel.tscn b/scenes/ui/InventoryPanel.tscn index c6ee571..460675f 100644 --- a/scenes/ui/InventoryPanel.tscn +++ b/scenes/ui/InventoryPanel.tscn @@ -13,6 +13,10 @@ corner_radius_top_left = 8 corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 +content_margin_left = 24.0 +content_margin_top = 18.0 +content_margin_right = 24.0 +content_margin_bottom = 18.0 [node name="InventoryPanel" type="PanelContainer"] visible = false @@ -23,43 +27,57 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 offset_left = -400.0 -offset_top = -235.0 +offset_top = -260.0 offset_right = 400.0 -offset_bottom = 235.0 +offset_bottom = 260.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_inventory_panel") script = ExtResource("1_inventory") -[node name="Title" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -350.0 -offset_top = 18.0 -offset_right = 350.0 -offset_bottom = 46.0 -grow_horizontal = 2 +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 12 + +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 theme_override_colors/font_color = Color(1, 0.9, 0.5, 1) theme_override_font_sizes/font_size = 24 -text = "INVENTORY" +text = "INVENTAIRE" horizontal_alignment = 1 +vertical_alignment = 1 -[node name="Entries" type="RichTextLabel" parent="."] -layout_mode = 0 -offset_left = 28.0 -offset_top = 66.0 -offset_right = 355.0 -offset_bottom = 400.0 +[node name="Columns" type="HBoxContainer" parent="Layout"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_constants/separation = 20 + +[node name="Entries" type="RichTextLabel" parent="Layout/Columns"] +custom_minimum_size = Vector2(300, 0) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) theme_override_font_sizes/normal_font_size = 18 +scroll_active = true +scroll_following = false -[node name="Details" type="RichTextLabel" parent="."] -layout_mode = 0 -offset_left = 380.0 -offset_top = 66.0 -offset_right = 770.0 -offset_bottom = 420.0 +[node name="Details" type="RichTextLabel" parent="Layout/Columns"] +custom_minimum_size = Vector2(400, 0) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) theme_override_font_sizes/normal_font_size = 17 +scroll_active = true +scroll_following = false + +[node name="Footer" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 28) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 0.9, 0.5, 1) +theme_override_font_sizes/font_size = 16 +text = "↑/↓ Sélectionner E Équiper U Utiliser D Jeter I Fermer" +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/scenes/ui/LootPanel.tscn b/scenes/ui/LootPanel.tscn index 0e2b6a7..84659bd 100644 --- a/scenes/ui/LootPanel.tscn +++ b/scenes/ui/LootPanel.tscn @@ -13,6 +13,10 @@ corner_radius_top_left = 8 corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 +content_margin_left = 30.0 +content_margin_top = 18.0 +content_margin_right = 30.0 +content_margin_bottom = 18.0 [node name="LootPanel" type="PanelContainer"] visible = false @@ -31,49 +35,31 @@ grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_loot_panel") script = ExtResource("1_loot") -[node name="Title" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -180.0 -offset_top = 18.0 -offset_right = 180.0 -offset_bottom = 46.0 -grow_horizontal = 2 +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 14 + +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 theme_override_colors/font_color = Color(1, 0.9, 0.5, 1) theme_override_font_sizes/font_size = 24 text = "COFFRE OUVERT" horizontal_alignment = 1 +vertical_alignment = 1 -[node name="Entries" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 66.0 -offset_right = -30.0 -offset_bottom = -70.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Entries" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 148) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) theme_override_font_sizes/normal_font_size = 19 -[node name="TakeAll" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -180.0 -offset_top = -52.0 -offset_right = 180.0 -offset_bottom = -22.0 -grow_horizontal = 2 -grow_vertical = 0 +[node name="TakeAll" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 theme_override_colors/font_color = Color(1, 0.9, 0.5, 1) theme_override_font_sizes/font_size = 17 text = "Entrée / Espace — Tout prendre" horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/scenes/ui/QuestPanel.tscn b/scenes/ui/QuestPanel.tscn index 2246a8a..d7f60e1 100644 --- a/scenes/ui/QuestPanel.tscn +++ b/scenes/ui/QuestPanel.tscn @@ -13,6 +13,10 @@ corner_radius_top_left = 8 corner_radius_top_right = 8 corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 +content_margin_left = 36.0 +content_margin_top = 28.0 +content_margin_right = 36.0 +content_margin_bottom = 28.0 [node name="QuestPanel" type="PanelContainer"] visible = false @@ -22,70 +26,46 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -300.0 -offset_top = -205.0 -offset_right = 300.0 -offset_bottom = 205.0 +offset_left = -480.0 +offset_top = -360.0 +offset_right = 480.0 +offset_bottom = 360.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBox_quest_panel") script = ExtResource("1_quest") -[node name="Title" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -270.0 -offset_top = 18.0 -offset_right = 270.0 -offset_bottom = 46.0 -grow_horizontal = 2 -theme_override_colors/font_color = Color(0.55, 1, 0.67, 1) -theme_override_font_sizes/font_size = 21 -horizontal_alignment = 1 +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 16 -[node name="Body" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 58.0 -offset_right = -30.0 -offset_bottom = -175.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 42) +layout_mode = 2 +theme_override_colors/font_color = Color(0.55, 1, 0.67, 1) +theme_override_font_sizes/font_size = 24 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Body" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 300) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) -theme_override_font_sizes/normal_font_size = 17 +theme_override_font_sizes/normal_font_size = 19 -[node name="Entries" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 30.0 -offset_top = 220.0 -offset_right = -30.0 -offset_bottom = -48.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Entries" type="RichTextLabel" parent="Layout"] +custom_minimum_size = Vector2(0, 190) +layout_mode = 2 +size_flags_vertical = 3 theme_override_colors/default_color = Color(0.7, 1, 0.75, 1) -theme_override_font_sizes/normal_font_size = 17 +theme_override_font_sizes/normal_font_size = 19 -[node name="Help" type="Label" parent="."] -layout_mode = 1 -anchors_preset = 10 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -270.0 -offset_top = -42.0 -offset_right = 270.0 -offset_bottom = -18.0 -grow_horizontal = 2 +[node name="Help" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 theme_override_colors/font_color = Color(0.55, 1, 0.67, 1) -theme_override_font_sizes/font_size = 16 -text = "↑/↓ Choisir Entrée Accepter A Abandonner Échap Fermer" +theme_override_font_sizes/font_size = 17 +text = "↑/↓ Choisir Entrée Accepter A Abandonner Échap Fermer" horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/scenes/ui/RaceClassChoicePanel.tscn b/scenes/ui/RaceClassChoicePanel.tscn new file mode 100644 index 0000000..c2147da --- /dev/null +++ b/scenes/ui/RaceClassChoicePanel.tscn @@ -0,0 +1,60 @@ +[gd_scene load_steps=3 format=3] + +[ext_resource type="Script" path="res://scripts/presentation/race_class_choice_panel.gd" id="1_panel"] + +[sub_resource type="StyleBoxFlat" id="StyleBox_panel"] +bg_color = Color(0.035, 0.055, 0.09, 0.99) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(0.96, 0.76, 0.28, 0.95) +corner_radius_top_left = 8 +corner_radius_top_right = 8 +corner_radius_bottom_right = 8 +corner_radius_bottom_left = 8 +content_margin_left = 28.0 +content_margin_top = 22.0 +content_margin_right = 28.0 +content_margin_bottom = 22.0 + +[node name="RaceClassChoicePanel" type="PanelContainer"] +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -390.0 +offset_top = -300.0 +offset_right = 390.0 +offset_bottom = 300.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBox_panel") +script = ExtResource("1_panel") + +[node name="Layout" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 12 + +[node name="Title" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 34) +layout_mode = 2 +theme_override_colors/font_color = Color(0.96, 0.82, 0.42, 1) +theme_override_font_sizes/font_size = 23 +horizontal_alignment = 1 + +[node name="Intro" type="Label" parent="Layout"] +custom_minimum_size = Vector2(0, 28) +layout_mode = 2 +autowrap_mode = 2 +theme_override_colors/font_color = Color(0.8, 0.88, 1, 1) +horizontal_alignment = 1 + +[node name="Options" type="RichTextLabel" parent="Layout"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_colors/default_color = Color(0.92, 0.95, 1, 1) +theme_override_font_sizes/normal_font_size = 16 diff --git a/scenes/ui/SaveLoadPanel.tscn b/scenes/ui/SaveLoadPanel.tscn index 20622a1..68736fb 100644 --- a/scenes/ui/SaveLoadPanel.tscn +++ b/scenes/ui/SaveLoadPanel.tscn @@ -52,7 +52,7 @@ layout_mode = 2 theme_override_colors/font_color = Color(0.96, 0.84, 0.44, 1) theme_override_font_sizes/font_size = 26 horizontal_alignment = 1 -text = "LOAD RUN" +text = "CHARGER UNE PARTIE" [node name="Slots" type="VBoxContainer" parent="Panel/Layout"] layout_mode = 2 @@ -92,4 +92,4 @@ horizontal_alignment = 1 [node name="CancelButton" type="Button" parent="Panel/Layout"] custom_minimum_size = Vector2(0, 40) layout_mode = 2 -text = "BACK" +text = "RETOUR" diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 3c50859..7164806 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -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" diff --git a/scripts/check-visual-capture.py b/scripts/check-visual-capture.py index 3541232..f3815db 100755 --- a/scripts/check-visual-capture.py +++ b/scripts/check-visual-capture.py @@ -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: diff --git a/scripts/domain/ai/companion_behaviors.gd b/scripts/domain/ai/companion_behaviors.gd index 063afc6..33f9de2 100644 --- a/scripts/domain/ai/companion_behaviors.gd +++ b/scripts/domain/ai/companion_behaviors.gd @@ -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 diff --git a/scripts/domain/combat/combat_engine.gd b/scripts/domain/combat/combat_engine.gd index e392df8..9f0d4bd 100644 --- a/scripts/domain/combat/combat_engine.gd +++ b/scripts/domain/combat/combat_engine.gd @@ -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": diff --git a/scripts/domain/combat/health_regeneration.gd b/scripts/domain/combat/health_regeneration.gd new file mode 100644 index 0000000..2eb6d5e --- /dev/null +++ b/scripts/domain/combat/health_regeneration.gd @@ -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 diff --git a/scripts/domain/combat/health_regeneration.gd.uid b/scripts/domain/combat/health_regeneration.gd.uid new file mode 100644 index 0000000..892073b --- /dev/null +++ b/scripts/domain/combat/health_regeneration.gd.uid @@ -0,0 +1 @@ +uid://3ccnf6g0ily8 diff --git a/scripts/domain/combat/ranged_combat.gd b/scripts/domain/combat/ranged_combat.gd index 2d23ddd..dd88396 100644 --- a/scripts/domain/combat/ranged_combat.gd +++ b/scripts/domain/combat/ranged_combat.gd @@ -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" diff --git a/scripts/domain/entities/companion_state.gd b/scripts/domain/entities/companion_state.gd index e987b91..f4715ed 100644 --- a/scripts/domain/entities/companion_state.gd +++ b/scripts/domain/entities/companion_state.gd @@ -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: diff --git a/scripts/domain/game_state.gd b/scripts/domain/game_state.gd index 6ff0c20..4891725 100644 --- a/scripts/domain/game_state.gd +++ b/scripts/domain/game_state.gd @@ -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 diff --git a/scripts/domain/inventory/equipment_state.gd b/scripts/domain/inventory/equipment_state.gd index 5a15bd9..5bafef6 100644 --- a/scripts/domain/inventory/equipment_state.gd +++ b/scripts/domain/inventory/equipment_state.gd @@ -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 diff --git a/scripts/domain/inventory/inventory_state.gd b/scripts/domain/inventory/inventory_state.gd index d96d460..ee905d8 100644 --- a/scripts/domain/inventory/inventory_state.gd +++ b/scripts/domain/inventory/inventory_state.gd @@ -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) diff --git a/scripts/domain/items/loot_resolver.gd b/scripts/domain/items/loot_resolver.gd index 2c55c95..6443eec 100644 --- a/scripts/domain/items/loot_resolver.gd +++ b/scripts/domain/items/loot_resolver.gd @@ -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, diff --git a/scripts/domain/magic/magic_engine.gd b/scripts/domain/magic/magic_engine.gd index 1915094..d02e9d9 100644 --- a/scripts/domain/magic/magic_engine.gd +++ b/scripts/domain/magic/magic_engine.gd @@ -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]: diff --git a/scripts/domain/progression/class_engine.gd b/scripts/domain/progression/class_engine.gd index b2e548a..1713474 100644 --- a/scripts/domain/progression/class_engine.gd +++ b/scripts/domain/progression/class_engine.gd @@ -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] = [] diff --git a/scripts/domain/run/run_settings.gd b/scripts/domain/run/run_settings.gd index 2eea25b..fdb483a 100644 --- a/scripts/domain/run/run_settings.gd +++ b/scripts/domain/run/run_settings.gd @@ -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 diff --git a/scripts/domain/run/run_state.gd b/scripts/domain/run/run_state.gd index 95e8e70..e0c0770 100644 --- a/scripts/domain/run/run_state.gd +++ b/scripts/domain/run/run_state.gd @@ -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 diff --git a/scripts/domain/turn_resolver.gd b/scripts/domain/turn_resolver.gd index cf12821..37b5ef2 100644 --- a/scripts/domain/turn_resolver.gd +++ b/scripts/domain/turn_resolver.gd @@ -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))) diff --git a/scripts/domain/world/floor_generator.gd b/scripts/domain/world/floor_generator.gd index 46dce31..047d9d5 100644 --- a/scripts/domain/world/floor_generator.gd +++ b/scripts/domain/world/floor_generator.gd @@ -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])) diff --git a/scripts/domain/world/floor_populator.gd b/scripts/domain/world/floor_populator.gd index 71107ae..9964a06 100644 --- a/scripts/domain/world/floor_populator.gd +++ b/scripts/domain/world/floor_populator.gd @@ -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, diff --git a/scripts/domain/world/surface_generator.gd b/scripts/domain/world/surface_generator.gd index b33495e..8cd1ea3 100644 --- a/scripts/domain/world/surface_generator.gd +++ b/scripts/domain/world/surface_generator.gd @@ -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) diff --git a/scripts/domain/world/trap_engine.gd b/scripts/domain/world/trap_engine.gd index 80f7f1c..bd807a3 100644 --- a/scripts/domain/world/trap_engine.gd +++ b/scripts/domain/world/trap_engine.gd @@ -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, + } diff --git a/scripts/game/game.gd b/scripts/game/game.gd index 1b07c73..8375593 100644 --- a/scripts/game/game.gd +++ b/scripts/game/game.gd @@ -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) diff --git a/scripts/game/input_bindings.gd b/scripts/game/input_bindings.gd index e38b0c9..d26b3d3 100644 --- a/scripts/game/input_bindings.gd +++ b/scripts/game/input_bindings.gd @@ -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", diff --git a/scripts/game/temporary_playtest_kit.gd b/scripts/game/temporary_playtest_kit.gd new file mode 100644 index 0000000..7d35f80 --- /dev/null +++ b/scripts/game/temporary_playtest_kit.gd @@ -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) diff --git a/scripts/game/temporary_playtest_kit.gd.uid b/scripts/game/temporary_playtest_kit.gd.uid new file mode 100644 index 0000000..5e410f4 --- /dev/null +++ b/scripts/game/temporary_playtest_kit.gd.uid @@ -0,0 +1 @@ +uid://b1f30fl11cbkt diff --git a/scripts/infrastructure/audio_import_manifest.gd b/scripts/infrastructure/audio_import_manifest.gd index ce0e5cd..c99951a 100644 --- a/scripts/infrastructure/audio_import_manifest.gd +++ b/scripts/infrastructure/audio_import_manifest.gd @@ -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 diff --git a/scripts/infrastructure/audio_library.gd b/scripts/infrastructure/audio_library.gd index b4639d8..a2b73b7 100644 --- a/scripts/infrastructure/audio_library.gd +++ b/scripts/infrastructure/audio_library.gd @@ -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 = "" diff --git a/scripts/infrastructure/save/save_repository.gd b/scripts/infrastructure/save/save_repository.gd index 353a438..8eab79a 100644 --- a/scripts/infrastructure/save/save_repository.gd +++ b/scripts/infrastructure/save/save_repository.gd @@ -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 = [] diff --git a/scripts/presentation/companion_panel.gd b/scripts/presentation/companion_panel.gd index 7790976..aa16d9b 100644 --- a/scripts/presentation/companion_panel.gd +++ b/scripts/presentation/companion_panel.gd @@ -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) diff --git a/scripts/presentation/death_panel.gd b/scripts/presentation/death_panel.gd index 56451f8..d12535e 100644 --- a/scripts/presentation/death_panel.gd +++ b/scripts/presentation/death_panel.gd @@ -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 diff --git a/scripts/presentation/dialogue_panel.gd b/scripts/presentation/dialogue_panel.gd index 8f2919e..1a7130e 100644 --- a/scripts/presentation/dialogue_panel.gd +++ b/scripts/presentation/dialogue_panel.gd @@ -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 diff --git a/scripts/presentation/event_panel.gd b/scripts/presentation/event_panel.gd index 611c3a5..e23378a 100644 --- a/scripts/presentation/event_panel.gd +++ b/scripts/presentation/event_panel.gd @@ -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 = {} diff --git a/scripts/presentation/help_panel.gd b/scripts/presentation/help_panel.gd index 2748a47..e923ec3 100644 --- a/scripts/presentation/help_panel.gd +++ b/scripts/presentation/help_panel.gd @@ -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) diff --git a/scripts/presentation/hud.gd b/scripts/presentation/hud.gd index b195ca5..d215de9 100644 --- a/scripts/presentation/hud.gd +++ b/scripts/presentation/hud.gd @@ -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: diff --git a/scripts/presentation/inventory_panel.gd b/scripts/presentation/inventory_panel.gd index 56e46ab..00ae3af 100644 --- a/scripts/presentation/inventory_panel.gd +++ b/scripts/presentation/inventory_panel.gd @@ -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: diff --git a/scripts/presentation/loot_feedback.gd b/scripts/presentation/loot_feedback.gd index 0f1d10c..c55c4c4 100644 --- a/scripts/presentation/loot_feedback.gd +++ b/scripts/presentation/loot_feedback.gd @@ -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 diff --git a/scripts/presentation/loot_panel.gd b/scripts/presentation/loot_panel.gd index dec99fe..4f489e8 100644 --- a/scripts/presentation/loot_panel.gd +++ b/scripts/presentation/loot_panel.gd @@ -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) diff --git a/scripts/presentation/menu/character_creation.gd b/scripts/presentation/menu/character_creation.gd index e318ca4..b9696c0 100644 --- a/scripts/presentation/menu/character_creation.gd +++ b/scripts/presentation/menu/character_creation.gd @@ -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) diff --git a/scripts/presentation/menu/main_menu.gd b/scripts/presentation/menu/main_menu.gd index 68b37c5..d3dc9e7 100644 --- a/scripts/presentation/menu/main_menu.gd +++ b/scripts/presentation/menu/main_menu.gd @@ -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() diff --git a/scripts/presentation/quest_panel.gd b/scripts/presentation/quest_panel.gd index 1b0d7e9..8a7ef72 100644 --- a/scripts/presentation/quest_panel.gd +++ b/scripts/presentation/quest_panel.gd @@ -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] = [] diff --git a/scripts/presentation/race_class_choice_panel.gd b/scripts/presentation/race_class_choice_panel.gd new file mode 100644 index 0000000..d835dce --- /dev/null +++ b/scripts/presentation/race_class_choice_panel.gd @@ -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" diff --git a/scripts/presentation/race_class_choice_panel.gd.uid b/scripts/presentation/race_class_choice_panel.gd.uid new file mode 100644 index 0000000..c7d18a3 --- /dev/null +++ b/scripts/presentation/race_class_choice_panel.gd.uid @@ -0,0 +1 @@ +uid://chvjdg03j75dt diff --git a/scripts/presentation/save_load_panel.gd b/scripts/presentation/save_load_panel.gd index af277c2..53aaf37 100644 --- a/scripts/presentation/save_load_panel.gd +++ b/scripts/presentation/save_load_panel.gd @@ -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))] diff --git a/scripts/presentation/targeting_overlay.gd b/scripts/presentation/targeting_overlay.gd index e762f7e..bcccb50 100644 --- a/scripts/presentation/targeting_overlay.gd +++ b/scripts/presentation/targeting_overlay.gd @@ -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] diff --git a/scripts/run-visual-check.sh b/scripts/run-visual-check.sh index aeb68da..3a0f1b4 100755 --- a/scripts/run-visual-check.sh +++ b/scripts/run-visual-check.sh @@ -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 diff --git a/tests/e2e/test_audio_settings_e2e.gd b/tests/e2e/test_audio_settings_e2e.gd index 79695e2..f1444f3 100644 --- a/tests/e2e/test_audio_settings_e2e.gd +++ b/tests/e2e/test_audio_settings_e2e.gd @@ -10,6 +10,21 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame +func test_bundled_music_switches_from_exploration_to_combat() -> void: + var audio := game.get_node("AudioLibrary") as AudioLibrary + var exploration_stream := audio.get_ambience_stream() + assert_not_null(exploration_stream) + assert_string_contains(exploration_stream.resource_path, "dungeon_exploration.wav") + + var state := game.get_game_state() + var enemy: ActorState = state.enemies[&"goblin"] + enemy.cell = state.player.cell + Vector2i.RIGHT + game.submit_test_action(Vector2i.RIGHT) + + assert_eq(audio.current_ambience_context, "combat") + assert_string_contains(audio.get_ambience_stream().resource_path, "dungeon_combat.wav") + assert_true(audio.get_ambience_player().playing) + func test_options_control_audio_buses_and_imported_manifest_playback_without_external_files() -> void: var audio = game.get_node("AudioLibrary") as AudioLibrary var manifest := AudioImportManifest.new() diff --git a/tests/e2e/test_black_fog_e2e.gd b/tests/e2e/test_black_fog_e2e.gd index e513fb1..65271da 100644 --- a/tests/e2e/test_black_fog_e2e.gd +++ b/tests/e2e/test_black_fog_e2e.gd @@ -11,21 +11,18 @@ func before_each() -> void: func test_real_scene_walk_out_of_sight_exposes_visible_explored_and_unknown_fog_states() -> void: var renderer := game.get_node("World/MapRenderer") as MapRenderer var state := game.get_game_state() + state.enemies.clear() + var old_cell := Vector2i(2, 7) + var new_cell := Vector2i(17, 7) + for step in range(7): + game.submit_test_action(Vector2i.RIGHT) - game.submit_test_interact() - var results := game.submit_test_action(Vector2i.UP) - - assert_eq(results[0].kind, &"moved") - assert_true(state.visible_cells.has(Vector2i(4, 17))) - assert_true(state.explored_cells.has(Vector2i(1, 12))) - assert_false(state.visible_cells.has(Vector2i(1, 12))) - assert_false(state.explored_cells.has(Vector2i(29, 19))) - assert_eq(renderer.get_cell_visibility_state(Vector2i(4, 17)), &"visible") - assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"explored") - assert_eq(renderer.get_cell_visibility_state(Vector2i(29, 19)), &"unknown") - assert_eq(renderer.get_cell_render_color(Vector2i(4, 17)), Color.WHITE) - assert_lt( - renderer.get_cell_render_color(Vector2i(29, 19)).get_luminance(), - renderer.get_cell_render_color(Vector2i(1, 12)).get_luminance() - ) - assert_lte(renderer.get_cell_render_color(Vector2i(1, 12)).get_luminance(), 0.35) + assert_true(state.visible_cells.has(new_cell)) + assert_true(state.explored_cells.has(old_cell)) + assert_false(state.visible_cells.has(old_cell)) + assert_false(state.explored_cells.has(Vector2i(41, 15))) + assert_eq(renderer.get_cell_visibility_state(new_cell), &"visible") + assert_eq(renderer.get_cell_visibility_state(old_cell), &"explored") + assert_eq(renderer.get_cell_visibility_state(Vector2i(41, 15)), &"unknown") + assert_eq(renderer.get_cell_render_color(new_cell), Color.WHITE) + assert_lt(renderer.get_cell_render_color(Vector2i(41, 15)).get_luminance(), renderer.get_cell_render_color(old_cell).get_luminance()) diff --git a/tests/e2e/test_bobka_safe_room_e2e.gd b/tests/e2e/test_bobka_safe_room_e2e.gd index 4e86173..6899510 100644 --- a/tests/e2e/test_bobka_safe_room_e2e.gd +++ b/tests/e2e/test_bobka_safe_room_e2e.gd @@ -42,7 +42,7 @@ func test_real_bobka_dialogue_gives_three_free_rations_in_safe_room() -> void: await _dispatch_key(KEY_E) var panel := game.get_node("HUD/DialoguePanel") as PanelContainer assert_true(panel.visible, "ration %d opens Bobka dialogue" % (ration_number + 1)) - assert_string_contains((game.get_node("HUD/DialoguePanel/Entries") as RichTextLabel).get_parsed_text(), "Prendre une ration.") + assert_string_contains((game.get_node("HUD/DialoguePanel/Layout/Entries") as RichTextLabel).get_parsed_text(), "Prendre une ration.") await _dispatch_key(KEY_ENTER) assert_eq(run.inventory.count_by_definition(&"consumable_ration"), ration_number + 1) assert_eq(run.gold, gold_before) diff --git a/tests/e2e/test_combat_hud_e2e.gd b/tests/e2e/test_combat_hud_e2e.gd index 3b23318..368bc32 100644 --- a/tests/e2e/test_combat_hud_e2e.gd +++ b/tests/e2e/test_combat_hud_e2e.gd @@ -10,89 +10,46 @@ func before_each() -> void: func test_configured_input_event_uses_the_same_action_path_as_submit_test_action() -> void: var state := game.get_game_state() - var input_event := InputEventKey.new() - input_event.physical_keycode = KEY_DOWN - input_event.pressed = true + state.enemies.clear() + var input_event := _key_event(KEY_DOWN) game._unhandled_input(input_event) - - assert_eq(state.player.cell, Vector2i(4, 13)) - assert_eq(game.get_node("HUD/EventLog").get_parsed_text(), "You move to (4, 13).\nThe goblin moves.\n") + assert_eq(state.player.cell, Vector2i(4, 8)) + assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "You move to (4, 8).") var submitted_game := GameScene.instantiate() as Game add_child_autofree(submitted_game) await get_tree().process_frame + submitted_game.get_game_state().enemies.clear() var test_results := submitted_game.submit_test_action(Vector2i.DOWN) - - assert_eq(submitted_game.get_game_state().player.cell, Vector2i(4, 13)) - assert_eq(test_results.size(), 2) + assert_eq(submitted_game.get_game_state().player.cell, Vector2i(4, 8)) assert_eq(test_results[0].kind, &"moved") - assert_eq(test_results[0].from_cell, Vector2i(4, 12)) - assert_eq(test_results[0].to_cell, Vector2i(4, 13)) - assert_eq(test_results[1].kind, &"enemy_moved") - -func test_real_game_scene_completes_walking_combat_and_defeat_route() -> void: - assert_not_null(game.get_node_or_null("World/MapRenderer")) - assert_not_null(game.get_node_or_null("World/Player")) - assert_not_null(game.get_node_or_null("World/Enemies")) - assert_not_null(game.get_node_or_null("Camera2D")) - assert_not_null(game.get_node_or_null("HUD/PlayerHealthLabel")) - assert_not_null(game.get_node_or_null("HUD/EnemyHealthLabel")) - assert_not_null(game.get_node_or_null("HUD/CombatSummaryLabel")) - assert_not_null(game.get_node_or_null("HUD/EventLog")) +func test_real_game_scene_completes_adjacent_bump_combat_and_defeat_route() -> void: var state := game.get_game_state() + state.enemies.clear() + var enemy := ActorState.new(&"goblin", state.player.cell + Vector2i.RIGHT, 6, 2) + state.enemies[enemy.id] = enemy + game._sync_enemy_views() var hud := game.get_node("HUD") as GameHud - var player_view := game.get_node("World/Player") as ActorView - var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView + hud.refresh(state, [], game.get_run_state()) assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6") - assert_eq(hud.combat_summary_label.text, "Target: Goblin HP: 6/6") - - # The new spawn is beside a wall and a closed door; neither consumes a turn. - var start := state.player.cell - var wall := game.submit_test_action(Vector2i(-1, -1)) - assert_eq(wall.size(), 1) - assert_eq(wall[0].kind, &"blocked") - assert_eq(state.player.cell, start) - var door := game.submit_test_action(Vector2i.UP) - assert_eq(door.size(), 1) - assert_eq(door[0].kind, &"blocked") - assert_eq(state.player.cell, start) - assert_string_contains(hud.event_log.get_parsed_text(), "Your way is blocked.") - - # Move the existing goblin onto the adapted combat lane after the map assertions. - state.enemies[&"goblin"].cell = start + Vector2i(2, 0) - var movement := game.submit_test_action(Vector2i.RIGHT) - assert_eq(movement[0].kind, &"moved") - assert_eq(state.player.cell, start + Vector2i.RIGHT) - assert_eq(movement[1].kind, &"enemy_melee") - await _wait_for_feedback() - assert_eq(player_view.last_damage, 2) - assert_string_contains(game.get_node("HUD/PlayerHealthLabel").text, "10/12") - assert_string_contains(hud.event_log.get_parsed_text(), "You move to (5, 12).") - assert_string_contains(hud.event_log.get_parsed_text(), "The goblin hits you for 2.") var first_melee := game.submit_test_action(Vector2i.RIGHT) assert_eq(first_melee[0].kind, &"melee") assert_eq(first_melee[1].kind, &"enemy_melee") - await _wait_for_feedback() - assert_eq(enemy_view.last_damage, 3) - assert_eq(player_view.last_damage, 2) - assert_string_contains(game.get_node("HUD/EnemyHealthLabel").text, "3/6") - assert_eq(hud.combat_summary, "Target: Goblin HP: 3/6") - assert_eq(hud.combat_summary_label.text, "Target: Goblin HP: 3/6") - assert_string_contains(hud.event_log.get_parsed_text(), "You strike the goblin for 3.") + assert_eq(state.player.cell, Vector2i(4, 7)) + assert_eq(enemy.cell, Vector2i(5, 7)) + assert_string_contains(hud.event_log.get_parsed_text(), "with mains nues") var lethal_melee := game.submit_test_action(Vector2i.RIGHT) assert_eq(lethal_melee[0].kind, &"melee") assert_eq(lethal_melee[1].kind, &"enemy_defeated") assert_false(state.enemies.has(&"goblin")) - await _wait_for_feedback() - assert_eq(game.get_node("World/Enemies").get_child_count(), 0) - assert_eq(game.get_node_or_null("World/Enemies/Goblin"), null) - assert_eq(game.get_node("HUD/EnemyHealthLabel").text, "No active target") assert_eq(hud.combat_summary, "No active target") - assert_eq(hud.combat_summary_label.text, "No active target") - assert_string_contains(hud.event_log.get_parsed_text(), "The goblin is defeated.") -func _wait_for_feedback() -> void: - await get_tree().create_timer(0.34).timeout +func _key_event(keycode: Key) -> InputEventKey: + var event := InputEventKey.new() + event.keycode = keycode + event.physical_keycode = keycode + event.pressed = true + return event diff --git a/tests/e2e/test_death_mode_e2e.gd b/tests/e2e/test_death_mode_e2e.gd index 350f7fe..7458d87 100644 --- a/tests/e2e/test_death_mode_e2e.gd +++ b/tests/e2e/test_death_mode_e2e.gd @@ -1,6 +1,7 @@ extends GutTest const GameScene = preload("res://scenes/Game.tscn") +const MainMenuScene = preload("res://scenes/menu/MainMenu.tscn") const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd") const ItemDefinitionType = preload("res://scripts/domain/items/item_definition.gd") const ItemInstanceType = preload("res://scripts/domain/items/item_instance.gd") @@ -15,7 +16,12 @@ func test_classic_death_ends_actions_shows_death_panel_and_preserves_the_run_slo assert_true(game.get_run_state().is_game_over) assert_eq(game.get_run_state().slot_policy, &"preserve") assert_true(panel.visible) - assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Classique") + assert_string_contains((panel.get_node("Layout/Body") as RichTextLabel).get_parsed_text(), "Classique") + assert_true((panel.get_node("Layout/Actions/LoadButton") as Button).visible) + var navigation: Array[StringName] = [] + game.connect("death_navigation_requested", func(action: StringName) -> void: navigation.append(action)) + (panel.get_node("Layout/Actions/NewRunButton") as Button).pressed.emit() + assert_eq(navigation, [&"new_run"]) assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"run_ended")) assert_eq(game.submit_test_action(Vector2i.RIGHT), []) @@ -27,9 +33,30 @@ func test_permadeath_death_retires_the_run_slot_and_reports_the_mode() -> void: assert_true(game.get_run_state().is_game_over) assert_eq(game.get_run_state().slot_policy, &"retire") assert_true(panel.visible) - assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "permanente") + assert_string_contains((panel.get_node("Layout/Body") as RichTextLabel).get_parsed_text(), "permanente") + assert_false((panel.get_node("Layout/Actions/LoadButton") as Button).visible) + var navigation: Array[StringName] = [] + game.connect("death_navigation_requested", func(action: StringName) -> void: navigation.append(action)) + (panel.get_node("Layout/Actions/MenuButton") as Button).pressed.emit() + assert_eq(navigation, [&"menu"]) assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"permadeath_run_retired")) +func test_death_navigation_returns_to_the_real_main_menu_and_opens_requested_flow() -> void: + var menu := MainMenuScene.instantiate() as MainMenu + add_child_autofree(menu) + await get_tree().process_frame + await get_tree().process_frame + menu._start_new_run(RunSettingsType.new("death-nav", &"crawler", false), "Death Nav") + await get_tree().process_frame + var game := menu.get_node("Game") as Game + + game.death_navigation_requested.emit(&"new_run") + await get_tree().process_frame + + assert_null(menu.get_node_or_null("Game")) + assert_false(menu.get_node("Menu").visible) + assert_true(menu.get_node("CharacterCreation").visible) + func test_qualified_narrative_resurrection_continues_the_real_game_without_showing_death_panel() -> void: var game := await _game(true) var state := game.get_game_state() @@ -50,16 +77,21 @@ func test_qualified_narrative_resurrection_continues_the_real_game_without_showi func _kill_player_through_real_enemy_turn(game: Game) -> void: var state := game.get_game_state() - var enemy: ActorState = state.enemies[&"goblin"] + var enemy: ActorState = state.enemies.get(&"goblin") + if enemy == null: + enemy = ActorState.new(&"goblin", state.player.cell + Vector2i.RIGHT, 6, 2) + state.enemies[enemy.id] = enemy enemy.cell = state.player.cell + Vector2i.RIGHT enemy.weapon_damage = state.player.hit_points enemy.damage_variance = 0 enemy.accuracy = 30 - game.submit_test_interact() + var results: Array[TurnResult] = [] + TurnResolver.append_enemy_response(state, results) + game._resolve_player_action(results, false) func _game(permadeath: bool) -> Game: var game := GameScene.instantiate() as Game - game.configure_new_run(RunSettingsType.new("F6-E2E", &"crawler", permadeath), "F6 Hero", &"vanguard") + game.configure_new_run(RunSettingsType.new("F6-E2E", &"crawler", permadeath), "F6 Hero") add_child_autofree(game) await get_tree().process_frame return game diff --git a/tests/e2e/test_demo_map_chest_e2e.gd b/tests/e2e/test_demo_map_chest_e2e.gd index 2847118..a409199 100644 --- a/tests/e2e/test_demo_map_chest_e2e.gd +++ b/tests/e2e/test_demo_map_chest_e2e.gd @@ -8,48 +8,31 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame -func test_real_input_opens_door_then_chest_and_preserves_stairs_route() -> void: +func test_real_input_opens_surface_door_and_reaches_the_generated_first_floor() -> void: var state := game.get_game_state() var hud := game.get_node("HUD") as GameHud - var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label var event_log := game.get_node("HUD/EventLog") as RichTextLabel - state.enemies.erase(&"goblin") + assert_eq(state.map.size, Vector2i(42, 16)) + assert_eq(state.floor_state.floor_number, 0) + assert_true(state.floor_state.chests.is_empty()) - assert_eq(state.map.size, Vector2i(30, 20)) - assert_eq(prompt_label.text, "Espace — Ouvrir la porte") + state.player.cell = Vector2i(35, 7) + hud.refresh(state, [], game.get_run_state()) + assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte") game._unhandled_input(_key_event(KEY_E)) assert_eq(game.last_turn_results[0].kind, &"door_opened") - assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR) + assert_eq(state.map.get_cell(Vector2i(36, 7)), GridMapState.CellKind.FLOOR) - for keycode in [KEY_UP, KEY_UP, KEY_UP, KEY_UP]: - game._unhandled_input(_key_event(keycode)) - assert_eq(state.player.cell, Vector2i(4, 8)) - assert_eq(prompt_label.text, "Espace — Ouvrir le coffre") - game._unhandled_input(_key_event(KEY_UP)) - assert_eq(state.player.cell, Vector2i(4, 8)) - assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.CHEST) - assert_string_contains(event_log.get_parsed_text(), "Your way is blocked.") + for step in range(4): + game._unhandled_input(_key_event(KEY_RIGHT)) + assert_eq(state.player.cell, state.floor_state.exit) + assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier") + game._unhandled_input(_key_event(KEY_E)) - game._unhandled_input(_key_event(KEY_SPACE)) - assert_eq(game.last_turn_results[0].kind, &"chest_opened") - assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.FLOOR) - assert_eq(hud.get_context_prompt(), "") - assert_string_contains(event_log.get_parsed_text(), "Coffre ouvert :") - assert_true(game.get_node("HUD/LootPanel").visible) - game._unhandled_input(_key_event(KEY_SPACE)) - assert_false(game.get_node("HUD/LootPanel").visible) - game._unhandled_input(_key_event(KEY_UP)) - assert_eq(state.player.cell, Vector2i(4, 7)) - - for keycode in [KEY_UP, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_UP, KEY_UP]: - game._unhandled_input(_key_event(keycode)) - assert_eq(state.player.cell, Vector2i(18, 4)) - game.get_run_state().current_floor_deadline().turns_remaining = 2 * FloorDeadline.TURNS_PER_DAY - hud.refresh(state, [], game.get_run_state()) - assert_eq(prompt_label.text, "Espace — Descendre l’escalier") - game._unhandled_input(_key_event(KEY_SPACE)) assert_eq(game.get_run_state().current_floor, 1) - assert_eq(game.get_game_state().player.cell, game.get_game_state().floor_state.entrance) + assert_eq(state.map.size, Vector2i(210, 105)) + assert_eq(state.floor_state.rooms.size(), 170) + assert_false(state.floor_state.metadata.get("hand_authored", true)) assert_string_contains(event_log.get_parsed_text(), "You descend the stairs.") func _key_event(keycode: Key) -> InputEventKey: diff --git a/tests/e2e/test_dialogue_e2e.gd b/tests/e2e/test_dialogue_e2e.gd index 7f1fe98..787dcf9 100644 --- a/tests/e2e/test_dialogue_e2e.gd +++ b/tests/e2e/test_dialogue_e2e.gd @@ -18,8 +18,8 @@ func test_real_merchant_dialogue_choice_opens_shop_and_journals_choice() -> void await _dispatch_key(KEY_E) var panel := game.get_node("HUD/DialoguePanel") as PanelContainer assert_true(panel.visible) - assert_string_contains((game.get_node("HUD/DialoguePanel/Title") as Label).text, "Marchand") - assert_string_contains((game.get_node("HUD/DialoguePanel/Entries") as RichTextLabel).get_parsed_text(), "Voir toute sa marchandise.") + assert_string_contains((game.get_node("HUD/DialoguePanel/Layout/Title") as Label).text, "Marchand") + assert_string_contains((game.get_node("HUD/DialoguePanel/Layout/Entries") as RichTextLabel).get_parsed_text(), "Voir toute sa marchandise.") assert_eq(game.get_run_state().recent_events(1)[0].kind, &"dialogue_started") await _dispatch_key(KEY_DOWN) @@ -36,7 +36,7 @@ func test_real_guide_dialogue_hides_and_reveals_condition_gated_choice_then_jour state.floor_state.npcs[&"guide-e2e"] = ActorState.new(&"guide-e2e", state.player.cell + Vector2i.RIGHT, 1, 0, &"npc_guide_mordecai") await _dispatch_key(KEY_E) - var entries := game.get_node("HUD/DialoguePanel/Entries") as RichTextLabel + var entries := game.get_node("HUD/DialoguePanel/Layout/Entries") as RichTextLabel assert_false(entries.get_parsed_text().contains("Parlez-moi du choix de race")) await _dispatch_key(KEY_ESCAPE) diff --git a/tests/e2e/test_display_camera_grid_e2e.gd b/tests/e2e/test_display_camera_grid_e2e.gd index dad8982..7b7659c 100644 --- a/tests/e2e/test_display_camera_grid_e2e.gd +++ b/tests/e2e/test_display_camera_grid_e2e.gd @@ -17,7 +17,7 @@ func test_real_game_keyboard_movement_keeps_actor_in_cell_and_updates_camera_wit var hud_screen_position: Vector2 = player_health_label.get_global_rect().position var start_cell := state.player.cell - assert_eq(Game.REFERENCE_VIEWPORT, Vector2i(1280, 720)) + assert_eq(Game.REFERENCE_VIEWPORT, Vector2i(1920, 1080)) assert_true(renderer.get_cell_rect(start_cell).encloses(game.get_actor_cell_rect(&"player"))) var keyboard_event := InputEventKey.new() diff --git a/tests/e2e/test_door_interaction_e2e.gd b/tests/e2e/test_door_interaction_e2e.gd index 49fb7dc..714ab87 100644 --- a/tests/e2e/test_door_interaction_e2e.gd +++ b/tests/e2e/test_door_interaction_e2e.gd @@ -1,46 +1,23 @@ extends GutTest const GameScene = preload("res://scenes/Game.tscn") -var game: Game -func before_each() -> void: - game = GameScene.instantiate() +func test_real_game_keyboard_space_and_test_seam_open_surface_door_then_allow_walking_through_it() -> void: + var game := GameScene.instantiate() as Game add_child_autofree(game) await get_tree().process_frame - -func test_input_map_binds_space_and_e_to_interact() -> void: - assert_true(InputMap.action_has_event(&"interact", _key_event(KEY_SPACE))) - assert_true(InputMap.action_has_event(&"interact", _key_event(KEY_E))) - -func test_real_game_keyboard_space_and_test_seam_open_door_then_allow_walking_through_it() -> void: var state := game.get_game_state() - var hud := game.get_node("HUD") as GameHud - var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label - var event_log := game.get_node("HUD/EventLog") as RichTextLabel - var door_cell := Vector2i(4, 11) + var log := game.get_node("HUD/EventLog") as RichTextLabel + state.player.cell = Vector2i(35, 7) + (game.get_node("HUD") as GameHud).refresh(state, [], game.get_run_state()) + game._unhandled_input(_key_event(KEY_SPACE)) + assert_eq(game.last_turn_results[0].kind, &"door_opened") + assert_eq(state.map.get_cell(Vector2i(36, 7)), GridMapState.CellKind.FLOOR) + assert_string_contains(log.get_parsed_text(), "You open the door.") - assert_eq(state.map.get_cell(door_cell), GridMapState.CellKind.FLOOR) - assert_eq(hud.get_context_prompt(), "") - assert_eq(prompt_label.text, "") - assert_string_contains(event_log.get_parsed_text(), "You open the door.") - - var move_results := game.submit_test_action(Vector2i.UP) - assert_eq(move_results[0].kind, &"moved") - assert_eq(state.player.cell, door_cell) - - var submitted_game := GameScene.instantiate() as Game - add_child_autofree(submitted_game) - await get_tree().process_frame - var submitted_results: Array[TurnResult] = submitted_game.submit_test_interact() - assert_eq(submitted_results[0].kind, &"door_opened") - assert_eq(submitted_game.get_game_state().map.get_cell(door_cell), GridMapState.CellKind.FLOOR) - - var e_game := GameScene.instantiate() as Game - add_child_autofree(e_game) - await get_tree().process_frame - e_game._unhandled_input(_key_event(KEY_E)) - assert_eq(e_game.get_game_state().map.get_cell(door_cell), GridMapState.CellKind.FLOOR) + game.submit_test_action(Vector2i.RIGHT) + assert_eq(state.player.cell, Vector2i(36, 7)) func _key_event(keycode: Key) -> InputEventKey: var event := InputEventKey.new() diff --git a/tests/e2e/test_door_to_stairs_exit_e2e.gd b/tests/e2e/test_door_to_stairs_exit_e2e.gd index ac8fd90..e39f0c5 100644 --- a/tests/e2e/test_door_to_stairs_exit_e2e.gd +++ b/tests/e2e/test_door_to_stairs_exit_e2e.gd @@ -8,30 +8,19 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame -func test_real_input_event_completes_door_to_stairs_descent_and_arrives_on_floor_one() -> void: +func test_real_input_event_completes_surface_door_to_generated_dungeon_descent() -> void: var state := game.get_game_state() var hud := game.get_node("HUD") as GameHud var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label var event_log := game.get_node("HUD/EventLog") as RichTextLabel var initial_map := state.map - var initial_map_size := state.map.size - state.enemies.erase(&"goblin") - - game._unhandled_input(_key_event(KEY_SPACE)) - assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR) - for keycode in [KEY_UP, KEY_UP, KEY_UP, KEY_UP]: - game._unhandled_input(_key_event(keycode)) - assert_eq(state.player.cell, Vector2i(4, 8)) - game._unhandled_input(_key_event(KEY_E)) - assert_true(game.get_node("HUD/LootPanel").visible) - game._unhandled_input(_key_event(KEY_SPACE)) - assert_false(game.get_node("HUD/LootPanel").visible) - for keycode in [KEY_UP, KEY_UP, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_UP, KEY_UP]: - game._unhandled_input(_key_event(keycode)) - - assert_eq(state.player.cell, Vector2i(18, 4)) - game.get_run_state().current_floor_deadline().turns_remaining = 2 * FloorDeadline.TURNS_PER_DAY + state.player.cell = Vector2i(35, 7) hud.refresh(state, [], game.get_run_state()) + + game._unhandled_input(_key_event(KEY_SPACE)) + for step in range(4): + game._unhandled_input(_key_event(KEY_RIGHT)) + assert_eq(state.player.cell, Vector2i(39, 7)) assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier") game._unhandled_input(_key_event(KEY_E)) @@ -41,8 +30,7 @@ func test_real_input_event_completes_door_to_stairs_descent_and_arrives_on_floor assert_string_contains(event_log.get_parsed_text(), "You open the door.") assert_string_contains(event_log.get_parsed_text(), "You descend the stairs.") assert_ne(state.map, initial_map) - assert_ne(state.map.size, initial_map_size) - assert_eq(initial_map.get_cell(Vector2i(18, 4)), GridMapState.CellKind.STAIRS) + assert_eq(state.map.size, Vector2i(210, 105)) assert_eq(state.player.cell, state.floor_state.entrance) func _key_event(keycode: Key) -> InputEventKey: diff --git a/tests/e2e/test_enemy_ai_e2e.gd b/tests/e2e/test_enemy_ai_e2e.gd index d2788be..50d786c 100644 --- a/tests/e2e/test_enemy_ai_e2e.gd +++ b/tests/e2e/test_enemy_ai_e2e.gd @@ -4,12 +4,34 @@ const ActorState = preload("res://scripts/domain/actor_state.gd") const GridMapState = preload("res://scripts/domain/grid_map_state.gd") const GameScene = preload("res://scenes/Game.tscn") +func test_enemy_view_is_hidden_until_its_cell_enters_current_field_of_view() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var state := game.get_game_state() + state.enemies.clear() + var enemy := ActorState.new(&"hidden_enemy", Vector2i(24, 8), 6, 2) + state.enemies[enemy.id] = enemy + game._sync_enemy_views() + var view := game.enemy_views[enemy.id] as ActorView + + assert_false(state.visible_cells.has(enemy.cell)) + assert_false(view.visible) + + enemy.cell = state.player.cell + Vector2i.RIGHT + game.sync_presentation_for_testing() + game._sync_enemy_views() + assert_true(state.visible_cells.has(enemy.cell)) + assert_true(view.visible) + func test_real_game_enemy_detects_approaches_attacks_and_dies_with_feedback() -> void: var game := GameScene.instantiate() as Game add_child_autofree(game) await get_tree().process_frame var state := game.get_game_state() - var enemy: ActorState = state.enemies[&"goblin"] + var enemy := ActorState.new(&"goblin", state.player.cell + Vector2i(3, 0), 3, 2) + state.enemies[enemy.id] = enemy + game._sync_enemy_views() enemy.cell = state.player.cell + Vector2i(3, 0) enemy.hit_points = 3 enemy.max_hit_points = 3 @@ -19,8 +41,9 @@ func test_real_game_enemy_detects_approaches_attacks_and_dies_with_feedback() -> var approach := game.submit_test_action(Vector2i.DOWN) assert_eq(approach.map(func(result: TurnResult) -> StringName: return result.kind), [&"moved", &"enemy_moved"]) - assert_eq(enemy.cell, Vector2i(6, 12)) + assert_eq(enemy.cell, state.player.cell + Vector2i(2, -1)) assert_ne(enemy.cell, state.player.cell) + assert_eq((game.get_node("World/Enemies/Goblin") as ActorView).position, Vector2(enemy.cell * ActorView.TILE_SIZE)) # A real contextual action keeps the player in place, allowing the detected # enemy to execute its adjacent C2 melee turn. diff --git a/tests/e2e/test_equip_use_item_e2e.gd b/tests/e2e/test_equip_use_item_e2e.gd index e90f4c5..ef3b964 100644 --- a/tests/e2e/test_equip_use_item_e2e.gd +++ b/tests/e2e/test_equip_use_item_e2e.gd @@ -25,7 +25,7 @@ func test_inventory_keyboard_flow_equips_live_combat_weapon_uses_consumable_and_ await _dispatch_key(KEY_I) var panel := game.get_node("HUD/InventoryPanel") as PanelContainer - var details := game.get_node("HUD/InventoryPanel/Details") as RichTextLabel + var details := game.get_node("HUD/InventoryPanel/Layout/Columns/Details") as RichTextLabel assert_true(panel.visible) assert_string_contains(details.get_parsed_text(), "Epee rouillee") assert_eq(state.player.weapon_damage, 3) @@ -57,7 +57,7 @@ func test_inventory_ui_reveals_unidentified_equipment_and_shows_slot_comparison( inventory.add_item(mysterious) await _dispatch_key(KEY_I) - var details := game.get_node("HUD/InventoryPanel/Details") as RichTextLabel + var details := game.get_node("HUD/InventoryPanel/Layout/Columns/Details") as RichTextLabel await _dispatch_key(KEY_E) await _dispatch_key(KEY_DOWN) assert_string_contains(details.get_parsed_text(), "Unidentified weapon") diff --git a/tests/e2e/test_event_puzzle_e2e.gd b/tests/e2e/test_event_puzzle_e2e.gd index 47a39e7..3d9cb3e 100644 --- a/tests/e2e/test_event_puzzle_e2e.gd +++ b/tests/e2e/test_event_puzzle_e2e.gd @@ -18,8 +18,8 @@ func test_real_input_dispatches_one_shot_note_event_and_persists_completion() -> await _dispatch_key(KEY_E) var panel := game.get_node("HUD/EventPanel") as PanelContainer assert_true(panel.visible) - assert_string_contains((panel.get_node("Title") as Label).text, "Événement") - assert_string_contains((panel.get_node("Entries") as RichTextLabel).get_parsed_text(), "Prendre la note") + assert_string_contains((panel.get_node("Layout/Title") as Label).text, "Événement") + assert_string_contains((panel.get_node("Layout/Entries") as RichTextLabel).get_parsed_text(), "Prendre la note") assert_eq(game.get_run_state().recent_events(1)[0].kind, &"event_started") await _dispatch_key(KEY_ENTER) @@ -45,11 +45,11 @@ func test_real_input_solves_pressure_plate_puzzle_and_journals_reward() -> void: await _dispatch_key(KEY_E) var panel := game.get_node("HUD/EventPanel") as PanelContainer assert_true(panel.visible) - assert_string_contains((panel.get_node("Title") as Label).text, "Énigme") - assert_string_contains((panel.get_node("Entries") as RichTextLabel).get_parsed_text(), "Chercher un mecanisme") + assert_string_contains((panel.get_node("Layout/Title") as Label).text, "Énigme") + assert_string_contains((panel.get_node("Layout/Entries") as RichTextLabel).get_parsed_text(), "Chercher un mecanisme") await _dispatch_key(KEY_ENTER) - assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "compartiment cache") + assert_string_contains((panel.get_node("Layout/Body") as RichTextLabel).get_parsed_text(), "compartiment cache") assert_eq(game.get_run_state().gold, 25) assert_true(game.get_run_state().inventory.items.any(func(item: ItemInstance) -> bool: return item.definition.id == &"consumable_stimpack")) await _dispatch_key(KEY_ENTER) diff --git a/tests/e2e/test_exploration_fov_e2e.gd b/tests/e2e/test_exploration_fov_e2e.gd index 568070e..f4ba24f 100644 --- a/tests/e2e/test_exploration_fov_e2e.gd +++ b/tests/e2e/test_exploration_fov_e2e.gd @@ -11,29 +11,19 @@ func before_each() -> void: func test_real_game_updates_fog_after_public_action_and_preserves_opaque_fov() -> void: var renderer := game.get_node("World/MapRenderer") as MapRenderer var state := game.get_game_state() - var opaque_obstacle := Vector2i(4, 11) - var cell_behind_obstacle := Vector2i(4, 10) - assert_true(state.visible_cells.has(opaque_obstacle)) - assert_false(state.visible_cells.has(cell_behind_obstacle)) + state.enemies.clear() + var old_cell := Vector2i(2, 7) + var new_cell := Vector2i(17, 7) + for step in range(7): + var results := game.submit_test_action(Vector2i.RIGHT) + assert_eq(results[0].kind, &"moved") - game.submit_test_interact() - var results := game.submit_test_action(Vector2i.UP) - - assert_eq(results[0].kind, &"moved") - assert_true(state.explored_cells.has(Vector2i(1, 12))) - assert_false(state.visible_cells.has(Vector2i(1, 12))) - # This is the instantiated Game.tscn scene, driven through its public action - # seam: moving out of sight leaves one explored, one visible, and one unknown cell. - assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"explored") - assert_eq(renderer.get_cell_render_color(Vector2i(1, 12)), renderer.EXPLORED_DIM_COLOR) - assert_true(state.visible_cells.has(Vector2i(4, 17))) - assert_eq(renderer.get_cell_visibility_state(Vector2i(4, 17)), &"visible") - assert_eq(renderer.get_cell_render_color(Vector2i(4, 17)), Color.WHITE) - assert_false(state.explored_cells.has(Vector2i(29, 19))) - assert_eq(renderer.get_cell_visibility_state(Vector2i(29, 19)), &"unknown") - assert_eq(renderer.get_cell_render_color(Vector2i(29, 19)), Color(0.005, 0.008, 0.02, 1.0)) - assert_lt( - renderer.get_cell_render_color(Vector2i(29, 19)).get_luminance(), - renderer.get_cell_render_color(Vector2i(1, 12)).get_luminance() - ) - assert_lte(renderer.get_cell_render_color(Vector2i(1, 12)).get_luminance(), 0.35) + assert_true(state.explored_cells.has(old_cell)) + assert_false(state.visible_cells.has(old_cell)) + assert_eq(renderer.get_cell_visibility_state(old_cell), &"explored") + assert_eq(renderer.get_cell_render_color(old_cell), renderer.EXPLORED_DIM_COLOR) + assert_true(state.visible_cells.has(new_cell)) + assert_eq(renderer.get_cell_visibility_state(new_cell), &"visible") + assert_eq(renderer.get_cell_render_color(new_cell), Color.WHITE) + assert_false(state.explored_cells.has(Vector2i(41, 15))) + assert_eq(renderer.get_cell_visibility_state(Vector2i(41, 15)), &"unknown") diff --git a/tests/e2e/test_floor_three_choice_e2e.gd b/tests/e2e/test_floor_three_choice_e2e.gd index f18e3ad..eda3e96 100644 --- a/tests/e2e/test_floor_three_choice_e2e.gd +++ b/tests/e2e/test_floor_three_choice_e2e.gd @@ -26,7 +26,7 @@ func test_level_three_open_choice_blocks_actions_until_a_perk_is_chosen_and_jour assert_true(game.get_run_state().recent_events(8).any(func(event: GameEvent) -> bool: return event.kind == &"level_three_choice_required")) await _dispatch_key(KEY_RIGHT) - assert_eq(state.player.cell, Vector2i(4, 12)) + assert_eq(state.player.cell, Vector2i(4, 7)) await _dispatch_key(KEY_ENTER) assert_false(panel.visible) assert_eq(game.get_perk_engine().rank_for(&"increvable"), 1) diff --git a/tests/e2e/test_floor_three_race_class_e2e.gd b/tests/e2e/test_floor_three_race_class_e2e.gd new file mode 100644 index 0000000..957ac43 --- /dev/null +++ b/tests/e2e/test_floor_three_race_class_e2e.gd @@ -0,0 +1,39 @@ +extends GutTest + +const GameScene = preload("res://scenes/Game.tscn") +const FloorGeneratorType = preload("res://scripts/domain/world/floor_generator.gd") + +func test_entering_dungeon_floor_three_requires_race_then_class_before_play_continues() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var state := game.get_game_state() + var run := game.get_run_state() + var floor_two := FloorGeneratorType.generate(run.seed, 2, game.spell_catalog) + run.current_floor = 2 + run.set_floor_state(floor_two) + state.set_floor_state(floor_two) + state.player.cell = floor_two.exit + run.current_floor_deadline().turns_remaining = 2 * FloorDeadline.TURNS_PER_DAY + + game.submit_test_interact() + await get_tree().process_frame + + var panel := game.get_node("HUD/RaceClassChoicePanel") as PanelContainer + assert_eq(run.current_floor, 3) + assert_true(panel.visible) + assert_eq(game.get_dialogue_player().race, &"") + assert_eq(game.get_dialogue_player().archetype, &"") + var frozen_cell := state.player.cell + game.submit_test_action(Vector2i.RIGHT) + assert_eq(state.player.cell, frozen_cell) + + panel.confirm() + await get_tree().process_frame + assert_ne(game.get_dialogue_player().race, &"") + assert_eq(game.get_dialogue_player().archetype, &"") + panel.confirm() + await get_tree().process_frame + assert_ne(game.get_dialogue_player().archetype, &"") + assert_eq(run.base_archetype, game.get_dialogue_player().archetype) + assert_false(panel.visible) diff --git a/tests/e2e/test_floor_three_race_class_e2e.gd.uid b/tests/e2e/test_floor_three_race_class_e2e.gd.uid new file mode 100644 index 0000000..eabe32f --- /dev/null +++ b/tests/e2e/test_floor_three_race_class_e2e.gd.uid @@ -0,0 +1 @@ +uid://dxy3qbc6qj0gf diff --git a/tests/e2e/test_health_regeneration_e2e.gd b/tests/e2e/test_health_regeneration_e2e.gd new file mode 100644 index 0000000..1844830 --- /dev/null +++ b/tests/e2e/test_health_regeneration_e2e.gd @@ -0,0 +1,44 @@ +extends GutTest + +const GameScene = preload("res://scenes/Game.tscn") +const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd") +const PlayerActionType = preload("res://scripts/domain/run/player_action.gd") + +var game: Game + +func before_each() -> void: + game = GameScene.instantiate() + game.configure_new_run(RunSettingsType.new("PASSIVE-REGEN-E2E", &"crawler", false, true), "Regenerator") + add_child_autofree(game) + await get_tree().process_frame + await get_tree().process_frame + game.get_game_state().enemies.clear() + +func test_a_real_turn_silently_regenerates_player_and_living_companion_health() -> void: + var state := game.get_game_state() + state.player.hit_points = state.player.max_hit_points - 4 + state.companion.actor.hit_points = state.companion.actor.max_hit_points - 4 + var log_size := game.get_run_state().log.size() + + game.submit_player_action(PlayerActionType.new(&"move", _walkable_direction())) + + assert_eq(state.player.hit_points, state.player.max_hit_points - 3) + assert_eq(state.companion.actor.hit_points, state.companion.actor.max_hit_points - 3) + var new_events := game.get_run_state().recent_events(game.get_run_state().log.size() - log_size) + assert_false(new_events.any(func(event: GameEvent) -> bool: return event.kind == &"health_regenerated")) + +func test_a_dead_companion_is_not_revived_by_the_players_turn() -> void: + var state := game.get_game_state() + state.companion.actor.hit_points = 0 + + game.submit_player_action(PlayerActionType.new(&"move", _walkable_direction())) + + assert_eq(state.companion.actor.hit_points, 0) + +func _walkable_direction() -> Vector2i: + var state := game.get_game_state() + for direction in [Vector2i.UP, Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT]: + if state.map.is_walkable(state.player.cell + direction): + return direction + fail_test("The generated start must provide a walkable cardinal action.") + return Vector2i.ZERO diff --git a/tests/e2e/test_health_regeneration_e2e.gd.uid b/tests/e2e/test_health_regeneration_e2e.gd.uid new file mode 100644 index 0000000..042c413 --- /dev/null +++ b/tests/e2e/test_health_regeneration_e2e.gd.uid @@ -0,0 +1 @@ +uid://cxyqev4mq3tk7 diff --git a/tests/e2e/test_hud_prompts_e2e.gd b/tests/e2e/test_hud_prompts_e2e.gd index 3e1cbfa..0243d3b 100644 --- a/tests/e2e/test_hud_prompts_e2e.gd +++ b/tests/e2e/test_hud_prompts_e2e.gd @@ -8,39 +8,27 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame -func test_real_game_exposes_door_and_stairs_prompts_with_help_and_event_log() -> void: - var hud := game.get_node("HUD") as GameHud +func test_real_game_exposes_surface_door_and_stairs_prompts_with_help_and_event_log() -> void: var state := game.get_game_state() - var help_label := game.get_node("HUD/HelpLabel") as Label - var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label - var event_log := game.get_node("HUD/EventLog") as RichTextLabel - + var hud := game.get_node("HUD") as GameHud + var prompt := game.get_node("HUD/ContextPromptLabel") as Label + state.player.cell = Vector2i(35, 7) + hud.refresh(state, [], game.get_run_state()) assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte") - assert_eq(prompt_label.text, "Espace — Ouvrir la porte") - assert_string_contains(help_label.text, "Déplacer : ZQSD / Flèches") - assert_string_contains(help_label.text, "nord-est : pavé num. 9") - assert_string_contains(help_label.text, "Interagir : Espace ou E") + assert_eq(prompt.text, "Espace — Ouvrir la porte") - var interact_event := InputEventKey.new() - interact_event.keycode = KEY_SPACE - interact_event.physical_keycode = KEY_SPACE - interact_event.pressed = true - game._unhandled_input(interact_event) - assert_eq(hud.get_context_prompt(), "") - assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR) - - state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR) - state.player.cell = Vector2i(18, 4) - game.get_run_state().current_floor_deadline().turns_remaining = 2 * FloorDeadline.TURNS_PER_DAY + game._unhandled_input(_key_event(KEY_E)) + state.player.cell = state.floor_state.exit hud.refresh(state, [], game.get_run_state()) assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier") - assert_eq(prompt_label.text, "Espace — Descendre l’escalier") - var stairs_results := game.submit_test_interact() - assert_eq(stairs_results[0].kind, &"stairs_used") + game._unhandled_input(_key_event(KEY_E)) assert_eq(game.get_run_state().current_floor, 1) assert_eq(hud.get_context_prompt(), "Espace — Monter l’escalier") - assert_eq(prompt_label.text, "Espace — Monter l’escalier") + assert_eq(prompt.text, "Espace — Monter l’escalier") - var results := game.submit_test_action(Vector2i.LEFT) - assert_eq(results[0].kind, &"moved") - assert_string_contains(event_log.get_parsed_text(), "You move to") +func _key_event(keycode: Key) -> InputEventKey: + var event := InputEventKey.new() + event.keycode = keycode + event.physical_keycode = keycode + event.pressed = true + return event diff --git a/tests/e2e/test_input_action_router_e2e.gd b/tests/e2e/test_input_action_router_e2e.gd index 257a3ca..d3978f0 100644 --- a/tests/e2e/test_input_action_router_e2e.gd +++ b/tests/e2e/test_input_action_router_e2e.gd @@ -10,38 +10,58 @@ func before_each() -> void: func test_input_pipeline_routes_e_interaction_and_movement_through_action_router() -> void: var state := game.get_game_state() - var start_cell := state.player.cell + state.player.cell = Vector2i(35, 7) + (game.get_node("HUD") as GameHud).refresh(state, [], game.get_run_state()) + game._unhandled_input(_key_event(KEY_E)) + assert_eq(game.last_turn_results[0].kind, &"door_opened") + game._unhandled_input(_key_event(KEY_RIGHT)) + assert_eq(game.last_turn_results[0].kind, &"moved") + assert_eq(state.player.cell, Vector2i(36, 7)) - await _dispatch_key(KEY_E) - assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR) - assert_eq(game.get_run_state().recent_events(2)[0].kind, &"door_opened") +func test_repeated_vertical_arrow_presses_each_move_exactly_once_and_echo_is_ignored() -> void: + var state := game.get_game_state() + state.enemies.clear() + state.player.cell = Vector2i(4, 7) + var starting_turn := game.get_run_state().current_turn - await _dispatch_key(KEY_DOWN) - assert_eq(state.player.cell, start_cell + Vector2i.DOWN) - assert_eq(game.get_run_state().recent_events(2)[0].kind, &"moved") + for _index in range(6): + game._unhandled_input(_key_event(KEY_DOWN)) + game._unhandled_input(_key_event(KEY_UP)) + + assert_eq(state.player.cell, Vector2i(4, 7)) + assert_eq(game.get_run_state().current_turn, starting_turn + 12) + var echo_event := _key_event(KEY_DOWN) + echo_event.echo = true + game._unhandled_input(echo_event) + assert_eq(state.player.cell, Vector2i(4, 7)) + assert_eq(game.get_run_state().current_turn, starting_turn + 12) + +func test_arrow_movement_is_not_lost_when_a_hud_control_keeps_keyboard_focus() -> void: + var state := game.get_game_state() + state.enemies.clear() + state.player.cell = Vector2i(4, 7) + var focused_control := LineEdit.new() + focused_control.focus_mode = Control.FOCUS_ALL + focused_control.text = "A control that consumes navigation keys" + game.get_node("HUD").add_child(focused_control) + focused_control.grab_focus() + await get_tree().process_frame + + Input.parse_input_event(_key_event(KEY_DOWN)) + await get_tree().process_frame + + assert_eq(state.player.cell, Vector2i(4, 8)) func test_input_pipeline_routes_inventory_input_to_the_live_panel_and_journal() -> void: - var panel := game.get_node("HUD/InventoryPanel") as PanelContainer - var event_log := game.get_node("HUD/EventLog") as RichTextLabel - - await _dispatch_key(KEY_I) - + game._unhandled_input(_key_event(KEY_I)) + assert_true((game.get_node("HUD/InventoryPanel") as PanelContainer).visible) var event := game.get_run_state().recent_events(1)[0] assert_eq(event.kind, &"inventory_opened") assert_eq(event.payload, {"item_count": 0}) - assert_eq(event.turn, 1) - assert_true(panel.visible) - assert_string_contains(event_log.get_parsed_text(), "Inventory opened") -func _dispatch_key(keycode: Key) -> void: - Input.parse_input_event(_key_event(keycode, true)) - await get_tree().process_frame - Input.parse_input_event(_key_event(keycode, false)) - await get_tree().process_frame - -func _key_event(keycode: Key, pressed: bool) -> InputEventKey: +func _key_event(keycode: Key) -> InputEventKey: var event := InputEventKey.new() event.keycode = keycode event.physical_keycode = keycode - event.pressed = pressed + event.pressed = true return event diff --git a/tests/e2e/test_level_up_e2e.gd b/tests/e2e/test_level_up_e2e.gd index 5a7dcdb..6091fe4 100644 --- a/tests/e2e/test_level_up_e2e.gd +++ b/tests/e2e/test_level_up_e2e.gd @@ -24,6 +24,11 @@ func test_real_character_input_opens_panel_and_allocates_level_up_points_without assert_eq(state.player.progression.attribute_points, 1) assert_eq(state.player.progression.skill_points, 1) assert_true(game.get_run_state().recent_events(8).any(func(event: GameEvent) -> bool: return event.kind == &"level_up")) + var xp_bar := game.get_node("HUD/ExperienceBar") as ProgressBar + var xp_label := game.get_node("HUD/ExperienceLabel") as Label + assert_eq(xp_bar.value, 0.0) + assert_eq(xp_bar.max_value, 200.0) + assert_eq(xp_label.text, "Niveau 2 — XP 0/200") await _dispatch_key(KEY_P) var panel := game.get_node("HUD/CharacterPanel") as PanelContainer diff --git a/tests/e2e/test_melee_feedback_e2e.gd b/tests/e2e/test_melee_feedback_e2e.gd index 0e9d6e5..0e679ea 100644 --- a/tests/e2e/test_melee_feedback_e2e.gd +++ b/tests/e2e/test_melee_feedback_e2e.gd @@ -11,6 +11,7 @@ func test_real_game_resolves_damage_and_death_before_a3_feedback_and_journals_st enemy.cell = state.player.cell + Vector2i.RIGHT enemy.hit_points = 3 enemy.max_hit_points = 3 + enemy.loot_table = &"floor1_reward" var presenter := game.get_node("EventPresenter") as EventPresenter var observed: Array[GameEvent] = [] presenter.event_presented.connect(func(event: GameEvent) -> void: @@ -24,6 +25,13 @@ func test_real_game_resolves_damage_and_death_before_a3_feedback_and_journals_st var recent := game.get_run_state().recent_events(8).filter(func(event: GameEvent) -> bool: return event.kind in [&"attack_started", &"attack_hit", &"damage_dealt", &"actor_died", &"xp_granted", &"loot_dropped"]) assert_eq(recent.map(func(event: GameEvent) -> StringName: return event.kind), [&"attack_started", &"attack_hit", &"damage_dealt", &"actor_died", &"xp_granted", &"loot_dropped"]) assert_eq(recent[2].payload.damage, 3) + assert_true(state.floor_state.ground_items.has(enemy.cell)) + if state.floor_state.ground_items.has(enemy.cell): + assert_false(state.floor_state.ground_items[enemy.cell].is_empty()) + assert_true(state.floor_state.ground_items[enemy.cell][0] is ItemInstance) + var loot_event: GameEvent = recent.filter(func(event: GameEvent) -> bool: return event.kind == &"loot_dropped")[0] + assert_true(loot_event.payload.has("items")) + assert_true(loot_event.payload.has("gold")) await _wait_for_feedback(observed) assert_eq(observed.map(func(event: GameEvent) -> StringName: return event.kind), [&"attack_started", &"attack_hit", &"damage_dealt", &"actor_died", &"xp_granted", &"loot_dropped"]) assert_string_contains(game.get_node("HUD/EventLog").get_parsed_text(), "defeated") diff --git a/tests/e2e/test_new_run_creation_e2e.gd b/tests/e2e/test_new_run_creation_e2e.gd index f719f9f..a861d0f 100644 --- a/tests/e2e/test_new_run_creation_e2e.gd +++ b/tests/e2e/test_new_run_creation_e2e.gd @@ -22,8 +22,12 @@ func test_actual_menu_creation_flow_starts_game_and_emits_event() -> void: assert_true(creation.visible) (creation.get_node("Panel/Layout/Fields/NameEdit") as LineEdit).text = "A6 Hero" - (creation.get_node("Panel/Layout/Fields/ArchetypeOption") as OptionButton).select(1) + assert_null(creation.get_node_or_null("Panel/Layout/Fields/ArchetypeOption")) + assert_null(creation.get_node_or_null("Panel/Layout/Fields/RaceOption")) (creation.get_node("Panel/Layout/Fields/PetCheck") as CheckBox).button_pressed = true + await get_tree().process_frame + (creation.get_node("Panel/Layout/Fields/PetDetails/PetNameEdit") as LineEdit).text = "Donut" + (creation.get_node("Panel/Layout/Fields/PetDetails/PetSpeciesEdit") as LineEdit).text = "Chatte devenue intelligente" (creation.get_node("Panel/Layout/Fields/SeedEdit") as LineEdit).text = "A6-E2E-SEED" (creation.get_node("Panel/Layout/Fields/DifficultyOption") as OptionButton).select(2) (creation.get_node("Panel/Layout/Fields/PermadeathOption") as OptionButton).select(1) @@ -39,8 +43,12 @@ func test_actual_menu_creation_flow_starts_game_and_emits_event() -> void: assert_eq(game.get_run_state().settings.difficulty_id, &"veteran") assert_true(game.get_run_state().settings.permadeath) assert_true(game.get_run_state().settings.pet_enabled) + assert_eq(game.get_game_state().companion.name, "Donut") + assert_eq(game.get_game_state().companion.species, "Chatte devenue intelligente") assert_eq(game.get_run_state().player_name, "A6 Hero") - assert_eq(game.get_run_state().base_archetype, &"mystic") + assert_eq(game.get_run_state().base_archetype, &"") + assert_eq(game.get_dialogue_player().race, &"") + assert_eq(game.get_dialogue_player().archetype, &"") assert_eq(game.get_run_state().current_floor, 0) assert_eq(game.get_run_state().recent_events(1)[0].kind, &"game_started") assert_eq(started_events.size(), 1) diff --git a/tests/e2e/test_no_audio_startup_e2e.gd b/tests/e2e/test_no_audio_startup_e2e.gd index fd57fb2..2caa295 100644 --- a/tests/e2e/test_no_audio_startup_e2e.gd +++ b/tests/e2e/test_no_audio_startup_e2e.gd @@ -25,6 +25,22 @@ func before_each() -> void: func after_each() -> void: OS.set_environment("DCW_AUDIO_HOME", previous_audio_home) +func test_normal_game_starts_with_bundled_exploration_music_playing() -> void: + # This scene uses the production AudioLibrary rather than the isolated + # replacement installed by before_each. + game.queue_free() + await get_tree().process_frame + game = GameScene.instantiate() + add_child_autofree(game) + await get_tree().process_frame + var audio := game.get_node("AudioLibrary") as AudioLibrary + + assert_eq(audio.current_ambience_context, "exploration") + assert_true(audio.has_playable_ambience()) + assert_true(audio.get_ambience_player().playing) + if audio.get_ambience_stream() != null: + assert_string_contains(audio.get_ambience_stream().resource_path, "assets/audio/") + func test_real_game_resolves_combat_with_empty_audio_home() -> void: var audio = game.get_node("AudioLibrary") diff --git a/tests/e2e/test_pet_companion_e2e.gd b/tests/e2e/test_pet_companion_e2e.gd index e6aaad5..f116dff 100644 --- a/tests/e2e/test_pet_companion_e2e.gd +++ b/tests/e2e/test_pet_companion_e2e.gd @@ -9,7 +9,7 @@ var game: Game func before_each() -> void: game = GameScene.instantiate() - game.configure_new_run(RunSettings.new("E4-PET-E2E", &"crawler", false, true), "Pet Tester", &"vanguard") + game.configure_new_run(RunSettings.new("E4-PET-E2E", &"crawler", false, true), "Pet Tester") add_child_autofree(game) await get_tree().process_frame await get_tree().process_frame @@ -24,20 +24,40 @@ func test_pet_choice_spawns_visible_companion_and_real_input_changes_command_sta await _dispatch_key(KEY_K) assert_true(panel.visible) - assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Follow") + var panel_text := (panel.get_node("Body") as RichTextLabel).get_parsed_text() + assert_string_contains(panel_text, "Reste en arrière") + assert_string_contains(panel_text, "Défends-moi") + assert_string_contains(panel_text, "Attaque à vue") await _dispatch_key(KEY_RIGHT) - assert_eq(companion.stance, CompanionState.Stance.DEFEND) + assert_eq(companion.stance, CompanionState.Stance.DEFEND_ME) assert_string_contains(String(game.get_run_state().recent_events(1)[0].kind), "companion_stance") await _dispatch_key(KEY_ESCAPE) assert_false(panel.visible) +func test_companion_uses_the_temporary_dog_sprite() -> void: + var companion_sprite := game.get_node("World/Companion") as Sprite2D + assert_not_null(companion_sprite.texture) + assert_string_contains(companion_sprite.texture.resource_path, "war_dog.png") + +func test_floor_transition_places_the_living_pet_next_to_the_player() -> void: + var state := game.get_game_state() + state.player.cell = state.floor_state.exit + state.exit_reached = false + game.get_run_state().current_floor_deadline().turns_remaining = 0 + + game.submit_player_action(preload("res://scripts/domain/run/player_action.gd").new(&"interact")) + + assert_eq(game.get_run_state().current_floor, 1) + assert_lte(state.companion.actor.cell.distance_to(state.player.cell), 1.0) + assert_ne(state.companion.actor.cell, state.player.cell) + func test_live_enemy_attack_is_intercepted_in_support_and_companion_death_leaves_player_run_alive() -> void: var state := game.get_game_state() var companion := state.companion companion.actor.hit_points = 1 companion.actor.max_hit_points = 1 companion.actor.cell = state.player.cell + Vector2i.RIGHT - assert_true(companion.set_stance(CompanionState.Stance.SUPPORT)) + assert_true(companion.set_stance(CompanionState.Stance.DEFEND_ME)) var enemy: ActorState = state.enemies.values()[0] enemy.cell = state.player.cell + Vector2i.LEFT enemy.weapon_damage = 20 diff --git a/tests/e2e/test_pickup_inventory_e2e.gd b/tests/e2e/test_pickup_inventory_e2e.gd index 5e04ffb..2e68d35 100644 --- a/tests/e2e/test_pickup_inventory_e2e.gd +++ b/tests/e2e/test_pickup_inventory_e2e.gd @@ -37,7 +37,7 @@ func test_real_interact_picks_visible_ground_item_then_inventory_action_opens_li await _dispatch_key(KEY_I) var panel := game.get_node("HUD/InventoryPanel") as PanelContainer - var entries := game.get_node("HUD/InventoryPanel/Entries") as RichTextLabel + var entries := game.get_node("HUD/InventoryPanel/Layout/Columns/Entries") as RichTextLabel assert_true(panel.visible) assert_string_contains(entries.get_parsed_text(), "Bandage x2") assert_eq(game.get_run_state().recent_events(1)[0].kind, &"inventory_opened") diff --git a/tests/e2e/test_quest_lifecycle_e2e.gd b/tests/e2e/test_quest_lifecycle_e2e.gd index 1494304..15ffda0 100644 --- a/tests/e2e/test_quest_lifecycle_e2e.gd +++ b/tests/e2e/test_quest_lifecycle_e2e.gd @@ -24,7 +24,7 @@ func test_real_input_board_accepts_tracks_completes_rewards_and_journals_quest() await _dispatch_key(KEY_E) var panel := game.get_node("HUD/QuestPanel") as PanelContainer assert_true(panel.visible) - assert_string_contains((panel.get_node("Entries") as RichTextLabel).get_parsed_text(), "Prime : gobelins") + assert_string_contains((panel.get_node("Layout/Entries") as RichTextLabel).get_parsed_text(), "Prime : gobelins") assert_eq(game.get_run_state().recent_events(1)[0].kind, &"quest_board_read") await _dispatch_key(KEY_ENTER) diff --git a/tests/e2e/test_ranged_targeting_e2e.gd b/tests/e2e/test_ranged_targeting_e2e.gd index e1d82b0..11f7c43 100644 --- a/tests/e2e/test_ranged_targeting_e2e.gd +++ b/tests/e2e/test_ranged_targeting_e2e.gd @@ -11,6 +11,7 @@ func test_real_game_ranged_action_opens_targeting_selects_enemy_and_resolves_dam enemy.cell = state.player.cell + Vector2i(3, 0) enemy.hit_points = 6 enemy.max_hit_points = 6 + enemy.loot_table = &"floor1_reward" game.equip_test_ranged_weapon({ "id": "weapon_hand_crossbow", "weapon_kind": "ranged", "damage": 6, "damage_variance": 0, "accuracy": 0, "range": 4, @@ -31,6 +32,7 @@ func test_real_game_ranged_action_opens_targeting_selects_enemy_and_resolves_dam game.submit_test_target(&"goblin") assert_false(state.enemies.has(&"goblin")) # immediate domain resolution precedes A3 presentation + assert_true(state.floor_state.ground_items.has(enemy.cell)) assert_eq(state.player.ammunition, 1) assert_false(overlay.visible) var recent := game.get_run_state().recent_events(8) @@ -38,6 +40,36 @@ func test_real_game_ranged_action_opens_targeting_selects_enemy_and_resolves_dam await _wait_for_projectile(presented) assert_eq(presented.size(), 1) +func test_f_targeting_can_be_cancelled_without_a_turn_and_valid_shot_spends_one_turn_while_enemy_approaches() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var state := game.get_game_state() + var enemy: ActorState = state.enemies[&"goblin"] + state.player.cell = Vector2i(4, 7) + enemy.cell = Vector2i(8, 7) + enemy.ai_behavior = &"aggressive" + enemy.vision_range = 8 + game.equip_test_ranged_weapon({ + "id": "weapon_hand_crossbow", "weapon_kind": "ranged", "damage": 1, + "damage_variance": 0, "accuracy": 100, "range": 6, + }, 2) + var starting_turn := game.get_run_state().current_turn + + await _dispatch_key(KEY_F) + var overlay := game.get_node("HUD/TargetingOverlay") as TargetingOverlay + assert_true(overlay.visible) + assert_eq(game.get_run_state().current_turn, starting_turn, "Choosing a target does not spend a turn.") + await _dispatch_key(KEY_ESCAPE) + assert_false(overlay.visible) + assert_eq(game.get_run_state().current_turn, starting_turn, "Cancelling targeting does not spend a turn.") + + await _dispatch_key(KEY_F) + await _dispatch_key(KEY_ENTER) + assert_eq(game.get_run_state().current_turn, starting_turn + 1) + assert_eq(enemy.cell, Vector2i(7, 7), "A surviving enemy immediately advances after the shot.") + assert_eq(state.player.ammunition, 1) + func test_real_game_rejects_blocked_target_without_damage_or_ammunition_loss() -> void: var game := GameScene.instantiate() as Game add_child_autofree(game) @@ -60,6 +92,17 @@ func test_real_game_rejects_blocked_target_without_damage_or_ammunition_loss() - assert_eq(rejected.size(), 1) assert_eq(rejected[0].payload.reason, &"line_of_sight_blocked") +func _dispatch_key(keycode: Key) -> void: + var event := InputEventKey.new() + event.keycode = keycode + event.physical_keycode = keycode + event.pressed = true + Input.parse_input_event(event) + await get_tree().process_frame + event.pressed = false + Input.parse_input_event(event) + await get_tree().process_frame + func _wait_for_projectile(presented: Array[GameEvent]) -> void: var deadline := Time.get_ticks_msec() + 1000 while presented.is_empty() and Time.get_ticks_msec() < deadline: diff --git a/tests/e2e/test_recruit_party_e2e.gd b/tests/e2e/test_recruit_party_e2e.gd index 31558b7..e664b78 100644 --- a/tests/e2e/test_recruit_party_e2e.gd +++ b/tests/e2e/test_recruit_party_e2e.gd @@ -20,7 +20,7 @@ func test_wandering_crawler_dialogue_recruits_visible_party_member_and_opens_par await _dispatch_key(KEY_E) var dialogue := game.get_node("HUD/DialoguePanel") as PanelContainer assert_true(dialogue.visible) - assert_string_contains((dialogue.get_node("Entries") as RichTextLabel).get_parsed_text(), "Rejoindre le groupe.") + assert_string_contains((dialogue.get_node("Layout/Entries") as RichTextLabel).get_parsed_text(), "Rejoindre le groupe.") await _dispatch_key(KEY_ENTER) assert_false(dialogue.visible) diff --git a/tests/e2e/test_run_event_journal_e2e.gd b/tests/e2e/test_run_event_journal_e2e.gd index 24e1ea0..2121ff6 100644 --- a/tests/e2e/test_run_event_journal_e2e.gd +++ b/tests/e2e/test_run_event_journal_e2e.gd @@ -9,7 +9,7 @@ func before_each() -> void: await get_tree().process_frame func test_real_input_event_records_one_action_turn_and_hud_renders_its_run_state_messages() -> void: - game._unhandled_input(_key_event(KEY_DOWN)) + game._unhandled_input(_key_event(KEY_LEFT)) var run := game.get_run_state() var events := run.recent_events(2) var event_log := game.get_node("HUD/EventLog") as RichTextLabel diff --git a/tests/e2e/test_save_load_e2e.gd b/tests/e2e/test_save_load_e2e.gd index c312362..c814b50 100644 --- a/tests/e2e/test_save_load_e2e.gd +++ b/tests/e2e/test_save_load_e2e.gd @@ -17,6 +17,21 @@ func before_each() -> void: func after_each() -> void: repository.delete_all() +func test_editor_safe_v_opens_manual_save_slots_and_writes_the_selected_slot() -> void: + await _start_new_run("Sauvegarde manuelle", "SAVE-SHORTCUT") + var game := menu.get_node("Game") as Game + + await _dispatch_key(KEY_V) + + var panel := menu.get_node("SaveLoadPanel") as SaveLoadPanel + assert_true(panel.visible) + assert_eq(panel.title_label.text, "SAUVEGARDER LA PARTIE") + assert_string_contains(panel.status_label.text, "manuelle") + panel.slot_requested.emit(1) + assert_true(repository.list_slots()[0].exists) + assert_string_contains(panel.status_label.text, "emplacement 1") + assert_eq(game.get_run_state().current_turn, 1, "Opening the save panel must not consume a gameplay turn.") + func test_save_restart_and_load_slot_restores_equal_run_state() -> void: await _start_new_run("G1 restart hero", "G1-E2E-SEED") var original := menu.get_node("Game") as Game @@ -55,6 +70,18 @@ func _start_new_run(name: String, seed: String) -> void: await _click_button(creation.get_node("Panel/Layout/Actions/StartRunButton") as Button) await get_tree().process_frame +func _dispatch_key(keycode: Key, ctrl_pressed: bool = false) -> void: + var pressed := InputEventKey.new() + pressed.keycode = keycode + pressed.physical_keycode = keycode + pressed.ctrl_pressed = ctrl_pressed + pressed.pressed = true + Input.parse_input_event(pressed) + await get_tree().process_frame + pressed.pressed = false + Input.parse_input_event(pressed) + await get_tree().process_frame + func _click_button(button: Button) -> void: assert_not_null(button) var click_position := button.get_global_rect().get_center() diff --git a/tests/e2e/test_secret_trap_shrine_e2e.gd b/tests/e2e/test_secret_trap_shrine_e2e.gd index 8366e06..19bc6f9 100644 --- a/tests/e2e/test_secret_trap_shrine_e2e.gd +++ b/tests/e2e/test_secret_trap_shrine_e2e.gd @@ -10,6 +10,24 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame +func test_walking_on_an_undiscovered_trap_records_complete_structured_events() -> void: + var state := game.get_game_state() + state.enemies.clear() + state.player.perception = 0 + var trap_cell := state.player.cell + Vector2i.RIGHT + state.floor_state.traps[trap_cell] = {"trap_id": &"trap_dart"} + + game._unhandled_input(_key_event(KEY_RIGHT)) + + assert_eq(state.player.cell, trap_cell) + var trap_events := game.get_run_state().recent_events(8).filter(func(event: GameEvent) -> bool: return event.kind in [&"trap_triggered", &"trap_status_applied"]) + # One structured trigger, one structured status, plus the legacy TurnResult + # compatibility event are all journaled with complete actor/cell metadata. + assert_eq(trap_events.size(), 3) + assert_eq(trap_events.filter(func(event: GameEvent) -> bool: return event.kind == &"trap_status_applied").size(), 1) + assert_true(trap_events.all(func(event: GameEvent) -> bool: return event.actor_id == state.player.id and event.cell == trap_cell)) + assert_true(state.player.has_status(&"poison")) + func test_real_input_route_reveals_secret_discovers_and_disarms_trap_then_uses_shrine_and_reads_board() -> void: var state := game.get_game_state() state.enemies.clear() diff --git a/tests/e2e/test_shop_rest_e2e.gd b/tests/e2e/test_shop_rest_e2e.gd index 9fde98d..468aaa7 100644 --- a/tests/e2e/test_shop_rest_e2e.gd +++ b/tests/e2e/test_shop_rest_e2e.gd @@ -15,7 +15,7 @@ func test_real_merchant_interaction_opens_shop_and_purchase_updates_inventory_an var floor := state.floor_state state.enemies.clear() floor.npcs.clear() - var merchant := ActorState.new(&"merchant-e2e", Vector2i(5, 12), 1, 0, &"npc_wandering_merchant") + var merchant := ActorState.new(&"merchant-e2e", state.player.cell + Vector2i.RIGHT, 1, 0, &"npc_wandering_merchant") floor.npcs[merchant.id] = merchant game.get_run_state().gold = 100 var no_events: Array[GameEvent] = [] @@ -23,7 +23,7 @@ func test_real_merchant_interaction_opens_shop_and_purchase_updates_inventory_an assert_eq((game.get_node("HUD/GoldLabel") as Label).text, "Or: 100") await _dispatch_key(KEY_E) - var dialogue_entries := game.get_node("HUD/DialoguePanel/Entries") as RichTextLabel + var dialogue_entries := game.get_node("HUD/DialoguePanel/Layout/Entries") as RichTextLabel assert_true((game.get_node("HUD/DialoguePanel") as PanelContainer).visible) assert_string_contains(dialogue_entries.get_parsed_text(), "Voir toute sa marchandise.") assert_eq(game.get_run_state().recent_events(1)[0].kind, &"dialogue_started") diff --git a/tests/e2e/test_spell_casting_e2e.gd b/tests/e2e/test_spell_casting_e2e.gd index 0254ee2..b8c621d 100644 --- a/tests/e2e/test_spell_casting_e2e.gd +++ b/tests/e2e/test_spell_casting_e2e.gd @@ -16,6 +16,7 @@ func test_real_game_cast_opens_spell_targeting_and_resolves_imported_spell_befor state.player.xp = 99 state.player.progression.set_total_xp(99) enemy.xp_reward = 1 + enemy.loot_table = &"floor1_reward" var started_events := game.submit_test_cast() var overlay := game.get_node("HUD/SpellTargetingOverlay") as SpellTargetingOverlay @@ -32,6 +33,7 @@ func test_real_game_cast_opens_spell_targeting_and_resolves_imported_spell_befor game.submit_test_spell_target(&"spell_epines_empoisonnees", &"goblin") assert_false(state.enemies.has(&"goblin")) # Domain outcome is immediate; A3 feedback is asynchronous. + assert_true(state.floor_state.ground_items.has(enemy.cell)) assert_eq(state.player.focus, 10) assert_eq(state.player.progression.level, 2) assert_true(game.get_run_state().recent_events(10).any(func(event: GameEvent) -> bool: return event.kind == &"level_up")) diff --git a/tests/e2e/test_stair_deadline_e2e.gd b/tests/e2e/test_stair_deadline_e2e.gd index 7205634..2d28511 100644 --- a/tests/e2e/test_stair_deadline_e2e.gd +++ b/tests/e2e/test_stair_deadline_e2e.gd @@ -8,29 +8,17 @@ func before_each() -> void: add_child_autofree(game) await get_tree().process_frame -func test_real_game_early_down_stairs_are_blocked_then_rest_makes_descent_eligible() -> void: +func test_surface_stairs_are_immediately_open_then_first_dungeon_floor_has_a_deadline() -> void: var state := game.get_game_state() var hud := game.get_node("HUD") as GameHud - var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label - var log := game.get_node("HUD/EventLog") as RichTextLabel - state.enemies.clear() state.player.cell = state.floor_state.exit - - assert_string_contains(hud.get_context_prompt(), "encore 13 jour") - game._unhandled_input(_key_event(KEY_E)) - assert_eq(game.get_run_state().current_floor, 0) - assert_eq(prompt_label.text, hud.get_context_prompt()) - assert_string_contains(log.get_parsed_text(), "Les escaliers refusent") - assert_string_contains(log.get_parsed_text(), "13 jour") - - game.advance_floor_deadline(13 * FloorDeadline.REAL_SECONDS_PER_DAY) - assert_eq(game.get_run_state().deadline_for(0).remaining_days(), 2) + hud.refresh(state, [], game.get_run_state()) assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier") - game._unhandled_input(_key_event(KEY_E)) assert_eq(game.get_run_state().current_floor, 1) assert_eq(state.player.cell, state.floor_state.entrance) assert_eq(hud.get_context_prompt(), "Espace — Monter l’escalier") + assert_eq(game.get_run_state().current_floor_deadline().remaining_days(), 15) func _key_event(keycode: Key) -> InputEventKey: var event := InputEventKey.new() diff --git a/tests/e2e/test_temporary_playtest_chests_e2e.gd b/tests/e2e/test_temporary_playtest_chests_e2e.gd new file mode 100644 index 0000000..6d57e12 --- /dev/null +++ b/tests/e2e/test_temporary_playtest_chests_e2e.gd @@ -0,0 +1,103 @@ +extends GutTest + +const GameScene = preload("res://scenes/Game.tscn") +const RunSettings = preload("res://scripts/domain/run/run_settings.gd") +const TemporaryPlaytestKit = preload("res://scripts/game/temporary_playtest_kit.gd") +const SaveRepository = preload("res://scripts/infrastructure/save/save_repository.gd") + +var game: Game + +func before_each() -> void: + game = GameScene.instantiate() + game.configure_new_run(RunSettings.new("TEMP-CHESTS", &"crawler"), "Chest Tester") + add_child_autofree(game) + await get_tree().process_frame + +func test_new_playtest_run_has_exactly_three_accessible_fixed_gameplay_chests() -> void: + var state := game.get_game_state() + assert_eq(state.floor_state.chests.size(), 3) + var rewards: Array[Dictionary] = [] + for cell: Vector2i in state.floor_state.chests: + assert_eq(state.map.get_cell(cell), GridMapState.CellKind.CHEST) + assert_lte(cell.distance_to(state.player.cell), 3.0) + rewards.append(state.floor_state.chests[cell].reward) + + assert_true(_has_reward_item(rewards, &"weapon_rusty_sword")) + assert_true(_has_reward_item(rewards, &"weapon_hand_crossbow")) + assert_true(_has_reward_item(rewards, &"misc_grimoire_ombre")) + assert_true(rewards.any(func(reward: Dictionary) -> bool: return int(reward.get("ammunition", 0)) >= 10)) + +func test_all_three_playtest_chests_open_and_transfer_rewards_through_the_normal_ui_flow() -> void: + var state := game.get_game_state() + state.enemies.clear() + for chest_cell: Vector2i in TemporaryPlaytestKit.CHESTS: + state.player.cell = chest_cell + Vector2i.DOWN + state.update_exploration() + var results := game.submit_test_interact() + assert_eq(results[0].kind, &"chest_opened") + assert_true((game.get_node("HUD/LootPanel") as PanelContainer).visible) + await _dispatch_key(KEY_ENTER) + assert_false((game.get_node("HUD/LootPanel") as PanelContainer).visible) + + var inventory_ids := game.get_run_state().inventory.items.map(func(item: ItemInstance) -> StringName: return item.definition.id) + assert_has(inventory_ids, &"weapon_rusty_sword") + assert_has(inventory_ids, &"weapon_hand_crossbow") + assert_has(inventory_ids, &"misc_grimoire_ombre") + assert_eq(state.player.ammunition, 20) + +func test_temporary_rewards_grant_ammunition_and_teach_the_offensive_spell_through_normal_use() -> void: + var state := game.get_game_state() + var ranged_reward := _reward_with_item(state.floor_state.chests, &"weapon_hand_crossbow") + var spell_reward := _reward_with_item(state.floor_state.chests, &"misc_grimoire_ombre") + + game.pending_loot = ranged_reward.duplicate(true) + game._take_all_loot() + assert_eq(state.player.ammunition, 20) + assert_true(game.get_run_state().inventory.items.any(func(item: ItemInstance) -> bool: return item.definition.id == &"weapon_hand_crossbow")) + + game.pending_loot = spell_reward.duplicate(true) + game._take_all_loot() + var grimoire: ItemInstance = game.get_run_state().inventory.items.filter(func(item: ItemInstance) -> bool: return item.definition.id == &"misc_grimoire_ombre")[0] + var use_result := game.get_run_state().inventory.use_item(grimoire.instance_id, state.player, game.get_run_state().identification) + game._apply_item_use_effects(use_result.get("effects", [])) + assert_true(game.get_spell_state().knows(&"spell_ombre_vive")) + +func test_loaded_run_does_not_recreate_consumed_temporary_chests() -> void: + var state := game.get_game_state() + state.floor_state.chests.clear() + for cell: Vector2i in TemporaryPlaytestKit.CHESTS: + state.map.set_cell(cell, GridMapState.CellKind.FLOOR) + var repository := SaveRepository.new() + repository.delete_all() + assert_true(repository.save(1, game.get_run_state(), state, game.get_dialogue_player()).ok) + var loaded := repository.load(1, game.spell_catalog) + var restored := GameScene.instantiate() as Game + restored.configure_loaded_run(loaded) + add_child_autofree(restored) + await get_tree().process_frame + + assert_true(restored.get_game_state().floor_state.chests.is_empty()) + repository.delete_all() + +func _dispatch_key(keycode: Key) -> void: + var event := InputEventKey.new() + event.keycode = keycode + event.physical_keycode = keycode + event.pressed = true + Input.parse_input_event(event) + await get_tree().process_frame + event.pressed = false + Input.parse_input_event(event) + await get_tree().process_frame + +func _reward_with_item(chests: Dictionary[Vector2i, Dictionary], item_id: StringName) -> Dictionary: + for chest: Dictionary in chests.values(): + if chest.reward.items.any(func(item: Dictionary) -> bool: return StringName(item.item_id) == item_id): + return chest.reward + return {} + +func _has_reward_item(rewards: Array[Dictionary], item_id: StringName) -> bool: + for reward: Dictionary in rewards: + if reward.get("items", []).any(func(item: Dictionary) -> bool: return StringName(item.get("item_id", "")) == item_id): + return true + return false diff --git a/tests/e2e/test_temporary_playtest_chests_e2e.gd.uid b/tests/e2e/test_temporary_playtest_chests_e2e.gd.uid new file mode 100644 index 0000000..6c9a5ac --- /dev/null +++ b/tests/e2e/test_temporary_playtest_chests_e2e.gd.uid @@ -0,0 +1 @@ +uid://tf6xjw0oab8c diff --git a/tests/e2e/test_world_chest_loot_e2e.gd b/tests/e2e/test_world_chest_loot_e2e.gd index fc4f913..b8a5750 100644 --- a/tests/e2e/test_world_chest_loot_e2e.gd +++ b/tests/e2e/test_world_chest_loot_e2e.gd @@ -12,23 +12,20 @@ func before_each() -> void: func test_real_chest_open_displays_french_reward_then_take_all_updates_inventory_and_closes_panel() -> void: var state := game.get_game_state() state.enemies.clear() - var chest_cell := Vector2i(4, 7) + var chest_cell := state.player.cell + Vector2i.UP state.floor_state.chests[chest_cell] = { "loot_table_id": &"floor1_reward", "opened": false, "reward_seed": "e2e-reward", } + state.map.set_cell(chest_cell, GridMapState.CellKind.CHEST) var journal := game.get_node("HUD/EventLog") as RichTextLabel - for keycode in [KEY_E, KEY_UP, KEY_UP, KEY_UP, KEY_UP]: - await _dispatch_key(keycode) - assert_eq(state.player.cell, Vector2i(4, 8)) - await _dispatch_key(KEY_E) var chest_event := game.get_run_state().recent_events(1)[0] var panel := game.get_node("HUD/LootPanel") as Control - var entries := game.get_node("HUD/LootPanel/Entries") as RichTextLabel + var entries := game.get_node("HUD/LootPanel/Layout/Entries") as RichTextLabel assert_eq(chest_event.kind, &"chest_opened") assert_true(chest_event.payload.has("items")) assert_true(chest_event.payload.has("gold")) diff --git a/tests/integration/test_companion_support.gd b/tests/integration/test_companion_support.gd index 0aa87e5..70e9c89 100644 --- a/tests/integration/test_companion_support.gd +++ b/tests/integration/test_companion_support.gd @@ -15,7 +15,7 @@ func test_support_companion_intercepts_enemy_damage_then_dies_without_ending_or_ var enemy := _actor(&"goblin", Vector2i(2, 1), 12, 20, {"ai": "aggressive", "vision_range": 6}) var state := GameState.new(map, player, {enemy.id: enemy}) state.companion = CompanionState.from_choice(&"moth", Vector2i(4, 1), 1) - assert_true(state.companion.set_stance(CompanionState.Stance.SUPPORT)) + assert_true(state.companion.set_stance(CompanionState.Stance.DEFEND_ME)) var results: Array[TurnResult] = [] TurnResolver.append_enemy_response(state, results) @@ -26,6 +26,39 @@ func test_support_companion_intercepts_enemy_damage_then_dies_without_ending_or_ assert_true(enemy.is_alive()) assert_true(player.is_alive()) +func test_attack_on_sight_companion_follows_player_when_the_only_hostile_is_not_detected() -> void: + var map := GridMapState.new(Vector2i(10, 5), GridMapState.CellKind.FLOOR) + for y in range(5): + map.set_cell(Vector2i(5, y), GridMapState.CellKind.WALL) + var player := _actor(&"player", Vector2i(3, 2), 20, 3) + var hidden_enemy := _actor(&"hidden", Vector2i(7, 2), 20, 2, {"ai": "aggressive", "vision_range": 8}) + var state := GameState.new(map, player, {hidden_enemy.id: hidden_enemy}) + state.companion = CompanionState.from_choice(&"dog", Vector2i(1, 2)) + assert_true(state.companion.set_stance(CompanionState.Stance.ATTACK_ON_SIGHT)) + + var results := state.try_player_action(Vector2i.DOWN) + + assert_eq(state.player.cell, Vector2i(3, 3)) + assert_lt(state.companion.actor.cell.distance_to(state.player.cell), Vector2i(1, 2).distance_to(state.player.cell), "Without a detected hostile, attack-on-sight must move closer to the exploring player.") + assert_true(results.any(func(result: TurnResult) -> bool: return result.kind == &"companion_moved")) + +func test_attack_on_sight_companion_pursues_then_attacks_a_detected_hostile_automatically() -> void: + var map := GridMapState.new(Vector2i(8, 5), GridMapState.CellKind.FLOOR) + var player := _actor(&"player", Vector2i(1, 1), 20, 3) + var enemy := _actor(&"goblin", Vector2i(4, 1), 20, 0, {"ai": "passive", "vision_range": 0}) + var state := GameState.new(map, player, {enemy.id: enemy}) + state.companion = CompanionState.from_choice(&"dog", Vector2i(2, 1)) + state.companion.actor.accuracy = 100 + assert_true(state.companion.set_stance(CompanionState.Stance.ATTACK_ON_SIGHT)) + + var pursuit_results := state.try_player_action(Vector2i.DOWN) + assert_eq(state.companion.actor.cell, Vector2i(3, 1)) + assert_true(pursuit_results.any(func(result: TurnResult) -> bool: return result.kind == &"companion_moved")) + + var attack_results := state.try_player_action(Vector2i.UP) + assert_lt(enemy.hit_points, enemy.max_hit_points) + assert_true(attack_results.any(func(result: TurnResult) -> bool: return result.kind == &"companion_melee")) + func test_living_companion_follows_after_player_move_without_sharing_a_cell_or_blocking_enemy_pathing() -> void: var map := GridMapState.new(Vector2i(8, 3), GridMapState.CellKind.FLOOR) var player := _actor(&"player", Vector2i(2, 1), 20, 3) diff --git a/tests/scripts/test_godot_import_runners.sh b/tests/scripts/test_godot_import_runners.sh index 93bb0c2..e2e7ba8 100755 --- a/tests/scripts/test_godot_import_runners.sh +++ b/tests/scripts/test_godot_import_runners.sh @@ -30,7 +30,7 @@ import sys import zlib os.makedirs("artifacts", exist_ok=True) -width, height = 1280, 720 +width, height = 1920, 1080 unknown = (1, 2, 5) visible = (176, 176, 176) explored = (19, 29, 39) diff --git a/tests/unit/test_action_router.gd b/tests/unit/test_action_router.gd index 994ab9d..ced7ba8 100644 --- a/tests/unit/test_action_router.gd +++ b/tests/unit/test_action_router.gd @@ -20,6 +20,16 @@ func test_interact_and_move_northeast_have_distinct_physical_bindings() -> void: assert_false(InputMap.action_has_event(&"move_northeast", interact_e)) assert_false(InputMap.action_has_event(&"interact", northeast_keypad_9)) +func test_f_starts_ranged_targeting_and_ctrl_s_or_v_requests_a_manual_save() -> void: + assert_true(InputMap.action_has_event(&"ranged", _key_event(KEY_F))) + assert_true(InputMap.action_has_event(&"save", _key_event(KEY_S, true))) + assert_true(InputMap.action_has_event(&"save", _key_event(KEY_V))) + assert_false(InputMap.has_action(&"attack"), "Melee is resolved by moving into an adjacent enemy, not by a conflicting F action.") + + var router := ActionRouter.new(null) + assert_eq(router.action_from_input(_action_event(&"ranged")).kind, &"ranged") + assert_eq(router.action_from_input(_action_event(&"save")).kind, &"save") + func test_action_from_input_maps_the_complete_command_vocabulary() -> void: var router := ActionRouter.new(null) var expected := { @@ -33,8 +43,8 @@ func test_action_from_input_maps_the_complete_command_vocabulary() -> void: &"move_southeast": [&"move", Vector2i(1, 1)], &"wait": [&"wait", Vector2i.ZERO], &"interact": [&"interact", Vector2i.ZERO], - &"attack": [&"attack", Vector2i.ZERO], &"ranged": [&"ranged", Vector2i.ZERO], + &"save": [&"save", Vector2i.ZERO], &"cast": [&"cast", Vector2i.ZERO], &"talk": [&"talk", Vector2i.ZERO], &"rest": [&"rest", Vector2i.ZERO], @@ -71,7 +81,7 @@ func test_submit_inventory_action_opens_the_inventory_panel() -> void: assert_eq(events[0].turn, 1) assert_eq(game.get_run_state().recent_events(1)[0], events[0]) assert_true((game.get_node("HUD/InventoryPanel") as PanelContainer).visible) - assert_eq(game.get_game_state().player.cell, Vector2i(4, 12)) + assert_eq(game.get_game_state().player.cell, Vector2i(4, 7)) func _action_event(input_action: StringName) -> InputEventAction: var event := InputEventAction.new() @@ -79,9 +89,11 @@ func _action_event(input_action: StringName) -> InputEventAction: event.pressed = true return event -func _key_event(keycode: Key) -> InputEventKey: +func _key_event(keycode: Key, ctrl_pressed: bool = false) -> InputEventKey: var event := InputEventKey.new() + event.device = 16 event.keycode = keycode event.physical_keycode = keycode + event.ctrl_pressed = ctrl_pressed event.pressed = true return event diff --git a/tests/unit/test_audio_playback.gd b/tests/unit/test_audio_playback.gd index c1e58a0..9ba2290 100644 --- a/tests/unit/test_audio_playback.gd +++ b/tests/unit/test_audio_playback.gd @@ -40,7 +40,7 @@ func test_unregistered_external_audio_file_is_never_decoded_or_playable() -> voi var file := FileAccess.open(wav_path, FileAccess.WRITE) file.store_string("this must never be decoded by AudioLibrary") file.close() - var library := AudioLibrary.new() + var library := AudioLibrary.new(root) add_child_autofree(library) library.set_ambience_context("combat") diff --git a/tests/unit/test_choice_panel_layout.gd b/tests/unit/test_choice_panel_layout.gd new file mode 100644 index 0000000..bdc2498 --- /dev/null +++ b/tests/unit/test_choice_panel_layout.gd @@ -0,0 +1,33 @@ +extends GutTest + +const PANEL_SCENES := [ + preload("res://scenes/ui/EventPanel.tscn"), + preload("res://scenes/ui/DialoguePanel.tscn"), + preload("res://scenes/ui/QuestPanel.tscn"), +] + +func test_choice_panels_allocate_distinct_narrative_choices_and_help_zones() -> void: + for scene: PackedScene in PANEL_SCENES: + var panel := scene.instantiate() as PanelContainer + add_child_autofree(panel) + panel.visible = true + await get_tree().process_frame + await get_tree().process_frame + + assert_eq(panel.get_child_count(), 1, "%s must have one layout root" % panel.name) + var layout := panel.get_node_or_null("Layout") as VBoxContainer + assert_not_null(layout) + var title := layout.get_node("Title") as Control + var body := layout.get_node("Body") as RichTextLabel + var entries := layout.get_node("Entries") as RichTextLabel + var help := layout.get_node("Help") as Control + body.text = "Un long récit qui doit rester dans sa zone.\nUne deuxième ligne.\nUne troisième ligne." + entries.text = "> Premier choix avec une description\n Deuxième choix\n Troisième choix" + await get_tree().process_frame + + assert_true(panel.get_global_rect().encloses(layout.get_global_rect())) + for control: Control in [title, body, entries, help]: + assert_true(panel.get_global_rect().encloses(control.get_global_rect()), "%s must contain %s" % [panel.name, control.name]) + assert_false(title.get_global_rect().intersects(body.get_global_rect())) + assert_false(body.get_global_rect().intersects(entries.get_global_rect())) + assert_false(entries.get_global_rect().intersects(help.get_global_rect())) diff --git a/tests/unit/test_choice_panel_layout.gd.uid b/tests/unit/test_choice_panel_layout.gd.uid new file mode 100644 index 0000000..90bb87c --- /dev/null +++ b/tests/unit/test_choice_panel_layout.gd.uid @@ -0,0 +1 @@ +uid://dxkhffdckl1an diff --git a/tests/unit/test_combat_presentation.gd b/tests/unit/test_combat_presentation.gd index 7fce844..720568e 100644 --- a/tests/unit/test_combat_presentation.gd +++ b/tests/unit/test_combat_presentation.gd @@ -11,9 +11,13 @@ func before_each() -> void: func test_combat_routes_damage_feedback_and_exposes_current_target_summary() -> void: var hud := game.get_node("HUD") as GameHud var player_view := game.get_node("World/Player") as ActorView - var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView var state := game.get_game_state() - state.enemies[&"goblin"].cell = state.player.cell + Vector2i(2, 0) + state.enemies.clear() + var enemy := ActorState.new(&"goblin", state.player.cell + Vector2i(2, 0), 6, 2) + state.enemies[enemy.id] = enemy + game._sync_enemy_views() + var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView + hud.refresh(state, [], game.get_run_state()) assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6") game.submit_test_action(Vector2i.RIGHT) @@ -23,9 +27,11 @@ func test_combat_routes_damage_feedback_and_exposes_current_target_summary() -> game.submit_test_action(Vector2i.RIGHT) await _wait_for_feedback() - assert_eq(enemy_view.last_damage, 3) - assert_eq(hud.combat_summary, "Target: Goblin HP: 3/6") - assert_string_contains(hud.event_log.get_parsed_text(), "You strike the goblin for 3.") + game.submit_test_action(Vector2i.RIGHT) + await _wait_for_feedback() + assert_false(is_instance_valid(enemy_view)) + assert_eq(hud.combat_summary, "No active target") + assert_string_contains(hud.event_log.get_parsed_text(), "with mains nues") func _wait_for_feedback() -> void: await get_tree().create_timer(0.32).timeout diff --git a/tests/unit/test_companion.gd b/tests/unit/test_companion.gd index ef9d485..da9678f 100644 --- a/tests/unit/test_companion.gd +++ b/tests/unit/test_companion.gd @@ -14,11 +14,28 @@ func test_pet_choice_creates_a_living_default_companion_and_stances_are_explicit assert_eq(companion.choice_id, &"moth") assert_true(companion.is_alive()) - assert_eq(companion.stance, CompanionState.Stance.FOLLOW) - assert_true(companion.set_stance(CompanionState.Stance.DEFEND)) - assert_eq(companion.stance, CompanionState.Stance.DEFEND) + assert_eq(companion.stance, CompanionState.Stance.STAY_BACK) + assert_true(companion.set_stance(CompanionState.Stance.DEFEND_ME)) + assert_eq(companion.stance, CompanionState.Stance.DEFEND_ME) assert_false(companion.set_stance(&"ambush")) - assert_eq(companion.stance, CompanionState.Stance.DEFEND) + assert_eq(companion.stance, CompanionState.Stance.DEFEND_ME) + +func test_stay_back_defend_me_and_attack_on_sight_have_distinct_deterministic_actions() -> void: + var map := GridMapState.new(Vector2i(10, 5), GridMapState.CellKind.FLOOR) + var player := _actor(&"player", Vector2i(5, 2)) + var enemy := _actor(&"goblin", Vector2i(6, 2)) + var companion := CompanionState.from_choice(&"dog", Vector2i(2, 2)) + + assert_eq(companion.stance, CompanionState.Stance.STAY_BACK) + assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}), {"kind": &"move", "to_cell": Vector2i(3, 2)}, "Stay back follows the player but ignores enemies.") + + companion.actor.cell = Vector2i(5, 3) + assert_true(companion.set_stance(CompanionState.Stance.DEFEND_ME)) + assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}), {"kind": &"melee", "target_id": &"goblin"}) + + companion.actor.cell = Vector2i(2, 2) + assert_true(companion.set_stance(CompanionState.Stance.ATTACK_ON_SIGHT)) + assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}, {enemy.cell: true}), {"kind": &"move", "to_cell": Vector2i(2, 3)}) func test_follow_defend_and_support_policies_have_distinct_deterministic_actions() -> void: var map := GridMapState.new(Vector2i(8, 3), GridMapState.CellKind.FLOOR) @@ -28,10 +45,34 @@ func test_follow_defend_and_support_policies_have_distinct_deterministic_actions assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}), {"kind": &"move", "to_cell": Vector2i(2, 1)}) companion.actor.cell = Vector2i(4, 1) - assert_true(companion.set_stance(CompanionState.Stance.DEFEND)) + assert_true(companion.set_stance(CompanionState.Stance.DEFEND_ME)) assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}), {"kind": &"melee", "target_id": &"goblin"}) - assert_true(companion.set_stance(CompanionState.Stance.SUPPORT)) - assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}), {"kind": &"idle"}) + assert_true(companion.set_stance(CompanionState.Stance.ATTACK_ON_SIGHT)) + assert_eq(CompanionBehaviors.decide(companion, player, {enemy.id: enemy}, map, {}, {enemy.cell: true}), {"kind": &"melee", "target_id": &"goblin"}) + +func test_attack_on_sight_chases_only_detected_hostiles_and_ignores_npcs() -> void: + var map := GridMapState.new(Vector2i(9, 3), GridMapState.CellKind.FLOOR) + var player := _actor(&"player", Vector2i(1, 1)) + var visible_enemy := _actor(&"enemy", Vector2i(5, 1)) + var hidden_enemy := _actor(&"hidden", Vector2i(8, 1)) + var npc := _actor(&"npc_merchant", Vector2i(3, 1)) + var companion := CompanionState.from_choice(&"dog", Vector2i(2, 1)) + companion.stance = CompanionState.Stance.ATTACK_ON_SIGHT + var detected: Dictionary[Vector2i, bool] = {visible_enemy.cell: true, npc.cell: true} + var blocked: Dictionary[Vector2i, bool] = {npc.cell: true} + + var decision := CompanionBehaviors.decide(companion, player, {hidden_enemy.id: hidden_enemy, visible_enemy.id: visible_enemy}, map, blocked, detected) + + assert_eq(decision, {"kind": &"move", "to_cell": Vector2i(2, 2)}) + assert_ne(decision.get("target_id", &""), npc.id) + +func test_stay_back_pet_does_not_attack_or_heal_a_nearby_player() -> void: + var map := GridMapState.new(Vector2i(5, 3), GridMapState.CellKind.FLOOR) + var player := _actor(&"player", Vector2i(2, 1), 12) + player.hit_points = 5 + var companion := CompanionState.from_choice(&"dog", Vector2i(1, 1)) + + assert_eq(CompanionBehaviors.decide(companion, player, {}, map, {}), {"kind": &"idle"}) func test_neutral_shared_xp_seam_splits_reward_without_levels_and_dead_companion_receives_none() -> void: var player := _actor(&"player", Vector2i.ZERO) @@ -45,6 +86,17 @@ func test_neutral_shared_xp_seam_splits_reward_without_levels_and_dead_companion assert_eq(player.xp, 14) assert_eq(companion.actor.xp, 4) +func test_pet_identity_and_regeneration_profile_use_defaults_and_accept_custom_values() -> void: + var default_pet := CompanionState.from_choice(&"moth", Vector2i.ZERO) + assert_eq(default_pet.name, "Familier") + assert_eq(default_pet.species, "Animal") + assert_eq(default_pet.endurance, 4) + assert_eq(default_pet.regeneration_skill, 1) + + var named_pet := CompanionState.from_choice(&"cat", Vector2i.ZERO, 8, "Donut", "Chatte devenue intelligente") + assert_eq(named_pet.name, "Donut") + assert_eq(named_pet.species, "Chatte devenue intelligente") + func test_player_kill_with_companion_uses_one_neutral_xp_allocation_and_one_journal_event() -> void: var map := GridMapState.new(Vector2i(4, 3), GridMapState.CellKind.FLOOR) var player := _actor(&"player", Vector2i(1, 1), 12) diff --git a/tests/unit/test_demo_map.gd b/tests/unit/test_demo_map.gd index 7fefe22..d85e238 100644 --- a/tests/unit/test_demo_map.gd +++ b/tests/unit/test_demo_map.gd @@ -2,16 +2,17 @@ extends GutTest const GameScene = preload("res://scenes/Game.tscn") -func test_initial_demo_map_is_30_by_20_with_a_known_door_chest_and_stairs_route() -> void: +func test_initial_level_is_the_reference_surface_not_the_old_demo_map() -> void: var game := GameScene.instantiate() as Game add_child_autofree(game) await get_tree().process_frame var state := game.get_game_state() - assert_eq(state.map.size, Vector2i(30, 20)) - assert_eq(state.player.cell, Vector2i(4, 12)) - assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.CLOSED_DOOR) - assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.CHEST) - assert_eq(state.map.get_cell(Vector2i(18, 4)), GridMapState.CellKind.STAIRS) - for cell in [Vector2i(4, 10), Vector2i(4, 8), Vector2i(4, 6), Vector2i(10, 4), Vector2i(17, 4)]: - assert_true(state.map.is_walkable(cell), "Expected the demo route to include %s." % cell) + assert_eq(state.map.size, Vector2i(42, 16)) + assert_eq(state.player.cell, Vector2i(4, 7)) + assert_eq(state.map.get_cell(Vector2i(36, 7)), GridMapState.CellKind.CLOSED_DOOR) + assert_eq(state.map.get_cell(Vector2i(39, 7)), GridMapState.CellKind.STAIRS) + assert_eq(state.floor_state.floor_number, 0) + assert_true(state.floor_state.chests.is_empty()) + for x in range(4, 36): + assert_true(state.map.is_walkable(Vector2i(x, 7)), "Expected the surface corridor to include (%d, 7)." % x) diff --git a/tests/unit/test_display_layout.gd b/tests/unit/test_display_layout.gd index 5d2f2fc..8c9f46a 100644 --- a/tests/unit/test_display_layout.gd +++ b/tests/unit/test_display_layout.gd @@ -6,16 +6,16 @@ const GameScene = preload("res://scenes/Game.tscn") const MainMenuScene = preload("res://scenes/menu/MainMenu.tscn") const CharacterCreationScene = preload("res://scenes/menu/CharacterCreation.tscn") -func test_reference_viewport_and_project_window_settings_are_1280_by_720() -> void: - assert_eq(GameType.REFERENCE_VIEWPORT, Vector2i(1280, 720)) - assert_eq(ProjectSettings.get_setting("display/window/size/viewport_width"), 1280) - assert_eq(ProjectSettings.get_setting("display/window/size/viewport_height"), 720) - assert_eq(ProjectSettings.get_setting("display/window/size/window_width_override"), 1280) - assert_eq(ProjectSettings.get_setting("display/window/size/window_height_override"), 720) +func test_reference_viewport_and_project_window_settings_are_1920_by_1080() -> void: + assert_eq(GameType.REFERENCE_VIEWPORT, Vector2i(1920, 1080)) + assert_eq(ProjectSettings.get_setting("display/window/size/viewport_width"), 1920) + assert_eq(ProjectSettings.get_setting("display/window/size/viewport_height"), 1080) + assert_eq(ProjectSettings.get_setting("display/window/size/window_width_override"), 1920) + assert_eq(ProjectSettings.get_setting("display/window/size/window_height_override"), 1080) assert_eq(ProjectSettings.get_setting("display/window/size/resizable"), true) assert_eq(ProjectSettings.get_setting("display/window/stretch/mode"), "canvas_items") -func test_menu_panels_have_one_layout_child_and_non_overlapping_layout_at_1280_by_720() -> void: +func test_menu_panels_have_one_layout_child_and_non_overlapping_layout_at_1920_by_1080() -> void: var main_menu := MainMenuScene.instantiate() as MainMenu var creation := CharacterCreationScene.instantiate() as CharacterCreation add_child_autofree(main_menu) @@ -23,7 +23,7 @@ func test_menu_panels_have_one_layout_child_and_non_overlapping_layout_at_1280_b await get_tree().process_frame await get_tree().process_frame - assert_eq(get_viewport().get_visible_rect().size, Vector2(1280, 720)) + assert_eq(get_viewport().get_visible_rect().size, Vector2(1920, 1080)) _assert_panel_has_only_layout_child(main_menu.get_node("Menu") as PanelContainer) _assert_panel_has_only_layout_child(creation.get_node("Panel") as PanelContainer) _assert_layout_children_do_not_overlap(main_menu.get_node("Menu/Layout") as Control) @@ -71,9 +71,27 @@ func test_camera_tracks_player_after_a_valid_action_and_uses_map_limits() -> voi assert_eq(MapRendererType.TILE_SIZE, Vector2i(32, 32)) assert_eq(camera.limit_left, 32) assert_eq(camera.limit_top, 48) - assert_eq(camera.limit_right, 992) - assert_eq(camera.limit_bottom, 688) + assert_eq(camera.limit_right, 1376) + assert_eq(camera.limit_bottom, 560) game.submit_test_action(Vector2i.DOWN) assert_eq(camera.position, Vector2(state.player.cell * GameType.TILE_SIZE) + game.get_node("World").position) + +func test_camera_limits_are_recomputed_when_entering_a_larger_generated_floor() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var camera := game.get_node("Camera2D") as Camera2D + var world := game.get_node("World") as Node2D + var state := game.get_game_state() + state.player.cell = state.floor_state.exit + + game.submit_test_interact() + + assert_eq(game.get_run_state().current_floor, 1) + assert_eq(camera.limit_left, int(world.position.x)) + assert_eq(camera.limit_top, int(world.position.y)) + assert_eq(camera.limit_right, int(world.position.x) + state.map.size.x * GameType.TILE_SIZE.x) + assert_eq(camera.limit_bottom, int(world.position.y) + state.map.size.y * GameType.TILE_SIZE.y) + assert_eq(camera.position, world.position + Vector2(state.player.cell * GameType.TILE_SIZE)) diff --git a/tests/unit/test_enemy_ai.gd b/tests/unit/test_enemy_ai.gd index 391c86c..d9e3e82 100644 --- a/tests/unit/test_enemy_ai.gd +++ b/tests/unit/test_enemy_ai.gd @@ -80,6 +80,19 @@ func test_unknown_behavior_produces_one_safe_diagnostic_event_in_the_turn_resolv assert_eq(results[0].payload, {"diagnostic": &"unsupported_ai_behavior", "behavior": &"ambush"}) assert_eq(unknown.cell, Vector2i(5, 1)) +func test_enemy_targets_the_nearest_living_pet_and_ties_favor_the_pet() -> void: + var map := GridMapState.new(Vector2i(7, 3), GridMapState.CellKind.FLOOR) + var player := _actor(&"player", Vector2i(4, 1)) + var enemy := _actor(&"enemy", Vector2i(1, 1), {"ai": "aggressive", "vision_range": 6}) + var state := GameState.new(map, player, {enemy.id: enemy}) + state.companion = preload("res://scripts/domain/entities/companion_state.gd").from_choice(&"moth", Vector2i(2, 1)) + var results: Array[TurnResult] = [] + + TurnResolver.append_enemy_response(state, results) + + assert_lt(state.companion.actor.hit_points, state.companion.actor.max_hit_points) + assert_eq(state.player.hit_points, state.player.max_hit_points) + func test_ranged_behavior_approaches_to_its_data_range_but_never_attacks_before_c4() -> void: var map := GridMapState.new(Vector2i(9, 3), GridMapState.CellKind.FLOOR) var player := _actor(&"player", Vector2i(7, 1)) diff --git a/tests/unit/test_floor_deadline.gd b/tests/unit/test_floor_deadline.gd index 6aebb45..a6e5205 100644 --- a/tests/unit/test_floor_deadline.gd +++ b/tests/unit/test_floor_deadline.gd @@ -55,6 +55,9 @@ func test_rest_requires_a_bed_and_bed_interaction_consumes_one_day() -> void: add_child_autofree(game) await get_tree().process_frame var state := game.get_game_state() + game.get_run_state().current_floor = 1 + game.get_run_state().floors[1] = state.floor_state + state.floor_state.floor_number = 1 var deadline := game.get_run_state().current_floor_deadline() var before := deadline.turns_remaining @@ -100,6 +103,7 @@ func test_run_state_keeps_independent_deadline_state_for_each_floor() -> void: func _key_event(keycode: Key) -> InputEventKey: var event := InputEventKey.new() + event.device = 16 event.keycode = keycode event.physical_keycode = keycode event.pressed = true diff --git a/tests/unit/test_floor_generator_doors.gd b/tests/unit/test_floor_generator_doors.gd index 4a39d59..355b9fb 100644 --- a/tests/unit/test_floor_generator_doors.gd +++ b/tests/unit/test_floor_generator_doors.gd @@ -34,6 +34,22 @@ func test_tree_corridors_have_closed_openable_boundary_doors() -> void: assert_eq(floor.map.get_cell(door_cell), GridMapStateType.CellKind.CLOSED_DOOR) assert_true(_has_adjacent_room(floor.map, door_cell), "door %s is at a room/corridor boundary" % door_cell) +func test_generated_doors_control_straight_passages_without_side_bypasses() -> void: + for seed_index in range(20): + var floor := FloorGeneratorType.generate("door-function-%03d" % seed_index, 1 + seed_index % 6, ContentCatalogType.new()) + for serialized_cell: Array in floor.metadata["tree_door_cells"]: + var door_cell := Vector2i(int(serialized_cell[0]), int(serialized_cell[1])) + var walkable_directions: Array[Vector2i] = [] + for direction: Vector2i in [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]: + if floor.map.is_walkable(door_cell + direction): + walkable_directions.append(direction) + assert_eq(walkable_directions.size(), 2, "seed %d door %s must not be a three-way junction" % [seed_index, door_cell]) + assert_true( + (walkable_directions.has(Vector2i.LEFT) and walkable_directions.has(Vector2i.RIGHT)) + or (walkable_directions.has(Vector2i.UP) and walkable_directions.has(Vector2i.DOWN)), + "seed %d door %s must separate opposite sides of one passage" % [seed_index, door_cell] + ) + func test_room_roles_follow_ascii_weights_and_floor_gates() -> void: var first_floor := FloorGeneratorType.generate("B3-role-gates", 1, ContentCatalogType.new()) var boss_floor := FloorGeneratorType.generate("B3-role-gates", 5, ContentCatalogType.new()) diff --git a/tests/unit/test_floor_generator_rooms.gd b/tests/unit/test_floor_generator_rooms.gd index a456148..495e096 100644 --- a/tests/unit/test_floor_generator_rooms.gd +++ b/tests/unit/test_floor_generator_rooms.gd @@ -3,21 +3,21 @@ extends GutTest const ContentCatalogType = preload("res://scripts/domain/content/content_catalog.gd") const FloorGeneratorType = preload("res://scripts/domain/world/floor_generator.gd") -const MAP_SIZE := Vector2i(80, 50) +const MAP_SIZE := Vector2i(210, 105) const ROOM_PADDING := 2 -func test_generator_creates_deterministic_padded_rooms_inside_the_minimal_floor() -> void: +func test_generator_creates_deterministic_padded_rooms_inside_the_full_first_floor() -> void: var catalog := ContentCatalogType.new() var first := FloorGeneratorType.generate("B2-rooms-contract", 1, catalog) var second := FloorGeneratorType.generate("B2-rooms-contract", 1, catalog) assert_eq(first.map.size, MAP_SIZE) - assert_gte(first.rooms.size(), 8) + assert_eq(first.rooms.size(), 170) assert_eq(first.to_dict(), second.to_dict()) for room in first.rooms: - assert_gte(room.bounds.size.x, 5, "%s minimum room width" % room.id) - assert_gte(room.bounds.size.y, 4, "%s minimum room height" % room.id) + assert_gte(room.bounds.size.x, 4, "%s minimum room width" % room.id) + assert_gte(room.bounds.size.y, 3, "%s minimum room height" % room.id) assert_true(_is_inside_map(room.bounds), "%s is inside the map" % room.id) for first_index in range(first.rooms.size()): diff --git a/tests/unit/test_floor_populator.gd b/tests/unit/test_floor_populator.gd index 2393e0c..79c3e94 100644 --- a/tests/unit/test_floor_populator.gd +++ b/tests/unit/test_floor_populator.gd @@ -92,6 +92,7 @@ func _assert_all_records_are_catalog_backed(catalog: ContentCatalog, floor: Floo for npc in floor.npcs.values(): assert_ne(catalog.get_npc(npc.content_id), {}) for chest in floor.chests.values(): + assert_eq(StringName(chest["loot_table_id"]), &"floor_treasure") assert_ne(catalog.get_loot_table(StringName(chest["loot_table_id"])), {}) for trap in floor.traps.values(): assert_ne(catalog.get_trap(StringName(trap["trap_id"])), {}) diff --git a/tests/unit/test_health_regeneration.gd b/tests/unit/test_health_regeneration.gd new file mode 100644 index 0000000..6943347 --- /dev/null +++ b/tests/unit/test_health_regeneration.gd @@ -0,0 +1,21 @@ +extends GutTest + +const ActorStateType = preload("res://scripts/domain/actor_state.gd") +const HealthRegenerationType = preload("res://scripts/domain/combat/health_regeneration.gd") + +func test_amount_matches_ascii_endurance_skill_perk_and_difficulty_rules() -> void: + assert_eq(HealthRegenerationType.amount(8, 1, 0, &"crawler"), 2) + assert_eq(HealthRegenerationType.amount(8, 7, 0, &"crawler"), 3) + assert_eq(HealthRegenerationType.amount(8, 1, 1, &"touriste"), 4) + assert_eq(HealthRegenerationType.amount(8, 1, 0, &"veteran"), 1) + assert_eq(HealthRegenerationType.amount(8, 1, 0, &"masochiste"), 1) + +func test_apply_caps_at_maximum_and_never_revives_a_dead_actor() -> void: + var actor := ActorStateType.new(&"player", Vector2i.ZERO, 12, 3) + actor.hit_points = 11 + + assert_eq(HealthRegenerationType.apply(actor, 8, 1, 0, &"crawler"), 1) + assert_eq(actor.hit_points, 12) + actor.hit_points = 0 + assert_eq(HealthRegenerationType.apply(actor, 8, 1, 0, &"crawler"), 0) + assert_eq(actor.hit_points, 0) diff --git a/tests/unit/test_health_regeneration.gd.uid b/tests/unit/test_health_regeneration.gd.uid new file mode 100644 index 0000000..b9e0d63 --- /dev/null +++ b/tests/unit/test_health_regeneration.gd.uid @@ -0,0 +1 @@ +uid://c4as8ktcg0adk diff --git a/tests/unit/test_hud_chest_prompt.gd b/tests/unit/test_hud_chest_prompt.gd index bb97dab..c918214 100644 --- a/tests/unit/test_hud_chest_prompt.gd +++ b/tests/unit/test_hud_chest_prompt.gd @@ -9,11 +9,11 @@ func test_hud_shows_exact_chest_prompt_only_while_the_chest_is_a_context_target( var state := game.get_game_state() var hud := game.get_node("HUD") as GameHud - state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR) - state.player.cell = Vector2i(4, 8) + var chest := state.player.cell + Vector2i.UP + state.map.set_cell(chest, GridMapState.CellKind.CHEST) hud.refresh(state) assert_eq(hud.get_context_prompt(), "Espace — Ouvrir le coffre") - state.player.cell = Vector2i(4, 10) + state.map.set_cell(chest, GridMapState.CellKind.FLOOR) hud.refresh(state) assert_eq(hud.get_context_prompt(), "") diff --git a/tests/unit/test_hud_layout.gd b/tests/unit/test_hud_layout.gd index 9f8ae21..43edeba 100644 --- a/tests/unit/test_hud_layout.gd +++ b/tests/unit/test_hud_layout.gd @@ -16,6 +16,26 @@ func test_help_band_displays_the_exact_control_labels() -> void: assert_string_contains(help_label.text, "nord-est : pavé num. 9") assert_string_contains(help_label.text, "Interagir : Espace ou E") +func test_xp_bar_shows_progress_inside_the_current_level_and_refreshes_after_xp_gain() -> void: + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var xp_bar := hud.get_node_or_null("ExperienceBar") as ProgressBar + var xp_label := hud.get_node_or_null("ExperienceLabel") as Label + + assert_not_null(xp_bar) + assert_not_null(xp_label) + assert_eq(xp_bar.min_value, 0.0) + assert_eq(xp_bar.max_value, 100.0) + assert_eq(xp_bar.value, 0.0) + assert_eq(xp_label.text, "Niveau 1 — XP 0/100") + + state.player.progression.set_total_xp(125) + hud.refresh(state, [], game.get_run_state()) + + assert_eq(xp_bar.max_value, 200.0) + assert_eq(xp_bar.value, 25.0) + assert_eq(xp_label.text, "Niveau 2 — XP 25/200") + func test_hud_uses_viewport_anchored_panels_with_distinct_stats_and_log_zones() -> void: var hud := game.get_node("HUD") as GameHud var layout := hud.get_node_or_null("ResponsiveLayout") as Control @@ -34,6 +54,38 @@ func test_hud_uses_viewport_anchored_panels_with_distinct_stats_and_log_zones() assert_true(stats_panel.get_global_rect().encloses(enemy_health.get_global_rect())) assert_true(log_panel.get_global_rect().encloses(event_log.get_global_rect())) assert_false(stats_panel.get_global_rect().intersects(log_panel.get_global_rect())) + var visible_stats: Array[Control] = [ + hud.get_node("PlayerHealthLabel"), + hud.get_node("PlayerFocusLabel"), + hud.get_node("ExperienceBar"), + hud.get_node("GoldLabel"), + hud.get_node("QuestTrackerLabel"), + hud.get_node("SpellLabel"), + hud.get_node("EnemyHealthLabel"), + hud.get_node("CombatSummaryLabel"), + hud.get_node("DeadlineLabel"), + ] + for first_index in range(visible_stats.size()): + for second_index in range(first_index + 1, visible_stats.size()): + assert_false( + visible_stats[first_index].get_global_rect().intersects(visible_stats[second_index].get_global_rect()), + "%s and %s must not overlap" % [visible_stats[first_index].name, visible_stats[second_index].name] + ) + +func test_long_deadline_text_wraps_and_stays_inside_the_stats_panel() -> void: + var hud := game.get_node("HUD") as GameHud + var state := game.get_game_state() + var run := game.get_run_state() + run.current_floor = 1 + run.ensure_floor_deadline(1) + hud.refresh(state, [], run) + await get_tree().process_frame + + var stats_panel := hud.get_node("ResponsiveLayout/StatsPanel") as PanelContainer + var deadline := hud.get_node("DeadlineLabel") as Label + assert_true(stats_panel.get_global_rect().encloses(deadline.get_global_rect())) + assert_lte(deadline.get_minimum_size().x, deadline.size.x) + assert_gt(deadline.size.y, deadline.get_line_height()) func test_compact_hud_leaves_a_dominant_unobstructed_central_play_area() -> void: var hud := game.get_node("HUD") as GameHud @@ -43,9 +95,14 @@ func test_compact_hud_leaves_a_dominant_unobstructed_central_play_area() -> void var help_panel := hud.get_node("ResponsiveLayout/HelpPanel") as PanelContainer var panels: Array[PanelContainer] = [stats_panel, log_panel, prompt_panel, help_panel] var occupied_area := 0.0 - var central_play_area := Rect2(300, 120, 680, 480) + var central_play_area := Rect2( + Game.REFERENCE_VIEWPORT.x * 0.25, + Game.REFERENCE_VIEWPORT.y * 0.17, + Game.REFERENCE_VIEWPORT.x * 0.5, + Game.REFERENCE_VIEWPORT.y * 0.66 + ) for panel in panels: var panel_rect: Rect2 = panel.get_global_rect() occupied_area += panel_rect.get_area() assert_false(panel_rect.intersects(central_play_area), "%s obscures the central play area" % panel.name) - assert_lte(occupied_area, float(Game.REFERENCE_VIEWPORT.x * Game.REFERENCE_VIEWPORT.y) * 0.15) + assert_lte(occupied_area, float(Game.REFERENCE_VIEWPORT.x * Game.REFERENCE_VIEWPORT.y) * 0.18) diff --git a/tests/unit/test_hud_prompts.gd b/tests/unit/test_hud_prompts.gd index 6b8bfac..7ba6455 100644 --- a/tests/unit/test_hud_prompts.gd +++ b/tests/unit/test_hud_prompts.gd @@ -11,7 +11,9 @@ func before_each() -> void: func test_context_prompt_describes_an_adjacent_closed_door_without_mutating_the_map() -> void: var hud := game.get_node("HUD") as GameHud var state := game.get_game_state() - var door_cell := Vector2i(4, 11) + var door_cell := Vector2i(36, 7) + state.player.cell = Vector2i(35, 7) + hud.refresh(state, [], game.get_run_state()) assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte") assert_eq(state.map.get_cell(door_cell), GridMapState.CellKind.CLOSED_DOOR) @@ -20,9 +22,7 @@ func test_context_prompt_describes_stairs_under_player_and_nothing_else() -> voi var hud := game.get_node("HUD") as GameHud var state := game.get_game_state() - state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR) - state.player.cell = Vector2i(18, 4) - game.get_run_state().current_floor_deadline().turns_remaining = 2 * FloorDeadline.TURNS_PER_DAY + state.player.cell = state.floor_state.exit hud.refresh(state, [], game.get_run_state()) assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier") diff --git a/tests/unit/test_inventory_panel_layout.gd b/tests/unit/test_inventory_panel_layout.gd new file mode 100644 index 0000000..8eac869 --- /dev/null +++ b/tests/unit/test_inventory_panel_layout.gd @@ -0,0 +1,25 @@ +extends GutTest + +const GameScene = preload("res://scenes/Game.tscn") + +func test_inventory_title_columns_and_footer_have_distinct_contained_layout_zones() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var panel := game.get_node("HUD/InventoryPanel") as InventoryPanel + panel.present(game.get_run_state().inventory, game.get_run_state().equipment, game.get_run_state().identification) + await get_tree().process_frame + + var title := panel.get_node("Layout/Title") as Control + var entries := panel.get_node("Layout/Columns/Entries") as Control + var details := panel.get_node("Layout/Columns/Details") as Control + var footer := panel.get_node("Layout/Footer") as Control + var panel_rect := panel.get_global_rect() + for control in [title, entries, details, footer]: + assert_true(panel_rect.encloses(control.get_global_rect()), "%s stays inside inventory panel" % control.name) + assert_false(title.get_global_rect().intersects(entries.get_global_rect())) + assert_false(title.get_global_rect().intersects(details.get_global_rect())) + assert_false(entries.get_global_rect().intersects(details.get_global_rect())) + assert_false(entries.get_global_rect().intersects(footer.get_global_rect())) + assert_false(details.get_global_rect().intersects(footer.get_global_rect())) + assert_string_contains((footer as Label).text, "I Fermer") diff --git a/tests/unit/test_inventory_panel_layout.gd.uid b/tests/unit/test_inventory_panel_layout.gd.uid new file mode 100644 index 0000000..7a9aac1 --- /dev/null +++ b/tests/unit/test_inventory_panel_layout.gd.uid @@ -0,0 +1 @@ +uid://p14i0dc4xokw diff --git a/tests/unit/test_loot_panel_layout.gd b/tests/unit/test_loot_panel_layout.gd new file mode 100644 index 0000000..23e0b45 --- /dev/null +++ b/tests/unit/test_loot_panel_layout.gd @@ -0,0 +1,16 @@ +extends GutTest + +const LootPanelScene = preload("res://scenes/ui/LootPanel.tscn") + +func test_chest_title_entries_and_action_have_distinct_layout_zones() -> void: + var panel := LootPanelScene.instantiate() as LootPanel + add_child_autofree(panel) + panel.visible = true + await get_tree().process_frame + + var title := panel.get_node("Layout/Title") as Control + var entries := panel.get_node("Layout/Entries") as Control + var take_all := panel.get_node("Layout/TakeAll") as Control + assert_false(title.get_global_rect().intersects(entries.get_global_rect())) + assert_false(title.get_global_rect().intersects(take_all.get_global_rect())) + assert_false(entries.get_global_rect().intersects(take_all.get_global_rect())) diff --git a/tests/unit/test_loot_panel_layout.gd.uid b/tests/unit/test_loot_panel_layout.gd.uid new file mode 100644 index 0000000..cf69504 --- /dev/null +++ b/tests/unit/test_loot_panel_layout.gd.uid @@ -0,0 +1 @@ +uid://38ghrwrgyhm4 diff --git a/tests/unit/test_loot_resolver.gd b/tests/unit/test_loot_resolver.gd index a7a4df4..522409f 100644 --- a/tests/unit/test_loot_resolver.gd +++ b/tests/unit/test_loot_resolver.gd @@ -25,6 +25,26 @@ func test_catalog_table_resolution_is_deterministic_and_preserves_gold_items_and assert_true(item.has("quantity")) assert_gt(int(item.quantity), 0) +func test_multi_roll_reward_never_selects_the_same_item_id_twice() -> void: + var table := { + "rolls": 4, + "entries": [ + {"item": "weapon_hunting_knife", "weight": 100}, + {"item": "consumable_bandage", "weight": 1, "min_qty": 2, "max_qty": 2}, + ], + } + + var reward := LootResolverType.resolve(table, "NO-DUPLICATES", "chest") + var ids: Array = (reward.items as Array).map(func(item: Dictionary) -> StringName: return StringName(item.item_id)) + var unique_ids := {} + for item_id in ids: + unique_ids[item_id] = true + + assert_eq(ids.size(), unique_ids.size()) + assert_lte(ids.size(), 2) + for item: Dictionary in reward.items: + assert_eq(int(item.quantity), 2 if item.item_id == &"consumable_bandage" else 1, "Repeated rolls must not inflate quantity beyond the authored range.") + func test_world_chest_keeps_table_trap_lock_and_opened_state_and_stores_its_single_reward() -> void: var chest: WorldChest = WorldChestType.new({ "loot_table_id": "floor1_reward", diff --git a/tests/unit/test_magic.gd b/tests/unit/test_magic.gd index 7107394..d037d89 100644 --- a/tests/unit/test_magic.gd +++ b/tests/unit/test_magic.gd @@ -48,8 +48,9 @@ func test_lethal_spell_awards_progression_xp_and_reports_level_gain() -> void: assert_false(target.is_alive()) assert_eq(caster.xp, 100) assert_eq(caster.progression.level, 2) - assert_eq(outcome.events.back().kind, &"xp_granted") - assert_eq(outcome.events.back().payload, {"xp": 1, "levels_gained": 1}) + assert_eq(outcome.events[-2].kind, &"xp_granted") + assert_eq(outcome.events[-2].payload, {"xp": 1, "levels_gained": 1}) + assert_eq(outcome.events.back().kind, &"loot_dropped") func test_cooldown_decrements_per_turn_and_blocks_recast_until_ready() -> void: var spell := _spell(&"spell_epines_empoisonnees") diff --git a/tests/unit/test_map_renderer_fog.gd b/tests/unit/test_map_renderer_fog.gd index 97fc8e5..b55c306 100644 --- a/tests/unit/test_map_renderer_fog.gd +++ b/tests/unit/test_map_renderer_fog.gd @@ -10,17 +10,23 @@ func before_each() -> void: func test_game_synchronizes_renderer_visibility_states_after_movement() -> void: var renderer := game.get_node("World/MapRenderer") as MapRenderer - assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"visible") + var state := game.get_game_state() + state.enemies.clear() + var start := state.player.cell + var old_edge := Vector2i(2, 7) + var newly_visible := Vector2i(17, 7) + assert_eq(renderer.get_cell_visibility_state(old_edge), &"visible") + assert_eq(renderer.get_cell_visibility_state(newly_visible), &"unknown") - game.submit_test_interact() - game.submit_test_action(Vector2i.UP) + for step in range(7): + game.submit_test_action(Vector2i.RIGHT) - assert_eq(renderer.get_cell_visibility_state(Vector2i(1, 12)), &"explored") - assert_eq(renderer.get_cell_visibility_state(Vector2i(4, 17)), &"visible") - assert_eq(renderer.get_cell_visibility_state(Vector2i(29, 19)), &"unknown") - assert_eq(renderer.get_cell_render_color(Vector2i(1, 12)), renderer.EXPLORED_DIM_COLOR) - assert_eq(renderer.get_cell_render_color(Vector2i(4, 17)), Color.WHITE) - assert_eq(renderer.get_cell_render_color(Vector2i(29, 19)), Color(0.005, 0.008, 0.02, 1.0)) + assert_eq(renderer.get_cell_visibility_state(old_edge), &"explored") + assert_eq(renderer.get_cell_visibility_state(newly_visible), &"visible") + assert_eq(renderer.get_cell_visibility_state(Vector2i(41, 15)), &"unknown") + assert_eq(renderer.get_cell_render_color(old_edge), renderer.EXPLORED_DIM_COLOR) + assert_eq(renderer.get_cell_render_color(newly_visible), Color.WHITE) + assert_eq(renderer.get_cell_render_color(Vector2i(41, 15)), Color(0.005, 0.008, 0.02, 1.0)) assert_ne(renderer.UNKNOWN_COLOR, renderer.EXPLORED_DIM_COLOR) assert_lt(renderer.UNKNOWN_COLOR.get_luminance(), renderer.EXPLORED_DIM_COLOR.get_luminance()) assert_lte(renderer.EXPLORED_DIM_COLOR.get_luminance(), 0.35) diff --git a/tests/unit/test_minimap.gd b/tests/unit/test_minimap.gd index c6867e8..6a9e361 100644 --- a/tests/unit/test_minimap.gd +++ b/tests/unit/test_minimap.gd @@ -12,24 +12,28 @@ func before_each() -> void: func test_minimap_crops_to_player_camera_fov_and_never_reveals_hidden_threats() -> void: var minimap := game.get_node_or_null("HUD/Minimap") as Minimap var state := game.get_game_state() + var hidden_threat_cell := Vector2i(24, 8) + var enemy := ActorState.new(&"goblin", hidden_threat_cell, 6, 2) + state.enemies[enemy.id] = enemy + game.sync_presentation_for_testing() assert_not_null(minimap) assert_eq(minimap.get_camera_cell(), state.player.cell) assert_true(minimap.get_displayed_cells().has(state.player.cell)) - assert_false(minimap.get_displayed_cells().has(Vector2i(29, 19))) - assert_eq(minimap.get_cell_visibility_state(Vector2i(29, 19)), &"unknown") - assert_false(minimap.get_threat_marker_cells().has(Vector2i(24, 8))) + assert_false(minimap.get_displayed_cells().has(Vector2i(41, 15))) + assert_eq(minimap.get_cell_visibility_state(Vector2i(41, 15)), &"unknown") + assert_false(minimap.get_threat_marker_cells().has(hidden_threat_cell)) - state.player.cell = Vector2i(24, 8) + state.player.cell = hidden_threat_cell state.update_exploration() game.sync_presentation_for_testing() - assert_eq(minimap.get_camera_cell(), Vector2i(24, 8)) - assert_true(minimap.get_displayed_cells().has(Vector2i(24, 8))) - assert_false(minimap.get_displayed_cells().has(Vector2i(4, 12))) - assert_true(minimap.get_threat_marker_cells().has(Vector2i(24, 8))) + assert_eq(minimap.get_camera_cell(), hidden_threat_cell) + assert_true(minimap.get_displayed_cells().has(hidden_threat_cell)) + assert_false(minimap.get_displayed_cells().has(Vector2i(4, 7))) + assert_true(minimap.get_threat_marker_cells().has(hidden_threat_cell)) - state.visible_cells.erase(Vector2i(24, 8)) - state.explored_cells[Vector2i(24, 8)] = true + state.visible_cells.erase(hidden_threat_cell) + state.explored_cells[hidden_threat_cell] = true game.sync_presentation_for_testing() - assert_false(minimap.get_threat_marker_cells().has(Vector2i(24, 8))) + assert_false(minimap.get_threat_marker_cells().has(hidden_threat_cell)) diff --git a/tests/unit/test_save_repository.gd b/tests/unit/test_save_repository.gd index ea53200..c91a7b5 100644 --- a/tests/unit/test_save_repository.gd +++ b/tests/unit/test_save_repository.gd @@ -61,9 +61,33 @@ func test_save_load_round_trip_preserves_full_run_state_across_multiple_floors_i assert_eq(game.player.cell, Vector2i(2, 2)) assert_eq(game.player.focus, 9) assert_eq(game.companion.choice_id, &"moth") + assert_eq(game.companion.name, "Donut") + assert_eq(game.companion.species, "Chatte") + assert_eq(game.companion.endurance, 7) + assert_eq(game.companion.regeneration_skill, 3) + assert_eq(game.companion.regeneration_perk_bonus, 2) assert_eq(game.party.members[0].id, &"recruit-one") assert_eq(loaded.dialogue_player.race, &"race_humain_standard") +func test_legacy_ascii_companion_shape_restores_identity_stats_and_behavior() -> void: + var legacy_companion := { + "id": "companion-1", "name": "Donut", "species": "Chatte", "behavior": "soutien", + "x": 2, "y": 3, "hp": 7, "max_hp": 12, "attributes": {"end": 8}, + "skills": {"regeneration": 4}, "perks": {"regen_bonus": 2}, + } + var companion = repository._companion_from_data(legacy_companion) + + assert_not_null(companion) + assert_eq(companion.name, "Donut") + assert_eq(companion.species, "Chatte") + assert_eq(companion.stance, CompanionState.Stance.DEFEND_ME) + assert_eq(companion.actor.cell, Vector2i(2, 3)) + assert_eq(companion.actor.hit_points, 7) + assert_eq(companion.actor.max_hit_points, 12) + assert_eq(companion.endurance, 8) + assert_eq(companion.regeneration_skill, 4) + assert_eq(companion.regeneration_perk_bonus, 2) + func test_only_five_one_based_slots_are_available_and_missing_or_invalid_slots_are_explicit() -> void: assert_eq(repository.list_slots().map(func(meta: Dictionary) -> int: return int(meta.slot)), [1, 2, 3, 4, 5]) assert_false(repository.load(1, catalog).ok) @@ -140,7 +164,10 @@ func _full_fixture() -> Dictionary: player.focus = 9 var game := GameState.new(floor_two.map, player, floor_two.enemies) game.set_floor_state(floor_two) - game.companion = CompanionState.from_choice(&"moth", Vector2i(1, 2)) + game.companion = CompanionState.from_choice(&"moth", Vector2i(1, 2), 8, "Donut", "Chatte") + game.companion.endurance = 7 + game.companion.regeneration_skill = 3 + game.companion.regeneration_perk_bonus = 2 game.party = PartyState.new() game.party.members.append(ActorState.new(&"recruit-one", Vector2i(2, 1), 8, 2, &"npc_recruit")) var dialogue_player := {"race": "race_humain_standard", "archetype": "mystic", "level": 2} diff --git a/tests/unit/test_stairs_interaction.gd b/tests/unit/test_stairs_interaction.gd index 5cd37a8..4d6b3b5 100644 --- a/tests/unit/test_stairs_interaction.gd +++ b/tests/unit/test_stairs_interaction.gd @@ -56,9 +56,7 @@ func test_stairs_usage_transitions_to_floor_one_and_writes_the_journal() -> void var hud := game.get_node("HUD") as GameHud var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label var event_log := game.get_node("HUD/EventLog") as RichTextLabel - state.map.set_cell(Vector2i(4, 11), GridMapState.CellKind.FLOOR) - state.player.cell = Vector2i(18, 4) - game.get_run_state().current_floor_deadline().turns_remaining = 2 * FloorDeadline.TURNS_PER_DAY + state.player.cell = state.floor_state.exit var results := game.submit_test_interact() diff --git a/tests/unit/test_surface_floor_transition.gd b/tests/unit/test_surface_floor_transition.gd index accdc9f..7b9c3b4 100644 --- a/tests/unit/test_surface_floor_transition.gd +++ b/tests/unit/test_surface_floor_transition.gd @@ -19,10 +19,13 @@ func test_floor_zero_is_hand_authored_and_floor_one_is_seed_floor_one_procedural assert_eq(surface.floor_number, 0) assert_true(surface.metadata.get("hand_authored", false)) - assert_eq(surface.map.size, Vector2i(30, 20)) - assert_eq(surface.entrance, Vector2i(4, 12)) - assert_eq(surface.exit, Vector2i(18, 4)) + assert_eq(surface.map.size, Vector2i(42, 16)) + assert_eq(surface.entrance, Vector2i(4, 7)) + assert_eq(surface.exit, Vector2i(39, 7)) + assert_eq(surface.map.get_cell(Vector2i(36, 7)), GridMapStateType.CellKind.CLOSED_DOOR) assert_eq(surface.map.get_cell(surface.exit), GridMapStateType.CellKind.STAIRS) + assert_true(surface.enemies.is_empty()) + assert_true(surface.chests.is_empty()) assert_eq(first_floor.floor_number, 1) assert_false(first_floor.metadata.get("hand_authored", false)) assert_eq(first_floor.seed, _seed_value("B5-surface-contract", 1)) diff --git a/tests/unit/test_traps_and_special_tiles.gd b/tests/unit/test_traps_and_special_tiles.gd index f6a1578..d80a9d6 100644 --- a/tests/unit/test_traps_and_special_tiles.gd +++ b/tests/unit/test_traps_and_special_tiles.gd @@ -36,6 +36,19 @@ func test_visible_trap_is_discovered_from_its_ascii_perception_data_and_can_be_d assert_true(outcome.success) assert_true(state.floor_state.traps[cell].disarmed) +func test_trap_with_null_status_triggers_without_constructing_an_invalid_string_name() -> void: + var state := _state() + var cell := Vector2i(4, 3) + state.floor_state.traps[cell] = {"trap_id": &"trap_spikes"} + var before_hp := state.player.hit_points + + var outcome := TrapEngine.trigger(state.floor_state, state.player, cell, catalog) + + assert_true(outcome.triggered) + assert_eq(outcome.damage, 8) + assert_eq(state.player.hit_points, before_hp - 8) + assert_eq(outcome.events.map(func(event: Dictionary) -> StringName: return event.kind), [&"trap_triggered"]) + func test_undiscovered_trap_triggers_damage_and_data_backed_status_once() -> void: var state := _state() var cell := Vector2i(4, 3) diff --git a/tests/unit/test_turn_resolver.gd b/tests/unit/test_turn_resolver.gd index f5fb59d..5584e7b 100644 --- a/tests/unit/test_turn_resolver.gd +++ b/tests/unit/test_turn_resolver.gd @@ -36,6 +36,22 @@ func test_wall_and_closed_door_are_blocked_without_enemy_turn() -> void: assert_eq(door_results.size(), 1) assert_eq(door_results[0].kind, &"blocked") +func test_diagonal_movement_cannot_cut_the_corner_beside_a_closed_door() -> void: + var map := GridMapState.new(Vector2i(5, 5), GridMapState.CellKind.WALL) + var player_cell := Vector2i(2, 3) + var destination := Vector2i(3, 2) + map.set_cell(player_cell, GridMapState.CellKind.FLOOR) + map.set_cell(destination, GridMapState.CellKind.FLOOR) + map.set_cell(Vector2i(2, 2), GridMapState.CellKind.CLOSED_DOOR) + map.set_cell(Vector2i(3, 3), GridMapState.CellKind.WALL) + var state := GameState.new(map, ActorState.new(&"player", player_cell, 12, 3), {}) + + var results := state.try_player_action(Vector2i(1, -1)) + + assert_eq(results[0].kind, &"blocked") + assert_eq(state.player.cell, player_cell) + assert_eq(state.map.get_cell(Vector2i(2, 2)), GridMapState.CellKind.CLOSED_DOOR) + func test_melee_damages_adjacent_goblin_and_triggers_response() -> void: var state := make_state() state.try_player_action(Vector2i.RIGHT)