def placeQuestCreatures(self): import Game as G random = G.getRandom() # Find a forest level to put the creatures in game = EriuGame.game currentX, currentY = game.getCurrentMapTile().getXY() possibleGoals = game.getWorldMap().getTilesInRange(5, 10, currentX, currentY, Forest) print possibleGoals goalTile = random.choice(possibleGoals) goalArea = goalTile.getConnectedArea() print "Quest creatures added to level at", goalTile.getXY() creatures = [] for req in self.getRequirements(): creatureType = req.getCreatureType() for dummy in range(req.getEventsRequired()): creature = creatureType(questTarget=True) creatures.append(creature) # Start thread to generate level and populate it with items print "Setting up thread" thread = StartingLevelBuildingThread(goalArea, [], creatures) thread.start() print "Thread running!"
def getNearestTile(self, fromTile, tileClass): import Game as G random = G.getRandom() centerX, centerY = fromTile.getXY() radius = 1 while True: matches = self.getTilesAtRadius(radius, centerX, centerY, tileClass) if not matches: radius += 1 continue return random.choice(matches)
''' Created on Feb 14, 2014 @author: dstuart ''' import os import os.path import Game as G random = G.getRandom() prefixes = [] suffixes = [] prefixfile = open(os.path.join("data", "names", "twprefix"), 'r') suffixfile = open(os.path.join("data", "names", "twsuffix"), 'r') for line in prefixfile.readlines(): line = line.strip() if line: prefixes.append(line) prefixfile.close() for line in suffixfile.readlines(): line = line.strip() if line: suffixes.append(line) suffixfile.close()