diff --git a/src/location/bank.py b/src/location/bank.py index da123a1..aa1347c 100644 --- a/src/location/bank.py +++ b/src/location/bank.py @@ -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. diff --git a/src/location/docks.py b/src/location/docks.py index b6e7b56..5cab962 100644 --- a/src/location/docks.py +++ b/src/location/docks.py @@ -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!" diff --git a/src/location/tavern.py b/src/location/tavern.py index 8b2d3cd..6068dc8 100644 --- a/src/location/tavern.py +++ b/src/location/tavern.py @@ -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!" diff --git a/tests/location/test_bank.py b/tests/location/test_bank.py index 022da5b..69a78bc 100644 --- a/tests/location/test_bank.py +++ b/tests/location/test_bank.py @@ -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(): diff --git a/tests/location/test_docks.py b/tests/location/test_docks.py index d6c38ca..8aa80bd 100644 --- a/tests/location/test_docks.py +++ b/tests/location/test_docks.py @@ -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?") @@ -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() diff --git a/tests/location/test_tavern.py b/tests/location/test_tavern.py index 0d90989..bdd1fde 100644 --- a/tests/location/test_tavern.py +++ b/tests/location/test_tavern.py @@ -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?") @@ -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 = {}