def main(cursor): team_dict = team_q.get_real_active_teams(cursor) deity_dict = deity_q.get_all_deities(cursor) team_q.mass_get_team_deities(cursor, team_dict) # Stores lists of teams deities = {} # Make blank lists for d in deity_dict.keys(): deities[d] = [] # Find out who follows who for t, the_team in team_dict.items(): for d, v in the_team.deities.items(): deities[d].append(the_team.name) output = [] for d, the_deity in deity_dict.items(): if len(deities[d]) == 0: continue # Deity name and follower list if len(deities[d]) > 1: output.append("[b]%s[/b] %s followers (%s)" % (the_deity.name, len(deities[d]), ", ".join(deities[d]))) else: output.append("[b]%s[/b] 1 follower (%s)" % (the_deity.name, deities[d][0])) output.append("Objective: %s" % the_deity.objective) output.append("DI: %s" % the_deity.di) output.append("Chosen follower: \n") return ' <textarea rows="40" style="width:99%%;">%s</textarea>' % "\n".join(output)
def prep_for_to(self): self.teams() self.cities() team_q.mass_get_team_evolutions(self.cursor, self._teams) team_q.mass_get_team_deities(self.cursor, self._teams) city_q.mass_get_city_artefacts(self.cursor, self._cities) city_q.mass_get_city_wonders(self.cursor, self._cities)
def prep_for_ti(self): self.players() player_q.mass_get_player_powers(self.cursor, self._players) self.teams() team_q.mass_get_team_deities(self.cursor, self._teams) team_q.mass_get_team_spells(self.cursor, self._teams) team_q.mass_get_team_techs(self.cursor, self._teams) team_q.mass_get_team_stats(self.cursor, self._teams, common.current_turn()) team_q.mass_get_team_stats(self.cursor, self._teams, common.current_turn()-1) team_q.mass_get_team_stats(self.cursor, self._teams, common.current_turn()-2) self.cities() city_q.mass_get_city_buildings(self.cursor, self._cities) city_q.mass_get_city_artefacts(self.cursor, self._cities) city_q.mass_get_city_wonders(self.cursor, self._cities) self.armies() # squad_q.mass_get_squads(self.cursor, self._armies) self.mass_get_army_squads() self.mass_get_army_monsters() self.units() unit_q.mass_get_unit_equipment(self.cursor, self._units)
def main(cursor, options): the_world = world.World(cursor) team_dict = the_world.teams() team_list = [] # Work out our team try: t = options.team if t != "": for t, the_team in team_dict.items(): if the_team.name.lower() == options.team.lower(): team_list = [t] if team_list == []: raise Exception() else: raise Exception() except Exception as e: team_list = [t for t in team_dict.keys() if (team_dict[t].active and not team_dict[t].ir)] # Some caching stuff the_world.cities() the_world.armies() the_world.players() the_world.units() player_q.mass_get_player_powers(cursor, the_world._players) team_q.mass_get_team_deities(cursor, the_world._teams) team_q.mass_get_team_spells(cursor, the_world._teams) team_q.mass_get_team_techs(cursor, the_world._teams) team_q.mass_get_team_resources(cursor, the_world._teams) team_q.mass_get_team_evolutions(cursor, the_world._teams) city_q.mass_get_city_buildings(cursor, the_world._cities) city_q.mass_get_city_artefacts(cursor, the_world._cities) city_q.mass_get_city_wonders(cursor, the_world._cities) unit_q.mass_get_unit_equipment(cursor, the_world._units) squad_q.mass_get_squads(cursor, the_world._armies) print("Caches setup") t_output = [] for t in team_list: the_team = the_world._teams[t] headers = ti_f.headers(the_team) footers = ti_f.footers(the_team) js = ti_f.javascript(the_team) try: team_start = time.time() ti_output = ti_f.make_ti(cursor, the_world, the_team) output = "".join([js, ti_output]) md5_name = team_f.team_hash(the_team.name) try: f = open('%sti_%s.html' % (common.data['cache_path'], md5_name), 'w') f.write(output) f.close() except Exception as e: pass t_output.append(output) print("Made for %s in %s" % (the_world._teams[t].name, round(time.time() - team_start, 3))) except Exception as e: print("Error in making TI for team '%s'" % the_world._teams[t].name) raise return "".join(t_output)
def mass_get_team_deities(self, force_requery=False): if "mass_get_team_deities" not in self.mass_get_checker or force_requery: team_q.mass_get_team_deities(self.cursor, self.teams()) self.mass_get_checker.add("mass_get_team_deities")
def prep_for_start(self): self.teams() team_q.mass_get_team_deities(self.cursor, self._teams)