-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokemon-objects.js
More file actions
62 lines (45 loc) · 1.4 KB
/
pokemon-objects.js
File metadata and controls
62 lines (45 loc) · 1.4 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var prompt = require('prompt-sync')();
function pokemon(name, attack, hp, damage, isLegend, types){
this.name = name;
this.attack = attack;
this.hp = hp;
this.damage = damage;
this.isLegend = isLegend;
this.types = types;
}
var arrOfPoks = [];
arrOfPoks.push(new pokemon("William", "lightning", 100, 15,true, "human"));
arrOfPoks.push(new pokemon("Nick", "PooP", 100, 10, false, "poop"));
function printObjInfo(obj)
{
console.log("Pokemon info: ");
for(var key in obj)
{
console.log(key + ": " + obj[key]+" ");
}
}
function pokAttacked(attacked, attacker){
attacked.hp-=attacker.damage;
console.log(attacker.name + " attacked " + attacked.name);
printObjInfo(attacked);
}
function createPokemon()
{
console.log("--------------------------------------------------------CREATE YOUR OWN POKEMON---------------------------------------------------");
console.log();
var crPok = new pokemon(prompt("Pokemon Name? "), prompt("Pokemon attack? "), prompt("Pokemon HP? "), prompt("Pokemon damage? "),prompt("Pokemon is Legend? "),
prompt("Pokemon Type? "));
return crPok;
}
for(i = 0; i < arrOfPoks.length; i++)
{
printObjInfo(arrOfPoks[i]);
}
console.log();
pokAttacked(arrOfPoks[1], arrOfPoks[0]);
console.log();
console.log();
var mPok = createPokemon();
console.log();
printObjInfo(mPok);
console.log();