-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
86 lines (67 loc) · 1.81 KB
/
player.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import copy
import random
class Player:
def __init__(self,name,deck):
self.game = None
self.name = name
self.maxHealth = 30
self.health = 30
self.deck = deck
self.deck.owner=self
self.hand = []
self.activeMinions = []
self.maxMana = 1
self.currentMana = 1
self.AI=False
self.IP='127.0.0.1'
self.connection = ''
self.printing = True
def setGame(self,game):
self.game = game
def setIpAndPort(ip,port):
self.IP = ip
self.PORT = port
def updateActiveHealth(self,minionPosition,newHealth):
self.activeMinions[int(minionPosition)].setHealth(newHealth)
def heal(self,amount):
self.health += amount
if self.health > self.maxHealth:
self.health = self.maxHealth
def getHand(self):
return self.hand
def getHealth(self):
return self.health
def damageMinionOrHero(self,amount):
# If nettverk: få target fra nett
if not self.AI: #A bit counter intuitive as of now. not self.AI actually means self = AI...
if len(self.activeMinions)<=0:
index ="f"
else:
index = random.randint(0,len(self.activeMinions)-1)
else:
index = input("Hvilken minion vil du skade? ('f' for face): ")
if index=="f":
self.health = self.health - amount
print("Something did",amount,"damage to face")
else:
self.activeMinions[int(index)].damage(amount)
if self.game.printing:
print("Something did",amount,"damage to minion #",index)
def changeDeck(self,newDeck):
self.deck = newDeck
def reduceHealth(self,damage):
if self.game.printing:
print(self.name,"received",damage,"damage")
self.health = self.health - damage
def getActiveMinions(self):
return self.activeMinions
def doAction(self):
pass
def attack(self,minion,target):
pass
def getDeck(self):
return self.deck
def __str__(self):
return self.name
def getName(self):
return self.name