Add boar luring
No decay accounted for yet
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -53,6 +53,7 @@ class Tasks(Enum):
|
||||
SHEEP = auto()
|
||||
BOAR = auto()
|
||||
HUNT = auto()
|
||||
LURE = auto()
|
||||
FARM = auto()
|
||||
FISH_VILLAGER = auto()
|
||||
FISH_SHIP_SHORE = auto()
|
||||
|
||||
14
aoe/world.py
14
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user