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
17 changes: 15 additions & 2 deletions src/location/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,28 @@ def _businessDialogue(self):
"""Margaret's savings-minded take on the player's fishing business,
staged by boat ownership/crew size."""
if not self.player.hasBoat:
# Selling the last hull leaves her crew hired and paid every
# morning, so that isn't the same as never having had a boat (#284).
if self.player.workers > 0:
if self.player.workers == 1:
hands = "your hand is"
else:
hands = "your %d hands are" % self.player.workers
return (
"No boat to work, but %s still on the payroll - wages come "
"out of your purse every morning. Save here toward a new "
"hull, or let them go under Manage Fleet at the docks." % hands
)
return (
"A boat's a fine goal to save toward! Set some money aside "
"here and it'll be waiting for you when you're ready to buy one."
)
if self.player.workers == 0:
starter = business.tierInfo(business.currentTier(self.player))
return (
"A boat with no crew is just a rowboat and a dream! Bank your "
"A %s with no crew is just a hull and a dream! Bank your "
"catch money for a while and you'll have their wages covered "
"in no time."
"in no time." % starter["name"]
)
# Nothing to congratulate before the first payday. Wages are drawn from
# the player's purse, so the advice here is to keep money on hand.
Expand Down
11 changes: 11 additions & 0 deletions src/location/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ def _businessDialogue(self):
"""Sam's take on the player's fishing business, staged by boat tier and
crew size so it reflects real progress rather than being fixed text."""
if not self.player.hasBoat:
# Selling the last hull leaves her crew hired and on wages (#284).
if self.player.workers > 0:
if self.player.workers == 1:
hands = "your hand is"
else:
hands = "your %d hands are" % self.player.workers
return (
"No boat under you, and %s still drawing wages ashore! Buy "
"a hull to put them back to work, or let them go under "
"Manage Fleet." % hands
)
return (
"No boat yet, eh? Once you've got one, I can help you find "
"good hands to hire. A crew changes everything!"
Expand Down
10 changes: 10 additions & 0 deletions src/location/tavern.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ def _businessDialogue(self):
"""Old Tom's barroom banter about the player's fishing business,
staged by boat tier."""
if not self.player.hasBoat:
# Selling the last hull leaves her crew hired and on wages (#284).
if self.player.workers > 0:
if self.player.workers == 1:
hands = "a hand"
else:
hands = "%d hands" % self.player.workers
return (
"Paying %s to sit ashore with no boat? That's a quick way "
"to an empty purse. Get them a hull down at the docks!" % hands
)
return (
"No boat yet? Can't rightly call yourself a fisherman around "
"here without a crew behind you. Get one down at the docks!"
Expand Down
36 changes: 32 additions & 4 deletions tests/location/test_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,41 @@ def test_npc_business_dialogue_no_boat():
assert "save toward" in bankInstance._businessDialogue()


def test_npc_business_dialogue_no_crew():
# prepare
@pytest.mark.parametrize("tier,name", [(1, "Rowboat"), (2, "Trawler")])
def test_npc_business_dialogue_no_crew_names_the_hull(tier, name):
# prepare - Margaret used to call every uncrewed hull a rowboat (#284)
bankInstance = createBank()
boats.addBoat(bankInstance.player, 1)
boats.addBoat(bankInstance.player, tier)

# call
response = bankInstance._businessDialogue()

# check
assert "A %s with no crew is just a hull and a dream" % name in response
if tier != 1:
assert "rowboat" not in response.lower()


@pytest.mark.parametrize(
"hired,expected", [(1, "your hand is"), (2, "your 2 hands are")]
)
def test_npc_business_dialogue_crew_ashore_after_last_boat_sold(hired, expected):
# prepare - selling the last boat leaves her crew hired and on wages,
# which isn't the same as never having had a boat (#284)
bankInstance = createBank()
boat = boats.addBoat(bankInstance.player, 1)
for _ in range(hired):
boats.hireWorker(bankInstance.player)
boats.sellBoat(bankInstance.player, boat["id"])

# call
response = bankInstance._businessDialogue()

# check
assert "rowboat and a dream" in bankInstance._businessDialogue()
assert not bankInstance.player.hasBoat
assert "save toward" not in response
assert "No boat to work, but %s still on the payroll" % expected in response
assert "Manage Fleet" in response


def test_npc_business_dialogue_reports_wages_paid():
Expand Down
25 changes: 25 additions & 0 deletions tests/location/test_docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from src.progression import progression
from unittest.mock import MagicMock, patch

import pytest


def createDocks(unlocked=True):
currentPrompt = Prompt("What would you like to do?")
Expand Down Expand Up @@ -129,6 +131,29 @@ def test_npc_business_dialogue_staged_by_boat_ownership():
assert "No boat yet" in response


@pytest.mark.parametrize(
"hired,expected", [(1, "your hand is"), (2, "your 2 hands are")]
)
def test_npc_business_dialogue_crew_ashore_after_last_boat_sold(hired, expected):
# prepare - selling the last boat leaves her crew hired and on wages, and
# Manage Fleet still offers Dismiss a Worker, so Sam mustn't offer to find
# hands for a player who already has them (#284)
docksInstance = createDocks()
boat = boats.addBoat(docksInstance.player, 1)
for _ in range(hired):
boats.hireWorker(docksInstance.player)
boats.sellBoat(docksInstance.player, boat["id"])

# call
response = docksInstance._businessDialogue()

# check
assert not docksInstance.player.hasBoat
assert "No boat yet" not in response
assert "%s still drawing wages ashore" % expected in response
assert "Manage Fleet" in response


def test_npc_business_dialogue_staged_by_empty_crew():
# prepare - a boat but no crew hired yet
docksInstance = createDocks()
Expand Down
24 changes: 24 additions & 0 deletions tests/location/test_tavern.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from src.progression import progression
from unittest.mock import MagicMock, patch

import pytest


def createTavern(unlocked=True):
currentPrompt = Prompt("What would you like to do?")
Expand Down Expand Up @@ -151,6 +153,28 @@ def test_npc_business_dialogue_no_boat():
assert "No boat yet" in tavernInstance._businessDialogue()


@pytest.mark.parametrize(
"hired,expected", [(1, "Paying a hand"), (2, "Paying 2 hands")]
)
def test_npc_business_dialogue_crew_ashore_after_last_boat_sold(hired, expected):
# prepare - selling the last boat leaves her crew hired and on wages, so
# Old Tom mustn't say there's no crew behind the player (#284)
tavernInstance = createTavern()
boat = boats.addBoat(tavernInstance.player, 1)
for _ in range(hired):
boats.hireWorker(tavernInstance.player)
boats.sellBoat(tavernInstance.player, boat["id"])

# call
response = tavernInstance._businessDialogue()

# check
assert not tavernInstance.player.hasBoat
assert "No boat yet" not in response
assert "without a crew" not in response
assert "%s to sit ashore with no boat" % expected in response


def test_npc_business_dialogue_staged_by_tier():
# prepare - one crewed boat per tier
responses = {}
Expand Down
Loading