-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfight.js
36 lines (30 loc) · 828 Bytes
/
fight.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';
// Character Class definition
class Character {
constructor(name, health, attack, defense) {
this.name = name;
this.health = health;
this.attack = attack;
this.defense = defense;
}
}
Character.prototype.attackCharacter = function(defender) {
// Implement me!
}
// Main Fight Logic
var player = new Character('Edward Norton', 100, 25, 20);
var enemy = new Character('Tyler Durden', 100, 25, 20);
var round = 1;
while (player.health && enemy.health) {
runRound(round, player, enemy);
round++;
console.log('');
}
function runRound(round, p1, p2) {
// Implement me!
}
function endGame(winner, loser) {
console.log('\n======== GAME OVER ========');
console.log(winner.name + " wins against " + loser.name + " with " + winner.health + " health remaining!");
process.exit();
}