diff --git a/__pycache__/vikingsClasses.cpython-311.pyc b/__pycache__/vikingsClasses.cpython-311.pyc new file mode 100644 index 0000000..c3e33df Binary files /dev/null and b/__pycache__/vikingsClasses.cpython-311.pyc differ diff --git a/vikingsClasses.py b/vikingsClasses.py index 25322cd..b9567de 100644 --- a/vikingsClasses.py +++ b/vikingsClasses.py @@ -2,16 +2,20 @@ # 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.damage = damage + self.health = self.health - self.damage # Viking @@ -19,42 +23,82 @@ def receiveDamage(self, damage): class Viking(Soldier): def __init__(self, name, health, strength): # your code here + super().__init__(health,strength) + self.name = name + def battleCry(self): # your code here - + return "Odin Owns You All!" + def receiveDamage(self, damage): # your code here - + self.damage = damage + self.health -= damage + if self.health > 0: + return f"{self.name} has received {self.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 + super().__init__(health, strength) def receiveDamage(self, damage): # your code here + self.damage = damage + self.health-=damage + if self.health > 0: + return f"A Saxon has received {self.damage} points of damage" + else: + return f"A Saxon has died in combat" # Davicente + class War(): def __init__(self): # your code here + self.vikingArmy = [] + self.saxonArmy = [] 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 + if self.vikingArmy and self.saxonArmy: + viking = random.choice(self.vikingArmy) + saxon = random.choice(self.saxonArmy) + live = saxon.receiveDamage(viking.attack()) + if saxon.health <= 0: + self.saxonArmy.remove(saxon) + return live def saxonAttack(self): # your code here + if self.vikingArmy and self.saxonArmy: + viking = random.choice(self.vikingArmy) + saxon = random.choice(self.saxonArmy) + live = viking.receiveDamage(saxon.attack()) + if viking.health <= 0: + self.vikingArmy.remove(viking) + return live def showStatus(self): # your code here - pass - - + if not self.saxonArmy: + return "Vikings have won the war of the century!" + elif not self.vikingArmy: + return "Saxons have fought for their lives and survive another day..." + else: + return "Vikings and Saxons are still in the thick of battle." + pass +