Skip to content

Add interactive dialogue system for NPC tutorials#49

Merged
dmccoystephenson merged 5 commits intomainfrom
copilot/expand-dialogue-options
Feb 2, 2026
Merged

Add interactive dialogue system for NPC tutorials#49
dmccoystephenson merged 5 commits intomainfrom
copilot/expand-dialogue-options

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

  • Enhance NPC class to support multiple dialogue options with questions and answers
  • Add game tutorial dialogue options for each NPC based on their location/role
  • Add backstory dialogue option for all NPCs
  • Update talkToNPC() methods in all locations to use interactive dialogue system
  • Create comprehensive tests for new dialogue functionality
  • Manually test the dialogue system in-game
  • Code review completed with no issues
  • Security scan completed with no vulnerabilities
  • Address PR feedback: Fix dialogue_options initialization to preserve empty list identity
  • Address PR feedback: Add test coverage for showInteractiveDialogue method
  • Improve test to include cleanup and prevent side effects

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:

  1. "Tell me about yourself." - Shows the NPC's backstory
    2-5. Four contextual questions about game mechanics specific to their role

NPCs and their dialogue topics:

  • Old Tom the Barkeep (Tavern): Backstory, money-making, tavern activities, villagers, general advice
  • Gilbert the Shopkeeper (Shop): Backstory, shop items, fishing mechanics, bait upgrades, selling tips
  • Sam the Dock Worker (Docks): Backstory, fishing instructions, locations, energy management, fishing wisdom
  • Margaret the Teller (Bank): Backstory, banking operations, interest rates, saving advice, financial wisdom

Technical Changes

  1. Enhanced NPC Class (src/npc/npc.py)

    • Added dialogue_options parameter with explicit None check to preserve list identity
    • Implemented get_dialogue_options() and get_dialogue_response(index) methods
  2. Interactive Dialogue UI (src/ui/userInterface.py)

    • Created showInteractiveDialogue(npc) method with question menu and looping
    • Handles option selection, response display, and [Back] navigation
    • Full test coverage for all scenarios
  3. Updated All Locations (src/location/*.py)

    • Modified talkToNPC() in Bank, Docks, Shop, and Tavern to use interactive dialogue
    • Each location now has contextual tutorial content

All 100 tests pass. Security scan clean.

NPC Backstory Dialogue

Original prompt

This section details on the original issue you should resolve

<issue_title>Expand dialogue options</issue_title>
<issue_description>Expand dialogue options for NPCs such that the player can ask questions to learn more about how to play the game.

Talking with an NPC should be an interactive experience where you can choose from a number of dialogue options.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Expand dialogue options for NPC interactions Add interactive dialogue system for NPC tutorials Feb 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an interactive question/answer dialogue system for NPC tutorial interactions, replacing the prior static “backstory-only” dialogue flow.

Changes:

  • Extends NPC to support a dialogue_options list 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 []
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
self.dialogue_options = dialogue_options or []
if dialogue_options is None:
self.dialogue_options = []
else:
self.dialogue_options = dialogue_options

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit b4ba8e9. Changed to explicit None check to preserve empty list identity. Added test to verify behavior.

Comment on lines +90 to +94
def showInteractiveDialogue(self, npc):
"""Shows an interactive dialogue menu with the NPC"""
while True:
self.lotsOfSpace()
self.divider()
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit c4d40d8. Added three tests for showInteractiveDialogue: no options fallback, valid option selection, and invalid input handling.

@dmccoystephenson
Copy link
Member

@copilot address comments

Copilot AI and others added 2 commits February 2, 2026 02:26
… coverage

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot address comments

All comments addressed in commits c4d40d8 and b4ba8e9. Fixed dialogue_options initialization and added comprehensive test coverage for showInteractiveDialogue.

@dmccoystephenson dmccoystephenson marked this pull request as ready for review February 2, 2026 02:29
@dmccoystephenson
Copy link
Member

@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>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@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.

Added in commit bcbe8cc. Each NPC now has "Tell me about yourself." as the first dialogue option, showing their backstory.

NPC Backstory Dialogue

@dmccoystephenson dmccoystephenson merged commit 312dab7 into main Feb 2, 2026
1 check passed
@dmccoystephenson dmccoystephenson deleted the copilot/expand-dialogue-options branch February 2, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand dialogue options

2 participants