From b4623304e1d0de93dc74187d1c28611ff6a18f7e Mon Sep 17 00:00:00 2001 From: ECG01 Date: Wed, 4 Dec 2024 15:29:49 -0400 Subject: [PATCH] ECG_Viking_project --- __pycache__/vikingsClasses.cpython-311.pyc | Bin 0 -> 5353 bytes vikingsClasses.py | 60 ++++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 __pycache__/vikingsClasses.cpython-311.pyc diff --git a/__pycache__/vikingsClasses.cpython-311.pyc b/__pycache__/vikingsClasses.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c3e33dfeb07e594384687311f37720302c8fc32b GIT binary patch literal 5353 zcmd5=|4$pq6`x&u?KRlgi48|cNSB0=GfjNQC2Fcma+HQ%8n}>C&?PFOa`(Io7>v!$ z8VIhrL)A&=o>0{vs6c8@@>LNRnpFJ<`bXFZ3Cq$+k*faC--yT$RetJwGrQ}x4Uu|n zrOw*VGxO%loA=)5?Hhj+2(%C==l=ZRw7Zp%zhT2Fl36*-L1mL@L=#eEf{5fc(ZtV* z=Gqnsc?w@%CIrTD14q(@Z5Qz1Yw|?K^8nA=#B(v83_M@Mif&C9C()LF;38uQb1n8G zn2kdPDw{+n6M{x2L{0ddOt?_G3Ag3~Drs(5L8^MkGbt^p(}XP&%tO(!eRz&7k{9wM z4mDo#BDAb+;PB&QM;MEWRnLsBrm{0t*~n5oJ)ND2x~gtNPfbxTOr$ap0~b{k<<-N) zyOSRoIyEMBZCRz0!Ez`FnwixT z*~?4Gxnz3UxU8oq&FZa`Y8bi^TUe>e@i>gl#^bq=d9aw(<3Rx;K-S3fjxz=KdTXUq zfuBGDo)kdo@8F#=gnmVse z>&yx}B9oP#gtZOaNiii3P(7h1m-JyaHrH+mUe_JOS=~Tt8tmxWm@5uH9xZpgg&Hlu z!;Ul-^`I@%>bxG0S6kxo`HZ%h!n!{m|71~3aSlb5P+XUyWp)Ug%#=vo*oy?=W()yY zv!4UeCG{K-o3w~h_W`kq?2_I_ZX@BVKB^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{Bp z6Md7w#r`7ZJtmPw=>j%QBFhql1Dizb8taRAr4a#hBb$ccglog>5KI8LD*q6LaU)?D z5KNP}fb~MZl5g;TFy5m-h9T%D#$SOPxCB9{kiZ&y4&;CU|2Z_17uff*#^^mMz%`|r p6du07-j_92zh8jVu9*~Wzrfy?HP*R)!FNEK$qVdzc?5&$;a|aH9;pBT literal 0 HcmV?d00001 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 +