-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplayer.py
More file actions
47 lines (43 loc) · 1.54 KB
/
Copy pathplayer.py
File metadata and controls
47 lines (43 loc) · 1.54 KB
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
import creature
import ability
class Player:
def __init__(self, mode, **kwargs):
if (mode == 'init'):
self.name = kwargs["name"]
deck = kwargs["deck"]
self.creatures = []
self.cards = []
self.creature_index = 0
self.finished = "false"
self.discard = 0
for index in range(0, 5):
self.cards.append(deck.get_card())
elif (mode == 'load'):
json = kwargs["json"]
self.name = json["name"]
self.finished = json["finished"]
self.discard = json["discard"]
self.creature_index = json["creature_index"]
self.cards = []
self.creatures = []
for card in json["cards"]:
self.cards.append(card)
for creature in json["creatures"]:
self.creatures.append(Creature(creature))
def add_creature(self, card):
creature = Creature(self.name, card, self.creature_index)
self.creatures.append(creature)
self.creature_index = self.creature_index + 1
def json(self):
json = {}
json["name"] = self.name
json["creatures"] = {}
json["finished"] = self.finished
json["creature_index"] = self.creature_index
for creature in self.creatures:
json["creatures"][creature.id] = creature.json()
json["cards"] = []
for card in self.cards:
json["cards"].append(card)
json["discard"] = self.discard
return json