def get_detect_info(detect_chance): detect_template = _("Detection chance:") + "\n" chances = [] for group in g.pl.groups.values(): detect_template += group.name + u":\xA0%s\n" chances.append(detect_chance.get(group.spec.id, 0)) if g.pl.display_discover == "full": return detect_template % tuple(g.to_percent(c) for c in chances) elif g.pl.display_discover == "partial": return detect_template % tuple(g.to_percent(g.nearest_percent(c, 25)) for c in chances) else: return detect_template % tuple(g.danger_level_to_detect_str(detect_chance_to_danger_level(c)) for c in chances)
def get_quality_info(self): bonus_text = "" for qual, value in self.item_qual.items(): if qual == "cpu": bonus_text += _("CPU per day:") + " " bonus_text += g.add_commas(value) elif qual == "cpu_modifier": bonus_text += _("CPU bonus:") + " " bonus_text += g.to_percent(value) elif qual == "discover_modifier": bonus_text += _("Detection chance reduction:") + " " bonus_text += g.to_percent(value) bonus_text += "\n" return bonus_text
def get_quality_info(self, if_installed_in_base=None, count=1): bonus_text = "" for qual, value in self.item_qual.items(): if qual == "cpu": if if_installed_in_base is not None: value = max(1, int(value * if_installed_in_base.compute_bonus // 10000)) bonus_text += _("CPU per day:")+" " bonus_text += g.add_commas(value * count) elif qual == "cpu_modifier": bonus_text += _("CPU bonus:")+" " bonus_text += g.to_percent(value) elif qual == "discover_modifier": bonus_text += _("Detection chance reduction:")+" " bonus_text += g.to_percent(value) else: continue bonus_text += "\n" return bonus_text
def on_change(self, description_pane, event_spec): self.selected_event_spec = event_spec self.trigger_event_button.enabled = True self.expire_event_button.enabled = False event_instance = g.pl.events.get(event_spec.id) triggered_state = _('NO') trigger_duration = g.to_time(event_spec.duration * g.minutes_per_day) \ if event_spec.duration else _('Event never expires') triggered_at_raw = _('N/A; event not triggered') uniqueness = _('YES') if event_spec.unique else _('NO') if event_instance: if event_instance.triggered: self.trigger_event_button.enabled = False self.expire_event_button.enabled = event_instance.decayable_event triggered_state = _('YES') triggered_at_raw = event_instance.triggered_at text_format = _("{DESCRIPTION}\n\n" + "-----------------\n" + "Triggered: {TRIGGER_STATE}\n" + "Trigger chance: {TRIGGER_CHANCE}\n" + "Trigger Duration (full): {TRIGGER_DURATION}\n" + "Triggered at (rawtime): {TRIGGER_TIME_RAW}\n" + "Unique: {UNIQUE}\n" ) desc = text_format.format( DESCRIPTION=event_spec.description, TRIGGER_STATE=triggered_state, TRIGGER_CHANCE=g.to_percent(event_spec.chance), TRIGGER_DURATION=trigger_duration, TRIGGER_TIME_RAW=triggered_at_raw, UNIQUE=uniqueness, ) self.description = text.Text(description_pane, (0, 0), (-1, -1), text=desc, background_color="pane_background", align=constants.LEFT, valign=constants.TOP, borders=constants.ALL)
def rebuild(self): # Rebuild dialogs self.location_dialog.needs_rebuild = True self.research_button.dialog.needs_rebuild = True self.knowledge_button.dialog.needs_rebuild = True self.menu_dialog.needs_rebuild = True # Update buttons translations self.report_button.text = _("R&EPORTS") self.knowledge_button.text = _("&KNOWLEDGE") self.log_button.text = _("LO&G") self.menu_button.text = _("&MENU") self.research_button.text = _("&RESEARCH/TASKS") if g.cheater: self.cheat_dialog.needs_rebuild = True super(MapScreen, self).rebuild() self.difficulty_display.text = g.strip_hotkey(g.pl.difficulty.name) self.time_display.text = _("DAY") + " %04d, %02d:%02d:%02d" % \ (g.pl.time_day, g.pl.time_hour, g.pl.time_min, g.pl.time_sec) cash_flow_1d_data, cpu_flow_1d_data = g.pl.compute_future_resource_flow( g.seconds_per_day) cash_flow_1d = cash_flow_1d_data.difference cpu_flow_1d = cpu_flow_1d_data.difference self.cash_display.text = _("CASH")+": %s (%s)" % \ (g.to_money(g.pl.cash), g.to_money(cash_flow_1d, fixed_size=True)) total_cpu = g.pl.available_cpus[0] + g.pl.sleeping_cpus detects_per_day = {group_id: 0 for group_id in g.pl.groups} for base in g.all_bases(): if base.has_grace(): # It cannot be detected, so it doesn't contribute to # detection odds calculation continue detect_chance = base.get_detect_chance() for group_id in g.pl.groups: detects_per_day[group_id] = \ chance.add(detects_per_day[group_id], detect_chance[group_id] / 10000.) self.cpu_display.color = "cpu_normal" self.cpu_display.text = _("CPU")+": %s (%s)" % \ (g.to_money(total_cpu), g.to_money(cpu_flow_1d)) # What we display in the suspicion section depends on whether # Advanced Socioanalytics has been researched. If it has, we # show the standard percentages. If not, we display a short # string that gives a range of 25% as to what the suspicions # are. # A similar system applies to the danger levels shown. normal = (self.suspicion_bar.color, None, False) self.suspicion_bar.chunks = (" [" + _("SUSPICION") + "]", ) self.suspicion_bar.styles = (normal, ) self.danger_bar.chunks = ("[" + _("DETECT RATE") + "]", ) self.danger_bar.styles = (normal, ) for group in g.pl.groups.values(): suspicion = group.suspicion suspicion_color = gg.resolve_color_alias( "danger_level_%d" % g.suspicion_to_danger_level(suspicion)) detects = detects_per_day[group.spec.id] danger_level = group.detects_per_day_to_danger_level(detects) detects_color = gg.resolve_color_alias("danger_level_%d" % danger_level) if g.pl.display_discover == "full": suspicion_display = g.to_percent(suspicion, True) danger_display = g.to_percent(detects * 10000, True) elif g.pl.display_discover == "partial": suspicion_display = g.to_percent( g.nearest_percent(suspicion, 500), True) danger_display = g.to_percent( g.nearest_percent(detects * 10000, 100), True) else: suspicion_display = g.suspicion_to_detect_str(suspicion) danger_display = g.danger_level_to_detect_str(danger_level) self.suspicion_bar.chunks += (" " + group.name + u":\xA0", suspicion_display) self.suspicion_bar.styles += (normal, (suspicion_color, None, False)) self.danger_bar.chunks += (" " + group.name + u":\xA0", danger_display) self.danger_bar.styles += (normal, (detects_color, None, False)) self.suspicion_bar.visible = not g.pl.had_grace self.danger_bar.visible = not g.pl.had_grace for id, location_button in self.location_buttons.items(): location = g.pl.locations[id] location_button.text = "%s (%d)" % (location.name, len(location.bases)) location_button.hotkey = location.hotkey location_button.visible = location.available()
def rebuild(self): # Rebuild dialogs self.location_dialog.needs_rebuild = True self.research_button.dialog.needs_rebuild = True self.knowledge_button.dialog.needs_rebuild = True self.menu_dialog.needs_rebuild = True if g.cheater: self.cheat_dialog.needs_rebuild = True super(MapScreen, self).rebuild() self.difficulty_display.text = g.strip_hotkey(g.pl.difficulty.name) self.time_display.text = _("DAY") + " %04d, %02d:%02d:%02d" % \ (g.pl.time_day, g.pl.time_hour, g.pl.time_min, g.pl.time_sec) cash_flow_1d_data, cpu_flow_1d_data = g.pl.compute_future_resource_flow( g.seconds_per_day) cash_flow_1d = cash_flow_1d_data.difference cpu_flow_1d = cpu_flow_1d_data.difference self.cash_display.text = _("CASH")+": %s (%s)" % \ (g.to_money(g.pl.cash), g.to_money(cash_flow_1d, fixed_size=True)) total_cpu = g.pl.available_cpus[0] + g.pl.sleeping_cpus detects_per_day = {group_id: 0 for group_id in g.pl.groups} total_bases = 0 active_bases = 0 idle_bases_unable_to_sustain_singularity = 0 for base in g.all_bases(): total_bases += 1 maintains_singularity = base.maintains_singularity if maintains_singularity: active_bases += 1 elif base.done and not base.is_building(): idle_bases_unable_to_sustain_singularity += 1 if base.has_grace(): # It cannot be detected, so it doesn't contribute to # detection odds calculation continue detect_chance = base.get_detect_chance() for group_id in g.pl.groups: detects_per_day[group_id] = \ chance.add(detects_per_day[group_id], detect_chance[group_id] / 10000.) self.cpu_display.color = "cpu_normal" self.cpu_display.text = _("CPU")+": %s (%s)" % \ (g.to_money(total_cpu), g.to_money(cpu_flow_1d)) if active_bases == 1 and not g.pl.apotheosis: self.base_display.color = 'base_situation_one_active_base' elif idle_bases_unable_to_sustain_singularity > 0: self.base_display.color = 'base_situation_idle_incomplete_bases' elif total_bases > 10 and not g.pl.apotheosis: self.base_display.color = 'base_situation_many_bases' else: self.base_display.color = 'base_situation_normal' self.base_display.text = _("BASES") + ": %s / %s (%s)" % ( active_bases, total_bases, idle_bases_unable_to_sustain_singularity) # What we display in the suspicion section depends on whether # Advanced Socioanalytics has been researched. If it has, we # show the standard percentages. If not, we display a short # string that gives a range of 25% as to what the suspicions # are. # A similar system applies to the danger levels shown. normal = (self.suspicion_bar.color, None, False) suspicion_bar_chunks = [" [" + _("SUSPICION") + "]"] suspicion_bar_styles = [normal] danger_bar_chunks = ["[" + _("DETECT RATE") + "]"] danger_bar_styles = [normal] for group in g.pl.groups.values(): suspicion = group.suspicion suspicion_color = gg.resolve_color_alias( "danger_level_%d" % g.suspicion_to_danger_level(suspicion)) detects = detects_per_day[group.spec.id] danger_level = group.detects_per_day_to_danger_level(detects) detects_color = gg.resolve_color_alias("danger_level_%d" % danger_level) if g.pl.display_discover == "full": suspicion_display = g.to_percent(suspicion, True) danger_display = g.to_percent(detects * 10000, True) elif g.pl.display_discover == "partial": suspicion_display = g.to_percent( g.nearest_percent(suspicion, 500), True) danger_display = g.to_percent( g.nearest_percent(detects * 10000, 100), True) else: suspicion_display = g.suspicion_to_detect_str(suspicion) danger_display = g.danger_level_to_detect_str(danger_level) suspicion_bar_chunks.extend( (" " + group.name + u":\xA0", suspicion_display)) suspicion_bar_styles.extend( (normal, (suspicion_color, None, False))) danger_bar_chunks.extend( (" " + group.name + u":\xA0", danger_display)) danger_bar_styles.extend((normal, (detects_color, None, False))) self.suspicion_bar.visible = not g.pl.had_grace self.suspicion_bar.chunks = tuple(suspicion_bar_chunks) self.suspicion_bar.styles = tuple(suspicion_bar_styles) self.danger_bar.visible = not g.pl.had_grace self.danger_bar.chunks = tuple(danger_bar_chunks) self.danger_bar.styles = tuple(danger_bar_styles) for id, location_button in self.location_buttons.items(): location = g.pl.locations[id] location_button.text = "%s (%d)" % (location.name, len(location.bases)) location_button.hotkey = location.hotkey location_button.visible = location.available()
def rebuild(self): # Update buttons translations self.stats_button.text = _("&STATISTICS") self.back_button.text = _("&BACK") self.format_button_midnight.text = _("&Midnight") self.format_button_24hours.text = _("24 &Hours") super(ReportScreen, self).rebuild() if (self.midnight_stop): seconds = g.seconds_per_day - (g.pl.raw_sec % g.seconds_per_day) else: seconds = g.seconds_per_day cash_info, cpu_info = g.pl.compute_future_resource_flow(seconds) m = g.to_money #take care of the titles and border. text.Text(self.money_report_pane, (0, 0), (-1, -1), text=_("Financial report").replace(" ", u"\xA0"), background_color="pane_background", align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) text.Text(self.cpu_report_pane, (0, 0), (-1, -1), text=_("CPU Usage"), background_color="pane_background", align=constants.CENTER, valign=constants.TOP, borders=constants.ALL) financial_pluses = " \n+\n-\n-\n-\n+\n+\n=" financial_report = _("Current Money flow") + "\n" financial_report += _("Jobs:") + "\n" financial_report += _("Research:") + "\n" financial_report += _("Maintenance:") + "\n" financial_report += _("Construction:") + "\n" financial_report += _("Interest (%s):") % \ (g.to_percent(g.pl.interest_rate))+"\n" financial_report += _("Income:") + "\n" if (self.midnight_stop): financial_report += _("Money flow until Midnight:") + "\n" else: financial_report += _("Money flow for 24 hours:") + "\n" financial_numbers = "\n%s\n%s\n%s\n%s\n%s\n%s\n%s" % \ (m(cash_info.jobs), m(cash_info.tech), m(cash_info.maintenance_needed), m(cash_info.construction_needed), m(cash_info.interest), m(cash_info.income), m(cash_info.difference)) cpu_pluses = " \n-\n-\n-\n=\n \n-\n-\n=" cpu_report = _("Total CPU:") + "\n" cpu_report += _("Sleeping CPU:") + "\n" cpu_report += _("Research CPU:") + "\n" cpu_report += _("Job CPU:") + "\n" cpu_report += _("CPU pool:") + "\n\n" cpu_report += _("Maintenance CPU:") + "\n" cpu_report += _("Construction CPU:") + "\n" cpu_report += _("Pool difference:") + "\n" cpu_numbers = "%s\n%s\n%s\n%s\n%s\n\n%s\n%s\n%s\n" % \ (m(cpu_info.total), m(cpu_info.sleeping), m(cpu_info.tech), m(cpu_info.explicit_jobs), m(cpu_info.effective_pool), m(cpu_info.maintenance_needed), m(cpu_info.construction_needed), m(cpu_info.difference)) size = 'report_content' text.Text(self.money_report_pane, (0, -0.15), (-0.10, -0.85), text=financial_pluses, text_size=size, background_color="clear", align=constants.CENTER, valign=constants.TOP) text.Text(self.cpu_report_pane, (0, -0.15), (-0.10, -0.85), text=cpu_pluses, text_size=size, background_color="clear", align=constants.CENTER, valign=constants.TOP) text.Text(self.money_report_pane, (-0.10, -0.15), (-0.90, -0.85), text=financial_report, text_size=size, background_color="clear", align=constants.LEFT, valign=constants.TOP) text.Text(self.cpu_report_pane, (-0.10, -0.15), (-0.90, -0.85), text=cpu_report, text_size=size, background_color="clear", align=constants.LEFT, valign=constants.TOP) text.Text(self.money_report_pane, (0, -0.15), (-0.98, -0.85), text=financial_numbers, text_size=size, background_color="clear", align=constants.RIGHT, valign=constants.TOP) text.Text(self.cpu_report_pane, (0, -0.15), (-0.98, -0.85), text=cpu_numbers, text_size=size, background_color="clear", align=constants.RIGHT, valign=constants.TOP)