Add interactive dialogue system for NPC tutorials#49
Conversation
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an interactive question/answer dialogue system for NPC tutorial interactions, replacing the prior static “backstory-only” dialogue flow.
Changes:
- Extends
NPCto support adialogue_optionslist and query helpers (get_dialogue_options,get_dialogue_response). - Adds
UserInterface.showInteractiveDialogue(npc)to render a selectable question menu and loop until exit. - Updates Bank/Docks/Shop/Tavern
talkToNPC()flows and corresponding tests to use interactive dialogue.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/npc/npc.py |
Adds dialogue options storage and accessors on NPCs. |
src/ui/userInterface.py |
Implements the interactive dialogue menu loop and response display. |
src/location/bank.py |
Switches bank NPC interaction to interactive dialogue and adds tutorial Q/A content. |
src/location/docks.py |
Switches docks NPC interaction to interactive dialogue and adds tutorial Q/A content. |
src/location/shop.py |
Switches shop NPC interaction to interactive dialogue and adds tutorial Q/A content. |
src/location/tavern.py |
Switches tavern NPC interaction to interactive dialogue and adds tutorial Q/A content. |
tests/npc/test_npc.py |
Adds unit tests for NPC dialogue options and response retrieval. |
tests/location/test_bank.py |
Updates talk-to-NPC test to expect interactive dialogue invocation with an NPC object. |
tests/location/test_docks.py |
Updates talk-to-NPC test to expect interactive dialogue invocation with an NPC object. |
tests/location/test_shop.py |
Updates talk-to-NPC test to expect interactive dialogue invocation with an NPC object. |
tests/location/test_tavern.py |
Updates talk-to-NPC test to expect interactive dialogue invocation with an NPC object. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/npc/npc.py
Outdated
| def __init__(self, name: str, backstory: str, dialogue_options: list = None): | ||
| self.name = name | ||
| self.backstory = backstory | ||
| self.dialogue_options = dialogue_options or [] |
There was a problem hiding this comment.
dialogue_options = dialogue_options or [] treats an explicitly provided empty list the same as None, replacing it with a new list instance. If callers pass an empty list intending to populate it later (or rely on object identity), the NPC won’t see those updates. Prefer an explicit None check (and optionally copy the list) so [] remains a valid provided value.
| self.dialogue_options = dialogue_options or [] | |
| if dialogue_options is None: | |
| self.dialogue_options = [] | |
| else: | |
| self.dialogue_options = dialogue_options |
There was a problem hiding this comment.
Fixed in commit b4ba8e9. Changed to explicit None check to preserve empty list identity. Added test to verify behavior.
| def showInteractiveDialogue(self, npc): | ||
| """Shows an interactive dialogue menu with the NPC""" | ||
| while True: | ||
| self.lotsOfSpace() | ||
| self.divider() |
There was a problem hiding this comment.
showInteractiveDialogue introduces new interactive control flow and input handling, but there’s no automated test coverage for it while UserInterface already has tests for showDialogue/showOptions (see tests/ui/test_userInterface.py). Adding tests that mock input to select an option and then [Back] would help prevent regressions.
There was a problem hiding this comment.
Fixed in commit c4d40d8. Added three tests for showInteractiveDialogue: no options fallback, valid option selection, and invalid input handling.
|
@copilot address comments |
… coverage Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
|
@copilot Include a dialogue option for each NPC asking about their background. Looks like the backstories they used to say are no longer present at the moment. |
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>

Summary
Implements an interactive question/answer dialogue system for NPCs, replacing the prior static backstory-only dialogue flow. Players can now ask NPCs questions to learn about game mechanics and character backgrounds.
Each NPC has 5 dialogue options:
2-5. Four contextual questions about game mechanics specific to their role
NPCs and their dialogue topics:
Technical Changes
Enhanced NPC Class (
src/npc/npc.py)dialogue_optionsparameter with explicitNonecheck to preserve list identityget_dialogue_options()andget_dialogue_response(index)methodsInteractive Dialogue UI (
src/ui/userInterface.py)showInteractiveDialogue(npc)method with question menu and loopingUpdated All Locations (
src/location/*.py)talkToNPC()in Bank, Docks, Shop, and Tavern to use interactive dialogueAll 100 tests pass. Security scan clean.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.