File: _definitions.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 (60 lines) | stat: -rw-r--r-- 1,669 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
48
49
50
51
52
53
54
55
56
57
58
59
60
# a list of trusted classes - other classes will not be loaded
import AIFleetMission
import AIstate
import character.character_module
import ColonisationAI
import CombatRatingsAI
import fleet_orders

trusted_classes = {
    f"{cls.__module__}.{cls.__name__}": cls
    for cls in [
        AIFleetMission.AIFleetMission,
        fleet_orders.AIFleetOrder,
        fleet_orders.OrderMilitary,
        fleet_orders.OrderDefend,
        fleet_orders.OrderColonize,
        fleet_orders.OrderOutpost,
        fleet_orders.OrderPause,
        fleet_orders.OrderInvade,
        fleet_orders.OrderMove,
        fleet_orders.OrderRepair,
        fleet_orders.OrderResupply,
        character.character_module.Trait,
        character.character_module.Aggression,
        character.character_module.EmpireIDTrait,
        character.character_module.Character,
        AIstate.AIstate,
        ColonisationAI.OrbitalColonizationManager,
        ColonisationAI.OrbitalColonizationPlan,
        CombatRatingsAI.ShipCombatStats,
    ]
}

# prefixes to encode types not supported by json
# or not fully supported as dictionary key
ENUM_PREFIX = "__ENUM__"
INT_PREFIX = "__INT__"
FLOAT_PREFIX = "__FLOAT__"
TRUE = "__TRUE__"
FALSE = "__FALSE__"
NONE = "__NONE__"
SET_PREFIX = "__SET__"
TUPLE_PREFIX = "__TUPLE__"


# placeholder char to represent quotes in nested containers
# which would break json decoding if present.
PLACEHOLDER = "$"


class CanNotSaveGameException(Exception):
    """Exception raised when constructing the savegame string failed."""

    pass


class InvalidSaveGameException(Exception):
    """Exception raised if the savegame could not be loaded."""

    pass