Skip to content

Instantly share code, notes, and snippets.

@ayu-mushi
Created September 9, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayu-mushi/3602b13631ec6b0026f89d07e9f61dd8 to your computer and use it in GitHub Desktop.
Save ayu-mushi/3602b13631ec6b0026f89d07e9f61dd8 to your computer and use it in GitHub Desktop.
issei_attack
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