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
14 changes: 10 additions & 4 deletions src/business/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
# bring in a passive catch each day in exchange for a daily wage. This turns
# accumulated money into ongoing production rather than just a number that grows.

from fish import fish

BOAT_PRICE = 500
MAX_WORKERS = 5
WORKER_DAILY_WAGE = 10
WORKER_FISH_PER_DAY = 6
WORKER_CATCH_SPECIES = "Minnow" # workers bring in the common catch
WORKER_FISH_PER_DAY = 5


def runDailyProduction(player, stats=None):
Expand Down Expand Up @@ -36,9 +37,14 @@ def runDailyProduction(player, stats=None):
return summary

wages = affordable * WORKER_DAILY_WAGE
caught = affordable * WORKER_FISH_PER_DAY
player.money -= wages
player.addFish(WORKER_CATCH_SPECIES, caught)
# Each worker fishes the same waters as the player, landing a rarity-rolled
# species (not just the cheapest one), so the crew's income is competitive
# with simply upgrading your own gear.
caught = 0
for _ in range(affordable):
player.addFish(fish.rollFishType(), WORKER_FISH_PER_DAY)
caught += WORKER_FISH_PER_DAY
summary["wagesPaid"] = wages
summary["fishCaught"] = caught
if stats is not None:
Expand Down
18 changes: 18 additions & 0 deletions tests/business/test_business.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

from src.business import business
from src.player.player import Player
from src.stats.stats import Stats
Expand Down Expand Up @@ -40,6 +42,22 @@ def test_workers_catch_fish_and_draw_wages():
assert stats.totalFishCaught == expectedFish


def test_workers_catch_rolled_species_not_just_minnow():
# prepare - a boat and one worker; force the rolled species to Bass
player = Player()
player.hasBoat = True
player.workers = 1
player.money = 1000

# call - workers fish a rarity-rolled species, not a hard-coded one
with patch.object(business.fish, "rollFishType", return_value="Bass"):
business.runDailyProduction(player)

# check - the catch landed as the rolled species
assert player.fishByType.get("Bass") == business.WORKER_FISH_PER_DAY
assert "Minnow" not in player.fishByType


def test_unaffordable_workers_quit():
# prepare - 3 workers but only enough money for one day's wage of one worker
player = Player()
Expand Down
Loading