Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

week1 project #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions vikingsClasses modified.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import random

# Soldier


class Soldier:
def __init__(self, health, strength):
self.health=health
self.strength=strength

def attack(self):
return self.strength

def receiveDamage(self, damage):
self.health-=damage


# Viking

class Viking(Soldier):
def __init__(self, name, health, strength):
super().__init__(health, strength)
self.name=name
def battleCry(self):
return "Odin Owns You All!"

def receiveDamage(self, damage):
self.health-=damage
if self.health>0:
return f'{self.name} has recieved {damage} points of damage'
else:
return f'{self.name} has died in act of combat'

# Saxon

class Saxon(Soldier):
def __init__(self, health, strength):
super().__init__(health, strength)
def receiveDamage(self, damage):
self.health-=damage
if self.health>0:
return f'A Saxon has recieved {damage} points of damage'
else:
return 'A Saxon has died in act of combat'

# Davicente

class War():
def __init__(self):
self.vikingArmy=[]
self.saxonArmy=[]
def addViking(self, viking):
self.vikingArmy.append(viking)
def addSaxon(self, saxon):
self.saxonArmy.append(saxon)

def vikingAttack(self):
randomsax=random.choice(self.saxonArmy)
randomvik=random.choice(self.vikingArmy)
dmg=randomvik.attack()
self.randomsax.recieveDamage(dmg)
if self.randomsax()<=0:
self.saxonArmy.remove(randomsax)
return f'{randomsax} has fallen'
return dmg

def saxonAttack(self):
randomsax=random.choice(self.saxonArmy)
randomvik=random.choice(self.vikingArmy)
dmg=randomsax.attack()
if self.randomvik()<=0:
self.vikingArmy.remove(randomvik)
return f'{randomvik} has fallen'
return dmg

def showStatus(self):
if len(self.saxonArmy)==0:
return 'Vikings have won the war of the century'
elif len(self.vikingArmy)==0:
return 'Saxons have fought for their lives and survive another day...'
else:
return 'Vikings and Saxons are still in the thick of battle'

pass


66 changes: 45 additions & 21 deletions vikingsClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,80 @@

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

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.health-=damage
if self.health>0:
return f'{self.name} has recieved {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.health-=damage
if self.health>0:
return f'A Saxon has recieved {damage} points of damage'
else:
return 'A Saxon has died in act of 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

randomsax=random.choice(self.saxonArmy)
randomvik=random.choice(self.vikingArmy)
dmg=randomvik.attack()
self.randomsax.recieveDamage(dmg)
if self.randomsax()<=0:
self.saxonArmy.remove(randomsax)
return f'{randomsax} has fallen'
return dmg

def saxonAttack(self):
# your code here
randomsax=random.choice(self.saxonArmy)
randomvik=random.choice(self.vikingArmy)
dmg=randomsax.attack()
if self.randomvik()<=0:
self.vikingArmy.remove(randomvik)
return f'{randomvik} has fallen'
return dmg

def showStatus(self):
# your code here
pass

if len(self.saxonArmy)==0:
return 'Vikings have won the war of the century'
elif len(self.vikingArmy)==0:
return 'Saxons have fought for their lives and survive another day...'
else:
return 'Vikings and Saxons are still in the thick of battle'

pass