Move more code into separate classes
It might make logical sense. Honestly, I'm just tired of the code for World being so long.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import copy
|
||||
|
||||
from aoe.types import *
|
||||
from aoe.exceptions import *
|
||||
|
||||
|
||||
|
||||
@@ -136,6 +137,23 @@ class Gather():
|
||||
BIG_NUMBER = 1e6
|
||||
|
||||
|
||||
def check_gather(self, world, task, count=1):
|
||||
if task in [Tasks.IDLE, Tasks.BUILD]:
|
||||
return
|
||||
|
||||
required = self.required_gather_buildings[task]
|
||||
have = set(world.buildings)
|
||||
|
||||
match = any(map(have.issuperset, required))
|
||||
|
||||
if not match:
|
||||
raise GatherBuildingNotAvailableException
|
||||
|
||||
if task == task.FARM:
|
||||
if world.villager_tasks[task] + count > len(world.unused_farms):
|
||||
raise GatherBuildingNotAvailableException
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.gather_rates = {
|
||||
Tasks.BERRIES: 18.6/60,
|
||||
|
||||
Reference in New Issue
Block a user