├── older_stuff_from_another_realm
├── README.md
├── item.js
├── catchrate.js
├── statusFunctions.js
├── battleFunctions.js
├── experience.js
├── evolutions.js
├── damage.js
├── sense.js
└── 1_battle.js
├── README.md
├── index.html
├── evolutions.js
├── typeModifiers.js
├── style.css
├── Document.html
└── main.js
/older_stuff_from_another_realm/README.md:
--------------------------------------------------------------------------------
1 | source https://github.com/shri/pokemon/tree/44c29b357bc870b5b8bb6f433c220ecacf82a33a/client/helperFunctions
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Poke
2 | There is a fork of this game that is receiving updates here https://github.com/RichardPaulAstley/richardpaulastley.github.io
3 |
4 | The original version can be played at www.worms.io/poke
5 |
6 | ### Changelog:
7 | #### 0.0.2
8 | - Controls visible when scrolling Pokemon list
9 |
10 | #### 0.0.1
11 | - Added pokeballs
12 | - Better console performance
13 | - High-level pokes aspd nerf
14 | - Stats rebalanced
15 | - Heal is now working as it should
16 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/item.js:
--------------------------------------------------------------------------------
1 | function effect(pokemon, name) {
2 | switch (name) {
3 | case 'potion': updateRemainingHP(pokemon, 20); break;
4 | case 'super potion': updateRemainingHP(pokemon, 50); break;
5 | case 'antidote': healStatus(pokemon, 'psn'); break;
6 | case 'burn heal': healStatus(pokemon, 'brn'); break;
7 | case 'awaken': healStatus(pokemon, 'slp'); break;
8 | case 'paralyz heal': healStatus(pokemon, 'par'); break;
9 | case 'ice heal': healStatus(pokemon, 'frz'); break;
10 | case 'revive': revive(pokemon, false); break;
11 | case 'max revive': revive(pokemon, true); break;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/catchrate.js:
--------------------------------------------------------------------------------
1 | //catch rate formula from http://www.dragonflycave.com/rbycapture.aspx
2 | //does not account for wobbles - only returns true or false
3 | //limited to generation 1 only - newer games use different formula
4 |
5 | function checkCatch(balltype, target) {
6 | if (balltype == 'masterball') {
7 | return true;
8 | }
9 | var R1;
10 | switch(balltype) {
11 | case 'pokeball':
12 | R1 = 255*Math.random(); break;
13 | case 'greatball':
14 | R1 = 200*Math.random(); break;
15 | default:
16 | R1 = 150*Math.random(); break;
17 | }
18 |
19 | var S;
20 | switch(target.status) {
21 | case 'slp':
22 | S = 25; break;
23 | case 'frz':
24 | S = 25; break;
25 | case 'par':
26 | S = 12; break;
27 | case 'brn':
28 | S = 12; break;
29 | case 'psn':
30 | S = 12; break;
31 | default:
32 | S = 0; break;
33 | }
34 |
35 | var R3 = R1 - S;
36 |
37 | if (R3 < 0) {
38 | return true;
39 | }
40 |
41 | if (target.catchrate < R3) {
42 | return false;
43 | }
44 |
45 | var F = target.HP * 255;
46 | if (balltype == 'greatball') {
47 | F /= 8;
48 | }
49 | else {
50 | F /= 12;
51 | }
52 |
53 | if (target.remainingHP / 4 > 0) {
54 | F /= (target.remainingHP);
55 | }
56 |
57 | F = Math.min(255, F);
58 |
59 | var R2 = 255 * Math.random();
60 | if (R2 < F) {
61 | return true;
62 | }
63 |
64 | return false;
65 | }
66 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/statusFunctions.js:
--------------------------------------------------------------------------------
1 | //changes the status of a pokemon during battle and applies the appropriate stat changes
2 | updateStatus = function (pokemon, status) {
3 | if (status != 'psn' && status != 'par' && status != 'slp' && status != 'frz' && status != 'brn' && status != 'non' && status != 'fnt') {
4 | throw new Meteor.Error("passed invalid status string: " + status + ". status must be par, slp, frz, brn, fnt, or non");
5 | }
6 | if (pokemon.status == 'non') {
7 | pokemon.status = status;
8 | }
9 | else if (status = 'fnt') {
10 | pokemon.status = 'fnt';
11 | }
12 | else if (status = 'non') {
13 | if (pokemon.status != 'fnt') {
14 | pokemon.status = 'non';
15 | }
16 | }
17 | //apply stat changes for paralysis and burn
18 | if (pokemon.status == 'par') {
19 | updateBattleStat(pokemon, -6, 'speed');
20 | }
21 |
22 | if (pokemon.status == 'brn') {
23 | updateBattleStat(pokemon, Math.min(pokemon.attackstage - 2, -6), 'attack')
24 | }
25 |
26 | if (pokemon.status == 'non') {
27 | updateBattleStat(pokemon, 0, 'speed');
28 | updateBattleStat(pokemon, 0, 'attack');
29 | }
30 |
31 | return pokemon.status;
32 | }
33 |
34 | //heals a specific status condition, returns true if successful
35 | //called by certain items
36 | function healStatus(pokemon, status) {
37 | if(status == 'psn') {
38 | if (pokemon.status == 'psn') {
39 | updateStatus(pokemon, 'non');
40 | return true;
41 | }
42 | return false;
43 | }
44 |
45 | else if(status == 'brn') {
46 | if (pokemon.status == 'brn') {
47 | updateStatus(pokemon, 'non');
48 | return true;
49 | }
50 | return false;
51 | }
52 |
53 | else if(status == 'slp') {
54 | if (pokemon.status == 'slp') {
55 | updateStatus(pokemon, 'non');
56 | return true;
57 | }
58 | return false;
59 | }
60 |
61 | else if(status == 'par') {
62 | if (pokemon.status == 'par') {
63 | updateStatus(pokemon, 'non');
64 | return true;
65 | }
66 | return false;
67 | }
68 |
69 | else if(status == 'frz') {
70 | if (pokemon.status == 'frz') {
71 | updateStatus(pokemon, 'non');
72 | return true;
73 | }
74 | return false;
75 | }
76 |
77 | else {
78 | throw new Meteor.Error("you tried to heal the status " + status + ", which is not valid");
79 | }
80 | }
81 |
82 | //heals the pokemon by a specific point value
83 | updateRemainingHP = function (pokemon, points) {
84 | pokemon.remainingHP = Math.min(pokemon.HP, pokemon.remainingHP + points);
85 | }
86 |
87 | //method for reviving pokemon, which can only be done via revive or max revive
88 | function revive(pokemon, max) {
89 | //block using non-revive items and attempting to revive pokemon that haven't fainted
90 | if (pokemon.statue != 'fnt') {
91 | throw new Meteor.Error("the pokemon " + pokemon + " has not fainted. you can only use revive or max revive on a fainted pokemon.");
92 | }
93 | //revive the pokemon
94 | pokemon.status = 'non';
95 | if (!max) {
96 | pokemon.remainingHP = Math.floor(pokemon.HP/2);
97 | }
98 | else {
99 | pokemon.remainingHP = pokemon.HP;
100 | }
101 | return pokemon;
102 | }
103 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/battleFunctions.js:
--------------------------------------------------------------------------------
1 | //applies changes to stats during battle
2 | updateBattleStat = function (pokemon, stage, stat) {
3 | var modifier;
4 | switch(stage) {
5 | case -6: modifier = 1.0/4; break;
6 | case -5: modifier = 2.0/7; break;
7 | case -4: modifier = 1.0/3; break;
8 | case -3: modifier = 2.0/5; break;
9 | case -2: modifier = 1.0/2; break;
10 | case -1: modifier = 1.0/3; break;
11 | case 0: modifier = 1.0; break;
12 | case 1: modifier = 1.5; break;
13 | case 2: modifier = 2.0; break;
14 | case 3: modifier = 2.5; break;
15 | case 4: modifier = 3.0; break;
16 | case 5: modifier = 3.5; break;
17 | case 6: modifier = 4.0; break;
18 | default: modifier = 1.0; break;
19 | }
20 | switch(stat) {
21 | case "attack": pokemon.battleattack = pokemon.attack * modifier; break;
22 | case "defense": pokemon.battledefense = pokemon.defense * modifier; break;
23 | case "spattack": pokemon.battlespattack = pokemon.spattack * modifier; break;
24 | case "spdefense": pokemon.battlespdefense = pokemon.spdefense * modifier; break;
25 | case "speed": pokemon.battlespeed = pokemon.speed * modifier; break;
26 | default: break;
27 | }
28 | return pokemon;
29 | }
30 |
31 | //reverts stat changes, for use upon switching or ending the battle
32 | normalizeStats = function (pokemon) {
33 | pokemon.battleattack = pokemon.attack;
34 | pokemon.battledefense = pokemon.defense;
35 | pokemon.battlespattack = pokemon.spattack;
36 | pokemon.battlespdefense = pokemon.spdefense;
37 | pokemon.battlespeed = pokemon.speed;
38 | return pokemon;
39 | }
40 |
41 | //carries out a move from an attacker on a defender
42 | //resolves all effects of the move
43 | useMove = function (attacker, defender, move) {
44 | if(checkHit(attacker, defender, move)) {
45 | var damage = calcDamage(attacker, defender, move);
46 | console.log(damage);
47 | if (isNaN(damage) == true)
48 | {
49 | damage = 0;
50 | }
51 | defender.remainingHP = Math.max(0, defender.remainingHP - damage);
52 |
53 | //check for fainting (checks attacker as well for selfdestruct and explosion)
54 | //updateStatus() method is in statusFunctions.js
55 | if (attacker.remainingHP == 0) {
56 | updateStatus(attacker, 'fnt');
57 | }
58 | if (defender.remainingHP == 0) {
59 | updateStatus(defender, 'fnt');
60 | }
61 |
62 | // if (attacker.status != 'fnt') {
63 | // move.userEffect(attacker);
64 | // }
65 | // if (defender.status != 'fnt') {
66 | // move.targetEffect(defender);
67 | // }
68 |
69 | return defender.remainingHP;
70 | }
71 | }
72 |
73 | //calculates if a move hits or not, depending on the move's conditions and accuracy
74 | //uses move's accuracy as a percentage hit rate, does not follow original game freak algorithms
75 | checkHit = function (attacker, defender, move) {
76 | //if the defender fails the move's hit conditions (such as being airborne from using Fly) then it does not hit
77 | var accuracy = moves[move]['accuracy'];
78 | if (accuracy == '-') {
79 | accuracy = 100;
80 | }
81 | if (100*Math.random() < accuracy) {
82 | return true;
83 | }
84 | return false;
85 | }
86 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Poke
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
25 | Enable Delete
26 |
27 |
28 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
![]()
38 |
39 |
hp:
40 |
41 |
42 |
43 |
44 |
45 |
52 |
53 |
54 |
55 |
56 |
57 |
![]()
58 |
59 |
hp:
60 |
61 |
xp:
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
76 |
77 |
Version: 0.0.2
78 |
GitHub
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/experience.js:
--------------------------------------------------------------------------------
1 | var experiencePoints = { };
2 | experiencePoints["Slow"] = [0, 1, 10, 33, 80, 156, 270, 428, 640, 911, 1250, 1663, 2160, 2746, 3430, 4218, 5120, 6141, 7290, 8573, 10000, 11576, 13310, 15208, 17280, 19531, 21970, 24603, 27440, 30486, 33750, 37238, 40960, 44921, 49130, 53593, 58320, 63316, 68590, 74148, 80000, 86151, 92610, 99383, 106480, 113906, 121670, 129778, 138240, 147061, 156250, 165813, 175760, 186096, 196830, 207968, 219520, 231491, 243890, 256723, 270000, 283726, 297910, 312558, 327680, 343281, 359370, 375953, 393040, 410636, 428750, 447388, 466560, 486271, 506530, 527343, 548720, 570666, 593190, 616298, 640000, 664301, 689210, 714733, 740880, 767656, 795070, 823128, 851840, 881211, 911250, 941963, 973360, 1005446, 1038230, 1071718, 1105920, 1140841, 1176490, 1212873, 1250000];
3 | experiencePoints["Medium Slow"] = [0, -53, 9, 57, 96, 135, 179, 236, 314, 419, 560, 742, 973, 1261, 1612, 2035, 2535, 3120, 3798, 4575, 5460, 6458, 7577, 8825, 10208, 11735, 13411, 15244, 17242, 19411, 21760, 24294, 27021, 29949, 33084, 36435, 40007, 43808, 47846, 52127, 56660, 61450, 66505, 71833, 77440, 83335, 89523, 96012, 102810, 109923, 117360, 125126, 133229, 141677, 150476, 159635, 169159, 179056, 189334, 199999, 211060, 222522, 234393, 246681, 259392, 272535, 286115, 300140, 314618, 329555, 344960, 360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260, 547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160, 789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860];
4 | experiencePoints["Medium Fast"] = [0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261, 10648, 12167, 13824, 15625, 17576, 19683, 21952, 24389, 27000, 29791, 32768, 35937, 39304, 42875, 46656, 50653, 54872, 59319, 64000, 68921, 74088, 79507, 85184, 91125, 97336, 103823, 110592, 117649, 125000, 132651, 140608, 148877, 157464, 166375, 175616, 185193, 195112, 205379, 216000, 226981, 238328, 250047, 262144, 274625, 287496, 300763, 314432, 328509, 343000, 357911, 373248, 389017, 405224, 421875, 438976, 456533, 474552, 493039, 512000, 531441, 551368, 571787, 592704, 614125, 636056, 658503, 681472, 704969, 729000, 753571, 778688, 804357, 830584, 857375, 884736, 912673, 941192, 970299, 1000000];
5 | experiencePoints["Fast"] = [0, 0, 6, 21, 51, 100, 172, 274, 409, 583, 800, 1064, 1382, 1757, 2195, 2700, 3276, 3930, 4665, 5487, 6400, 7408, 8518, 9733, 11059, 12500, 14060, 15746, 17561, 19511, 21600, 23832, 26214, 28749, 31443, 34300, 37324, 40522, 43897, 47455, 51200, 55136, 59270, 63605, 68147, 72900, 77868, 83058, 88473, 94119, 100000, 106120, 112486, 119101, 125971, 133100, 140492, 148154, 156089, 164303, 172800, 181584, 190662, 200037, 209715, 219700, 229996, 240610, 251545, 262807, 274400, 286328, 298598, 311213, 324179, 337500, 351180, 365226, 379641, 394431, 409600, 425152, 441094, 457429, 474163, 491300, 508844, 526802, 545177, 563975, 583200, 602856, 622950, 643485, 664467, 685900, 707788, 730138, 752953, 776239, 800000];
6 |
7 | //pass opponent pokemon, own pokemon and type = "wild" "trainer"
8 | function gainExperience( type, opponent, own )
9 | {
10 | var a = ( type == "wild" ) ? 1 : 1.5;
11 | return parseInt( a * opponent.level * pokemonInfo[ opponent.pokemon - 1 ].exp[ 0 ][ "base exp" ] / 7 );
12 | }
13 |
14 | function levelUp( own )
15 | {
16 | var lvl = own.level;
17 | var exp = own.experience;
18 | var stats = pokemonInfo[ own.pokemon - 1 ].stats[ 0 ];
19 | var growth = stats[ "growth rate" ];
20 | var boo = false;
21 | while ( exp > experiencePoints.growth[ lvl ] )
22 | {
23 | lvl = lvl + 1;
24 | boo = true;
25 | }
26 | if ( boo == false )
27 | {
28 | return false;
29 | }
30 | else
31 | {
32 | var result = {
33 | level : lvl,
34 | specialattack : parseInt((stats[ "sp atk" ] + 50) * lvl / 50 + 5),
35 | specialdefense : parseInt((stats[ "sp def" ] + 50) * lvl / 50 + 5),
36 | attack : parseInt((stats[ "attack" ] + 50) * lvl / 50 + 5),
37 | defense : parseInt((stats[ "defense" ] + 50) * lvl / 50 + 5),
38 | speed : parseInt((stats[ "speed" ] + 50) * lvl / 50 + 5),
39 | hp: parseInt( stats[ "hp" ] * lvl / 50 + 10 )
40 | };
41 | return result;
42 | }
43 |
44 | }
45 |
46 | function evolve( own )
47 | {
48 | var name = pokemonInfo[ own.pokemon - 1 ].pokemon[ 0 ].Pokemon;
49 | if ( evolutions.name != undefined )
50 | {
51 | if ( own.level >= evolutions.level )
52 | {
53 | return evolutions.to;
54 | }
55 | return false;
56 | }
57 | }
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/evolutions.js:
--------------------------------------------------------------------------------
1 | var evolutions = {
2 | "Bulbasaur":{
3 | "level":"16",
4 | "to":"Ivysaur"
5 | },
6 | "Ivysaur":{
7 | "level":"32",
8 | "to":"Venusaur"
9 | },
10 | "Charmander":{
11 | "level":"16",
12 | "to":"Charmeleon"
13 | },
14 | "Charmeleon":{
15 | "level":"36",
16 | "to":"Charizard"
17 | },
18 | "Squirtle":{
19 | "level":"16",
20 | "to":"Wartortle"
21 | },
22 | "Wartortle":{
23 | "level":"36",
24 | "to":"Blastoise"
25 | },
26 | "Caterpie":{
27 | "level":"7",
28 | "to":"Metapod"
29 | },
30 | "Metapod":{
31 | "level":"10",
32 | "to":"Butterfree"
33 | },
34 | "Weedle":{
35 | "level":"7",
36 | "to":"Kakuna"
37 | },
38 | "Kakuna":{
39 | "level":"10",
40 | "to":"Beedrill"
41 | },
42 | "Pidgey":{
43 | "level":"18",
44 | "to":"Pidgeotto"
45 | },
46 | "Pidgeotto":{
47 | "level":"36",
48 | "to":"Pidgeot"
49 | },
50 | "Rattata":{
51 | "level":"20",
52 | "to":"Raticate"
53 | },
54 | "Spearow":{
55 | "level":"20",
56 | "to":"Fearow"
57 | },
58 | "Ekans":{
59 | "level":"22",
60 | "to":"Arbok"
61 | },
62 | "Sandshrew":{
63 | "level":"22",
64 | "to":"Sandslash"
65 | },
66 | "Nidoran♀":{
67 | "level":"16",
68 | "to":"Nidorina"
69 | },
70 | "Nidoran♂":{
71 | "level":"16",
72 | "to":"Nidorino"
73 | },
74 | "Zubat":{
75 | "level":"22",
76 | "to":"Golbat"
77 | },
78 | "Oddish":{
79 | "level":"21",
80 | "to":"Gloom"
81 | },
82 | "Paras":{
83 | "level":"24",
84 | "to":"Parasect"
85 | },
86 | "Venonat":{
87 | "level":"31",
88 | "to":"Venomoth"
89 | },
90 | "Diglett":{
91 | "level":"26",
92 | "to":"Dugtrio"
93 | },
94 | "Meowth":{
95 | "level":"28",
96 | "to":"Persian"
97 | },
98 | "Psyduck":{
99 | "level":"33",
100 | "to":"Golduck"
101 | },
102 | "Mankey":{
103 | "level":"28",
104 | "to":"Primeape"
105 | },
106 | "Poliwag":{
107 | "level":"25",
108 | "to":"Poliwhirl"
109 | },
110 | "Abra":{
111 | "level":"16",
112 | "to":"Kadabra"
113 | },
114 | "Machop":{
115 | "level":"28",
116 | "to":"Machoke"
117 | },
118 | "Bellsprout":{
119 | "level":"21",
120 | "to":"Weepinbell"
121 | },
122 | "Tentacool":{
123 | "level":"30",
124 | "to":"Tentacruel"
125 | },
126 | "Geodude":{
127 | "level":"25",
128 | "to":"Graveler"
129 | },
130 | "Ponyta":{
131 | "level":"40",
132 | "to":"Rapidash"
133 | },
134 | "Slowpoke":{
135 | "level":"37",
136 | "to":"Slowbro"
137 | },
138 | "Magnemite":{
139 | "level":"30",
140 | "to":"Magneton"
141 | },
142 | "Doduo":{
143 | "level":"31",
144 | "to":"Dodrio"
145 | },
146 | "Seel":{
147 | "level":"34",
148 | "to":"Dewgong"
149 | },
150 | "Grimer":{
151 | "level":"38",
152 | "to":"Muk"
153 | },
154 | "Gastly":{
155 | "level":"25",
156 | "to":"Haunter"
157 | },
158 | "Drowzee":{
159 | "level":"26",
160 | "to":"Hypno"
161 | },
162 | "Krabby":{
163 | "level":"28",
164 | "to":"Kingler"
165 | },
166 | "Voltorb":{
167 | "level":"30",
168 | "to":"Electrode"
169 | },
170 | "Cubone":{
171 | "level":"28",
172 | "to":"Marowak"
173 | },
174 | "Tyrogue":{
175 | "level":"20",
176 | "to":"Hitmontop"
177 | },
178 | "Koffing":{
179 | "level":"35",
180 | "to":"Weezing"
181 | },
182 | "Rhyhorn":{
183 | "level":"42",
184 | "to":"Rhydon"
185 | },
186 | "Horsea":{
187 | "level":"32",
188 | "to":"Seadra"
189 | },
190 | "Goldeen":{
191 | "level":"33",
192 | "to":"Seaking"
193 | },
194 | "Smoochum":{
195 | "level":"30",
196 | "to":"Jynx"
197 | },
198 | "Elekid":{
199 | "level":"30",
200 | "to":"Electabuzz"
201 | },
202 | "Magby":{
203 | "level":"30",
204 | "to":"Magmar"
205 | },
206 | "Magikarp":{
207 | "level":"20",
208 | "to":"Gyarados"
209 | },
210 | "Omanyte":{
211 | "level":"40",
212 | "to":"Omastar"
213 | },
214 | "Kabuto":{
215 | "level":"40",
216 | "to":"Kabutops"
217 | },
218 | "Dratini":{
219 | "level":"30",
220 | "to":"Dragonair"
221 | },
222 | "Dragonair":{
223 | "level":"55",
224 | "to":"Dragonite"
225 | }
226 | };
227 |
228 | function checkEvolution( poke )
229 | {
230 | var evolve = evolutions[ pokemonInfo[ poke - 1 ].pokemon[ 0 ].Pokemon ];
231 | if ( poke.level >= evolve.level )
232 | {
233 | return true;
234 | }
235 | else
236 | {
237 | return false;
238 | }
239 | }
--------------------------------------------------------------------------------
/evolutions.js:
--------------------------------------------------------------------------------
1 | const EVOLUTIONS = {
2 | "Bulbasaur":{
3 | "level":"35",
4 | "to":"Ivysaur"
5 | },
6 | "Ivysaur":{
7 | "level":"70",
8 | "to":"Venusaur"
9 | },
10 | "Charmander":{
11 | "level":"35",
12 | "to":"Charmeleon"
13 | },
14 | "Charmeleon":{
15 | "level":"70",
16 | "to":"Charizard"
17 | },
18 | "Squirtle":{
19 | "level":"35",
20 | "to":"Wartortle"
21 | },
22 | "Wartortle":{
23 | "level":"70",
24 | "to":"Blastoise"
25 | },
26 | "Caterpie":{
27 | "level":"10",
28 | "to":"Metapod"
29 | },
30 | "Metapod":{
31 | "level":"50",
32 | "to":"Butterfree"
33 | },
34 | "Weedle":{
35 | "level":"10",
36 | "to":"Kakuna"
37 | },
38 | "Kakuna":{
39 | "level":"50",
40 | "to":"Beedrill"
41 | },
42 | "Pidgey":{
43 | "level":"50",
44 | "to":"Pidgeotto"
45 | },
46 | "Pidgeotto":{
47 | "level":"80",
48 | "to":"Pidgeot"
49 | },
50 | "Rattata":{
51 | "level":"40",
52 | "to":"Raticate"
53 | },
54 | "Spearow":{
55 | "level":"40",
56 | "to":"Fearow"
57 | },
58 | "Ekans":{
59 | "level":"40",
60 | "to":"Arbok"
61 | },
62 | "Sandshrew":{
63 | "level":"70",
64 | "to":"Sandslash"
65 | },
66 | "Nidoran f":{
67 | "level":"40",
68 | "to":"Nidorina"
69 | },
70 | "Nidorina":{
71 | "level":"80",
72 | "to":"Nidoqueen"
73 | },
74 | "Nidoran m":{
75 | "level":"40",
76 | "to":"Nidorino"
77 | },
78 | "Nidorino":{
79 | "level":"80",
80 | "to":"Nidoking"
81 | },
82 | "Zubat":{
83 | "level":"50",
84 | "to":"Golbat"
85 | },
86 | "Oddish":{
87 | "level":"40",
88 | "to":"Gloom"
89 | },
90 | "Gloom":{
91 | "level":"70",
92 | "to":"Vileplume"
93 | },
94 | "Paras":{
95 | "level":"60",
96 | "to":"Parasect"
97 | },
98 | "Venonat":{
99 | "level":"50",
100 | "to":"Venomoth"
101 | },
102 | "Diglett":{
103 | "level":"60",
104 | "to":"Dugtrio"
105 | },
106 | "Meowth":{
107 | "level":"70",
108 | "to":"Persian"
109 | },
110 | "Psyduck":{
111 | "level":"80",
112 | "to":"Golduck"
113 | },
114 | "Mankey":{
115 | "level":"60",
116 | "to":"Primeape"
117 | },
118 | "Poliwag":{
119 | "level":"50",
120 | "to":"Poliwhirl"
121 | },
122 | "Poliwhirl":{
123 | "level":"80",
124 | "to":"Poliwrath"
125 | },
126 | "Abra":{
127 | "level":"50",
128 | "to":"Kadabra"
129 | },
130 | "Kadabra":{
131 | "level":"85",
132 | "to":"Alakazam"
133 | },
134 | "Machop":{
135 | "level":"50",
136 | "to":"Machoke"
137 | },
138 | "Machoke":{
139 | "level":"80",
140 | "to":"Machamp"
141 | },
142 | "Bellsprout":{
143 | "level":"50",
144 | "to":"Weepinbell"
145 | },
146 | "Weepinbell":{
147 | "level":"80",
148 | "to":"Victreebel"
149 | },
150 | "Tentacool":{
151 | "level":"60",
152 | "to":"Tentacruel"
153 | },
154 | "Geodude":{
155 | "level":"50",
156 | "to":"Graveler"
157 | },
158 | "Graveler":{
159 | "level":"75",
160 | "to":"Golem"
161 | },
162 | "Ponyta":{
163 | "level":"50",
164 | "to":"Rapidash"
165 | },
166 | "Slowpoke":{
167 | "level":"70",
168 | "to":"Slowbro"
169 | },
170 | "Magnemite":{
171 | "level":"70",
172 | "to":"Magneton"
173 | },
174 | "Doduo":{
175 | "level":"60",
176 | "to":"Dodrio"
177 | },
178 | "Seel":{
179 | "level":"60",
180 | "to":"Dewgong"
181 | },
182 | "Grimer":{
183 | "level":"60",
184 | "to":"Muk"
185 | },
186 | "Shellder":{
187 | "level":"60",
188 | "to":"Cloyster"
189 | },
190 | "Gastly":{
191 | "level":"80",
192 | "to":"Haunter"
193 | },
194 | "Haunter":{
195 | "level":"95",
196 | "to":"Gengar"
197 | },
198 | "Drowzee":{
199 | "level":"60",
200 | "to":"Hypno"
201 | },
202 | "Krabby":{
203 | "level":"60",
204 | "to":"Kingler"
205 | },
206 | "Voltorb":{
207 | "level":"70",
208 | "to":"Electrode"
209 | },
210 | "Cubone":{
211 | "level":"80",
212 | "to":"Marowak"
213 | },
214 | "Koffing":{
215 | "level":"60",
216 | "to":"Weezing"
217 | },
218 | "Rhyhorn":{
219 | "level":"85",
220 | "to":"Rhydon"
221 | },
222 | "Horsea":{
223 | "level":"60",
224 | "to":"Seadra"
225 | },
226 | "Goldeen":{
227 | "level":"60",
228 | "to":"Seaking"
229 | },
230 | "Magikarp":{
231 | "level":"95",
232 | "to":"Gyarados"
233 | },
234 | "Omanyte":{
235 | "level":"85",
236 | "to":"Omastar"
237 | },
238 | "Kabuto":{
239 | "level":"85",
240 | "to":"Kabutops"
241 | },
242 | "Dratini":{
243 | "level":"70",
244 | "to":"Dragonair"
245 | },
246 | "Dragonair":{
247 | "level":"90",
248 | "to":"Dragonite"
249 | }
250 | };
251 |
--------------------------------------------------------------------------------
/typeModifiers.js:
--------------------------------------------------------------------------------
1 | var TYPES = {
2 | "Fire" : {
3 | "Fire" : .5,
4 | "Water" : .5,
5 | "Grass" : 2,
6 | "Electric" : 1,
7 | "Ice" : 2,
8 | "Psychic" : 1,
9 | "Normal" : 1,
10 | "Fighting" : 1,
11 | "Flying" : 1,
12 | "Ground" : 1,
13 | "Rock" : .5,
14 | "Bug" : 2,
15 | "Poison" : 1,
16 | "Ghost" : 1,
17 | "Dragon" : .5
18 | },
19 | "Water" : {
20 | "Fire" : 2,
21 | "Water" : .5,
22 | "Grass" : .5,
23 | "Electric" : 1,
24 | "Ice" : 1,
25 | "Psychic" : 1,
26 | "Normal" : 1,
27 | "Fighting" : 1,
28 | "Flying" : 1,
29 | "Ground" : 2,
30 | "Rock" : 2,
31 | "Bug" : 1,
32 | "Poison" : 1,
33 | "Ghost" : 1,
34 | "Dragon" : .5
35 | },
36 | "Grass" : {
37 | "Fire" : .5,
38 | "Water" : 2,
39 | "Grass" : .5,
40 | "Electric" : 1,
41 | "Ice" : 1,
42 | "Psychic" : 1,
43 | "Normal" : 1,
44 | "Fighting" : 1,
45 | "Flying" : .5,
46 | "Ground" : 2,
47 | "Rock" : 2,
48 | "Bug" : .5,
49 | "Poison" : .5,
50 | "Ghost" : 1,
51 | "Dragon" : .5
52 | },
53 | "Electric" : {
54 | "Fire" : 1,
55 | "Water" : 2,
56 | "Grass" : .5,
57 | "Electric" : .5,
58 | "Ice" : 1,
59 | "Psychic" : 1,
60 | "Normal" : 1,
61 | "Fighting" : 1,
62 | "Flying" : 2,
63 | "Ground" : .25,
64 | "Rock" : 1,
65 | "Bug" : 1,
66 | "Poison" : 1,
67 | "Ghost" : 1,
68 | "Dragon" : .5
69 | },
70 | "Ice" : {
71 | "Fire" : 1,
72 | "Water" : .5,
73 | "Grass" : 2,
74 | "Electric" : 1,
75 | "Ice" : .5,
76 | "Psychic" : 1,
77 | "Normal" : 1,
78 | "Fighting" : 1,
79 | "Flying" : 2,
80 | "Ground" : 2,
81 | "Rock" : 1,
82 | "Bug" : 1,
83 | "Poison" : 1,
84 | "Ghost" : 1,
85 | "Dragon" : 2
86 | },
87 | "Psychic" : {
88 | "Fire" : 1,
89 | "Water" : 1,
90 | "Grass" : 1,
91 | "Electric" : 1,
92 | "Ice" : 1,
93 | "Psychic" : .5,
94 | "Normal" : 1,
95 | "Fighting" : 2,
96 | "Flying" : 1,
97 | "Ground" : 1,
98 | "Rock" : 1,
99 | "Bug" : 1,
100 | "Poison" : 2,
101 | "Ghost" : 1,
102 | "Dragon" : 1
103 | },
104 | "Normal" : {
105 | "Fire" : 1,
106 | "Water" : 1,
107 | "Grass" : 1,
108 | "Electric" : 1,
109 | "Ice" : 1,
110 | "Psychic" : 1,
111 | "Normal" : 1,
112 | "Fighting" : 1,
113 | "Flying" : 1,
114 | "Ground" : 1,
115 | "Rock" : .5,
116 | "Bug" : 1,
117 | "Poison" : 1,
118 | "Ghost" : .25,
119 | "Dragon" : 1
120 | },
121 | "Fighting" : {
122 | "Fire" : 1,
123 | "Water" : 1,
124 | "Grass" : 1,
125 | "Electric" : 1,
126 | "Ice" : 2,
127 | "Psychic" : .5,
128 | "Normal" : 2,
129 | "Fighting" : 1,
130 | "Flying" : .5,
131 | "Ground" : 1,
132 | "Rock" : 2,
133 | "Bug" : .5,
134 | "Poison" : .5,
135 | "Ghost" : .25,
136 | "Dragon" : 1
137 | },
138 | "Flying" : {
139 | "Fire" : 1,
140 | "Water" : 1,
141 | "Grass" : 2,
142 | "Electric" : .5,
143 | "Ice" : 1,
144 | "Psychic" : 1,
145 | "Normal" : 1,
146 | "Fighting" : 2,
147 | "Flying" : 1,
148 | "Ground" : 1,
149 | "Rock" : .5,
150 | "Bug" : 2,
151 | "Poison" : 1,
152 | "Ghost" : 1,
153 | "Dragon" : 1
154 | },
155 | "Ground" : {
156 | "Fire" : 2,
157 | "Water" : 1,
158 | "Grass" : .5,
159 | "Electric" : 2,
160 | "Ice" : 1,
161 | "Psychic" : 1,
162 | "Normal" : 1,
163 | "Fighting" : 1,
164 | "Flying" : .25,
165 | "Ground" : 1,
166 | "Rock" : .5,
167 | "Bug" : 2,
168 | "Poison" : 1,
169 | "Ghost" : 1,
170 | "Dragon" : 1
171 | },
172 | "Rock" : {
173 | "Fire" : 2,
174 | "Water" : 1,
175 | "Grass" : 1,
176 | "Electric" : 1,
177 | "Ice" : 2,
178 | "Psychic" : 1,
179 | "Normal" : 1,
180 | "Fighting" : .5,
181 | "Flying" : 2,
182 | "Ground" : .5,
183 | "Rock" : 1,
184 | "Bug" : 2,
185 | "Poison" : 1,
186 | "Ghost" : 1,
187 | "Dragon" : 1
188 | },
189 | "Bug" : {
190 | "Fire" : .5,
191 | "Water" : 1,
192 | "Grass" : 2,
193 | "Electric" : 1,
194 | "Ice" : 1,
195 | "Psychic" : 2,
196 | "Normal" : 1,
197 | "Fighting" : .5,
198 | "Flying" : .5,
199 | "Ground" : 1,
200 | "Rock" : 1,
201 | "Bug" : 1,
202 | "Poison" : 2,
203 | "Ghost" : 1,
204 | "Dragon" : 1
205 | },
206 | "Poison" : {
207 | "Fire" : 1,
208 | "Water" : 1,
209 | "Grass" : 2,
210 | "Electric" : 1,
211 | "Ice" : 1,
212 | "Psychic" : 1,
213 | "Normal" : 1,
214 | "Fighting" : 1,
215 | "Flying" : 1,
216 | "Ground" : .5,
217 | "Rock" : .5,
218 | "Bug" : 2,
219 | "Poison" : .5,
220 | "Ghost" : .5,
221 | "Dragon" : 1
222 | },
223 | "Ghost" : {
224 | "Fire" : 1,
225 | "Water" : 1,
226 | "Grass" : 1,
227 | "Electric" : 1,
228 | "Ice" : 1,
229 | "Psychic" : .25,
230 | "Normal" : .25,
231 | "Fighting" : 1,
232 | "Flying" : 1,
233 | "Ground" : 1,
234 | "Rock" : .1,
235 | "Bug" : 1,
236 | "Poison" : 1,
237 | "Ghost" : 2,
238 | "Dragon" : 1
239 | },
240 | "Dragon" : {
241 | "Fire" : 1,
242 | "Water" : 1,
243 | "Grass" : 1,
244 | "Electric" : 1,
245 | "Ice" : 1,
246 | "Psychic" : 1,
247 | "Normal" : 1,
248 | "Fighting" : 1,
249 | "Flying" : 1,
250 | "Ground" : 1,
251 | "Rock" : .1,
252 | "Bug" : 1,
253 | "Poison" : 1,
254 | "Ghost" : 1,
255 | "Dragon" : 1
256 | }
257 | }
258 |
--------------------------------------------------------------------------------
/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: rgb(219, 219, 219);
3 | }
4 |
5 | #gameContainer {
6 | font-family: 'Lato', sans-serif;
7 | color: #111111;
8 | width: 800px;
9 | margin: auto;
10 | background-color: rgb(82, 153, 228);
11 | height: 602px;
12 | padding: 10px;
13 | border-radius: 3px;
14 | box-shadow: 0 0 10px black;
15 | position: relative;
16 | }
17 |
18 | ul {
19 | list-style-type: none;
20 | padding: 0px;
21 | -webkit-margin-before: 0em;
22 | -webkit-margin-after: 0 em;
23 | }
24 |
25 | .container {
26 | display: block;
27 | position: relative;
28 | width: 160px;
29 | min-height: 100px;
30 | max-height: 400px;
31 | background-color: rgb(217, 217, 217);
32 | border: solid 1px rgb(10, 0, 130);
33 | box-shadow: 0 0 3px rgb(10, 0, 130);
34 | border-radius: 5px;
35 | }
36 |
37 | .poke .inner {
38 | position: relative;
39 | line-height: 25px;
40 | font-size: 12px;
41 | text-align: center;
42 | width: 165px;
43 | float: left;
44 | }
45 |
46 | #player .inner {
47 | border-right: solid 1px rgb(7, 0, 90);
48 | border-bottom: solid 1px rgb(7, 0, 90);
49 | }
50 |
51 | .poke .inner .img.attacked-right{
52 | margin-left: 15px;
53 | }
54 | .poke .inner .img.attacked-left{
55 | margin-right: 15px;
56 | }
57 | .poke .inner .img {
58 | transition: margin 0.08s ease-out;
59 | margin-left: 0px;
60 | margin-right: 0px;
61 | }
62 |
63 |
64 |
65 | .poke .inner .name {
66 | font-size: 18px;
67 | font-weight: 500;
68 | }
69 |
70 | #enemy {
71 | float: right;
72 | border-radius: 10px 0 0 10px;
73 | border-right: none;
74 | width: 370px;
75 | }
76 |
77 | #enemy .inner {
78 | float: right;
79 | }
80 |
81 | #capture-options {
82 | float: left;
83 | width: 190px;
84 | box-sizing: border-box;
85 | padding: 10px;
86 | }
87 |
88 | #areasList {
89 | float: right;
90 | min-height: none;
91 | max-height: none;
92 | height: 400px;
93 | border-radius: 0 5px 5px 5px;
94 | width: 190px;
95 | text-align: right;
96 | }
97 |
98 | #areasList li,#areasList a {
99 | margin-right: 6px;
100 | }
101 |
102 | #enemy .status, #enemy .expBar {
103 | display: none;
104 | }
105 |
106 |
107 | #player {
108 | float: left;
109 | border-radius: 0 10px 10px 0;
110 | border-left: none;
111 | position: absolute;
112 | top: 270px;
113 | left: 172px;
114 | width: 438px;
115 | height: 340px;
116 | }
117 |
118 | #playerPokes {
119 | float: left;
120 | height: 600px;
121 | overflow: hidden;
122 | text-align: center;
123 | text-align: left;
124 | max-height: 600px;
125 | }
126 |
127 | #playerPokes .checkDescription {
128 | font-size: 14px;
129 | }
130 |
131 | #playerPokes .controls {
132 | position: relative;
133 | }
134 |
135 | #playerPokesList {
136 | position: relative;
137 | padding-left: 8px;
138 | overflow-y: auto;
139 | overflow-x: hidden;
140 | height: 525px;
141 | }
142 |
143 | #heal {
144 | display: block;
145 | width: 100px;
146 | height: 30px;
147 | margin: auto;
148 | margin-top: 10px;
149 | margin-bottom: 10px;
150 | }
151 |
152 | #console {
153 | float: left;
154 | width: 259px;
155 | height: 220px;
156 | box-sizing: border-box;
157 | padding-left: 9px;
158 | overflow: scroll;
159 | border-bottom: solid 1px black;
160 | }
161 |
162 | #console .console-text {
163 |
164 | }
165 |
166 |
167 | #playerBox {
168 | width: 265px;
169 | height: 109px;
170 | float: right;
171 | }
172 |
173 | #playerBox button {
174 | margin-left: 10px;
175 | width: 150px;
176 | }
177 |
178 | #gitLink {
179 | position: absolute;
180 | top: 597px;
181 | left: 761px;
182 | }
183 |
184 | #version {
185 | position: absolute;
186 | top: 598px;
187 | left: 621px;
188 | }
189 |
190 |
191 |
192 |
193 |
194 | /* progressbar reset*/
195 | progress, /* All HTML5 progress enabled browsers */
196 | progress[role] /* polyfill */
197 | {
198 |
199 | /* Turns off styling - not usually needed, but good to know. */
200 | appearance: none;
201 | -moz-appearance: none;
202 | -webkit-appearance: none;
203 |
204 | /* gets rid of default border in Firefox and Opera. */
205 | border: none;
206 |
207 | /* Needs to be in here for Safari polyfill so background images work as expected. */
208 | background-size: auto;
209 |
210 | /* Dimensions */
211 | width: 400px;
212 | height: 60px;
213 |
214 | }
215 |
216 | /* Polyfill */
217 | progress[role]:after {
218 | background-image: none; /* removes default background from polyfill */
219 | }
220 |
221 | /* Ensure fallback text doesn't appear in polyfill */
222 | progress[role] strong {
223 | display: none;
224 | }
225 |
226 | /* progress bg */
227 |
228 | progress, /* Firefox */
229 | progress[role][aria-valuenow] { /* Polyfill */
230 | background: rgb(6, 64, 65) !important; /* !important is needed by the polyfill */
231 | }
232 |
233 | /* Chrome */
234 | progress::-webkit-progress-bar {
235 | background: rgb(6, 64, 65);
236 | }
237 |
238 | /* progress value */
239 |
240 | /* IE10 */
241 | progress {
242 | color: rgb(15, 238, 141);
243 | }
244 |
245 | /* Firefox */
246 | progress::-moz-progress-bar {
247 | background: rgb(15, 238, 141);
248 | }
249 |
250 | /* Chrome */
251 | progress::-webkit-progress-value {
252 | background: rgb(15, 238, 141);
253 | border-radius: 0 10px 0 0;
254 | }
255 |
256 | /* Polyfill */
257 | progress[aria-valuenow]:before {
258 | background: rgb(15, 238, 141);
259 | }
260 |
261 |
262 | progress {
263 | width: 70px;
264 | height: 5px;
265 | position: relative;
266 | top: -3px;
267 | box-shadow: 0 0 2px black;
268 | }
269 |
270 | progress.expBar {
271 | width: 120px;
272 | }
273 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/damage.js:
--------------------------------------------------------------------------------
1 | // pass move used and two pokemon instances
2 |
3 | var typemodifiers = {
4 | "Fire" : {
5 | "Fire" : .5,
6 | "Water" : .5,
7 | "Grass" : 2,
8 | "Electric" : 1,
9 | "Ice" : 2,
10 | "Psychic" : 1,
11 | "Normal" : 1,
12 | "Fighting" : 1,
13 | "Flying" : 1,
14 | "Ground" : 1,
15 | "Rock" : .5,
16 | "Bug" : 2,
17 | "Poison" : 1,
18 | "Ghost" : 1,
19 | "Dragon" : .5
20 | },
21 | "Water" : {
22 | "Fire" : 2,
23 | "Water" : .5,
24 | "Grass" : .5,
25 | "Electric" : 1,
26 | "Ice" : 1,
27 | "Psychic" : 1,
28 | "Normal" : 1,
29 | "Fighting" : 1,
30 | "Flying" : 1,
31 | "Ground" : 2,
32 | "Rock" : 2,
33 | "Bug" : 1,
34 | "Poison" : 1,
35 | "Ghost" : 1,
36 | "Dragon" : .5
37 | },
38 | "Grass" : {
39 | "Fire" : .5,
40 | "Water" : 2,
41 | "Grass" : .5,
42 | "Electric" : 1,
43 | "Ice" : 1,
44 | "Psychic" : 1,
45 | "Normal" : 1,
46 | "Fighting" : 1,
47 | "Flying" : .5,
48 | "Ground" : 2,
49 | "Rock" : 2,
50 | "Bug" : .5,
51 | "Poison" : .5,
52 | "Ghost" : 1,
53 | "Dragon" : .5
54 | },
55 | "Electric" : {
56 | "Fire" : 1,
57 | "Water" : 2,
58 | "Grass" : .5,
59 | "Electric" : .5,
60 | "Ice" : 1,
61 | "Psychic" : 1,
62 | "Normal" : 1,
63 | "Fighting" : 1,
64 | "Flying" : 2,
65 | "Ground" : 0,
66 | "Rock" : 1,
67 | "Bug" : 1,
68 | "Poison" : 1,
69 | "Ghost" : 1,
70 | "Dragon" : .5
71 | },
72 | "Ice" : {
73 | "Fire" : 1,
74 | "Water" : .5,
75 | "Grass" : 2,
76 | "Electric" : 1,
77 | "Ice" : .5,
78 | "Psychic" : 1,
79 | "Normal" : 1,
80 | "Fighting" : 1,
81 | "Flying" : 2,
82 | "Ground" : 2,
83 | "Rock" : 1,
84 | "Bug" : 1,
85 | "Poison" : 1,
86 | "Ghost" : 1,
87 | "Dragon" : 2
88 | },
89 | "Psychic" : {
90 | "Fire" : 1,
91 | "Water" : 1,
92 | "Grass" : 1,
93 | "Electric" : 1,
94 | "Ice" : 1,
95 | "Psychic" : .5,
96 | "Normal" : 1,
97 | "Fighting" : 2,
98 | "Flying" : 1,
99 | "Ground" : 1,
100 | "Rock" : 1,
101 | "Bug" : 1,
102 | "Poison" : 2,
103 | "Ghost" : 1,
104 | "Dragon" : 1
105 | },
106 | "Normal" : {
107 | "Fire" : 1,
108 | "Water" : 1,
109 | "Grass" : 1,
110 | "Electric" : 1,
111 | "Ice" : 1,
112 | "Psychic" : 1,
113 | "Normal" : 1,
114 | "Fighting" : 1,
115 | "Flying" : 1,
116 | "Ground" : 1,
117 | "Rock" : .5,
118 | "Bug" : 1,
119 | "Poison" : 1,
120 | "Ghost" : 0,
121 | "Dragon" : 1
122 | },
123 | "Fighting" : {
124 | "Fire" : 1,
125 | "Water" : 1,
126 | "Grass" : 1,
127 | "Electric" : 1,
128 | "Ice" : 2,
129 | "Psychic" : .5,
130 | "Normal" : 2,
131 | "Fighting" : 1,
132 | "Flying" : .5,
133 | "Ground" : 1,
134 | "Rock" : 2,
135 | "Bug" : .5,
136 | "Poison" : .5,
137 | "Ghost" : 0,
138 | "Dragon" : 1
139 | },
140 | "Flying" : {
141 | "Fire" : 1,
142 | "Water" : 1,
143 | "Grass" : 2,
144 | "Electric" : .5,
145 | "Ice" : 1,
146 | "Psychic" : 1,
147 | "Normal" : 1,
148 | "Fighting" : 2,
149 | "Flying" : 1,
150 | "Ground" : 1,
151 | "Rock" : .5,
152 | "Bug" : 2,
153 | "Poison" : 1,
154 | "Ghost" : 1,
155 | "Dragon" : 1
156 | },
157 | "Ground" : {
158 | "Fire" : 2,
159 | "Water" : 1,
160 | "Grass" : .5,
161 | "Electric" : 2,
162 | "Ice" : 1,
163 | "Psychic" : 1,
164 | "Normal" : 1,
165 | "Fighting" : 1,
166 | "Flying" : 0,
167 | "Ground" : 1,
168 | "Rock" : .5,
169 | "Bug" : 2,
170 | "Poison" : 1,
171 | "Ghost" : 1,
172 | "Dragon" : 1
173 | },
174 | "Rock" : {
175 | "Fire" : 2,
176 | "Water" : 1,
177 | "Grass" : 1,
178 | "Electric" : 1,
179 | "Ice" : 2,
180 | "Psychic" : 1,
181 | "Normal" : 1,
182 | "Fighting" : .5,
183 | "Flying" : 2,
184 | "Ground" : .5,
185 | "Rock" : 1,
186 | "Bug" : 2,
187 | "Poison" : 1,
188 | "Ghost" : 1,
189 | "Dragon" : 1
190 | },
191 | "Bug" : {
192 | "Fire" : .5,
193 | "Water" : 1,
194 | "Grass" : 2,
195 | "Electric" : 1,
196 | "Ice" : 1,
197 | "Psychic" : 2,
198 | "Normal" : 1,
199 | "Fighting" : .5,
200 | "Flying" : .5,
201 | "Ground" : 1,
202 | "Rock" : 1,
203 | "Bug" : 1,
204 | "Poison" : 2,
205 | "Ghost" : 1,
206 | "Dragon" : 1
207 | },
208 | "Poison" : {
209 | "Fire" : 1,
210 | "Water" : 1,
211 | "Grass" : 2,
212 | "Electric" : 1,
213 | "Ice" : 1,
214 | "Psychic" : 1,
215 | "Normal" : 1,
216 | "Fighting" : 1,
217 | "Flying" : 1,
218 | "Ground" : .5,
219 | "Rock" : .5,
220 | "Bug" : 2,
221 | "Poison" : .5,
222 | "Ghost" : .5,
223 | "Dragon" : 1
224 | },
225 | "Ghost" : {
226 | "Fire" : 1,
227 | "Water" : 1,
228 | "Grass" : 1,
229 | "Electric" : 1,
230 | "Ice" : 1,
231 | "Psychic" : 0,
232 | "Normal" : 0,
233 | "Fighting" : 1,
234 | "Flying" : 1,
235 | "Ground" : 1,
236 | "Rock" : .1,
237 | "Bug" : 1,
238 | "Poison" : 1,
239 | "Ghost" : 2,
240 | "Dragon" : 1
241 | },
242 | "Dragon" : {
243 | "Fire" : 1,
244 | "Water" : 1,
245 | "Grass" : 1,
246 | "Electric" : 1,
247 | "Ice" : 1,
248 | "Psychic" : 1,
249 | "Normal" : 1,
250 | "Fighting" : 1,
251 | "Flying" : 1,
252 | "Ground" : 1,
253 | "Rock" : .1,
254 | "Bug" : 1,
255 | "Poison" : 1,
256 | "Ghost" : 1,
257 | "Dragon" : 1
258 | }
259 | }
260 | // pass offense pokemon instance, defense pokemon instance, and move
261 | calcDamage = function ( offense, defense, move )
262 | {
263 | console.log(offense.pokemon-1);
264 | console.log(defense.pokemon-1);
265 | var offtype = pokemonInfo[ offense.pokemon - 1 ].stats[0].types.text;
266 | var deftype = pokemonInfo[ defense.pokemon - 1 ].stats[0].types.text;
267 | var move = moves[ move ];
268 | var movetype = move.type.text;
269 |
270 | var A = offense.level;
271 | if ( movetype == "Water" || movetype == "Grass" || movetype == "Fire" || movetype == "Ice" || movetype == "Electric" || movetype == "Psychic")
272 | {
273 | var B = offense.spattack;
274 | var D = defense.spdefense;
275 | }
276 | else
277 | {
278 | var B = offense.attack;
279 | var D = defense.defense;
280 | }
281 | var C = move.power;
282 | var X = 1;
283 | if ( offtype == movetype )
284 | {
285 | X = 1.5;
286 | }
287 | var Y = typemodifiers[ offtype ][ deftype ];
288 | var Z = Math.random() * ( 255 - 217 + 1 ) + 217;
289 | if ( C != "-" )
290 | {
291 | var damage = ( ( 2 * A / 5 + 2 ) * B * C / D / 50 + 2 ) * X * Y * Z / 255;
292 | }
293 | else
294 | {
295 | return 0;
296 | }
297 | console.log(damage);
298 | return parseInt(damage);
299 | }
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/sense.js:
--------------------------------------------------------------------------------
1 | (function(window, document){
2 | 'use strict';
3 |
4 | var _instance,
5 | config;
6 |
7 | var sense = {
8 | get: function() {
9 | return _instance;
10 | },
11 | init: function(options){
12 | return _instance || new Sense(options)
13 | }
14 | };
15 |
16 | /**
17 | * Constructor
18 | */
19 | function Sense(options){
20 | _instance = this;
21 | config = options || {debug: false};
22 |
23 | if (config.debug) {
24 | initDebuggingWindow();
25 | }
26 |
27 | }
28 |
29 | /**
30 | * Given arguments and default options, return an object containing options and the callback
31 | * @param args: Array of arguments
32 | * @param defaultOptions: Object containing default options
33 | * @returns {{options: *, callback: *}}
34 | */
35 | var getArgs = function (args, defaultOptions) {
36 | var callback;
37 | if (args.length === 1){
38 | // We only have the callback, so use default options
39 | callback = args[0];
40 | return {
41 | options: defaultOptions,
42 | callback: function(data){
43 | updateDebugger(data);
44 | callback(data);
45 | }
46 | };
47 | }
48 |
49 | if (args.length === 2){
50 | // We have both the callback and an arguments hash
51 | callback = args[1];
52 | return {
53 | options: args[0],
54 | callback: function(data){
55 | updateDebugger(data);
56 | callback(data);
57 | }
58 | }
59 | }
60 | };
61 |
62 | /**
63 | * Show a debugger with data on the
64 | * @param data
65 | */
66 | var initDebuggingWindow = function(){
67 | if (config.debug){
68 | var el = document.createElement('div');
69 | el.innerHTML = "" +
70 | "" +
71 | "
";
72 | window.onload = function(){
73 | document.body.appendChild(el);
74 | }
75 | }
76 | };
77 |
78 | /**
79 | * Update the debugger div
80 | * @param data: JSON
81 | */
82 | var updateDebugger = function(data){
83 | if (config.debug){
84 | document.getElementById('sense-debugger')
85 | .innerText = JSON.stringify(data, undefined, 2);
86 | }
87 | };
88 |
89 | var withinThreshold = function(a, b, threshold){
90 | return b < a + threshold && b > a - threshold
91 | };
92 |
93 | /**
94 | * Orientation ([options], callback)
95 | * - Options:
96 | * alphaThreshold (number)
97 | * betaThreshold (number)
98 | * gammaThreshold (number)
99 | * radians (boolean)
100 | *
101 | * - Data:
102 | * alpha (num)
103 | * beta (num)
104 | * gamma (num)
105 | */
106 | Sense.prototype.orientation = function() {
107 | if (window.DeviceOrientationEvent) {
108 | var defaults = {
109 | alphaThreshold: 0,
110 | betaThreshold: 0,
111 | gammaThreshold: 0,
112 | radians: false
113 | },
114 | args = getArgs(arguments, defaults),
115 | callback = args.callback,
116 | options = args.options,
117 | prevData = {
118 | alpha: 0,
119 | beta: 0,
120 | gamma: 0
121 | };
122 |
123 | window.addEventListener('deviceorientation', function (eventData) {
124 |
125 | var data = {
126 | alpha: options.radians ? eventData.alpha * Math.PI / 180.0 : eventData.alpha,
127 | beta: options.radians ? eventData.beta * Math.PI / 180.0 : eventData.beta,
128 | gamma: options.radians ? eventData.gamma * Math.PI / 180.0 : eventData.gamma
129 | };
130 |
131 | if(Math.abs(data.alpha - prevData.alpha) >= options.alphaThreshold ||
132 | Math.abs(data.beta - prevData.beta) >= options.betaThreshold ||
133 | Math.abs(data.gamma - prevData.gamma) >= options.gammaThreshold
134 | ) {
135 | callback(data)
136 | prevData = data
137 | }
138 | })
139 |
140 | }
141 | };
142 |
143 | /*
144 | Tilt function!
145 | */
146 | Sense.prototype.tilt = function() {
147 | if (window.DeviceOrientationEvent) {
148 | var callback,
149 | options = {
150 | threshold: 5,
151 | direction: "both",
152 | gestureDuration: 500
153 | },
154 | args = getArgs(arguments, options),
155 | lastSample,
156 | intervalExpired = true;
157 |
158 | callback = args.callback;
159 | options = args.options;
160 |
161 | setInterval(function(){intervalExpired = true}, options.gestureDuration)
162 |
163 | window.addEventListener('deviceorientation', function(eventData){
164 | // Here, you take the eventData and the options that you have and
165 | // process the data, and then feed it to the callback
166 | if(intervalExpired) {
167 | lastSample = eventData.gamma;
168 | intervalExpired = false;
169 | }
170 | var delta = lastSample - eventData.gamma;
171 |
172 | if(delta > options.threshold) {
173 | lastSample = eventData.gamma;
174 | var data = {
175 | direction: "LEFT",
176 | magnitude: Math.round(delta)
177 |
178 | };
179 | callback(data);
180 | }
181 |
182 | if(delta < -options.threshold) {
183 | lastSample = eventData.gamma;
184 | var data = {
185 | direction: "RIGHT",
186 | magnitude: Math.round(-delta)
187 | };
188 | callback(data);
189 | }
190 |
191 | })
192 | }
193 | };
194 |
195 | /**
196 | * Flick ([options], callback)
197 | * - Options:
198 | * interval (int)
199 | * sensitivity
200 | *
201 | * - Data:
202 | * direction String 'left', 'right'
203 | * magnitude (float)
204 | */
205 | Sense.prototype.flick = function() {
206 | if (window.DeviceMotionEvent) {
207 | var FLICK_ACCELERATION = 15;
208 | var defaults = {
209 | interval: 150,
210 | sensitivity: 1
211 | },
212 | args = getArgs(arguments, defaults),
213 | callback = args.callback,
214 | options = args.options;
215 |
216 | var flicking = false;
217 |
218 | window.addEventListener('devicemotion', function (eventData) {
219 |
220 | var acceleration = eventData.acceleration;
221 |
222 | if (Math.abs(acceleration.x) > options.sensitivity * FLICK_ACCELERATION) {
223 | if (!flicking){
224 | flicking = true;
225 | callback({
226 | direction: acceleration.x > 0 ? 'left' : 'right',
227 | magnitude: Math.abs(acceleration.x)
228 | });
229 | setTimeout(function(){
230 | flicking = false;
231 | }, options.interval);
232 | }
233 | }
234 | })
235 | }
236 | };
237 |
238 | Sense.prototype.fling = function() {
239 | if (window.DeviceMotionEvent) {
240 | var THROW_ACCELERATION = 10;
241 | var defaults = {
242 | interval: 150,
243 | sensitivity: 1
244 | },
245 | args = getArgs(arguments, defaults),
246 | callback = args.callback,
247 | options = args.options;
248 |
249 | var throwing = false;
250 |
251 | window.addEventListener('devicemotion', function (eventData) {
252 |
253 | var acceleration = eventData.acceleration;
254 |
255 | if (acceleration.z > options.sensitivity * THROW_ACCELERATION) {
256 | if (!throwing){
257 | throwing = true;
258 | callback({
259 | magnitude: Math.abs(acceleration.z)
260 | });
261 | setTimeout(function(){
262 | throwing = false;
263 | }, options.interval);
264 | }
265 | }
266 | })
267 | }
268 | };
269 |
270 | Sense.prototype.flip = function() {
271 | var gammas = [];
272 | if (window.DeviceOrientationEvent) {
273 | var callback,
274 | options = {
275 | gestureDuration: 250
276 | },
277 | args = getArgs(arguments, options),
278 | intervalExpired = false;
279 |
280 | callback = args.callback;
281 | options = args.options;
282 |
283 | setInterval(function(){intervalExpired = true}, options.gestureDuration);
284 |
285 | window.addEventListener('deviceorientation', function(eventData){
286 | var final_gamma = 0;
287 | var found = false;
288 | if(intervalExpired) {
289 | gammas[gammas.length] = eventData.gamma;
290 | for (var i=1; i < 5; i++) {
291 | if (Math.abs(gammas[gammas.length-1] - gammas[gammas.length-1-i]) > 160) {
292 | found = true;
293 | final_gamma = gammas[gammas.length - 1];
294 | gammas = [];
295 | break;
296 | }
297 | }
298 | intervalExpired = false;
299 | }
300 |
301 | if (found) {
302 | var data = {
303 | magnitude: Math.round(final_gamma)
304 | };
305 | callback(data);
306 | }
307 | })
308 | }
309 | };
310 |
311 |
312 | /*
313 | Tilt scrolling!
314 | */
315 | Sense.prototype.addTiltScroll = function(optns) {
316 | if (window.DeviceOrientationEvent) {
317 | var options = optns == null ? {
318 | maxHorizontalAngle: 80,
319 | maxHorizontalOffset: 100,
320 | maxHorizontalSpeed: 15,
321 | maxVerticalAngle: 40,
322 | maxVerticalOffset: 100,
323 | maxVerticalSpeed: 15
324 | } : optns,
325 | lastNormHAngle = 0,
326 | lastNormVAngle = 0;
327 |
328 | var horizontalFrameOffset = -options.maxHorizontalAngle/2,
329 | verticalFrameOffset = -options.maxVerticalAngle/2;
330 |
331 | window.addEventListener('deviceorientation', function(eventData){
332 | var hAngle = eventData.gamma,
333 | vAngle = -eventData.beta;
334 |
335 | if(hAngle < horizontalFrameOffset){
336 | horizontalFrameOffset = hAngle;
337 | }
338 |
339 | if(hAngle > horizontalFrameOffset + options.maxHorizontalAngle){
340 | horizontalFrameOffset = hAngle - options.maxHorizontalAngle;
341 | }
342 |
343 | if(vAngle < verticalFrameOffset){
344 | verticalFrameOffset = vAngle;
345 | }
346 |
347 | if(vAngle > verticalFrameOffset + options.maxVerticalAngle){
348 | verticalFrameOffset = vAngle - options.maxVerticalAngle;
349 | }
350 |
351 | var normalHAngle = (hAngle - horizontalFrameOffset) * 2 /options.maxHorizontalAngle - 1.0,
352 | normalVAngle = (vAngle - verticalFrameOffset) * 2 /options.maxVerticalAngle - 1.0,
353 | positionHDelta = (normalHAngle - lastNormHAngle) * options.maxHorizontalOffset,
354 | positionVDelta = (normalVAngle - lastNormVAngle) * options.maxVerticalOffset;
355 |
356 | if(lastNormHAngle != 0)
357 |
358 | lastNormHAngle = normalHAngle;
359 | lastNormVAngle = normalVAngle;
360 |
361 | var data = {
362 | scrollByX: clippingMap(normalHAngle) * options.maxHorizontalSpeed + positionHDelta,
363 | scrollByY: clippingMap(normalVAngle) * options.maxVerticalSpeed + positionVDelta
364 | };
365 |
366 | function clippingMap(num) {
367 | var quadraticWidth = .6,
368 | transition = 1.0 - quadraticWidth;
369 | if (Math.abs(num) < transition) return 0;
370 | if (num > 0) return Math.pow((num - transition) / quadraticWidth, 2);
371 | return -Math.pow((num + transition) / quadraticWidth, 2)
372 | }
373 | window.scrollBy(data.scrollByX, data.scrollByY);
374 | })
375 | }
376 | };
377 |
378 | window.sense = sense;
379 |
380 | }(window, document));
381 |
--------------------------------------------------------------------------------
/older_stuff_from_another_realm/1_battle.js:
--------------------------------------------------------------------------------
1 | // function trainerBattle(user, opponent) {
2 | // //set the two trainers participating in this battle
3 | // this.user = user;
4 | // this.opponent = opponent;
5 |
6 | // oppCounter = 0;
7 | // this.userPokemon = Meteor.call('getPokemonInParty')[0];
8 | // this.opponentPokemon = opponent.party[oppCounter];
9 |
10 | // while(!user.whiteout() && !opponent.whiteout()) {
11 | // while (userPokemon.status != 'fnt' && opponentPokemon.status != 'fnt') {
12 | // //prompt user for decision (fight, bag, switch), using janky pop-ups for now LOOL
13 | // var userDecision = prompt("fight, bag, or switch?");
14 | // if (userDecision != "fight" && userDecision != "bag" && userDecision != "switch") {
15 | // throw new Meteor.Error("You entered " + userDecision + ", which is an invalid choice");
16 | // }
17 |
18 | // //var opponentChoice = Math.floor(opponentPokemon.moves.length * Math.random());
19 | // var opponentChoice = 0; //temporary hacky fix
20 | // var opponentMove = opponentPokemon.moves[opponentChoice]; //select one of the opponent's moves at random
21 |
22 | // if (userDecision == 'switch') {
23 | // //get the new pokemon selected by the user, store as newPokemon
24 | // var newPokemonInt = prompt("enter a number from 1 to 6");
25 | // userPokemon = user.party[newPokemonInt];
26 |
27 | // normalizeStats(userPokemon); //method located in battleFunctions.js
28 | // userPokemon = newPokemon;
29 | // useMove(opponentPokemon, userPokemon, opponentMove); //method located in battleFunctions.js
30 | // }
31 | // else if (userDecision == 'bag') {
32 | // //get the item selection by the user, store as item
33 | // var item = prompt("enter the name of the item you want to use");
34 |
35 | // //check item.js
36 | // item.effect(userPokemon);
37 | // useMove(opponentPokemon, userPokemon, opponentMove);
38 | // }
39 |
40 | // else if (userDecision == 'fight') {
41 |
42 | // var userMove = prompt("type in the name of the move you want to use (capitalize the first letter):");
43 |
44 | // if (userPokemon.speed >= opponentPokemon.speed) {
45 | // useMove(userPokemon, opponentPokemon, userMove);
46 | // if (opponentPokemon.status != 'fnt') {
47 | // useMove(opponentPokemon, userPokemon, opponentMove);
48 | // }
49 | // }
50 |
51 | // else {
52 | // useMove(opponentPokemon, userPokemon, opponentMove);
53 | // if (userPokemon.status != 'fnt') {
54 | // useMove(userPokemon, opponentPokemon, userMove);
55 | // }
56 | // }
57 | // }
58 |
59 | // }
60 | // //when a pokemon faints, send out new pokemon
61 | // if (userPokemon.status == 'fnt') {
62 | // if (!user.whiteout()) {
63 | // //prompt for new pokemon, set to newPokemon
64 | // normalizeStats(userPokemon);
65 | // userPokemon = newPokemon;
66 | // }
67 | // }
68 |
69 | // //levelUp and evolve are located in experience.js
70 | // if (opponentPokemon.status == 'fnt') {
71 | // gainExperience('trainer', opponentPokemon, userPokemon);
72 | // //notify user of experience gained
73 | // if(userPokemon.level != levelUp(userPokemon)) {
74 | // //notify user of leveling up
75 | // userPokemon.level = levelUp(userPokemon);
76 | // }
77 | // if (userPokemon.Pokemon != evolve(userPokemon)) {
78 | // //notify user of evolving
79 | // userPokemon.Pokemon = evolve(userPokemon);
80 | // }
81 | // if (opponent.whiteout()) {
82 | // oppCounter += 1;
83 | // if (oppCounter <= opponent.party.length) {
84 | // opponentPokemon = opponent.party[oppCounter];
85 | // }
86 | // }
87 | // }
88 | // }
89 |
90 | // if (user.whiteout()) {
91 | // user.updateMoney(-user.money/2);
92 | // //console.log("NOOB ALERT");
93 | // return 'loss';
94 | // }
95 | // //if user wins, gain half of opponent's money
96 | // //assuming that the update money takes in the change as a parameter
97 | // if (opponent.whiteout()) {
98 | // user.updateMoney(opponent.money/2);
99 | // return 'win';
100 | // }
101 | // }
102 |
103 |
104 |
105 | // function wildBattle(user, wild) {
106 | // //set the two participating in this battle
107 | // this.user = user;
108 | // this.wild = wild;
109 |
110 | // //user.chooseStarter();
111 | // //var tempwild1 = {pokemon:'1', level: 3, moves: ['Tackle', 'Vine Whip'], attack: 45, defense: 45, spattack: 45, spdefense: 45, speed: 45, HP: 45, remainingHP:45, exp: 45, status: 'non', position: 0};
112 |
113 | // this.userPokemon = Meteor.call('getPokemonInParty')[0];
114 |
115 |
116 | // while(!user.whiteout() && wild.status != 'fnt') {
117 | // while (userPokemon.status != 'fnt' && opponentPokemon.status != 'fnt') {
118 | // //prompt user for decision (fight, bag, switch), using janky pop-ups for now LOOL
119 | // var userDecision = prompt("fight, bag, or switch?");
120 | // if (userDecision != "fight" && userDecision != "bag" && userDecision != "switch") {
121 | // throw new Meteor.Error("You entered " + userDecision + ", which is an invalid choice");
122 | // }
123 |
124 | // //var opponentChoice = Math.floor(opponentPokemon.moves.length * Math.random());
125 | // var opponentChoice = 0; //temporary hacky fix
126 | // var opponentMove = wild.moves[opponentChoice]; //select one of the opponent's moves at random
127 |
128 | // if (userDecision == 'switch') {
129 | // //get the new pokemon selected by the user, store as newPokemon
130 | // var newPokemonInt = prompt("enter a number from 0 to 5");
131 | // userPokemon = user.party[newPokemonInt];
132 |
133 | // normalizeStats(userPokemon); //method located in battleFunctions.js
134 | // userPokemon = newPokemon;
135 | // useMove(wild, userPokemon, opponentMove); //method located in battleFunctions.js
136 | // }
137 | // else if (userDecision == 'bag') {
138 | // //get the item selection by the user, store as item
139 | // var item = prompt("enter the name of the item you want to use");
140 |
141 | // //check item.js
142 | // item.effect(userPokemon);
143 | // useMove(wild, userPokemon, opponentMove);
144 | // }
145 |
146 | // else if (userDecision == 'fight') {
147 |
148 | // var userMove = prompt("type in the name of the move you want to use (capitalize the first letter):");
149 |
150 | // if (userPokemon.speed >= wild.speed) {
151 | // useMove(userPokemon, wild, userMove);
152 | // if (wild.status != 'fnt') {
153 | // useMove(wild, userPokemon, opponentMove);
154 | // }
155 | // }
156 |
157 | // else {
158 | // useMove(wild, userPokemon, opponentMove);
159 | // if (userPokemon.status != 'fnt') {
160 | // useMove(userPokemon, wild, userMove);
161 | // }
162 | // }
163 | // }
164 |
165 | // }
166 | // //when your pokemon faints, send out new pokemon
167 | // if (userPokemon.status == 'fnt') {
168 | // if (!user.whiteout()) {
169 | // //prompt for new pokemon, set to newPokemon
170 | // normalizeStats(userPokemon);
171 | // userPokemon = newPokemon;
172 | // }
173 | // }
174 |
175 | // //levelUp and evolve are located in experience.js
176 | // if (wild.status == 'fnt') {
177 | // gainExperience('trainer', opponentPokemon, userPokemon);
178 | // //notify user of experience gained
179 | // if(userPokemon.level != levelUp(userPokemon)) {
180 | // //notify user of leveling up
181 | // userPokemon.level = levelUp(userPokemon);
182 | // }
183 | // if (userPokemon.Pokemon != evolve(userPokemon)) {
184 | // //notify user of evolving
185 | // userPokemon.Pokemon = evolve(userPokemon);
186 | // }
187 | // return 'win';
188 | // }
189 | // }
190 |
191 | // if (user.whiteout()) {
192 | // //user.updateMoney(-user.money/2);
193 | // //console.log("NOOB ALERT");
194 | // return 'loss';
195 | // }
196 | // // //if user wins, gain half of opponent's money
197 | // // //assuming that the update money takes in the change as a parameter
198 | // // if (opponent.whiteout()) {
199 | // // user.updateMoney(opponent.money/2);
200 | // // return user;
201 | // // }
202 | // }
203 | console.log("here");
204 |
205 | battle = function(user, opponent) {
206 | this.user = user;
207 |
208 | this.party = user.party;
209 | this.userpokemon = this.party[0];
210 | this.wild = opponent;
211 | this.wildmoves = opponent.moves;
212 | this.faster = (this.userpokemon.speed >= opponent.speed);
213 | changeTrainerPokemon( pokemonInfo[this.userpokemon.pokemon-1].pokemon[ 0 ].Pokemon, this.userpokemon.remainingHP, this.userpokemon.HP, this.userpokemon.level );
214 | changeOpponentPokemon( pokemonInfo[this.wild.pokemon-1].pokemon[ 0 ].Pokemon, this.wild.remainingHP, this.wild.HP, this.wild.level );
215 | }
216 |
217 | battle.prototype.usePokeball = function(balltype) {
218 | var catchPoke = checkCatch(balltype, opponent);
219 | if (catchPoke) {
220 | catchPokemon(this.wild);
221 | //notify user that pokeball succeeded
222 | this.endBattle();
223 | }
224 | else {
225 | //notify user that pokeball failed
226 | }
227 | //decrement pokeball count
228 | return catchPoke;
229 | }
230 |
231 | battle.prototype.useAttack = function(move) {
232 | //useMove(this.userpokemon, this.wild, move);
233 | if (this.user.speed >= this.wild.speed) {
234 | var rHP = useMove(this.userpokemon, this.wild, move);
235 | attackTrainerPokemon(rHP,this.userpokemon.HP);
236 | console.log(rHP);
237 | if (rHP <= 0)
238 | {
239 | console.log("hi");
240 | $('#menu-left').hide();
241 | $('#menu-right').hide();
242 | $("#menu-message").show();
243 | $("#menu-message").html("You won!");
244 | setTimeout(function() {
245 | $("#menu-message").hide();
246 | $('#menu-left').show();
247 | $('#menu-right').show();
248 | $('#battle-content').hide();
249 | $('canvas').show();
250 | }, 2000);
251 | return;
252 | }
253 | this.getAttacked();
254 | }
255 | else {
256 | console.log("else");
257 | var rHP = this.getAttacked();
258 | if (rHP <= 0)
259 | {
260 | $('#menu-left').hide();
261 | $('#menu-right').hide();
262 | $("#menu-message").show();
263 | $("#menu-message").html("You won!");
264 | setTimeout(function() {
265 | $("#menu-message").hide();
266 | $('#menu-left').show();
267 | $('#menu-right').show();
268 | $('#battle-content').hide();
269 | $('canvas').show();
270 | $('audio#intro')[0].play();
271 | $('audio#battle')[0].pause();
272 | }, 2000);
273 | return;
274 | }
275 | var rHP = useMove(this.userpokemon, this.wild, move);
276 | attackTrainerPokemon(rHP,this.userpokemon.HP);
277 | if (rHP <= 0)
278 | {
279 | return;
280 | }
281 | }
282 | }
283 |
284 | battle.prototype.runAway = function() {
285 |
286 | }
287 |
288 | battle.prototype.getAttacked = function() {
289 | var rHP = useMove(this.wild, this.userpokemon, this.wildmoves[0]);
290 | attackOpponentPokemon(rHP,this.wild.HP);
291 | if (rHP <= 0)
292 | {
293 | return rHP;
294 | }
295 | }
296 |
297 | battle.prototype.useItem = function(item) {
298 | effect(this.userpokemon, item);
299 | this.getAttacked();
300 | }
301 |
302 | battle.prototype.changePokemon = function(next) {
303 | if (this.party[next] == this.userpokemon) {
304 | //throw new Meteor.Error("this pokemon is already in battle");
305 | }
306 | else {
307 | this.userpokemon = this.party[next];
308 | }
309 | this.getAttacked();
310 | }
311 |
312 |
313 | battle.prototype.endBattle = function() {
314 | if (this.wild.status == 'fnt' || this.user.whiteout()) {
315 | for (var i = 0; i < this.party.length; i++) {
316 | var rHP = this.party[i].remainingHP;
317 | //save stuff to database;
318 | }
319 | return true;
320 | }
321 | return false;
322 | }
323 |
--------------------------------------------------------------------------------
/Document.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
12 |
13 |
14 | 
.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

