File: __init__.py

package info (click to toggle)
freeorion 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 194,940 kB
  • sloc: cpp: 186,508; python: 40,969; ansic: 1,164; xml: 719; makefile: 32; sh: 7
file content (47 lines) | stat: -rw-r--r-- 1,303 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from logging import debug

from common.statistic_interface import StatKey
from freeorion_tools.statistics.statistic import Stats


class StatsWrapper:
    def __init__(self):
        self._stats_writer = Stats(writer=debug)

    def _write(self, key, val):
        self._stats_writer.write(key, val)

    def ship_count(self, ship_count: int):
        self._write(StatKey.SHIP_CONT, ship_count)

    def capital(self, planet_id, planet_name, species):
        self._write(
            StatKey.CapitalID,
            {"capital_planet_id": planet_id, "capital_planet_name": planet_name, "capital_species": species},
        )

    def empire(self, id_, name, turn):
        return self._write(StatKey.EmpireID, {"empire_id": id_, "name": name, "turn": turn})

    def empire_color(self, r, g, b, a):
        return self._write(
            StatKey.EmpireColors,
            {
                "R": r,
                "G": g,
                "B": b,
                "A": a,
            },
        )

    def output(self, turn, rp, pp):
        self._write(StatKey.Output, {"turn": turn, "RP": rp, "PP": pp})

    def adopt_policy(self, name):
        self._write(StatKey.PolicyAdoption, name)

    def deadopt_policy(self, name):
        self._write(StatKey.PolicyDeAdoption, name)


stats = StatsWrapper()