-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcivilization.py
56 lines (43 loc) · 1.64 KB
/
civilization.py
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
from __future__ import annotations
from typing import Self, List
from openciv.gameplay.effect import Effects, Effect
from openciv.gameplay.leader import Leader
from openciv.engine.managers.i18n import T_TranslationOrStr
from abc import abstractmethod
class Civilization:
def __init__(self, name: T_TranslationOrStr, description: T_TranslationOrStr) -> None:
self.name: T_TranslationOrStr = name
self.icon: str | None = None
self._loadable = False
self.description: T_TranslationOrStr = description
self._leaders: List[Leader] = []
self._effects: Effects = Effects()
# Init registers
self.register_effects()
self.register_leaders()
def effects(self) -> Effects:
return self._effects
def add_effect(self, effect: Effect) -> None:
self._effects.add(effect=effect, key_or_auto=str(effect.name))
def add_leader(self, leader: Leader) -> None:
self.leaders.append(leader)
@property
def leaders(self) -> List[Leader]:
return self._leaders
@leaders.setter
def leaders(self, leaders: List[Leader]) -> None:
self._leaders = leaders
@abstractmethod
def register_effects(self) -> None:
pass
@abstractmethod
def register_leaders(Self) -> None:
pass
def __str__(self) -> str:
leader_name_list: List[str] = []
for leader in self.leaders:
leader_name_list.append(str(leader.name) if leader.name else "Unknown")
leaders: str = ", ".join(leader_name_list)
return f"{self.name} - {self.description} <{leaders}>"
def __call__(self) -> Self:
return self