File: colony_status.py

package info (click to toggle)
freeorion 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 194,940 kB
  • sloc: cpp: 186,508; python: 40,969; ansic: 1,164; xml: 719; makefile: 32; sh: 7
file content (31 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (2)
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
from empire.survey_lock import survey_universe_lock
from freeorion_tools.caching import cache_for_current_turn


class _ColonyStatus:
    def __init__(self):
        self.colonies_under_attack = False
        self.colonies_under_threat = False


@survey_universe_lock
def colonies_is_under_attack() -> bool:
    return bool(_get_colony_status().colonies_under_attack)


@survey_universe_lock
def colonies_is_under_treat() -> bool:
    return bool(_get_colony_status().colonies_under_threat)


@cache_for_current_turn
def _get_colony_status() -> _ColonyStatus:
    return _ColonyStatus()


def set_colonies_is_under_treat():
    _get_colony_status().colonies_under_threat = True


def set_colonies_is_under_attack():
    _get_colony_status().colonies_under_attack = True