Ejemplo n.º 1
0
	def enter(worker):
		for id in BuildingManager.camps:
			ResourceManager.removeItem('sword')
			worker.campId = id
			worker.setTarget(BuildingManager.camps[id].pos)
			return
		
		worker.changeState(FindWork)
Ejemplo n.º 2
0
	def execute(worker):
		if worker.chopper:
			worker.changeState(ChopTree)
			return
			
		if worker.skipState:
			worker.changeState(CreateCraftsman)
			return
		
		# Create explorers if needed
		if EntityManager.explorerNeeded():
			worker.changeState(CreateExplorer)
			return
		
		# Create craftsman if needed
		elif EntityManager.craftsmanNeeded():
			worker.changeState(CreateCraftsman)
			return
			
		# Create soldier if needed
		elif EntityManager.soldierNeeded():
			worker.changeState(WalkToCamp)
			return
		
		# Gather resources
		if worker.item == None:
			if ResourceManager.resourceNeeded() == 'tree':
				worker.changeState(ChopTree)
			else:
				worker.changeState(MineIron)
		elif worker.item:
			worker.changeState(GoToBase)
Ejemplo n.º 3
0
	def enter(worker):
		if len(ResourceManager.trees) > 0:
			resource = ResourceManager.findTree()
			
			if resource:
				worker.harvestResource(resource)
			else:
				worker.changeState(FindWork)
		else:
			worker.changeState(FindWork)
Ejemplo n.º 4
0
 def enter(craftsman):
     if craftsman.building.type == 'kiln':
         if ResourceManager.checkResource(
                 ResourceManager.charCoalMaterials):
             for i in ResourceManager.charCoalMaterials:
                 ResourceManager.items[
                     i] -= ResourceManager.charCoalMaterials[i]
             craftsman.craft(craftsman.building)
             return
     elif craftsman.building.type == 'smelter':
         if ResourceManager.checkResource(ResourceManager.ironMaterials):
             for i in ResourceManager.ironMaterials:
                 ResourceManager.items[i] -= ResourceManager.ironMaterials[
                     i]
             craftsman.craft(craftsman.building)
             return
     elif craftsman.building.type == 'smithy':
         if ResourceManager.checkResource(ResourceManager.swordMaterials):
             for i in ResourceManager.swordMaterials:
                 ResourceManager.items[i] -= ResourceManager.swordMaterials[
                     i]
             craftsman.craft(craftsman.building)
             return
Ejemplo n.º 5
0
	def enter(worker):
		if len(ResourceManager.ironOre) > 0:
			resource = ResourceManager.findOre()
			
			if resource:
				worker.harvestResource(resource)
			else:
				worker.changeState(ChopTree)
		else:
			if len(EntityManager.soldiers) >= 3:
				worker.target = BuildingManager.getEnemyCastle()
				
				if worker.target:
					worker.changeState(Charge)
				return
				
			worker.changeState(FindWork)
Ejemplo n.º 6
0
    def onMessage(self, message):
        if message['type'] == 'buildComplete':
            newBuilding = Building(self.building.id, self.building.pos)
            buildingType = self.building.type
            BuildingManager.removeBuilding(self.building.id,
                                           StrategyManager.team, 'built')
            BuildingManager.addBuilding(newBuilding, buildingType)
            self.changeState(Idle)
        elif message['type'] == 'craftComplete':
            if self.building.type == 'kiln':
                ResourceManager.addItem('charCoal')
            elif self.building.type == 'smelter':
                ResourceManager.addItem('iron')
            elif self.building.type == 'smithy':
                ResourceManager.addItem('sword')

            self.crafting = False
            self.changeState(WorkInBuilding)

        if self.charge and message['type'] == 'tasksComplete':
            self.changeState(Scatter)
Ejemplo n.º 7
0
	def enter(worker):
		worker.setTarget(ResourceManager.getItemPosition())
Ejemplo n.º 8
0
    def soldierNeeded():
        # Wait with creating soldiers to not lose workers?
        if len(BuildingManager.camps) > 0:
            return ResourceManager.checkResource('sword', 1)

        return False