From e10cfc48cc9d8e91d27e59c3601816a8cdb8de7c Mon Sep 17 00:00:00 2001 From: sgalutira Date: Thu, 26 May 2016 19:04:06 -1000 Subject: [PATCH 1/3] Completed Spell --- constructors.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/constructors.js b/constructors.js index d0bf11a..aa74246 100644 --- a/constructors.js +++ b/constructors.js @@ -10,6 +10,12 @@ * @property {string} description * @method printDetails */ + function Spell (name, cost, description) { + this.name = name; + this.cost = cost; + this.description = description; + } + /** * Returns a string of all of the spell's details. @@ -18,6 +24,12 @@ * @name getDetails * @return {string} details containing all of the spells information. */ + Spell.prototype.getDetails = function(){ + var string = this.name + ' ' + this.cost + ' ' + this.description; + return string; + }; + + /** * A spell that deals damage. From 6387b3f0b7e3159b3f6f08aa98f4c0dfdd31bace Mon Sep 17 00:00:00 2001 From: sgalutira Date: Thu, 26 May 2016 19:46:29 -1000 Subject: [PATCH 2/3] DamageSpell --- constructors.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/constructors.js b/constructors.js index aa74246..ce80169 100644 --- a/constructors.js +++ b/constructors.js @@ -16,7 +16,6 @@ this.description = description; } - /** * Returns a string of all of the spell's details. * The format doesn't matter, as long as it contains the spell name, cost, and description. @@ -29,8 +28,6 @@ return string; }; - - /** * A spell that deals damage. * We want to keep this code DRY (Don't Repeat Yourself). @@ -55,6 +52,14 @@ * @property {number} damage * @property {string} description */ + function DamageSpell (name, cost, damage, description){ + Spell.call(this, name, cost, description); + this.damage = damage; + return this.damage; + + } + DamageSpell.prototype = Object.create(Spell.prototype); + /** * Now that you've created some spells, let's create From d181349bffcddff17090d2196df8c2301fb4c35c Mon Sep 17 00:00:00 2001 From: sgalutira Date: Sat, 28 May 2016 15:51:49 -1000 Subject: [PATCH 3/3] stuck on invoke --- constructors.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/constructors.js b/constructors.js index ce80169..03cdba1 100644 --- a/constructors.js +++ b/constructors.js @@ -77,6 +77,12 @@ * @method spendMana * @method invoke */ +function Spellcaster(name, health, mana){ + this.name = name; + this.health = health; + this.mana = mana; + this.isAlive = true; +} /** * @method inflictDamage @@ -88,6 +94,13 @@ * * @param {number} damage Amount of damage to deal to the spellcaster */ + Spellcaster.prototype.inflictDamage = function (damage){ + this.health = this.health - damage; + if (this.health === 0 || this.health < 0){ + this.health = 0; + this.isAlive = false; + } + }; /** * @method spendMana @@ -98,6 +111,14 @@ * @param {number} cost The amount of mana to spend. * @return {boolean} success Whether mana was successfully spent. */ + Spellcaster.prototype.spendMana = function (cost){ + if (this.mana > cost){ + this.mana = this.mana - cost; + return true; + }else if (this.mana < cost){ + return false; + } + }; /** * @method invoke @@ -125,3 +146,11 @@ * @param {Spellcaster} target The spell target to be inflicted. * @return {boolean} Whether the spell was successfully cast. */ + Spellcaster.prototype.invoke = function (spell, target){ + if (!(spell instanceof Spell)){ + return true; + }else{ + return false; + }if(spell instanceof DamageSpell === true){ + } + };