Created
September 9, 2019 07:59
-
-
Save ayu-mushi/3602b13631ec6b0026f89d07e9f61dd8 to your computer and use it in GitHub Desktop.
issei_attack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Maou(){ | |
this.hp = 100; | |
this.name = "魔王"; | |
} | |
Maou.prototype.attack = function(aite) { | |
// 魔王の攻撃 | |
alert(aite + "に魔王が二重攻撃!!"); | |
}; | |
function Cribou(){ | |
this.hp = 1; | |
this.name = "クリボー"; | |
} | |
Cribou.prototype.attack = function (aite){ | |
// クリボーの攻撃 | |
alert(aite + "にクリボーが攻撃"); | |
}; | |
function DarkPrincess(){ | |
this.hp = 101; | |
this.name = "†闇落ちの姫 ――Dark Princess†"; | |
} | |
DarkPrincess.prototype.attack = function (aite) { | |
this.hp = this.hp / 2; | |
alert(aite + "に闇落ち姫が攻撃!"); | |
// 闇落ち姫の攻撃 | |
}; | |
var yuusya = "勇者"; | |
maou0 = new Maou(); | |
maou0.attack(yuusya); | |
var chars = [new Maou(), new Cribou(), new Cribou(), new Cribou(), new DarkPrincess()]; | |
chars.forEach(function(chara){ chara.attack(yuusya); }); | |
chars.forEach(function(chara){ alert(chara.name + "のHPは" + chara.hp + "です。"); }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment