Revert "Allow hunting and building as initial villager tasks"

This reverts commit 8a8effe3d1.
I did not like adding kwargs in so many places, so there will be an
upcoming commit that implements the same change in a different way.
This commit is contained in:
Nate Bowman
2026-11-15 16:58:49 -05:00
parent 8a8effe3d1
commit 7ce4b4a150
3 changed files with 41 additions and 134 deletions

View File

@@ -128,12 +128,10 @@ class World():
next_decrease += self.current_time
if task in Gather.FARM_LIKE_TASKS:
self.events[next_decrease].append((self._remove_consumable_building,
(task,),
{}))
(task,)))
else:
self.events[next_decrease].append((self._decrease_gather_rate_by_overuse,
(task,),
{}))
(task,)))
self.rate_decrease_event_times[task] = next_decrease
@@ -172,7 +170,7 @@ class World():
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.events[update_time].append((self._add_huntable, ()))
self.assign_villager(previous_task, Tasks.LURE)
@@ -275,7 +273,7 @@ class World():
update_time = self.current_time + walking_time
self.events[update_time].append((self._add_relic, (), {}))
self.events[update_time].append((self._add_relic, ()))
def _add_relic(self):
@@ -322,8 +320,7 @@ class World():
self.events[update_time].append((self._add_building,
(building,
villagers_to_count,
building_tasks,),
{}))
building_tasks,)))
def _add_building(self, building, villagers_to, tasks_improved):
@@ -424,12 +421,12 @@ class World():
i += 1
def _free_production_building_of_thing(self, thing, **kwargs):
def _free_production_building_of_thing(self, thing):
building = self.production.building[thing]
self._free_production_building(building)
def _free_production_building(self, building, **kwargs):
def _free_production_building(self, building):
# This will not respect the order of a queue in a particular building.
# For example, if there is a TC with the queue [villager, loom] and
# there is no available housing, the TC will research loom. In the
@@ -442,10 +439,10 @@ class World():
i = 0
while i < len(self.production_queue):
thing, task, kwargs = self.production_queue[i]
thing, task = self.production_queue[i]
if self.production.building[thing] == building and \
house_check(self, thing):
self._start_producing(thing, task, **kwargs)
self._start_producing(thing, task)
del self.production_queue[i]
break
i += 1
@@ -474,7 +471,7 @@ class World():
self._free_housing()
def _add_thing(self, thing, initial_task, **kwargs):
def _add_thing(self, thing, initial_task):
self.units_being_built -= self.housing.required[thing]
self.population += self.housing.required[thing]
@@ -489,18 +486,7 @@ class World():
self.villager_tasks[Tasks.IDLE] += 1
if not initial_task:
initial_task = Tasks.IDLE
if initial_task == Tasks.LURE:
self.lure_huntable_with_villager(Tasks.IDLE, **kwargs)
elif initial_task == Tasks.BUILD:
if 'building_task' not in kwargs.keys():
kwargs['building_task'] = None
self.build(kwargs['building'],
Tasks.IDLE,
kwargs['villagers_to'],
kwargs['building_task'])
else:
self.assign_villager(Tasks.IDLE, initial_task)
self.assign_villager(Tasks.IDLE, initial_task)
elif thing == Units.MONK:
self.villager_tasks[Tasks.MONK_IDLE] += 1
self._get_next_waiting_relic()
@@ -514,7 +500,7 @@ class World():
self.villager_tasks[Tasks.TRADECART] += 1
def _start_producing(self, thing, initial_task, **kwargs):
def _start_producing(self, thing, initial_task):
try:
self._use_housing_and_production(thing)
except Exception as e:
@@ -522,22 +508,20 @@ class World():
is_housing = isinstance(e, YallGotHousedException)
if is_prod or (is_housing and not self.housed_is_error):
self.production_queue.append((thing, initial_task, kwargs))
self.production_queue.append((thing, initial_task))
else:
raise(e)
else:
update_time = self.current_time + self.build_times.build_times[thing]
self.events[update_time].append((self._add_thing,
(thing, initial_task,),
kwargs))
self.events[update_time].append((self._add_thing, (thing, initial_task,)))
def _queue_thing(self, thing, initial_task=None, **kwargs):
def _queue_thing(self, thing, initial_task=None):
self.dependencies.check_dependencies(self, thing)
self.costs.compute_cost(thing)
self.pay_cost(thing)
self._start_producing(thing, initial_task, **kwargs)
self._start_producing(thing, initial_task)
def queue_research(self, research):
@@ -548,8 +532,8 @@ class World():
self._queue_thing(unit)
def queue_villager(self, initial_task, **kwargs):
self._queue_thing(Units.VILLAGER, initial_task, **kwargs)
def queue_villager(self, initial_task):
self._queue_thing(Units.VILLAGER, initial_task)
def queue_fishing_ship(self, initial_task=Tasks.FISH_SHIP_DEEP):
@@ -565,13 +549,12 @@ class World():
def _handle_events(self):
for func, args, kwargs in self.events[self.current_time]:
for func, args in self.events[self.current_time]:
try:
func(*args, **kwargs)
func(*args)
except Exception as e:
raise type(e)(
f'Error in {func.__name__}{args}'
f' with keyword arguments {kwargs}'
f' at time {self.current_time}.'
f' Note that the actual gameplay command that caused'
f' the error may not have been issued at'
@@ -596,7 +579,7 @@ class World():
self.pay_cost(new_age)
update_time = self.current_time + self.build_times.build_times[new_age]
self.events[update_time].append((self._update_age, (new_age,), {}))
self.events[update_time].append((self._update_age, (new_age,)))
def _deal_with_civ(self):