Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/location/bank.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from pstats import Stats
from location.enum.locationType import LocationType
from player.player import Player
from prompt.prompt import Prompt
from world.timeService import TimeService
from stats.stats import Stats
from ui.userInterface import UserInterface
from npc.npc import NPC
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

In this file the Stats type hint is coming from pstats (line 1), which is a different class than the game’s stats.stats.Stats used elsewhere (e.g., src/location/shop.py:6). Since this PR touches the import block, please switch the Stats import here to from stats.stats import Stats for consistency and correct typing.

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 bbf82ef - changed import from pstats.Stats to stats.stats.Stats for correct typing.



# @author Daniel McCoy Stephenson
Expand All @@ -21,9 +22,15 @@ def __init__(
self.player = player
self.stats = stats
self.timeService = timeService
self.npc = NPC(
"Margaret the Teller",
"I've worked at this bank for fifteen years and I take pride in keeping everyone's money safe. "
"My grandmother taught me the value of saving, and I've helped many fishermen in this village "
"secure their futures. A penny saved is a penny earned, as they say!",
)

def run(self):
li = ["Make a Deposit", "Make a Withdrawal", "Go to docks"]
li = ["Make a Deposit", "Make a Withdrawal", "Talk to %s" % self.npc.name, "Go to docks"]
input = self.userInterface.showOptions(
"You're at the front of the line and the teller asks you what you want to do.",
li,
Expand Down Expand Up @@ -52,6 +59,10 @@ def run(self):
return LocationType.BANK

elif input == "3":
self.talkToNPC()
return LocationType.BANK

elif input == "4":
self.currentPrompt.text = "What would you like to do?"
return LocationType.DOCKS

Expand Down Expand Up @@ -100,3 +111,6 @@ def withdraw(self):
else:
self.currentPrompt.text = "You don't have that much money in the bank!"
break

def talkToNPC(self):
self.userInterface.showDialogue(self.npc.introduce())
23 changes: 19 additions & 4 deletions src/location/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from world.timeService import TimeService
from stats.stats import Stats
from ui.userInterface import UserInterface
from npc.npc import NPC


# @author Daniel McCoy Stephenson
Expand All @@ -25,9 +26,16 @@ def __init__(
self.player = player
self.stats = stats
self.timeService = timeService
self.npc = NPC(
"Sam the Dock Worker",
"Been working these docks since I was knee-high to a grasshopper. "
"My pa was a fisherman, and his pa before him. I help maintain the boats and docks, "
"and I've learned a thing or two about fishing over the years. "
"The sea provides for those who respect her!",
)

def run(self):
li = ["Fish", "Go Home", "Go to Shop", "Go to Tavern", "Go to Bank"]
li = ["Fish", "Talk to %s" % self.npc.name, "Go Home", "Go to Shop", "Go to Tavern", "Go to Bank"]
input = self.userInterface.showOptions(
"You breathe in the fresh air. Salty.", li
)
Expand All @@ -41,18 +49,22 @@ def run(self):
return LocationType.DOCKS

elif input == "2":
self.talkToNPC()
return LocationType.DOCKS

elif input == "3":
self.currentPrompt.text = "What would you like to do?"
return LocationType.HOME

elif input == "3":
elif input == "4":
self.currentPrompt.text = "What would you like to do?"
return LocationType.SHOP

elif input == "4":
elif input == "5":
self.currentPrompt.text = "What would you like to do?"
return LocationType.TAVERN

elif input == "5":
elif input == "6":
self.currentPrompt.text = (
"What would you like to do? Money in Bank: $%.2f"
% self.player.moneyInBank
Expand Down Expand Up @@ -97,3 +109,6 @@ def fish(self):
fishToAdd,
hours,
)

def talkToNPC(self):
self.userInterface.showDialogue(self.npc.introduce())
14 changes: 14 additions & 0 deletions src/location/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from world.timeService import TimeService
from stats.stats import Stats
from ui.userInterface import UserInterface
from npc.npc import NPC


# @author Daniel McCoy Stephenson
Expand All @@ -22,11 +23,18 @@ def __init__(
self.player = player
self.stats = stats
self.timeService = timeService
self.npc = NPC(
"Gilbert the Shopkeeper",
"I've been running this shop for thirty years, ever since I inherited it from my father. "
"I've seen many fishermen come and go, but the best ones always come back for quality bait. "
"I may not fish much anymore, but I know good gear when I see it!",
)

def run(self):
li = [
"Sell Fish",
"Buy Better Bait ( $%d )" % self.player.priceForBait,
"Talk to %s" % self.npc.name,
"Go to Docks",
]
input = self.userInterface.showOptions(
Expand All @@ -41,6 +49,9 @@ def run(self):
self.buyBetterBait()
return LocationType.SHOP
elif input == "3":
self.talkToNPC()
return LocationType.SHOP
elif input == "4":
self.currentPrompt.text = "What would you like to do?"
return LocationType.DOCKS

Expand All @@ -61,3 +72,6 @@ def buyBetterBait(self):

self.player.priceForBait = self.player.priceForBait * 1.25
self.currentPrompt.text = "You bought some better bait!"

def talkToNPC(self):
self.userInterface.showDialogue(self.npc.introduce())
16 changes: 15 additions & 1 deletion src/location/tavern.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from world.timeService import TimeService
from stats.stats import Stats
from ui.userInterface import UserInterface
from npc.npc import NPC


# @author Daniel McCoy Stephenson
Expand All @@ -28,9 +29,15 @@ def __init__(
self.timeService = timeService

self.currentBet = 0
self.npc = NPC(
"Old Tom the Barkeep",
"I sailed the seven seas for forty years before settling down here. "
"Lost my leg to a shark near the Caribbean, but I got plenty of stories to make up for it. "
"These days I pour drinks and listen to folks' troubles. Best job I ever had!",
)

def run(self):
li = ["Get drunk ( $10 )", "Gamble", "Go to Docks"]
li = ["Get drunk ( $10 )", "Gamble", "Talk to %s" % self.npc.name, "Go to Docks"]
input = self.userInterface.showOptions(
"You sit at the bar, watching the barkeep clean a mug with a dirty rag.", li
)
Expand All @@ -51,6 +58,10 @@ def run(self):
return LocationType.TAVERN

elif input == "3":
self.talkToNPC()
return LocationType.TAVERN

elif input == "4":
self.currentPrompt.text = "What would you like to do?"
return LocationType.DOCKS

Expand Down Expand Up @@ -138,3 +149,6 @@ def changeBet(self, prompt):
self.currentPrompt.text = (
"You don't have that much money on you! Money: $%d" % self.player.money
)

def talkToNPC(self):
self.userInterface.showDialogue(self.npc.introduce())
Empty file added src/npc/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions src/npc/npc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @author Daniel McCoy Stephenson
class NPC:
def __init__(self, name: str, backstory: str):
self.name = name
self.backstory = backstory

def introduce(self):
"""Returns the NPC's introduction text"""
return f"{self.name}: {self.backstory}"
8 changes: 8 additions & 0 deletions src/ui/userInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,11 @@ def showOptions(
return choice

self.currentPrompt.text = "Try again!"

def showDialogue(self, text):
self.lotsOfSpace()
self.divider()
print(text)
self.divider()
input(" [ CONTINUE ]")
self.currentPrompt.text = "What would you like to do?"
33 changes: 32 additions & 1 deletion tests/location/test_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def test_initialization():
assert bankInstance.player != None
assert bankInstance.stats != None
assert bankInstance.timeService != None
assert bankInstance.npc != None
assert bankInstance.npc.name == "Margaret the Teller"


def test_run_make_deposit_success():
Expand Down Expand Up @@ -92,7 +94,7 @@ def test_run_make_withdrawal_failure_no_money():
def test_run_go_to_docks_action():
# prepare
bankInstance = createBank()
bankInstance.userInterface.showOptions = MagicMock(return_value="3")
bankInstance.userInterface.showOptions = MagicMock(return_value="4")

# call
nextLocation = bankInstance.run()
Expand All @@ -101,6 +103,35 @@ def test_run_go_to_docks_action():
assert nextLocation == LocationType.DOCKS


def test_run_talk_to_npc_action():
# prepare
bankInstance = createBank()
bankInstance.userInterface.showOptions = MagicMock(return_value="3")
bankInstance.talkToNPC = MagicMock()

# call
nextLocation = bankInstance.run()

# check
assert nextLocation == LocationType.BANK
bankInstance.talkToNPC.assert_called_once()


def test_talkToNPC():
# prepare
bankInstance = createBank()
bankInstance.userInterface.showDialogue = MagicMock()

# call
bankInstance.talkToNPC()

# check
bankInstance.userInterface.showDialogue.assert_called_once()
call_args = bankInstance.userInterface.showDialogue.call_args[0][0]
assert "Margaret the Teller" in call_args
assert len(call_args) > 0


def test_deposit_success():
# prepare
bankInstance = createBank()
Expand Down
39 changes: 35 additions & 4 deletions tests/location/test_docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def test_initialization():
assert docksInstance.player != None
assert docksInstance.stats != None
assert docksInstance.timeService != None
assert docksInstance.npc != None
assert docksInstance.npc.name == "Sam the Dock Worker"


def test_run_fish_action():
Expand All @@ -46,7 +48,7 @@ def test_run_fish_action():
def test_run_go_home_action():
# prepare
docksInstance = createDocks()
docksInstance.userInterface.showOptions = MagicMock(return_value="2")
docksInstance.userInterface.showOptions = MagicMock(return_value="3")

# call
nextLocation = docksInstance.run()
Expand All @@ -55,10 +57,39 @@ def test_run_go_home_action():
assert nextLocation == LocationType.HOME


def test_run_talk_to_npc_action():
# prepare
docksInstance = createDocks()
docksInstance.userInterface.showOptions = MagicMock(return_value="2")
docksInstance.talkToNPC = MagicMock()

# call
nextLocation = docksInstance.run()

# check
assert nextLocation == LocationType.DOCKS
docksInstance.talkToNPC.assert_called_once()


def test_talkToNPC():
# prepare
docksInstance = createDocks()
docksInstance.userInterface.showDialogue = MagicMock()

# call
docksInstance.talkToNPC()

# check
docksInstance.userInterface.showDialogue.assert_called_once()
call_args = docksInstance.userInterface.showDialogue.call_args[0][0]
assert "Sam the Dock Worker" in call_args
assert len(call_args) > 0


def test_run_go_to_shop_action():
# prepare
docksInstance = createDocks()
docksInstance.userInterface.showOptions = MagicMock(return_value="3")
docksInstance.userInterface.showOptions = MagicMock(return_value="4")

# call
nextLocation = docksInstance.run()
Expand All @@ -70,7 +101,7 @@ def test_run_go_to_shop_action():
def test_run_go_to_tavern_action():
# prepare
docksInstance = createDocks()
docksInstance.userInterface.showOptions = MagicMock(return_value="4")
docksInstance.userInterface.showOptions = MagicMock(return_value="5")

# call
nextLocation = docksInstance.run()
Expand All @@ -82,7 +113,7 @@ def test_run_go_to_tavern_action():
def test_run_go_to_bank_action():
# prepare
docksInstance = createDocks()
docksInstance.userInterface.showOptions = MagicMock(return_value="5")
docksInstance.userInterface.showOptions = MagicMock(return_value="6")

# call
nextLocation = docksInstance.run()
Expand Down
33 changes: 32 additions & 1 deletion tests/location/test_shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def test_initialization():
assert shopInstance.player != None
assert shopInstance.stats != None
assert shopInstance.timeService != None
assert shopInstance.npc != None
assert shopInstance.npc.name == "Gilbert the Shopkeeper"


def test_run_sell_fish_action():
Expand Down Expand Up @@ -60,7 +62,7 @@ def test_run_buy_better_bait_action():
def test_run_go_to_docks_action():
# prepare
shopInstance = createShop()
shopInstance.userInterface.showOptions = MagicMock(return_value="3")
shopInstance.userInterface.showOptions = MagicMock(return_value="4")

# call
nextLocation = shopInstance.run()
Expand All @@ -69,6 +71,35 @@ def test_run_go_to_docks_action():
assert nextLocation == LocationType.DOCKS


def test_run_talk_to_npc_action():
# prepare
shopInstance = createShop()
shopInstance.userInterface.showOptions = MagicMock(return_value="3")
shopInstance.talkToNPC = MagicMock()

# call
nextLocation = shopInstance.run()

# check
assert nextLocation == LocationType.SHOP
shopInstance.talkToNPC.assert_called_once()


def test_talkToNPC():
# prepare
shopInstance = createShop()
shopInstance.userInterface.showDialogue = MagicMock()

# call
shopInstance.talkToNPC()

# check
shopInstance.userInterface.showDialogue.assert_called_once()
call_args = shopInstance.userInterface.showDialogue.call_args[0][0]
assert "Gilbert the Shopkeeper" in call_args
assert len(call_args) > 0


def test_sellFish():
# prepare
shopInstance = createShop()
Expand Down
Loading