-
Notifications
You must be signed in to change notification settings - Fork 0
/
Charakter.py
154 lines (113 loc) · 4.49 KB
/
Charakter.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
class charakter(object):
def __init__(self, name, health, mana, gold, lvl,klasse, posx, posy, max_health, max_mana, all_exp,current_exp,strenght ):
self.name = name
self.pos_x = posx
self.pos_y = posy
self.current_health = health
self.max_health = max_health
self.current_mana = mana
self.max_mana = max_mana
self.gold = gold
self.start_attack_damage = 10
self.attack_speed = 1
self.exp = current_exp
self.all_exp = all_exp
self.strenght = strenght
self.lvl = lvl
self.health_per_lvl = 10
self.mana_per_lvl = 10
self.strenght_per_lvl = 1
self.exp_multi = 2
self.abilitie1_cost=25
self.abilitie2_cost=50
self.abilitie3_cost=75
self.abilitie4_cost=100
self.charakterclass = klasse
self.attack_range = 20
self.need_teleport = False
if self.charakterclass == "Krieger":
self.ability1 = "Schwertwurf"
self.ability2 = "Schwertwirbel"
self.ability3 = "Macht der Phalanx"
self.ability4 = "Wille des Blutes"
def move(self, delta_x, delta_y):
self.pos_x = self.pos_x + delta_x
self.pos_y = self.pos_y + delta_y
return(self.pos_x,self.pos_y)
def get_exp(self, exp_gain):
self.exp = self.exp + exp_gain
self.all_exp = self.exp + exp_gain
if self.exp >= self.lvl* self.exp_multi:
self.lvl_up()
def get_gold(self,gold_gain):
self.gold = self.gold+gold_gain
def lvl_up(self):
self.lvl = self.lvl + 1
self.exp = 0
#print("LVL UP")
self.strenght = self.strenght + self.strenght_per_lvl
self.max_mana = self.max_mana + self.mana_per_lvl
self.max_health = self.max_health + self.health_per_lvl
#heal
self.current_mana = self.max_mana
self.current_health = self.max_health
def heal(self,amount):
self.current_health = self.current_health + amount
def die(self):
self.exp = self.exp - int(0.05*self.exp)
self.current_health = self.max_health / 2
self.current_mana = self.max_mana / 2
self.need_teleport = True
#print("You died")
def revived(self):
self.need_teleport = False
def attack(self):
self.calculate_attack_damage()
return self.attack_damage
def calculate_attack_damage(self):
attack_multi = self.start_attack_damage * self.strenght
self.attack_damage = self.start_attack_damage + attack_multi
#life multiplier
life_multiplier = 1
if self.current_health < self.max_health * 0.25:
life_multiplier = 3.0
elif self.current_health < self.max_health*0.5:
life_multiplier = 2.0
elif self.current_health > self.max_health*0.5:
life_multiplier = 1.5
#print("Life multiplier Ist: "+str(life_multiplier))
self.attack_damage = self.attack_damage*life_multiplier
def damaged(self, damage):
self.current_health = self.current_health - damage
if self.current_health <= 0:
self.die()
#print("Ouch")
def pay(self,payed):
successfully_payed = False
if self.gold >= payed:
self.gold = self.gold - payed
successfully_payed = True
return(successfully_payed)
def teleport_player(self,posx,posy):
self.pos_x = posx
self.pos_y = posy
def use_abilitie_1(self):
if self.abilitie1_cost<= self.current_mana:
self.current_mana = self.current_mana - self.abilitie1_cost
if self.ability1 == "Schwertwurf":
print("werfe Schwert")
def use_abilitie_2(self):
if self.abilitie2_cost<= self.current_mana:
self.current_mana = self.current_mana - self.abilitie2_cost
if self.ability3 == "Schwertwirbel":
print("wirble Schwert")
def use_abilitie_3(self):
if self.abilitie3_cost<= self.current_mana:
self.current_mana = self.current_mana - self.abilitie3_cost
if self.ability3 == "Macht der Phalanx":
print("Phanlanxiere")
def use_abilitie_4(self):
if self.abilitie4_cost<= self.current_mana:
self.current_mana = self.current_mana - self.abilitie4_cost
if self.ability4 == "Wille des Blutes":
print("Blut")