-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokemonFunction.js
91 lines (74 loc) · 2.36 KB
/
pokemonFunction.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function randLetter()
{
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
alphabet = alphabet.toLowerCase();
var index = Math.floor(Math.random() * 26);
return alphabet.substring(index, index+1);
}
console.log("Random Letter: "+ randLetter());
function randWord(){
var word = "";
var randLength = Math.floor(Math.random()*10);
for(i = 0; i < randLength; i++)
{
word+=randLetter();
}
return word;
}
console.log("random word : "+randWord());
function randSentence()
{
var sentence = "";
var num = Math.floor(Math.random()*10);
for(i = 0; i < num; i++)
{
sentence+=randWord() + " ";
}
sentence = sentence.substring(0,1).toUpperCase()
+ sentence.substring(1);
return sentence + ".";
}
console.log("random sentence: " + randSentence());
//The pokemon battle
console.log("______________________________________THE POKEMON BATTLE________________________________");
/*
var arrOfPokemon = [["Pikachu", 23, 1000], ["William", 77, 1000], ["CoolNick", 10, 1000], ["FaisalMan", 15, 1000], ["EdgarTheKid", 2, 1000],
["RodgerDodger", 666, 1000], ["KevinFromStuy", 1, 1000], ["KevinTheTeacher", 3, 1000], ["chrisTheSmurf", 0.3, 1000], ["IYAYIII", 90, 1000], ["KatieKate", 1000, 1000],
["Mr Mo", 17, 1000], ["Harraway", 8, 1000], ["Mohinur", 5, 1000],
["adenSellsFakeSupreme", 6, 1000], ["My Brother's name is Aaron", 99, 1000],
["Taseen Init", 33, 1000], ["Tahmidur u done know eh", 1.1, 1000],
["feel Da Bern - ado", 999.9, 1000]]; */
var fstPokemon = ["Pikachu", 23, 100];
var scndPokemon = ["William", 17, 150];
function coinFlip()
{
var arr = [fstPokemon, scndPokemon];
var starter = arr[Math.floor(Math.random()*2)];
return starter;
}
function pokeAttack()
{
var starter = coinFlip();
var follow = null;
if(starter == fstPokemon)
{
follow = scndPokemon;
}
else{
follow = fstPokemon;
}
console.log(starter[0] + " Will attack first");
while(starter[2] <= 0 || follow[2] <= 0 )
{
follow[2]-=starter[1];
starter[2]-=follow[1];
}
if(starter[2] > follow[2])
{
console.log(starter[0] + " DESTROYS " + follow[0]);
}
else{
console.log(follow[0] +" DESTROYS " + starter[0]);
}
}
pokeAttack();