当前位置: 首页>>代码示例>>Python>>正文


Python Builder.create方法代码示例

本文整理汇总了Python中builder.Builder.create方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.create方法的具体用法?Python Builder.create怎么用?Python Builder.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在builder.Builder的用法示例。


在下文中一共展示了Builder.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __make_new_builder

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import create [as 别名]
	def __make_new_builder(self, building_id, x, y, needs_collector, orientation):
		"""Return a Builder object if it is allowed to be built at the location, otherwise return None (not cached)."""
		coords = (x, y)
		if building_id == BUILDINGS.CLAY_PIT_CLASS or building_id == BUILDINGS.IRON_MINE_CLASS:
			# clay deposits and mountains are outside the production plan until they are constructed
			if coords in self.plan or coords not in self.settlement.ground_map:
				return None
		else:
			if coords not in self.plan or self.plan[coords][0] != BUILDING_PURPOSE.NONE or coords not in self.settlement.ground_map:
				return None
		builder = Builder.create(building_id, self.land_manager, Point(x, y), orientation=orientation)
		if not builder or not self.land_manager.legal_for_production(builder.position):
			return None
		if building_id == BUILDINGS.FISHERMAN_CLASS or building_id == BUILDINGS.BOATBUILDER_CLASS:
			for coords in builder.position.tuple_iter():
				if coords in self.plan and self.plan[coords][0] != BUILDING_PURPOSE.NONE:
					return None
		elif building_id != BUILDINGS.CLAY_PIT_CLASS and building_id != BUILDINGS.IRON_MINE_CLASS:
			# clay deposits and mountains are outside the production plan until they are constructed
			for coords in builder.position.tuple_iter():
				if coords not in self.plan or self.plan[coords][0] != BUILDING_PURPOSE.NONE:
					return None
		if needs_collector and not any(True for building in self.collector_buildings if building.position.distance(builder.position) <= building.radius):
			return None
		return builder
开发者ID:mitfik,项目名称:unknown-horizons,代码行数:27,代码来源:productionbuilder.py

示例2: __make_new_builder

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import create [as 别名]
    def __make_new_builder(self, building_id, x, y, needs_collector, orientation):
        """Return a Builder object if it is allowed to be built at the location, otherwise return None (not cached)."""
        coords = (x, y)
        # quick check to see whether the origin square is allowed to be in the requested place
        if building_id == BUILDINGS.CLAY_PIT_CLASS or building_id == BUILDINGS.IRON_MINE_CLASS:
            # clay deposits and mountains are outside the production plan until they are constructed
            if coords in self.plan or coords not in self.settlement.ground_map:
                return None
        elif building_id in self.coastal_building_classes:
            # coastal buildings can use coastal tiles
            if (
                coords not in self.land_manager.coastline
                and coords in self.plan
                and self.plan[coords][0] != BUILDING_PURPOSE.NONE
            ):
                return None
        else:
            if (
                coords not in self.plan
                or self.plan[coords][0] != BUILDING_PURPOSE.NONE
                or coords not in self.settlement.ground_map
            ):
                return None

                # create the builder, make sure that it is allowed according to the game logic
        builder = Builder.create(building_id, self.land_manager, Point(x, y), orientation=orientation)
        if not builder or not self.land_manager.legal_for_production(builder.position):
            return None

            # make sure that the position of the building is allowed according to the plan
        if building_id in self.coastal_building_classes:
            # coastal buildings can use coastal tiles
            for coords in builder.position.tuple_iter():
                if (
                    coords not in self.land_manager.coastline
                    and coords in self.plan
                    and self.plan[coords][0] != BUILDING_PURPOSE.NONE
                ):
                    return None
        elif building_id in [BUILDINGS.CLAY_PIT_CLASS, BUILDINGS.IRON_MINE_CLASS]:
            # clay deposits and mountains can't be in areas restricted by the plan
            pass
        else:
            for coords in builder.position.tuple_iter():
                if coords not in self.plan or self.plan[coords][0] != BUILDING_PURPOSE.NONE:
                    return None

                    # make sure the building is close enough to a collector if it produces any resources that have to be collected
        if needs_collector and not any(
            True
            for building in self.collector_buildings
            if building.position.distance(builder.position) <= building.radius
        ):
            return None
        return builder
开发者ID:perher,项目名称:unknown-horizons,代码行数:57,代码来源:productionbuilder.py


注:本文中的builder.Builder.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。