From 98d64b286c08096897eda67ab7b70d95e068651d Mon Sep 17 00:00:00 2001 From: Anna Sch Date: Fri, 12 Oct 2018 15:29:45 +0200 Subject: [PATCH] almost --- starter-code/src/viking.js | 77 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/starter-code/src/viking.js b/starter-code/src/viking.js index 0a93051b5..99fb42653 100755 --- a/starter-code/src/viking.js +++ b/starter-code/src/viking.js @@ -1,11 +1,80 @@ // Soldier -class Soldier {} +class Soldier { + constructor(health, strength) { + this.health = health; + this.strength= strength; + }; + + attack(){ + return this.strength; + }; + receiveDamage(damage){ + this.health=this.health - damage; + }; +}; // Viking -class Viking {} +class Viking extends Soldier{ + constructor(name,health,strength){ + super(); + this.name=name; + this.health=health; + this.strength=strength; + } + attack(){ + return this.strength; + } + receiveDamage(damage){ + this.health = this.health - damage; + if (this.health > 0){ + return this.name + " has received " + damage + " points of damage"; + } + return this.name + " has died in act of combat"; + } + battleCry(){ + return "Odin Owns You All!"; + } +}; // Saxon -class Saxon {} +class Saxon extends Soldier{ + constructor(health,strength){ + super(); + this.health=health; + this.strength=strength; + } + attack(){ + return this.strength; + } + receiveDamage(damage){ + this.health = this.health - damage; + if (this.health > 0){ + return "A Saxon has received " + damage + " points of damage"; + } + return "A Saxon has died in combat" + } +} // War -class War {} \ No newline at end of file +class War { + constructor(){ + this.vikingArmy = []; + this.saxonArmy = []; + } + addViking(Viking){ + this.vikingArmy.push(Viking); + } + addSaxon(Saxon){ + this.saxonArmy.push(Saxon); + } + vikingAttack(){ + + } + saxonAttack(){ + + } + showStatus(){ + + } + +} \ No newline at end of file