def execute(self): # TODO Add a check that figures out if all trees that should be planted are in range of the settlement. # If not, return range missing result (result, building) = super(LumberjackEvaluator, self).execute() if result != BUILD_RESULT.OK: return (result, None) production_builder = self.area_builder coastline = production_builder.land_manager.coastline island_ground_map = production_builder.island.ground_map forest_coords_list = [] for coords in building.position.get_radius_coordinates(Entities.buildings[BUILDINGS.LUMBERJACK].radius): if coords in production_builder.plan and production_builder.plan[coords][0] == BUILDING_PURPOSE.NONE and coords not in coastline: if island_ground_map[coords].object is not None and island_ground_map[coords].object.id == BUILDINGS.TREE: forest_coords_list.append(coords) elif island_ground_map[coords].settlement is not None and island_ground_map[coords].settlement.owner is self.area_builder.owner: builder = BasicBuilder(BUILDINGS.TREE, coords, 0) if not builder.have_resources(production_builder.land_manager): break if builder: assert builder.execute(production_builder.land_manager) forest_coords_list.append(coords) production_builder.register_change_list(forest_coords_list, BUILDING_PURPOSE.TREE, None) return (BUILD_RESULT.OK, building)
def execute(self): # TODO Add a check that figures out if all trees that should be planted are in range of the settlement. # If not, return range missing result (result, building) = super(LumberjackEvaluator, self).execute() if result != BUILD_RESULT.OK: return (result, None) production_builder = self.area_builder coastline = production_builder.land_manager.coastline island_ground_map = production_builder.island.ground_map forest_coords_list = [] for coords in building.position.get_radius_coordinates( Entities.buildings[BUILDINGS.LUMBERJACK].radius): if coords in production_builder.plan and production_builder.plan[ coords][ 0] == BUILDING_PURPOSE.NONE and coords not in coastline: if island_ground_map[ coords].object is not None and island_ground_map[ coords].object.id == BUILDINGS.TREE: forest_coords_list.append(coords) elif island_ground_map[ coords].settlement is not None and island_ground_map[ coords].settlement.owner is self.area_builder.owner: builder = BasicBuilder(BUILDINGS.TREE, coords, 0) if not builder.have_resources( production_builder.land_manager): break if builder: assert builder.execute(production_builder.land_manager) forest_coords_list.append(coords) production_builder.register_change_list(forest_coords_list, BUILDING_PURPOSE.TREE, None) return (BUILD_RESULT.OK, building)
def execute(self): (result, building) = super(LumberjackEvaluator, self).execute() if result != BUILD_RESULT.OK: return (result, None) production_builder = self.area_builder coastline = production_builder.land_manager.coastline island_ground_map = production_builder.island.ground_map forest_coords_list = [] for coords in building.position.get_radius_coordinates( Entities.buildings[BUILDINGS.LUMBERJACK].radius): if coords in production_builder.plan and production_builder.plan[ coords][ 0] == BUILDING_PURPOSE.NONE and coords not in coastline: ok = False if island_ground_map[ coords].object is not None and island_ground_map[ coords].object.id == BUILDINGS.TREE: ok = True else: builder = BasicBuilder(BUILDINGS.TREE, coords, 0) if not builder.have_resources( production_builder.land_manager): break if builder: assert builder.execute(production_builder.land_manager) ok = True if ok: forest_coords_list.append(coords) production_builder.register_change_list(forest_coords_list, BUILDING_PURPOSE.TREE, None) return (BUILD_RESULT.OK, building)
def execute(self): (result, building) = super(LumberjackEvaluator, self).execute() if result != BUILD_RESULT.OK: return (result, None) production_builder = self.area_builder coastline = production_builder.land_manager.coastline island_ground_map = production_builder.island.ground_map forest_coords_list = [] for coords in building.position.get_radius_coordinates(Entities.buildings[BUILDINGS.LUMBERJACK].radius): if coords in production_builder.plan and production_builder.plan[coords][0] == BUILDING_PURPOSE.NONE and coords not in coastline: ok = False if island_ground_map[coords].object is not None and island_ground_map[coords].object.id == BUILDINGS.TREE: ok = True else: builder = BasicBuilder(BUILDINGS.TREE, coords, 0) if not builder.have_resources(production_builder.land_manager): break if builder: assert builder.execute(production_builder.land_manager) ok = True if ok: forest_coords_list.append(coords) production_builder.register_change_list(forest_coords_list, BUILDING_PURPOSE.TREE, None) return (BUILD_RESULT.OK, building)
def _reached_destination_area(self): self.log.info('%s reached BO area', self) builder = BasicBuilder(BUILDINGS.WAREHOUSE, self.coords, 0) if not builder.have_resources(self.land_manager, ship=self.ship): self.report_failure('Not enough resources for a warehouse at %s' % str(self.coords)) return self.warehouse = builder.execute(self.land_manager, ship=self.ship) assert self.warehouse self.land_manager.settlement = self.warehouse.settlement self.log.info('%s built the warehouse', self) self._unload_all_resources(self.land_manager.settlement) self.report_success('Built the warehouse, transferred resources')
def _reached_destination_area(self): self.log.info('%s reached BO area', self) builder = BasicBuilder(BUILDINGS.WAREHOUSE, self.coords, 0) if not builder.have_resources(self.land_manager, ship=self.ship): self.report_failure('Not enough resources for a warehouse at {}'.format(str(self.coords))) return self.warehouse = builder.execute(self.land_manager, ship=self.ship) assert self.warehouse self.land_manager.settlement = self.warehouse.settlement self.log.info('%s built the warehouse', self) self._unload_all_resources(self.land_manager.settlement) self.report_success('Built the warehouse, transferred resources')