Move more code into gather file

This commit is contained in:
Nate Bowman
2026-07-30 21:02:14 -04:00
parent e25abd87ab
commit 194925ab04
4 changed files with 151 additions and 84 deletions

View File

@@ -154,6 +154,59 @@ class Gather():
raise GatherBuildingNotAvailableException
def permanently_modify_gather_rate(self, task, rate_multiplier):
self.gather_rates[task] *= rate_multiplier
self.original_gather_rates[task] *= rate_multiplier
def decrease_gather_rate_by_overuse(self, task):
# assumes rate decrease should trigger; does not check
new_rate = self.gather_decrease_rates[task]*self.gather_rates[task]
self.gather_rates[task] = new_rate
return new_rate
def improve_gather_rate_by_building(self, building, tasks):
if building == Buildings.FARM:
raise ValueError('Do not call this routine with a farm')
if building not in self.buildings_gather_increase.keys():
return []
if not tasks:
tasks = self.buildings_gather_increase[building].keys()
elif type(tasks) == Tasks:
tasks = [tasks]
for task in tasks:
amount = self.buildings_gather_increase[building][task]
if self.gather_rates[task] < self.original_gather_rates[task]:
self.gather_rates[task] = self.original_gather_rates[task]
self.gatherable_amounts[task] = amount
else:
self.gatherable_amounts[task] += amount
return tasks
def permanently_modify_consumable_capacity(self, building, task, increase):
current_initial_capacity = self.buildings_gather_increase[building]
self.buildings_gather_increase[building] += increase
return increase/current_initial_farm
def compute_gathered_resources_for_duration(self, villager_tasks, duration):
all_gathered = [0, 0, 0, 0]
for task, count in villager_tasks.items():
rate = self.gather_rates[task]
gathered = self.gathered_resources[task]
for resource, mult in gathered.items():
all_gathered[resource] += count*rate*mult*duration
return all_gathered
def __init__(self):
self.gather_rates = {
Tasks.BERRIES: 18.6/60,