-
Notifications
You must be signed in to change notification settings - Fork 0
Add interactive dialogue system for NPC tutorials #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
84955b4
Initial plan
Copilot 113eb2e
Add interactive dialogue system with tutorial content for NPCs
Copilot c4d40d8
Address PR feedback: fix dialogue_options initialization and add test…
Copilot b4ba8e9
Improve test to avoid side effects with cleanup
Copilot bcbe8cc
Add 'Tell me about yourself' dialogue option for all NPCs
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,23 @@ | ||
| # @author Daniel McCoy Stephenson | ||
| class NPC: | ||
| def __init__(self, name: str, backstory: str): | ||
| def __init__(self, name: str, backstory: str, dialogue_options: list = None): | ||
| self.name = name | ||
| self.backstory = backstory | ||
| if dialogue_options is None: | ||
| self.dialogue_options = [] | ||
| else: | ||
| self.dialogue_options = dialogue_options | ||
|
|
||
| def introduce(self): | ||
| """Returns the NPC's introduction text""" | ||
| return f"{self.name}: {self.backstory}" | ||
|
|
||
| def get_dialogue_options(self): | ||
| """Returns list of available dialogue options""" | ||
| return self.dialogue_options | ||
|
|
||
| def get_dialogue_response(self, option_index: int): | ||
| """Returns the response for a specific dialogue option""" | ||
| if 0 <= option_index < len(self.dialogue_options): | ||
| return self.dialogue_options[option_index].get("response", "") | ||
| return "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
showInteractiveDialogueintroduces new interactive control flow and input handling, but there’s no automated test coverage for it whileUserInterfacealready has tests forshowDialogue/showOptions(seetests/ui/test_userInterface.py). Adding tests that mockinputto select an option and then[Back]would help prevent regressions.There was a problem hiding this comment.
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.