def read_in_config(self, filename): parser = GameObject.read_in_config(self, filename) if parser.has_section('bio'): if parser.has_option('bio', 'projectile'): self.projectile = parser.get('bio', 'projectile') # Convert projectile string to real object. found = False for p in self.all_projectiles: if self.projectile == p.name: self.projectile = p found = True if not found: print "Warning: Projectile object could not be located for: %s" % self.projectile if parser.has_section('attacks'): self.attacks = mb_subs.actions(parser.items('attacks')) if parser.has_section('defences'): self.defences = mb_subs.actions(parser.items('defences'))
def read_in_config(self, filename): if filename is None: pass # sometimes we want to create location objects w/ no # corresponding config file. else: parser = GameObject.read_in_config(self, filename) # Redefine image size over game object defaults # since location sprites need to be larger to # cover game area. These probably won't ever # need to be defined in the file. # self.image_size_x = self.globals['screen_width'] self.image_size_y = self.globals['screen_height'] - 25 # if parser.has_section('bio'): if parser.has_option('bio', 'sounds'): sounds_str = parser.get('bio', 'sounds') self.sound_list = sounds_str.split(',') for i in range(len(self.sound_list)): self.sound_list[i] = os.path.join(self.gamedir, string.strip(self.sound_list[i])) self.num_sounds = len(self.sound_list) if parser.has_option('bio', 'traps'): traps_str = parser.get('bio', 'traps') self.traps = traps_str.split(',') # remove whitespace for i in range(len(self.traps)): self.traps[i] = string.strip(self.traps[i]) if parser.has_option('bio', 'weapons'): weapons_str = parser.get('bio', 'weapons') self.weapons = weapons_str.split(',') # remove whitespace for i in range(len(self.weapons)): self.weapons[i] = string.strip(self.weapons[i]) if parser.has_option('bio', 'monsters'): monsters_str = parser.get('bio', 'monsters') self.monsters = monsters_str.split(',') # remove whitespace for i in range(len(self.monsters)): self.monsters[i] = string.strip(self.monsters[i]) if parser.has_section('links'): if parser.has_option('links', 'left'): self.links['left'] = parser.get('links', 'left') else: self.links['left'] = None if parser.has_option('links', 'right'): self.links['right'] = parser.get('links', 'right') else: self.links['right'] = None if parser.has_option('links', 'up'): self.links['up'] = parser.get('links', 'up') else: self.links['up'] = None if parser.has_option('links', 'down'): self.links['down'] = parser.get('links', 'down') else: self.links['down'] = None else: self.links['left'] = self.links['right'] = None self.links['up'] = self.links['down'] = None if parser.has_section('locations'): self.descriptions = parser.items('locations')
def read_in_config(self, filename): parser = GameObject.read_in_config(self, filename) if parser.has_section('body'): if parser.has_option('body', 'heads'): self.heads = int(parser.get('body', 'heads')) if parser.has_option('body', 'eyes'): self.eyes = int(parser.get('body', 'eyes')) if parser.has_option('body', 'horns'): self.horns = int(parser.get('body', 'horns')) if parser.has_option('body', 'arms'): self.arms = int(parser.get('body', 'arms')) if parser.has_option('body', 'legs'): self.legs = int(parser.get('body', 'legs')) if parser.has_option('body', 'tails'): self.tails = int(parser.get('body', 'tails')) if parser.has_section('bio'): self.health = int(parser.get('bio', 'health')) if parser.has_option('bio', 'family'): self.family = parser.get('bio', 'family') if parser.has_option('bio', 'height'): self.height = float(parser.get('bio', 'height')) if parser.has_option('bio', 'weight'): self.weight = float(parser.get('bio', 'weight')) if parser.has_option('bio', 'agility'): self.agility = int(parser.get('bio', 'agility')) else: self.agility = 25 if parser.has_option('bio', 'mobility'): self.mobility = float(parser.get('bio', 'mobility')) if parser.has_option('bio', 'quickness'): self.quickness = float(parser.get('bio', 'quickness')) if parser.has_option('bio', 'strength'): self.strength = float(parser.get('bio', 'strength')) if parser.has_option('bio', 'jaw_strength'): self.jaw_strength = float(parser.get('bio', 'jaw_strength')) if parser.has_option('bio', 'grip_strength'): self.grip_strength = float(parser.get('bio', 'grip_strength')) if parser.has_option('bio', 'dexterity'): self.dexterity = float(parser.get('bio', 'dexterity')) if parser.has_option('bio', 'intelligence'): self.intelligence = float(parser.get('bio', 'intelligence')) if parser.has_option('bio', 'aggressiveness'): self.aggressiveness = float(parser.get('bio', 'aggressiveness')) if parser.has_option('bio', 'weapon_ability'): self.weapon_ability = float(parser.get('bio', 'weapon_ability')) if parser.has_option('bio', 'skin_strength'): self.skin_strength = float(parser.get('bio', 'skin_strength')) if parser.has_option('bio', 'leaping_ability'): self.leaping_ability = float( parser.get('bio', 'leaping_ability')) # Not ready to implement this yet. if parser.has_option('bio', 'weapons'): weapons_str = parser.get('bio', 'weapons') self.weapons = weapons_str.split(',') # end bio section. if parser.has_section('attacks'): self.attacks = mb_subs.actions(parser.items('attacks')) if parser.has_section('defences'): self.defences = mb_subs.actions(parser.items('defences')) if parser.has_section('fatalities'): self.fatalities = parser.options('fatalities') if parser.has_section('taunts'): self.taunts = parser.options('taunts') self.has_taunts = True return parser
def read_in_config(self, filename): parser = GameObject.read_in_config(self, filename) if parser.has_section('attacks'): self.attacks = mb_subs.actions(parser.items('attacks')) del parser