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
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
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
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
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
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
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