From e67085aab712965e44b22c5fb28d30ece65bd74c Mon Sep 17 00:00:00 2001 From: Nate Bowman Date: Fri, 6 Nov 2026 19:13:57 -0500 Subject: [PATCH] Add boar luring No decay accounted for yet --- aoe/gameplay.py | 9 +++++++++ aoe/gather.py | 21 +++++++++++++++++---- aoe/types.py | 1 + aoe/world.py | 14 +++++++++++++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/aoe/gameplay.py b/aoe/gameplay.py index 176686e..f311453 100644 --- a/aoe/gameplay.py +++ b/aoe/gameplay.py @@ -55,6 +55,15 @@ class Gameplay(): (old_task, new_task, count,))) + def lure_huntable_with_villager(self, + action_time, + previous_task, + walking_time=30): + self._check_time(action_time) + self.actions[action_time].append((self.world.lure_huntable_with_villager, + (previous_task, walking_time))) + + def _check_time(self, action_time): # TODO will it work if we do something at current time? if self.world.current_time > action_time: diff --git a/aoe/gather.py b/aoe/gather.py index 778b33e..7edc853 100644 --- a/aoe/gather.py +++ b/aoe/gather.py @@ -141,7 +141,11 @@ class Gather(): def check_gather(self, world, task, count=1): - if task in [Tasks.IDLE, Tasks.BUILD]: + if task in [ + Tasks.IDLE, + Tasks.BUILD, + Tasks.LURE, + ]: return required = self.required_gather_buildings[task] @@ -266,10 +270,18 @@ class Gather(): return len(self.farms) + def add_huntable(self): + self.improve_gather_rate_by_building(Tasks.LURE, None) + + def gather_resources_for_duration(self, villager_tasks, duration): # assumes there are sufficient resources in gatherable_amounts for task, count in villager_tasks.items(): - if task in [Tasks.BUILD, Tasks.IDLE]: + if task in [ + Tasks.BUILD, + Tasks.LURE, + Tasks.IDLE, + ]: continue rate = self.gather_rates[task] @@ -372,7 +384,7 @@ class Gather(): # 4 deer Tasks.BERRIES: 6*125, Tasks.SHEEP: 8*100, - Tasks.BOAR: 2*340, + Tasks.BOAR: 0, Tasks.HUNT: 4*140, Tasks.FARM: 0, # TODO next two should be shared @@ -401,8 +413,9 @@ class Gather(): Tasks.GOLD: 4*800, Tasks.STONE: 4*350, Tasks.BERRIES: 6*125, - Tasks.HUNT: 4*140} + Tasks.HUNT: 4*140}, #Buildings.FISHTRAP: {Tasks.WOOD: 100}, + Tasks.LURE: {Tasks.BOAR: 340}, } self.gather_decrease_rates = { diff --git a/aoe/types.py b/aoe/types.py index 2d9b1d3..84ebd39 100644 --- a/aoe/types.py +++ b/aoe/types.py @@ -53,6 +53,7 @@ class Tasks(Enum): SHEEP = auto() BOAR = auto() HUNT = auto() + LURE = auto() FARM = auto() FISH_VILLAGER = auto() FISH_SHIP_SHORE = auto() diff --git a/aoe/world.py b/aoe/world.py index 8fb9c87..0b77b80 100644 --- a/aoe/world.py +++ b/aoe/world.py @@ -80,7 +80,7 @@ class World(): def _schedule_next_gather_rate_decrease(self, task): - if task in [Tasks.IDLE, Tasks.BUILD]: + if task in [Tasks.IDLE, Tasks.BUILD, Tasks.LURE]: return # remove old decrease @@ -133,6 +133,18 @@ class World(): self._schedule_next_gather_rate_decrease(task) + def lure_huntable_with_villager(self, previous_task, walking_time=30): + update_time = self.current_time + walking_time + self.events[update_time].append((self._add_huntable, ())) + + self.assign_villager(previous_task, Tasks.LURE) + + + def _add_huntable(self): + self.gather.add_huntable() + self.assign_villager(Tasks.LURE, Tasks.BOAR) + + def assign_villager(self, previous_task, new_task, count=1): # new_task of None means kill the villager