def load_data(window): item_data = [ItemMethods.itemparser(item)[0] for item in GC.ITEMDATA] item_data = sorted(item_data, key=lambda item: GC.ITEMDATA[item.id]['num']) item_data = [item for item in item_data if not item.virtual] for item in item_data: if item.image: item.icon = create_icon(item.image.convert_alpha(), window) skill_data = [ StatusObject.statusparser(skill.find('id').text) for skill in GC.STATUSDATA.getroot().findall('status') ] for skill in skill_data: if skill.icon: skill.icon = create_icon(skill.icon.convert_alpha(), window) portrait_data = SaveLoad.create_portrait_dict() class_dict = SaveLoad.create_class_dict() for klass in class_dict.values(): generic_unit = GenericUnit(klass['name']) klass['images'] = (generic_unit.image1, generic_unit.image2, generic_unit.image3) klass['icon'] = create_icon(klass['images'][0], window) class_data = sorted([klass for klass in class_dict.values()], key=lambda x: (x['id'] % 100, x['id'])) unit_data = build_units(class_dict, portrait_data) return unit_data, class_dict, class_data, item_data, skill_data, portrait_data
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() gameStateObj.set_generic_mode() scripts = [ 'preBase', 'in_base_', 'narration', 'intro', 'prep', 'turnChange', 'move', 'menu', 'attack', 'interact' ] num = 0 while True: levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num) if not os.path.exists(levelfolder): break print('Level: %s' % num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width * gameStateObj.map.height)) if num == 10: for script in scripts: fp = levelfolder + '/' + script + 'Script.txt' run(gameStateObj, metaDataObj, fp) for _ in range(20): gameStateObj.turncount += 1 fp = levelfolder + '/turnChangeScript.txt' run(gameStateObj, metaDataObj, fp) fp = levelfolder + '/outroScript.txt' run(gameStateObj, metaDataObj, fp) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits))) num += 1
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() scripts = [ 'preBase', 'in_base_', 'narration', 'intro', 'prep', 'turnChange', 'move', 'menu', 'attack', 'interact' ] for num in range(0, GC.cf.CONSTANTS['num_levels']): print('Level: %s' % num) levelfolder = 'Data/Level' + str(num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width * gameStateObj.map.height)) if num == 3: for script in scripts: fp = levelfolder + '/' + script + 'Script.txt' run(gameStateObj, metaDataObj, fp) for _ in range(20): gameStateObj.turncount += 1 fp = levelfolder + '/turnChangeScript.txt' run(gameStateObj, metaDataObj, fp) fp = levelfolder + '/outroScript.txt' run(gameStateObj, metaDataObj, fp) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits)))
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() wait_for = 1 for num in range(0, GC.cf.CONSTANTS['num_levels']): time1 = time.clock() print('Level: %s' % num) SaveLoad.load_level('Data/Level' + str(num), gameStateObj, metaDataObj) print('Time to Load: %s' % (time.clock() - time1)) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width * gameStateObj.map.height)) for unit in gameStateObj.allunits: CustomObjects.handle_info_key(gameStateObj, metaDataObj, unit) info_menu = InfoMenu.InfoMenu() info_menu.begin(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) # Move right info_menu.move_right(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) info_menu.move_right(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) info_menu.move_right(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits)))
def build_units(class_dict, portrait_data): units = [] for unit in GC.UNITDATA.getroot().findall('unit'): u_i = {} u_i['id'] = unit.find('id').text u_i['name'] = unit.get('name') classes = unit.find('class').text.split(',') u_i['klass'] = classes[-1] u_i['gender'] = unit.find('gender').text u_i['level'] = int(unit.find('level').text) u_i['faction'] = unit.find('faction').text stats = SaveLoad.intify_comma_list(unit.find('bases').text) for n in xrange(len(stats), cf.CONSTANTS['num_stats']): stats.append(class_dict[u_i['klass']]['bases'][n]) assert len(stats) == cf.CONSTANTS[ 'num_stats'], "bases %s must be exactly %s integers long" % ( stats, cf.CONSTANTS['num_stats']) u_i['stats'] = SaveLoad.build_stat_dict(stats) # print("%s's stats: %s", u_i['name'], u_i['stats']) u_i['growths'] = SaveLoad.intify_comma_list(unit.find('growths').text) u_i['growths'].extend( [0] * (cf.CONSTANTS['num_stats'] - len(u_i['growths']))) assert len(u_i['growths']) == cf.CONSTANTS[ 'num_stats'], "growths %s must be exactly %s integers long" % ( stats, cf.CONSTANTS['num_stats']) u_i['items'] = ItemMethods.itemparser(unit.find('inventory').text) # Parse wexp u_i['wexp'] = unit.find('wexp').text.split(',') for index, wexp in enumerate(u_i['wexp'][:]): if wexp in CustomObjects.WEAPON_EXP.wexp_dict: u_i['wexp'][index] = CustomObjects.WEAPON_EXP.wexp_dict[wexp] u_i['wexp'] = [int(num) for num in u_i['wexp']] assert len(u_i['wexp']) == len( CustomObjects.WEAPON_TRIANGLE.types ), "%s's wexp must have as many slots as there are weapon types." % ( u_i['name']) u_i['desc'] = unit.find('desc').text # Tags u_i['tags'] = set(unit.find('tags').text.split( ',')) if unit.find('tags') is not None and unit.find( 'tags').text is not None else set() # Personal Skills personal_skills = unit.find('skills').text.split( ',') if unit.find('skills') is not None and unit.find( 'skills').text is not None else [] u_i['skills'] = [ StatusObject.statusparser(status) for status in personal_skills ] units.append(Unit(u_i, portrait_data)) return units
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() levelfolder = 'Data/Level0' SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) run(gameStateObj, metaDataObj) gameStateObj.clean_up() print('Num Units Remaining: %s'%(len(gameStateObj.allunits)))
def load_data(self): # === Terrain Data === # Saved dictionary of terrains 2-tuple {color: (id, name)} self.terrain_data = OrderedDict() # Ingest terrain_data for terrain in GC.TERRAINDATA.getroot().findall('terrain'): color = tuple( int(num) for num in terrain.find('color').text.split(',')) tid = terrain.find('id').text name = terrain.get('name') self.terrain_data[color] = (tid, name) # === Item Data === self.item_data = OrderedDict() items = [ItemMethods.itemparser(item)[0] for item in GC.ITEMDATA] items = sorted(items, key=lambda item: GC.ITEMDATA[item.id]['num']) items = [item for item in items if not item.virtual] for item in items: if item.image: item.image = item.image.convert_alpha() self.item_data[item.id] = item # === Skill Data === self.skill_data = OrderedDict() skills = [ StatusObject.statusparser(skill.find('id').text) for skill in GC.STATUSDATA.getroot().findall('status') ] for skill in skills: if skill.image: skill.image = skill.image.convert_alpha() self.skill_data[skill.id] = skill # === Portrait Data === # Has mouth and blink positions by name portrait_dict = SaveLoad.create_portrait_dict() # Setting up portrait data self.portrait_data = OrderedDict() for name, portrait in portrait_dict.items(): try: self.portrait_data[name] = UnitPortrait( name, portrait['blink'], portrait['mouth'], (0, 0)) except KeyError as e: print('%s: %s portrait not found' % (e, name)) for portrait in self.portrait_data.values(): portrait.create_image() portrait.image = portrait.image.convert_alpha() # === Class Data === self.class_dict = SaveLoad.create_class_dict() self.class_data = OrderedDict() for klass_id, klass in self.class_dict.items(): self.class_data[klass_id] = Klass(klass) # === Loaded Preset Unit Data === self.unit_data = build_named_units(self.class_dict)
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() for num in range(0, GC.cf.CONSTANTS['num_levels']): time1 = time.clock() print('Level: %s'%num) SaveLoad.load_level('Data/Level' + str(num), gameStateObj, metaDataObj) print('Time to Load: %s'%(time.clock() - time1)) print('Num Units: %s Map Size: %s'%(len(gameStateObj.allunits), gameStateObj.map.width*gameStateObj.map.height)) gameStateObj.clean_up() print('Num Units Remaining: %s'%(len(gameStateObj.allunits)))
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() for num in range(0, GC.cf.CONSTANTS['num_levels']): print('Level: %s'%num) levelfolder = 'Data/Level' + str(num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Num Units: %s Map Size: %s'%(len(gameStateObj.allunits), gameStateObj.map.width*gameStateObj.map.height)) for unit in gameStateObj.allunits: run(gameStateObj, metaDataObj, unit) gameStateObj.clean_up() print('Num Units Remaining: %s'%(len(gameStateObj.allunits)))
def load_level(self): if self.directory: image = self.directory + '/MapSprite.png' self.set_image(image) tilefilename = self.directory + '/TileData.png' self.tile_data.load(tilefilename) auto_loc = self.directory + '/Autotiles/' self.autotiles.load(auto_loc) overview_filename = self.directory + '/overview.txt' self.overview_dict = SaveLoad.read_overview_file(overview_filename) self.properties_menu.load(self.overview_dict) tile_info_filename = self.directory + '/tileInfo.txt' self.tile_info.load(tile_info_filename) unit_level_filename = self.directory + '/UnitLevel.txt' self.unit_data.load(unit_level_filename) self.faction_menu.load(self.unit_data) self.unit_menu.load(self.unit_data) self.reinforcement_menu.load(self.unit_data) self.trigger_menu.load(self.unit_data) if self.current_level_name: self.status_bar.showMessage('Loaded Level' + self.current_level_name) self.update_view()
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() gameStateObj.set_generic_mode() num = 0 while True: levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num) if not os.path.exists(levelfolder): break print('Level: %s' % num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width*gameStateObj.map.height)) for unit in gameStateObj.allunits: run(gameStateObj, metaDataObj, unit) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits))) num += 1
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() scripts = ['base', 'village', 'unlock', 'switch', 'talk', 'search'] for num in range(0, GC.cf.CONSTANTS['num_levels']): print('Level: %s' % num) levelfolder = 'Data/Level' + str(num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width * gameStateObj.map.height)) if num >= 0: for script in scripts: fp = levelfolder + '/' + script + 'Script.txt' run(gameStateObj, metaDataObj, fp) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits)))
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() gameStateObj.set_generic_mode() num = 0 while True: levelfolder = 'Data/Level' + str(num) if not os.path.exists(levelfolder): break time1 = time.clock() print('Level: %s' % num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Time to Load: %s' % (time.clock() - time1)) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width * gameStateObj.map.height)) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits))) num += 1
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() gameStateObj.set_generic_mode() scripts = ['base', 'village', 'unlock', 'switch', 'talk', 'search'] num = 0 while True: levelfolder = 'Data/Level' + str(num) if not os.path.exists(levelfolder): break print('Level: %s' % num) SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width*gameStateObj.map.height)) if num >= 0: for script in scripts: fp = levelfolder + '/' + script + 'Script.txt' run(gameStateObj, metaDataObj, fp) gameStateObj.clean_up() print('Num Units Remaining: %s'%(len(gameStateObj.allunits))) num += 1
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() gameStateObj.set_generic_mode() wait_for = 1 num = 0 while True: levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num) if not os.path.exists(levelfolder): break print('Level: %s' % num) time1 = time.clock() SaveLoad.load_level('Assets/Lex-Talionis/Data/Level' + str(num), gameStateObj, metaDataObj) print('Time to Load: %s' % (time.clock() - time1)) print('Num Units: %s Map Size: %s' % (len(gameStateObj.allunits), gameStateObj.map.width * gameStateObj.map.height)) for unit in gameStateObj.allunits: CustomObjects.handle_info_key(gameStateObj, metaDataObj, unit) info_menu = InfoMenu.InfoMenu() info_menu.begin(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) # Move right info_menu.move_right(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) info_menu.move_right(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) info_menu.move_right(gameStateObj, metaDataObj) for _ in range(wait_for): run(gameStateObj, metaDataObj, info_menu) gameStateObj.clean_up() print('Num Units Remaining: %s' % (len(gameStateObj.allunits))) num += 1
def __init__(self): self.id = 0 self.name = '' self.level = 1 self.gender = 0 self.faction = '' self.klass = 'Citizen' self.tags = set() self.desc = '' self.stats = SaveLoad.build_stat_dict(class_dict[self.klass]['bases']) self.growths = [0 for n in xrange(cf.CONSTANTS['num_stats'])] self.items = [] self.skills = [] self.wexp = [ 0 for n in xrange(len(CustomObjects.WEAPON_TRIANGLE.types)) ] self.team = 'player'
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() done = False for num in range(0, 12): if hasattr(gameStateObj, 'saving_thread'): gameStateObj.saving_thread.join() gameStateObj.save_slots = Transitions.load_saves() print('Level: %s' % num) gameStateObj.build_new() # Make the gameStateObj ready for a new game gameStateObj.set_generic_mode() gameStateObj.save_slot = 0 levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num) # Create a save for the first game gameStateObj.stateMachine.clear() gameStateObj.stateMachine.changeState('turn_change') SaveLoad.suspendGame(gameStateObj, "Start", slot=gameStateObj.save_slot) # Load the first level SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) # Set Casual Mode gameStateObj.mode['death'] = 0 # Run counter = 0 suspended_yet, dead_yet = False, False while not done: Engine.update_time() current_state = gameStateObj.stateMachine.getState() if current_state == 'free': units = [unit for unit in gameStateObj.allunits if unit.team == 'player' and not unit.dead and unit.name not in {'Sam', 'Ophie', 'Prim', 'Renae'}] if not dead_yet and units: unit = units[0] print(unit.name) unit.isDying = True gameStateObj.stateMachine.changeState('dying') gameStateObj.message.append(Dialogue.Dialogue_Scene(metaDataObj['death_quotes'], unit=unit)) gameStateObj.stateMachine.changeState('dialogue') dead_yet = True elif suspended_yet: gameStateObj.statedict['levelIsComplete'] = 'win' gameStateObj.message.append(Dialogue.Dialogue_Scene('Assets/Lex-Talionis/Data/seizeScript.txt')) gameStateObj.stateMachine.changeState('dialogue') suspended_yet = False else: SaveLoad.suspendGame(gameStateObj, 'Suspend', hard_loc='Suspend') gameStateObj.save_slots = None # Reset save slots gameStateObj.stateMachine.clear() gameStateObj.stateMachine.changeState('start_start') suspended_yet = True elif current_state == 'start_save' or current_state == 'start_start' or current_state == 'start_option': pyautogui.press('x') if current_state == 'start_save': dead_yet = False elif current_state == 'move': pyautogui.press('z') counter += 1 if not counter%20: pyautogui.press('s') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)