File: planet_supply.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 (20 lines) | stat: -rw-r--r-- 542 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
_planet_supply_map: dict[int, int] = {}


def get_planet_supply(pid: int, default: int) -> int:
    """
    Return planet supply.

    Note:
    This method has temporal coupling with the `update_planet_supply`.
    Supply map is persistent during session, so if you try to access it
    before planet was updated you will get old/default value.
    """
    return _planet_supply_map.get(pid, default)


def update_planet_supply(pid: int, value: int) -> None:
    """
    Update the planet supply.
    """
    _planet_supply_map[pid] = value