Ejemplo n.º 1
0
	def placeStarBases(self, starbases):
		''' Place starbases on the map '''
		
		while starbases > 0:
			pos = Random.getRandomPosition()
			qx = pos.QuadrantX
			qy = pos.QuadrantY
			sx = pos.SectorX
			sy = pos.SectorY
			
			if self.Quadrants[qx][qy].NoOfStarBases == 0 and self.Quadrants[qx][qy].Sectors[sx][sy] == ' ':
				self.Quadrants[qx][qy].Sectors[sx][sy] = StarBase.SYMBOL
				self.Quadrants[qx][qy].StarBases.append(StarBase(pos))
				starbases -= 1
Ejemplo n.º 2
0
	def placeKlingons(self, klingons):
		''' Place the enemy ships on the map '''
		
		while klingons > 0:
			pos = Random.getRandomPosition()
			qx = pos.QuadrantX
			qy = pos.QuadrantY
			sx = pos.SectorX
			sy = pos.SectorY
			
			if self.Quadrants[qx][qy].NoOfKlingons <= self.MAX_KLINGONS_IN_QUADRANT and self.Quadrants[qx][qy].Sectors[sx][sy] == ' ':
				self.Quadrants[qx][qy].Sectors[sx][sy] = Klingon.SYMBOL
				self.Quadrants[qx][qy].Klingons.append(Klingon(pos))
				klingons -= 1
Ejemplo n.º 3
0
    def placeStarBases(self, starbases):
        ''' Place starbases on the map '''

        while starbases > 0:
            pos = Random.getRandomPosition()
            qx = pos.QuadrantX
            qy = pos.QuadrantY
            sx = pos.SectorX
            sy = pos.SectorY

            if self.Quadrants[qx][qy].NoOfStarBases == 0 and self.Quadrants[
                    qx][qy].Sectors[sx][sy] == ' ':
                self.Quadrants[qx][qy].Sectors[sx][sy] = StarBase.SYMBOL
                self.Quadrants[qx][qy].StarBases.append(StarBase(pos))
                starbases -= 1
Ejemplo n.º 4
0
    def placeKlingons(self, klingons):
        ''' Place the enemy ships on the map '''

        while klingons > 0:
            pos = Random.getRandomPosition()
            qx = pos.QuadrantX
            qy = pos.QuadrantY
            sx = pos.SectorX
            sy = pos.SectorY

            if self.Quadrants[qx][
                    qy].NoOfKlingons <= self.MAX_KLINGONS_IN_QUADRANT and self.Quadrants[
                        qx][qy].Sectors[sx][sy] == ' ':
                self.Quadrants[qx][qy].Sectors[sx][sy] = Klingon.SYMBOL
                self.Quadrants[qx][qy].Klingons.append(Klingon(pos))
                klingons -= 1
Ejemplo n.º 5
0
    def placeEnterprise(self):
        '''Place The Enterprise on the map and returns it's position'''

        while True:
            pos = Random.getRandomPosition()
            qx = pos.QuadrantX
            qy = pos.QuadrantY
            sx = pos.SectorX
            sy = pos.SectorY

            if self.Quadrants[qx][qy].Sectors[sx][sy] == ' ':
                self.Quadrants[qx][qy].Sectors[sx][sy] = Enterprise.SYMBOL
                self.Quadrants[qx][qy].IsEnterprise = True
                break

        return pos
Ejemplo n.º 6
0
	def placeEnterprise(self):
		'''Place The Enterprise on the map and returns it's position'''
		
		while True:
			pos = Random.getRandomPosition()
			qx = pos.QuadrantX
			qy = pos.QuadrantY
			sx = pos.SectorX
			sy = pos.SectorY
			
			if self.Quadrants[qx][qy].Sectors[sx][sy] == ' ':
				self.Quadrants[qx][qy].Sectors[sx][sy] = Enterprise.SYMBOL
				self.Quadrants[qx][qy].IsEnterprise = True
				break
				
		return pos
Ejemplo n.º 7
0
	def placeStars(self):
		''' Populate quadrants with stars '''

		stars = self.NO_STARS
		
		while stars > 0:
			pos = Random.getRandomPosition()
			qx = pos.QuadrantX
			qy = pos.QuadrantY
			sx = pos.SectorX
			sy = pos.SectorY
			
			if self.Quadrants[qx][qy].NoOfStars <= self.MAX_STARS_IN_QUADRANT and self.Quadrants[qx][qy].Sectors[sx][sy] == ' ':
				self.Quadrants[qx][qy].Sectors[sx][sy] = Star.SYMBOL
				self.Quadrants[qx][qy].Stars.append(Star(maxint, False, pos))
				stars -= 1
Ejemplo n.º 8
0
    def placeStars(self):
        ''' Populate quadrants with stars '''

        stars = self.NO_STARS

        while stars > 0:
            pos = Random.getRandomPosition()
            qx = pos.QuadrantX
            qy = pos.QuadrantY
            sx = pos.SectorX
            sy = pos.SectorY

            if self.Quadrants[qx][
                    qy].NoOfStars <= self.MAX_STARS_IN_QUADRANT and self.Quadrants[
                        qx][qy].Sectors[sx][sy] == ' ':
                self.Quadrants[qx][qy].Sectors[sx][sy] = Star.SYMBOL
                self.Quadrants[qx][qy].Stars.append(Star(maxint, False, pos))
                stars -= 1