-
Notifications
You must be signed in to change notification settings - Fork 0
/
varbank.py
58 lines (42 loc) · 1.42 KB
/
varbank.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
from functools import reduce
from typing import Self
from datastore.misc import TURN_STATE
from ditems.inventory import Inventory
teams = [[], []]
delayed = []
disabled = []
done = []
archive = [[], []]
stage = 1
class Team:
_instance = {}
stage = 1
def __init__(self, teamNumber: int):
if teamNumber not in Team._instance:
self.num = teamNumber
self.gold: int = 0
self.members: list = []
self.graveyard: list = []
self.inventory = Inventory()
@classmethod
def Entry(cls, teamNumber: int) -> Self:
if teamNumber not in Team._instance:
cls._instance[teamNumber] = Team(teamNumber)
return cls._instance[teamNumber]
def getTeamInventory(self, unit):
self.inventory.owner = unit
return self.inventory
def __len__(self):
return len(self.members)
def getSize(self):
return reduce(lambda a, x: a + x.size, self.members, 0)
def __iter__(self):
return iter(self.members)
def __contains__(self, item):
return item in self.members
def getDoneUnits(self):
return list(filter(lambda x: x.turnState == TURN_STATE.DONE, self.members))
def getWaitedUnits(self):
return list(filter(lambda x: x.turnState == TURN_STATE.WAIT, self.members))
def getRow(self, row_num: int):
return list(filter(lambda x: x.position == row_num, self.members))