.gif)

15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/main.js:
--------------------------------------------------------------------------------
1 | /*
2 | global: POKEDEX
3 | global: TYPES
4 | global: EXP_TABLE
5 | global: ROUTES
6 | global: EVOLUTIONS
7 | */
8 | 'use strict'
9 |
10 | const pokeById = (id) => POKEDEX[id - 1]
11 | const pokeByName = (name) => POKEDEX.filter((el) => el.pokemon[0].Pokemon === name)[0]
12 |
13 | const EXP_TABLE = {}
14 | EXP_TABLE["Slow"] = [1, 2, 10, 33, 80, 156, 270, 428, 640, 911, 1250, 1663, 2160, 2746, 3430, 4218, 5120, 6141, 7290, 8573, 10000, 11576, 13310, 15208, 17280, 19531, 21970, 24603, 27440, 30486, 33750, 37238, 40960, 44921, 49130, 53593, 58320, 63316, 68590, 74148, 80000, 86151, 92610, 99383, 106480, 113906, 121670, 129778, 138240, 147061, 156250, 165813, 175760, 186096, 196830, 207968, 219520, 231491, 243890, 256723, 270000, 283726, 297910, 312558, 327680, 343281, 359370, 375953, 393040, 410636, 428750, 447388, 466560, 486271, 506530, 527343, 548720, 570666, 593190, 616298, 640000, 664301, 689210, 714733, 740880, 767656, 795070, 823128, 851840, 881211, 911250, 941963, 973360, 1005446, 1038230, 1071718, 1105920, 1140841, 1176490, 1212873, 1250000, 999999999999999999]
15 | EXP_TABLE["Medium Slow"] = [1, -53, 9, 57, 96, 135, 179, 236, 314, 419, 560, 742, 973, 1261, 1612, 2035, 2535, 3120, 3798, 4575, 5460, 6458, 7577, 8825, 10208, 11735, 13411, 15244, 17242, 19411, 21760, 24294, 27021, 29949, 33084, 36435, 40007, 43808, 47846, 52127, 56660, 61450, 66505, 71833, 77440, 83335, 89523, 96012, 102810, 109923, 117360, 125126, 133229, 141677, 150476, 159635, 169159, 179056, 189334, 199999, 211060, 222522, 234393, 246681, 259392, 272535, 286115, 300140, 314618, 329555, 344960, 360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260, 547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160, 789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860, 999999999999999999]
16 | EXP_TABLE["Medium Fast"] = [1, 2, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261, 10648, 12167, 13824, 15625, 17576, 19683, 21952, 24389, 27000, 29791, 32768, 35937, 39304, 42875, 46656, 50653, 54872, 59319, 64000, 68921, 74088, 79507, 85184, 91125, 97336, 103823, 110592, 117649, 125000, 132651, 140608, 148877, 157464, 166375, 175616, 185193, 195112, 205379, 216000, 226981, 238328, 250047, 262144, 274625, 287496, 300763, 314432, 328509, 343000, 357911, 373248, 389017, 405224, 421875, 438976, 456533, 474552, 493039, 512000, 531441, 551368, 571787, 592704, 614125, 636056, 658503, 681472, 704969, 729000, 753571, 778688, 804357, 830584, 857375, 884736, 912673, 941192, 970299, 1000000, 999999999999999999]
17 | EXP_TABLE["Fast"] = [1, 2, 6, 21, 51, 100, 172, 274, 409, 583, 800, 1064, 1382, 1757, 2195, 2700, 3276, 3930, 4665, 5487, 6400, 7408, 8518, 9733, 11059, 12500, 14060, 15746, 17561, 19511, 21600, 23832, 26214, 28749, 31443, 34300, 37324, 40522, 43897, 47455, 51200, 55136, 59270, 63605, 68147, 72900, 77868, 83058, 88473, 94119, 100000, 106120, 112486, 119101, 125971, 133100, 140492, 148154, 156089, 164303, 172800, 181584, 190662, 200037, 209715, 219700, 229996, 240610, 251545, 262807, 274400, 286328, 298598, 311213, 324179, 337500, 351180, 365226, 379641, 394431, 409600, 425152, 441094, 457429, 474163, 491300, 508844, 526802, 545177, 563975, 583200, 602856, 622950, 643485, 664467, 685900, 707788, 730138, 752953, 776239, 800000, 999999999999999999]
18 |
19 | var currentRouteId = 'starter'
20 | const ROUTES = {
21 | starter: {
22 | name: 'Starter Area'
23 | , pokes: ['Caterpie', 'Weedle']
24 | , minLevel: 2
25 | , maxLevel: 4
26 | , unlocked: true
27 | }
28 | , starter2: {
29 | name: 'Starter Area 2'
30 | , pokes: ['Rattata', 'Pidgey', 'Spearow']
31 | , minLevel: 5
32 | , maxLevel: 10
33 | , unlocked: true
34 | }
35 | , cavern1: {
36 | name: 'Cavern'
37 | , pokes: ['Zubat', 'Diglett', 'Machop', 'Abra']
38 | , minLevel: 8
39 | , maxLevel: 16
40 | , unlocked: true
41 | }
42 | , rock_arena: {
43 | name: 'Rock Arena'
44 | , pokes: ['Geodude', 'Onix']
45 | , minLevel: 20
46 | , maxLevel: 30
47 | , unlocked: true
48 | }
49 | , fields: {
50 | name: 'Fields'
51 | , pokes: ['Sandshrew', 'Nidoran f', 'Nidoran m', 'Venonat', 'Vulpix']
52 | , minLevel: 25
53 | , maxLevel: 40
54 | , unlocked: true
55 | }
56 | , toxic_area: {
57 | name: 'Toxic Area'
58 | , pokes: ['Grimer', 'Koffing']
59 | , minLevel: 25
60 | , maxLevel: 40
61 | , unlocked: true
62 | }
63 | , water_arena: {
64 | name: 'Water Arena'
65 | , pokes: ['Goldeen', 'Staryu', 'Shellder', 'Horsea', 'Seel']
66 | , minLevel: 35
67 | , maxLevel: 50
68 | , unlocked: true
69 | }
70 | , fields2: {
71 | name: 'Fields 2'
72 | , pokes: ['Mankey', 'Psyduck', 'Meowth', 'Ekans', 'Paras']
73 | , minLevel: 40
74 | , maxLevel: 55
75 | , unlocked: true
76 | }
77 | , thunder_arena: {
78 | name: 'Thunder Arena'
79 | , pokes: ['Pikachu', 'Magnemite', 'Voltorb']
80 | , minLevel: 50
81 | , maxLevel: 65
82 | , unlocked: true
83 | }
84 | , mtmoon: {
85 | name: 'Mt. Moon'
86 | , pokes: ['Jigglypuff', 'Voltorb', 'Porygon', 'Slowpoke']
87 | , minLevel: 60
88 | , maxLevel: 70
89 | , unlocked: true
90 | }
91 | , fields3: {
92 | name: 'Fields 3'
93 | , pokes: ['Growlithe', 'Drowzee', 'Cubone', 'Rhyhorn', 'Ponyta']
94 | , minLevel: 65
95 | , maxLevel: 75
96 | , unlocked: true
97 | }
98 | , scareland: {
99 | name: 'Scareland'
100 | , pokes: ['Gastly', 'Jynx', 'Mr. Mime']
101 | , minLevel: 75
102 | , maxLevel: 80
103 | , unlocked: true
104 | }
105 | , fields4: {
106 | name: 'Fields 4'
107 | , pokes: ['Hitmonlee', 'Hitmonchan', 'Lickitung', 'Snorlax', 'Dratini']
108 | , minLevel: 80
109 | , maxLevel: 85
110 | , unlocked: true
111 | }
112 | , fields5: {
113 | name: 'Fields 5'
114 | , pokes: ['Tangela', 'Scyther', 'Electabuzz', 'Pinsir', 'Omanyte', 'Kabuto', 'Aerodactyl']
115 | , minLevel: 85
116 | , maxLevel: 90
117 | , unlocked: true
118 | }
119 | , birds: {
120 | name: 'Birds'
121 | , pokes: ['Articuno', 'Zapdos', 'Moltres']
122 | , minLevel: 90
123 | , maxLevel: 99
124 | , unlocked: true
125 | }
126 | , god: {
127 | name: 'God'
128 | , pokes: ['Mew']
129 | , minLevel: 99
130 | , maxLevel: 99
131 | , unlocked: true
132 | }
133 | }
134 |
135 | const RNG = (func, chance) => {
136 | const rnd = Math.random() * 100
137 | if (rnd < chance) {
138 | func()
139 | return true
140 | }
141 | return false
142 | }
143 |
144 | const cloneJsonObject = (object) => JSON.parse(JSON.stringify(object))
145 | const randomArrayElement = (array) => array[Math.floor(Math.random() * array.length)]
146 |
147 | const makeDomHandler = () => {
148 | const domQuery = (cssQuery) => document.querySelector(cssQuery)
149 | const $ = domQuery
150 | const setValue = (domElement, newValue, append) => {
151 | if (append === undefined) { append = false }
152 | if (append) {
153 | domElement.innerHTML += newValue
154 | }
155 | if (!append) {
156 | if (domElement.innerHTML !== newValue) {
157 | domElement.innerHTML = newValue
158 | }
159 | }
160 | }
161 | const getValue = (domElement) => {
162 | return domElement.innerHTML
163 | }
164 | const setProp = (domElement, attribute, newValue) => {
165 | if (domElement[attribute] !== newValue) {
166 | domElement[attribute] = newValue
167 | }
168 | }
169 | const renderPokeOnContainer = (id, poke, face) => {
170 | face = face || 'front'
171 | const pokeStatusAsText = (poke) => {
172 | var output = ''
173 | output += 'Attack Speed: ' + poke.attackSpeed()/1000 + '
'
174 | output += '\nAttack: ' + poke.allCombat().attack() + '
'
175 | output += '\nDefense: ' + poke.allCombat().defense() + '
'
176 | return output
177 | }
178 | const containerCssQuery = '.container.poke' + '#' + id
179 | const container = $(containerCssQuery)
180 | const domElements = {
181 | name: container.querySelector('.name')
182 | , img: container.querySelector('.img')
183 | , hp: container.querySelector('.hp')
184 | , hpBar: container.querySelector('.hpBar')
185 | , expBar: container.querySelector('.expBar')
186 | , status: container.querySelector('.status')
187 | }
188 | setValue(domElements.name, poke.pokeName() + ' (' + poke.level() + ')')
189 | setProp(domElements.img, 'src', poke.image()[face])
190 | setValue(domElements.hp, poke.lifeAsText())
191 | setProp(domElements.hpBar, 'value', poke.life.current())
192 | setProp(domElements.hpBar, 'max', poke.life.max())
193 | setProp(domElements.expBar, 'value', Math.floor(poke.currentExp() - poke.thisLevelExp()))
194 | setProp(domElements.expBar, 'max', poke.nextLevelExp() - poke.thisLevelExp())
195 | setValue(domElements.status, pokeStatusAsText(poke))
196 | }
197 | const healElement = $('#heal')
198 | const renderHeal = (canHeal) => {
199 | if (canHeal === true) {
200 | setProp(healElement, 'disabled', false)
201 | setValue(healElement, 'Heal!')
202 | }
203 | if (typeof canHeal === 'number') {
204 | setProp(healElement, 'disabled', true)
205 | setValue(healElement, 'Heal: ' + Math.floor(((canHeal/30000)*100)) + '%')
206 | }
207 | }
208 | const renderPokeList = (id, list, player, deleteEnabledId) => {
209 | const listCssQuery = '.container.list' + '#' + id
210 | const listContainer = $(listCssQuery)
211 | const listElement = listContainer.querySelector('.list')
212 | setValue(listElement, '')
213 | const deleteEnabled = deleteEnabledId && $(deleteEnabledId).checked
214 | list.forEach((poke, index) => {
215 | setValue(
216 | listElement
217 | , `
218 |
228 | X
229 |
230 |
248 | ${poke.pokeName()} (${poke.level()})
249 |
250 | `
251 | , true
252 | )
253 | })
254 | }
255 | const renderRouteList = (id, routes) => {
256 | const listCssQuery = '.container.list' + '#' + id
257 | const listContainer = $(listCssQuery)
258 | const listElement = listContainer.querySelector('.list')
259 | setValue(listElement, '')
260 | Object.keys(routes).forEach((routeId) => {
261 | const route = routes[routeId]
262 | setValue(
263 | listElement
264 | , `
265 |
285 | ${route.name + ' (' + route.minLevel + '~' + route.maxLevel + ')'}
286 |
287 | `
288 | , true
289 | )
290 | })
291 | }
292 | const checkConfirmed = (id) => {
293 | return $(id).checked
294 | }
295 | const attackAnimation = (id, direction) => {
296 | const toAnimate = $('#' + id)
297 | toAnimate.classList = 'img attacked-' + direction
298 | window.setTimeout(() => toAnimate.classList = 'img', 80)
299 | }
300 | const gameConsoleLog = (text, color) => {
301 | const logElement = $('#console .console-text')
302 | if ($('#enableConsole').checked) {
303 | if (color) {
304 | logElement.innerHTML = '' + text + '' + '
' + logElement.innerHTML
305 | } else {
306 | logElement.innerHTML = text + '
' + logElement.innerHTML
307 | }
308 | }
309 | const logAsArray = logElement.innerHTML.split('
')
310 | if (logAsArray.length >= 100) {
311 | logAsArray.splice(logAsArray.length - 1, 1)
312 | logElement.innerHTML = logAsArray.join('
')
313 | }
314 | }
315 | const gameConsoleClear = () => {
316 | $('#console .console-text').innerHTML = ''
317 | }
318 | const renderBalls = (ballsAmmount) => {
319 | Object.keys(ballsAmmount).forEach(ballType => {
320 | $('.ball-ammount.' + ballType).innerHTML = ballsAmmount[ballType]
321 | })
322 | }
323 | const bindEvents = () => {
324 | $('#heal').addEventListener( 'click'
325 | , () => { userInteractions.healAllPlayerPokemons() }
326 | )
327 |
328 | $('#enableDelete').addEventListener( 'click'
329 | , () => { userInteractions.enablePokeListDelete() }
330 | )
331 |
332 | $(`#enableCatch`).addEventListener( 'click'
333 | , () => { userInteractions.changeCatchOption($(`#enableCatch`).checked) }
334 | )
335 |
336 | }
337 | bindEvents()
338 | return {
339 | renderPokeOnContainer: renderPokeOnContainer
340 | , renderPokeList: renderPokeList
341 | , renderRouteList: renderRouteList
342 | , renderHeal: renderHeal
343 | , attackAnimation: attackAnimation
344 | , checkConfirmed: checkConfirmed
345 | , gameConsoleLog: gameConsoleLog
346 | , gameConsoleClear: gameConsoleClear
347 | , renderBalls: renderBalls
348 | }
349 | }
350 |
351 | const makePoke = (pokeModel, initialLevel, initialExp) => {
352 | var poke = cloneJsonObject(pokeModel)
353 | const expTable = EXP_TABLE[poke.stats[0]["growth rate"]]
354 | var exp = initialLevel
355 | && expTable[initialLevel - 1]
356 | || initialExp
357 | const currentLevel = () => {
358 | return expTable
359 | .filter((xp_requirement) => xp_requirement <= exp)
360 | .length
361 |
362 | }
363 | const statValue = (raw) => {
364 | return Math.floor((((raw + 50) * currentLevel()) / (150)))
365 | }
366 | const hp = (rawHp) => {
367 | return Math.floor(((rawHp * currentLevel()) / 40))
368 | }
369 | const tryEvolve = () => {
370 | const pokemonHasEvolution =
371 | EVOLUTIONS[poke.pokemon[0].Pokemon] !== undefined
372 | if (pokemonHasEvolution) {
373 | const evolution = EVOLUTIONS[poke.pokemon[0].Pokemon].to
374 | const levelToEvolve = Number(EVOLUTIONS[poke.pokemon[0].Pokemon].level)
375 | if (currentLevel() >= levelToEvolve) {
376 | poke = cloneJsonObject(pokeByName(evolution))
377 | }
378 | }
379 | }
380 | const combat = {
381 | mutable: {
382 | hp: hp(poke.stats[0].hp) * 3
383 | }
384 | , maxHp: () => hp(poke.stats[0].hp) * 3
385 | , attack: () => statValue(poke.stats[0].attack)
386 | , defense: () => statValue(poke.stats[0].defense)
387 | , spAttack: () => statValue(poke.stats[0]['sp atk'])
388 | , spDefense: () => statValue(poke.stats[0]['sp def'])
389 | , speed: () => statValue(poke.stats[0].speed)
390 | }
391 | const poke_interface = {
392 | pokeName: () => poke.pokemon[0].Pokemon
393 | , image: () => {
394 | return {
395 | front: poke.images.front
396 | , back: poke.images.back
397 | }
398 | }
399 | , type: () => poke.stats[0].types.text
400 | , lifeAsText: () => '' + combat.mutable.hp + ' / ' + combat.maxHp()
401 | , life: {
402 | current: () => combat.mutable.hp
403 | , max: () => combat.maxHp()
404 | }
405 | , alive: () => combat.mutable.hp > 0
406 | , giveExp: (ammount) => {
407 | exp += ammount
408 | tryEvolve()
409 | }
410 | , currentExp: () => exp
411 | , nextLevelExp: () => expTable[currentLevel()]
412 | , thisLevelExp: () => expTable[currentLevel() - 1] || 10
413 | , level: () => currentLevel()
414 | , attackSpeed: () => {
415 | const speed = Math.floor(1000 / (500 + combat.speed()) * 800)
416 | if (speed <= 300) {
417 | return 300
418 | } else {
419 | return speed
420 | }
421 | }
422 | , attack: () => combat.attack()
423 | , takeDamage: (enemyAttack) => {
424 | const damageToTake = (enemyAttack - combat.defense() / 10) > 0
425 | && Math.ceil((enemyAttack - combat.defense()/10) * (Math.random() * 2) / 100)
426 | || 0
427 | combat.mutable.hp -= damageToTake
428 | return damageToTake
429 | }
430 | , baseExp: () => Number(poke.exp[0]['base exp'])
431 | , heal: () => combat.mutable.hp = combat.maxHp()
432 | , allCombat: () => combat
433 | , save: () => [poke.pokemon[0].Pokemon, exp]
434 | }
435 | return poke_interface
436 | }
437 | const makeRandomPoke = (level) => makePoke(randomArrayElement(POKEDEX), level)
438 |
439 | const makePlayer = () => {
440 | var pokemons = []
441 | var activePoke = 0
442 | var lastHeal = Date.now()
443 |
444 | const ballsRngs = {
445 | pokeball: 1,
446 | greatball: 4,
447 | ultraball: 10
448 | }
449 | var selectedBall = "pokeball"
450 | var ballsAmmount = {
451 | pokeball: 20,
452 | greatball: 0,
453 | ultraball: 0
454 | }
455 |
456 | const canHeal = () => {
457 | if ((Date.now() - lastHeal) > 30000) {
458 | return true
459 | }
460 | else {
461 | return Date.now() - lastHeal
462 | }
463 | }
464 | const player_interface = {
465 | addPoke: (poke) => {
466 | // const playerEqualPokes = pokemons.filter((playerPoke) => (playerPoke.pokeName() === poke.pokeName()))
467 | // if (playerEqualPokes.length === 0) {
468 | // pokemons.push(poke)
469 | // }
470 | // if (playerEqualPokes.length !== 0) {
471 | // if (poke.level() > playerEqualPokes[0].level()) {
472 | // pokemons.splice(pokemons.indexOf(playerEqualPokes[0]), 1)
473 | // pokemons.push(poke)
474 | // }
475 | // }
476 | pokemons.push(poke)
477 | }
478 | , setActive: (index) => {
479 | activePoke = index
480 | }
481 | , activePoke: () => pokemons[activePoke]
482 | , pokemons: () => pokemons
483 | , canHeal: canHeal
484 | , healAllPokemons: () => {
485 | if (canHeal() === true) {
486 | pokemons.forEach((poke) => poke.heal())
487 | lastHeal = Date.now()
488 | return "healed"
489 | }
490 | return canHeal()
491 | }
492 | , deletePoke: (index) => {
493 | if (index !== activePoke) {
494 | pokemons.splice(index, 1)
495 | if (index < activePoke) {
496 | activePoke -= 1
497 | }
498 | }
499 | }
500 | , savePokes: () => {
501 | localStorage.setItem(`totalPokes`, pokemons.length)
502 | pokemons.forEach((poke, index) => {
503 | localStorage.setItem(`poke${index}`, JSON.stringify(poke.save()))
504 | })
505 | localStorage.setItem(`ballsAmmount`, JSON.stringify(ballsAmmount))
506 | }
507 | , loadPokes: () => {
508 | Array(Number(localStorage.getItem(`totalPokes`))).fill(0).forEach((el, index) => {
509 | const pokeName = JSON.parse(localStorage.getItem('poke'+index))[0]
510 | const exp = JSON.parse(localStorage.getItem('poke'+index))[1]
511 | pokemons.push(makePoke(pokeByName(pokeName), false, Number(exp)))
512 | })
513 | if (JSON.parse(localStorage.getItem('ballsAmmount'))) {
514 | ballsAmmount = JSON.parse(localStorage.getItem('ballsAmmount'))
515 | }
516 |
517 | }
518 | , selectedBallRNG: () => {
519 | return ballsRngs[selectedBall]
520 | }
521 | , changeSelectedBall: (newBall) => {
522 | selectedBall = newBall
523 | }
524 | , consumeBall: (ballName) => {
525 | if (ballsAmmount[ballName] > 0) {
526 | ballsAmmount[ballName] -= 1
527 | return true
528 | }
529 | return false
530 | }
531 | , selectedBall: () => selectedBall
532 | , ballsAmmount: () => ballsAmmount
533 | , addBalls: (ballName, ammount) => {
534 | ballsAmmount[ballName] += ammount
535 | }
536 | }
537 | return player_interface
538 | }
539 |
540 | const makeEnemy = (starter) => {
541 | var active = starter
542 |
543 | const generateNew = (recipe) => {
544 | const poke = pokeByName(randomArrayElement(recipe.pokes))
545 | return makePoke(poke, recipe.minLevel + Math.round((Math.random() * (recipe.maxLevel - recipe.minLevel))))
546 | }
547 |
548 | return {
549 | activePoke: () => active,
550 | generateNew: (recipe) => active = generateNew(recipe)
551 | }
552 | }
553 |
554 | const makeUserInteractions = (player, enemy, dom, combatLoop) => {
555 | return {
556 | changePokemon: (newActiveIndex) => {
557 | player.setActive(newActiveIndex)
558 | combatLoop.changePlayerPoke(player.activePoke())
559 | renderView(dom, enemy, player)
560 | },
561 | deletePokemon: (index) => {
562 | player.deletePoke(index)
563 | combatLoop.changePlayerPoke(player.activePoke())
564 | renderView(dom, enemy, player)
565 | player.savePokes()
566 | },
567 | healAllPlayerPokemons: () => {
568 | if (player.healAllPokemons() === "healed") {
569 | dom.gameConsoleLog('Full heal!', 'white')
570 | combatLoop.refresh()
571 | renderView(dom, enemy, player)
572 | }
573 | },
574 | changeRoute: (newRouteId) => {
575 | currentRouteId = newRouteId
576 | enemy.generateNew(ROUTES[newRouteId])
577 | combatLoop.changeEnemyPoke(enemy.activePoke())
578 | renderView(dom, enemy, player)
579 | player.savePokes()
580 | dom.renderRouteList('areasList', ROUTES)
581 | },
582 | enablePokeListDelete: () => {
583 | dom.renderPokeList('playerPokes', player.pokemons(), player, '#enableDelete')
584 | },
585 | changeCatchOption: (newCatchOption) => {
586 | combatLoop.changeCatch(newCatchOption)
587 | },
588 | clearGameData: () => {
589 | if (dom.checkConfirmed('#confirmClearData')) {
590 | localStorage.clear()
591 | window.location.reload(true)
592 | }
593 | },
594 | clearConsole: () => {
595 | dom.gameConsoleClear()
596 | },
597 | changeSelectedBall: (newBall) => {
598 | player.changeSelectedBall(newBall)
599 | }
600 | }
601 | }
602 |
603 | const makeCombatLoop = (enemy, player, dom) => {
604 | var playerActivePoke = player.activePoke()
605 | var enemyActivePoke = enemy.activePoke()
606 | var playerTimerId = null
607 | var enemyTimerId = null
608 | var catchEnabled = false
609 | const playerTimer = () => {
610 | playerTimerId = window.setTimeout(
611 | () => dealDamage(playerActivePoke, enemyActivePoke, 'player')
612 | , playerActivePoke.attackSpeed()
613 | )
614 | }
615 | const enemyTimer = () => {
616 | enemyTimerId = window.setTimeout(
617 | () => dealDamage(enemyActivePoke, playerActivePoke, 'enemy')
618 | , enemyActivePoke.attackSpeed()
619 | )
620 | }
621 | const dealDamage = (attacker, defender, who) => {
622 | if (attacker.alive() && defender.alive()) {
623 | // both alive
624 | const damageMultiplier = TYPES[attacker.type()][defender.type()]
625 | const damage = defender.takeDamage(attacker.attack() * damageMultiplier)
626 | if (who === 'player') {
627 | dom.attackAnimation('playerImg', 'right')
628 | dom.gameConsoleLog(attacker.pokeName() + ' Attacked for ' + damage, 'green')
629 | playerTimer()
630 | }
631 | if (who === 'enemy') {
632 | dom.attackAnimation('enemyImg', 'left')
633 | dom.gameConsoleLog(attacker.pokeName() + ' Attacked for ' + damage, 'rgb(207, 103, 59)')
634 | enemyTimer()
635 | }
636 |
637 | dom.renderPokeOnContainer('enemy', enemy.activePoke())
638 | dom.renderPokeOnContainer('player', player.activePoke(), 'back')
639 | }
640 | if (!attacker.alive() || !defender.alive()) {
641 | // one is dead
642 | window.clearTimeout(playerTimerId)
643 | window.clearTimeout(enemyTimerId)
644 |
645 | if ((who === 'enemy') && !attacker.alive()
646 | || (who === 'player') && !defender.alive())
647 | {
648 | //enemyActivePoke is dead
649 |
650 | if (catchEnabled) {
651 | dom.gameConsoleLog('Trying to catch ' + enemy.activePoke().pokeName() + '...', 'purple')
652 | if (player.consumeBall(player.selectedBall())) {
653 | dom.renderBalls(player.ballsAmmount())
654 | const rngHappened =
655 | RNG(
656 | player.addPoke.bind(null, enemy.activePoke())
657 | , player.selectedBallRNG()
658 | )
659 | if (rngHappened) {
660 | dom.gameConsoleLog('You caught ' + enemy.activePoke().pokeName() + '!!', 'purple')
661 | renderView(dom, enemy, player)
662 | } else {
663 | dom.gameConsoleLog(enemy.activePoke().pokeName() + ' escaped!!', 'purple')
664 | }
665 | }
666 | }
667 |
668 | const ballsAmmount = Math.floor(Math.random() * 10) + 1
669 | const ballName = randomArrayElement(['pokeball', 'pokeball', 'pokeball', 'pokeball', 'pokeball', 'pokeball', 'greatball', 'greatball', 'ultraball'])
670 | const rngHappened2 =
671 | RNG(
672 | player.addBalls.bind(
673 | null,
674 | ballName,
675 | ballsAmmount
676 | )
677 | , 10
678 | )
679 | if (rngHappened2) {
680 | dom.gameConsoleLog('You found ' + ballsAmmount + ' ' + ballName + 's!!', 'purple')
681 | dom.renderBalls(player.ballsAmmount())
682 | }
683 |
684 | const beforeExp = player.pokemons().map((poke) => poke.level())
685 | const expToGive = (enemyActivePoke.baseExp() / 16) + (enemyActivePoke.level() * 3)
686 | playerActivePoke.giveExp(expToGive)
687 | dom.gameConsoleLog(playerActivePoke.pokeName() + ' won ' + Math.floor(expToGive) + 'xp', 'rgb(153, 166, 11)')
688 | player.pokemons().forEach((poke) => poke.giveExp((enemyActivePoke.baseExp() / 100) + (enemyActivePoke.level() / 10)))
689 | const afterExp = player.pokemons().map((poke) => poke.level())
690 |
691 | if (beforeExp.join('') !== afterExp.join('')) {
692 | dom.renderPokeList('playerPokes', player.pokemons(), player, '#enableDelete')
693 | }
694 |
695 | player.savePokes()
696 | enemy.generateNew(ROUTES[currentRouteId])
697 | enemyActivePoke = enemy.activePoke()
698 | enemyTimer()
699 | playerTimer()
700 | dom.renderPokeOnContainer('player', player.activePoke(), 'back')
701 | } else {
702 | dom.gameConsoleLog(playerActivePoke.pokeName() + ' Fainted! ')
703 | const playerLivePokesIndexes = player.pokemons().filter((poke, index) => {
704 | if (poke.alive()) {
705 | return true
706 | }
707 | })
708 | if (playerLivePokesIndexes.length > 0) {
709 | player.setActive(player.pokemons().indexOf(playerLivePokesIndexes[0]))
710 | playerActivePoke = player.activePoke()
711 | dom.gameConsoleLog('Go ' + playerActivePoke.pokeName() + '!')
712 | refresh()
713 | }
714 | dom.renderPokeList('playerPokes', player.pokemons(), player, '#enableDelete')
715 | }
716 | dom.renderPokeOnContainer('enemy', enemy.activePoke())
717 | }
718 | }
719 | const init = () => {
720 | playerTimer()
721 | enemyTimer()
722 | }
723 | const stop = () => {
724 | window.clearTimeout(playerTimerId)
725 | window.clearTimeout(enemyTimerId)
726 | }
727 | const refresh = () => {
728 | stop()
729 | init()
730 | }
731 | return {
732 | init: init
733 | , stop: stop
734 | , changePlayerPoke: (newPoke) => {
735 | playerActivePoke = newPoke
736 | refresh()
737 | }
738 | , changeEnemyPoke: (newPoke) => {
739 | enemyActivePoke = newPoke
740 | refresh()
741 | }
742 | , refresh: refresh
743 | , changeCatch: (shouldCatch) => catchEnabled = shouldCatch
744 | }
745 | }
746 |
747 | const renderView = (dom, enemy, player) => {
748 | dom.renderPokeOnContainer('enemy', enemy.activePoke())
749 | dom.renderPokeOnContainer('player', player.activePoke(), 'back')
750 | dom.renderPokeList('playerPokes', player.pokemons(), player, '#enableDelete')
751 | }
752 |
753 |
754 | // main
755 |
756 | const enemy = makeEnemy()
757 | enemy.generateNew(ROUTES[currentRouteId])
758 |
759 | const player = makePlayer()
760 | if (localStorage.getItem(`totalPokes`) !== null) {
761 | player.loadPokes()
762 | } else {
763 | player.addPoke(makePoke(pokeById(randomArrayElement([1, 4, 7])), 5))
764 | }
765 |
766 | const dom = makeDomHandler()
767 | dom.renderRouteList('areasList', ROUTES)
768 | dom.renderBalls(player.ballsAmmount())
769 | const combatLoop = makeCombatLoop(enemy, player, dom)
770 | const userInteractions = makeUserInteractions(player, enemy, dom, combatLoop)
771 |
772 | renderView(dom, enemy, player)
773 |
774 | combatLoop.init()
775 |
776 | requestAnimationFrame(function renderTime() {
777 | dom.renderHeal(player.canHeal())
778 | requestAnimationFrame(renderTime)
779 | })
780 |
--------------------------------------------------------------------------------