forked from ironhack-labs/mini-project-vikings-en
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vikingsClasses.py
114 lines (86 loc) · 2.98 KB
/
vikingsClasses.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
import random
# Soldier
class Soldier:
def __init__(self, health, strength):
# your code here
self.health = health
self.strength = strength
def attack(self):
# your code here
return self.strength
def receiveDamage(self, damage):
# your code here
self.health -= damage
# Viking
class Viking(Soldier):
def __init__(self, name, health, strength):
# your code here
self.name = name
self.health = health
self.strength = strength
def battleCry(self):
# your code here
return "Odin Owns You All!"
def receiveDamage(self, damage):
# your code here
self.health -= damage
if (self.health > 0):
return f"{self.name} has received {damage} points of damage"
else:
return f"{self.name} has died in act of combat"
# Saxon
class Saxon(Soldier):
def __init__(self, health, strength):
# your code here
self.health = health
self.strength = strength
def receiveDamage(self, damage):
# your code here
self.health -= damage
if (self.health > 0):
return f"A Saxon has received {damage} points of damage"
else:
return f"A Saxon has died in combat"
# Davicente
'''
vikingAttack
should make a Saxon receiveDamage() equal to the strength of a Viking
should remove dead saxons from the army
should return result of calling receiveDamage() of a Saxon with the strength of a Viking
saxonAttck
should make a Viking receiveDamage() equal to the strength of a Saxon
should remove dead vikings from the army
should return result of calling receiveDamage() of a Viking with the strength of a Saxon
'''
class War():
def __init__(self):
# your code here
self.saxonArmy = []
self.vikingArmy = []
def addViking(self, viking):
# your code here
self.vikingArmy.append(viking)
def addSaxon(self, saxon):
# your code here
self.saxonArmy.append(saxon)
def vikingAttack(self):
# your code here
message = self.saxonArmy[0].receiveDamage(self.vikingArmy[0].strength)
if(message == f"A Saxon has died in combat"):
self.saxonArmy.pop(0)
return message
def saxonAttack(self):
# your code here
message = self.vikingArmy[0].receiveDamage(self.saxonArmy[0].strength)
if(message == f"{self.vikingArmy[0].name} has died in act of combat"):
self.vikingArmy.pop(0)
return message
def showStatus(self):
# your code here
if(bool(self.saxonArmy) and (self.vikingArmy)):
return "Vikings and Saxons are still in the thick of battle."
elif(bool(self.saxonArmy)):
return "Saxons have fought for their lives and survive another day..."
else:
return "Vikings have won the war of the century!"
pass