def getNodeData(self, file):
        """
            get node data from a json file

            Parameters:
                file: filename
        """

        with open('./data/{}.json'.format(file), 'r') as json_file:
            try:
                objs = []
                data = json_file.read()
                dic = json.loads(data)['data']
                for i in dic:
                    objs.append(Entity(i['id'], i['name']))
                return objs
            except Exception as e:
                print(e)
示例#2
0
	def generateMap(self, width, height):
		# Make empty 2D array
		arr = []
		for i in range(width):
			arr.append([])
			for j in range(height):
				arr[i].append(None)

		for y in range(height):
			for x in range(width):
				if self.isTouchingCharacter(arr, (x, y), width, height, '#'):
					chance = .35
				else:
					chance = .1

				# If random chance, or edge piece, add wall
				if (random.uniform(0, 1) < chance) or (x == 0 or y == 0 or x == width-1 or y == height-1):
					wall = Entity(x, y, "#", self.msgBus)
					self.addEntity(wall)
					arr[x][y] = wall.char
示例#3
0
 def __init__(self, jsonObject):
     Entity.__init__(self, jsonObject)
     if not 'image' in self._js:
         self._js['image'] = {}
         self._js['image']['filename'] = ''
     self.productFolderHref = self._js['productFolder']['meta']['href']
示例#4
0
 def toString(self):
     return Entity.toString(self) + "\n" + str(
         self.sellPrice) + " руб " + str(
             self.buyPrice) + " руб " + " TP=" + str(
                 self.getTP()) + "\tTM=" + str(self.getTM())
示例#5
0
 def __init__(self, jsonObject):
     Entity.__init__(self, jsonObject)
示例#6
0
	def action(self, entity, vector2D):
		# WASD button handling to interact with world
		if self.shiftModifier:
			self.removeEntityAt(entity.x + vector2D[0], entity.y + vector2D[1])
		else:
			self.addEntity(Entity(entity.x + vector2D[0], entity.y + vector2D[1], "#", self.msgBus))
示例#7
0
 def __init__(self, initialX, initialY, char, msgBus, aiType=None):
     Entity.__init__(self, initialX, initialY, char, msgBus, aiType)