def war_details(self, war):
        start = datamodel.days_to_date(war.start_date_days)

        details = {
            "Start date":
            start,
            "End date":
            "-",
            "Attackers":
            ", ".join(
                self._get_url_for(wp.country) for wp in war.participants
                if wp.is_attacker),
            "Defenders":
            ", ".join(
                self._get_url_for(wp.country) for wp in war.participants
                if not wp.is_attacker),
            "Outcome":
            war.outcome,
        }
        if war.attacker_war_exhaustion or war.defender_war_exhaustion:
            details["Attacker exhaustion"] = war.attacker_war_exhaustion
            details["Defender exhaustion"] = war.defender_war_exhaustion
        if war.end_date_days:
            details["End date"] = datamodel.days_to_date(war.end_date_days)

        return details
예제 #2
0
    def collect_event_dicts(self, event_list, key_object):
        self._events[key_object] = []
        self._details[key_object] = self._get_details(key_object)
        self._titles[key_object] = self._get_title(key_object)
        self._formatted_urls[key_object] = self._get_url_for(key_object)
        for event in event_list:
            if not self.event_filter.include_event(event):
                continue
            if not config.CONFIG.show_everything and not event.event_is_known_to_player:
                continue
            if (event.country and any(c.is_other_player
                                      for c in event.involved_countries())
                    and not event.event_is_known_to_player):
                continue
            country_type = (event.country.country_type
                            if event.country is not None else None)
            if not config.CONFIG.show_all_country_types and country_type not in [
                    "default",
                    "fallen_empire",
                    "awakened_fallen_empire",
            ]:
                continue

            start = datamodel.days_to_date(event.start_date_days)
            end_date = None
            is_active = True
            if event.end_date_days is not None:
                end_date = datamodel.days_to_date(event.end_date_days)
                is_active = event.end_date_days >= self._most_recent_date
            event_dict = dict(
                country=event.country,
                start_date=start,
                is_active=is_active,
                end_date=end_date,
                event_type=str(event.event_type),
                war=event.war,
                leader=event.leader,
                system=event.system,
                planet=event.planet,
                faction=event.faction,
                target_country=event.target_country,
                description=event.description,
                fleet=event.fleet,
            )
            event_dict = {
                k: v
                for (k, v) in event_dict.items() if v is not None
            }

            if "planet" in event_dict and event_dict["system"] is None:
                event_dict["system"] = event_dict["planet"].system
            if "faction" in event_dict:
                event_dict["faction_type"] = event.faction.type
            if event.combat:
                event_dict.update(self._combat_dict(event.combat))

            self._events[key_object].append(event_dict)
            self._preformat_urls(event)
        if not self._events[key_object] and self.event_filter.is_empty_filter:
            del self._events[key_object]
예제 #3
0
def adjust_slider_values(tab_value, search):
    _, matches = _get_game_ids_matching_url(search)
    with datamodel.get_db_session(matches[0]) as session:
        max_date = utils.get_most_recent_date(session)

    if tab_value == config.GALAXY_MAP_TAB:
        marks = {0: "2200.01.01", 100: datamodel.days_to_date(max_date)}
        for x in range(20, 100, 20):
            marks[x] = datamodel.days_to_date(x / 100 * max_date)
        logger.info(f"Setting marks to {marks}")
        return marks
    else:
        return {}
 def leader_details(self, leader_model: datamodel.Leader) -> Dict[str, str]:
     country_url = self._get_url_for(leader_model.country)
     details = {
         "Leader Name":
         leader_model.leader_name,
         "Gender":
         game_info.convert_id_to_name(leader_model.gender),
         "Species":
         leader_model.species.species_name,
         "Class":
         f"{game_info.convert_id_to_name(leader_model.leader_class)} in the {country_url}",
         "Born":
         datamodel.days_to_date(leader_model.date_born),
         "Hired":
         datamodel.days_to_date(leader_model.date_hired),
         "Last active":
         datamodel.days_to_date(
             utils.get_most_recent_date(self._session) if leader_model.
             is_active else leader_model.last_date),
         "Status":
         "Active" if leader_model.is_active else "Dead or Dismissed",
     }
     return details