def spawn(world, cfg, pos=None): if pos == None: pos = getPositionAwayFromOtherObjects( world, cfg.getint("Outpost", "buffer_object"), cfg.getint("Outpost", "buffer_edge")) o = Outpost(pos) world.append(o) return o
def __addBauble(self, player, force=False): logging.info("Add Bauble (%s) for Player %d", repr(force), player.netid) # add player bauble b = Bauble(getPositionAwayFromOtherObjects(self.world, self.cfg.getint("Bauble", "buffer_object"), self.cfg.getint("Bauble", "buffer_edge")), self.__points_gold) self.__baubles[player.netid] = b self.world.append(b) logging.info("Done Adding Bauble")
def spawn(world, cfg, pos=None, setpoints=None, pname=None): if pos == None: pos = getPositionAwayFromOtherObjects(world, cfg.getint("Bubble", "buffer_object"), cfg.getint("Bubble", "buffer_edge")) points = cfg_rand_min_max(cfg, "Bubble", "points") if setpoints != None: points = setpoints b = Bubble(pos, float(cfg.getint("KingOfTheBubble", "bubble_radius_min")), points, cfg.getint("KingOfTheBubble", "bubble_points_drain_speed"), pname, world) world.append(b) return b
def __addBauble(self, player, force=False): logging.info("Add Bauble (%s) for Player %d", repr(force), player.netid) # add player bauble b = Bauble( getPositionAwayFromOtherObjects( self.world, self.cfg.getint("Bauble", "buffer_object"), self.cfg.getint("Bauble", "buffer_edge")), self.__points_gold) self.__baubles[player.netid] = b self.world.append(b) logging.info("Done Adding Bauble")
def spawn(world, cfg, pos=None, value=None): if pos == None: pos = getPositionAwayFromOtherObjects( world, cfg.getint("Bauble", "buffer_object"), cfg.getint("Bauble", "buffer_edge")) # Get value within tolerances r = random.random() v = 0 vi = 0 if value == None: for ent in BaseBaubleGame.VALUE_TABLE: if r < ent[0]: v = ent[1] break vi += 1 else: for ent in BaseBaubleGame.VALUE_TABLE: if ent[1] == value: v = ent[1] break vi += 1 if cfg.has_option("BaubleGame", "bauble_invert_ratio_percent"): wvr = map( float, cfg.get("BaubleGame", "bauble_invert_ratio_percent").split(","))[vi] else: wvr = 0.0 if random.random() < wvr: r = random.random() w = 0 for ent in BaseBaubleGame.INVERTWEIGHT_TABLE: if r < ent[0]: w = ent[1] break else: r = random.random() w = 0 for ent in BaseBaubleGame.WEIGHT_TABLE: if r < ent[0]: w = ent[1] break b = Bauble(pos, v, w) world.append(b) return b
def spawn(world, cfg, pos=None): if pos == None: pos = getPositionAwayFromOtherObjects(world, cfg.getint("Bauble", "buffer_object"), cfg.getint("Bauble", "buffer_edge")) # Get value within tolerances r = random.random() v = 0 for ent in BaubleHuntGame.VALUE_TABLE: if r < ent[0]: v = ent[1] break b = Bauble(pos, v) world.append(b) return b
def world_create(self): super(TheHungerBaublesGame, self).world_create() self.__cornucopia_position = getPositionAwayFromOtherObjects(self.world, self.cfg.getint("TheHungerBaubles", "cornucopia_buffer_object"), self.cfg.getint("TheHungerBaubles", "cornucopia_buffer_edge")) for obj in self.world.getObjectsInArea(self.__cornucopia_position, self.__cornucopia_radius + 128): # remove planets in Cornucopia if isinstance(obj, Planet): logging.info("Removing Planet from Middle of Cornucopia #%d", obj.id) self.world.remove(obj) # try and move worm holes away from center elif isinstance(obj, WormHole): logging.info("Moving WormHole from Middle of Cornucopia #%d", obj.id) ang = obj.body.position.get_angle_between(self.__cornucopia_position) dist = random.randint(self.__cornucopia_radius + 128, self.__cornucopia_radius + 256) obj.body.position = (min(max(32, self.__cornucopia_position[0] + math.cos(ang) * dist), self.world.width - 32), min(max(32, self.__cornucopia_position[1] + math.sin(ang) * dist), self.world.height - 32))
def spawn(world, cfg, pos=None): if pos == None: pos = getPositionAwayFromOtherObjects(world, cfg.getint("Outpost", "buffer_object"), cfg.getint("Outpost", "buffer_edge")) o = Outpost(pos) world.append(o) return o
def spawn(world, cfg, pos=None): if pos == None: pos = getPositionAwayFromOtherObjects(world, cfg.getint("Bauble", "buffer_object"), cfg.getint("Bauble", "buffer_edge")) b = Bauble(pos, cfg.getint("HungryHungryBaubles", "bauble_points_blue")) world.append(b) return b