Esempio n. 1
0
    def setGame(self, game):
        if game is None:
            return

        self.game = game
        self.setBudget(self.game.budget, Income(self.game, player=True).total)
        self.finances.setEnabled(True)
Esempio n. 2
0
    def __init__(self, game: Game, player: bool, total_at_top: bool = False) -> None:
        super().__init__()
        self.row = itertools.count(0)

        income = Income(game, player)

        if total_at_top:
            self.add_total(game, income, player)
            self.add_line()

        control_points = reversed(
            sorted(income.control_points, key=lambda c: c.income_per_turn)
        )
        for control_point in control_points:
            self.add_control_point(control_point)

        self.add_line()

        buildings = reversed(sorted(income.buildings, key=lambda b: b.income))
        for building in buildings:
            self.add_building(building)

        if not total_at_top:
            self.add_line()
            self.add_total(game, income, player)
Esempio n. 3
0
    def __init__(self, game: Game, player: bool) -> None:
        super().__init__()
        self.row = itertools.count(0)

        income = Income(game, player)

        control_points = reversed(
            sorted(income.control_points, key=lambda c: c.income_per_turn)
        )
        for control_point in control_points:
            self.add_control_point(control_point)

        self.add_line()

        buildings = reversed(sorted(income.buildings, key=lambda b: b.income))
        for building in buildings:
            self.add_building(building)

        self.add_line()

        self.add_row(
            middle=f"Income multiplier: {income.multiplier:.1f}",
            right=f"<b>{income.total}M</b>",
        )

        if player:
            budget = game.budget
        else:
            budget = game.enemy_budget

        self.add_row(middle="Balance", right=f"<b>{budget}M</b>")
        self.setRowStretch(next(self.row), 1)
Esempio n. 4
0
    def economic_strength_text(self) -> str:
        assert self.game is not None
        own = Income(self.game, player=True).total
        enemy = Income(self.game, player=False).total

        if not enemy:
            return "enemy economy ruined"

        ratio = own / enemy
        if ratio < 0.6:
            return "strong disadvantage"
        if ratio < 0.8:
            return "slight disadvantage"
        if ratio < 1.2:
            return "evenly matched"
        if ratio < 1.4:
            return "slight advantage"
        return "strong advantage"
Esempio n. 5
0
    def end_turn(self) -> None:
        """Processes coalition-specific turn finalization.

        For more information on turn finalization in general, see the documentation for
        `Game.finish_turn`.
        """
        self.air_wing.end_turn()
        self.budget += Income(self.game, self.player).total

        # Need to recompute before transfers and deliveries to account for captures.
        # This happens in in initialize_turn as well, because cheating doesn't advance a
        # turn but can capture bases so we need to recompute there as well.
        self.update_transit_network()

        # Must happen *before* unit deliveries are handled, or else new units will spawn
        # one hop ahead. ControlPoint.process_turn handles unit deliveries. The
        # coalition-specific turn-end happens before the theater-wide turn-end, so this
        # is handled correctly.
        self.transfers.perform_transfers()
Esempio n. 6
0
    def __init__(self, game: Game, player: bool) -> None:
        super().__init__()

        income = Income(game, player)

        self.addWidget(QLabel("<b>Control Points</b>"), 0, 0)
        self.addWidget(
            QLabel(
                f"{len(income.control_points)} bases x {income.income_per_base}M"
            ), 0, 1)
        self.addWidget(QLabel(f"{income.from_bases}M"), 0, 2)

        self.addWidget(QHorizontalSeparationLine(), 1, 0, 1, 3)

        buildings = reversed(sorted(income.buildings, key=lambda b: b.income))
        row = 2
        for row, building in enumerate(buildings, row):
            self.addWidget(
                QLabel(
                    f"<b>{building.category.upper()} [{building.name}]</b>"),
                row, 0)
            self.addWidget(
                QLabel(
                    f"{building.number} buildings x {building.income_per_building}M"
                ), row, 1)
            rlabel = QLabel(f"{building.income}M")
            rlabel.setProperty("style", "green")
            self.addWidget(rlabel, row, 2)

        self.addWidget(QHorizontalSeparationLine(), row + 1, 0, 1, 3)
        self.addWidget(QLabel(f"Income multiplier: {income.multiplier:.1f}"),
                       row + 2, 1)
        self.addWidget(QLabel(f"<b>{income.total}M</b>"), row + 2, 2)

        if player:
            budget = game.budget
        else:
            budget = game.enemy_budget
        self.addWidget(QLabel(f"Balance"), row + 3, 1)
        self.addWidget(QLabel(f"<b>{budget}M</b>"), row + 3, 2)
        self.setRowStretch(row + 4, 1)