-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.py
More file actions
39 lines (32 loc) · 898 Bytes
/
Copy pathconstants.py
File metadata and controls
39 lines (32 loc) · 898 Bytes
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
import enum
import logging
from typing import Final, Dict, Any
class GameState(enum.IntEnum):
IDLE = 0
LOADING = 1
RUNNING = 2
CRASHED = 666
class ConfigError(Exception):
pass
DEFAULT_SETTINGS: Final[Dict[str, Any]] = {
"max_players": 64,
"tick_rate": 60,
"dev_mode": False
}
def validate_game_config(config: Dict[str, Any]) -> bool:
try:
if not isinstance(config.get("tick_rate"), int) or config["tick_rate"] <= 0:
raise ConfigError("invalid tick rate detected")
return True
except (KeyError, TypeError, ConfigError) as e:
logging.error(f"config validation failed: {e}")
return False
class Sentinel:
def __repr__(self):
return "<NULL_STATE>"
NULL_VALUE = Sentinel()
MAX_RETRY_ATTEMPTS: Final[int] = 3
EXIT_CODES: Final[Dict[GameState, int]] = {
GameState.IDLE: 0,
GameState.CRASHED: 1
}