From 3ba138234b0d6f7d5c2101f128e22ab43ce4c27a Mon Sep 17 00:00:00 2001 From: Artem Zhuravkov Date: Mon, 9 Dec 2019 19:29:34 +0200 Subject: [PATCH 1/3] add monster --- models/kingkong.js | 9 +++++++++ models/scalapender.js | 9 +++++++++ models/snake.js | 9 +++++++++ models/spider.js | 9 +++++++++ models/wolf.js | 9 +++++++++ 5 files changed, 45 insertions(+) create mode 100644 models/kingkong.js create mode 100644 models/scalapender.js create mode 100644 models/snake.js create mode 100644 models/spider.js create mode 100644 models/wolf.js diff --git a/models/kingkong.js b/models/kingkong.js new file mode 100644 index 0000000..df5f9b4 --- /dev/null +++ b/models/kingkong.js @@ -0,0 +1,9 @@ +var KingKong = (function() { + function KingKong(level) { + Unit.call(this, 500, 1500, level); + } + KingKong.prototype = Object.create(Unit.prototype); + KingKong.prototype.constructor = KingKong; + + return KingKong; +}()); \ No newline at end of file diff --git a/models/scalapender.js b/models/scalapender.js new file mode 100644 index 0000000..1d5a280 --- /dev/null +++ b/models/scalapender.js @@ -0,0 +1,9 @@ +var Scalapender = (function() { + function Scalapender(level) { + Unit.call(this, 150, 1000, level); + } + Scalapender.prototype = Object.create(Unit.prototype); + Scalapender.prototype.constructor = Scalapender; + + return Scalapender; +}()); \ No newline at end of file diff --git a/models/snake.js b/models/snake.js new file mode 100644 index 0000000..828a2c0 --- /dev/null +++ b/models/snake.js @@ -0,0 +1,9 @@ +var Snake = (function() { + function Snake(level) { + Unit.call(this, 150, 1000, level); + } + Snake.prototype = Object.create(Unit.prototype); + Snake.prototype.constructor = Snake; + + return Snake; +}()); \ No newline at end of file diff --git a/models/spider.js b/models/spider.js new file mode 100644 index 0000000..0892ddf --- /dev/null +++ b/models/spider.js @@ -0,0 +1,9 @@ +var Spider = (function() { + function Spider(level) { + Unit.call(this, 150, 1000, level); + } + Spider.prototype = Object.create(Unit.prototype); + Spider.prototype.constructor = Spider; + + return Spider; +}()); \ No newline at end of file diff --git a/models/wolf.js b/models/wolf.js new file mode 100644 index 0000000..0f770f4 --- /dev/null +++ b/models/wolf.js @@ -0,0 +1,9 @@ +var Wolf = (function() { + function Wolf(level) { + Unit.call(this, 150, 1000, level); + } + Wolf.prototype = Object.create(Unit.prototype); + Wolf.prototype.constructor = Wolf; + + return Wolf; +}()); \ No newline at end of file From 46f6f629802aa841c6fbbaad4b25d57c65eea8bb Mon Sep 17 00:00:00 2001 From: Artem Zhuravkov Date: Mon, 9 Dec 2019 20:37:16 +0200 Subject: [PATCH 2/3] add step --- models/croco-turtle.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/croco-turtle.js b/models/croco-turtle.js index c0e7f6c..17f0230 100644 --- a/models/croco-turtle.js +++ b/models/croco-turtle.js @@ -5,6 +5,9 @@ var CrocoTurtle = (function () { CrocoTurtle.prototype = Object.create(Unit.prototype); CrocoTurtle.prototype.constructor = CrocoTurtle; + CrocoTurtle.prototype.step = function (){ + console.log('Step'); + }; return CrocoTurtle; }()); From 92f8607dbcb9cddcb16bac88629bd92aefeaafa2 Mon Sep 17 00:00:00 2001 From: Artem Zhuravkov Date: Wed, 11 Dec 2019 20:45:00 +0200 Subject: [PATCH 3/3] add attak method --- index.html | 1 + models/croco-turtle.js | 3 +++ models/unit.js | 6 +++--- script.js | 12 ++++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 660d6b5..091e869 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,7 @@ + diff --git a/models/croco-turtle.js b/models/croco-turtle.js index 17f0230..86d71c5 100644 --- a/models/croco-turtle.js +++ b/models/croco-turtle.js @@ -9,5 +9,8 @@ var CrocoTurtle = (function () { console.log('Step'); }; + CrocoTurtle.prototype.attak = function(monster){ + this.health -= monster.damage; + } return CrocoTurtle; }()); diff --git a/models/unit.js b/models/unit.js index e72f1b7..1b88ad9 100644 --- a/models/unit.js +++ b/models/unit.js @@ -6,9 +6,9 @@ var Unit = (function () { this.level = level; } - Unit.prototype.attack = function () { - console.log('Attack', this); - } + // Unit.prototype.attack = function () { + // console.log('Attack', this); + // } return Unit; }()); diff --git a/script.js b/script.js index 1e3cba9..d88f96c 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,9 @@ -var croco = new CrocoTurtle(50); -var bear = new MonsterBear(2); +var croco = new CrocoTurtle(1); +var bear = new MonsterBear(1); +var snac = new Snake(1); + +croco.attak(bear); +croco.attak(snac); + +console.log(croco); -croco.attack(); -bear.attack();