forked from Ishadijcks/Ishadijcks.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oak.js
256 lines (222 loc) · 7.99 KB
/
oak.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
var lastNumberOfPokemon = 0;
var oakItemList = [];
var oakExplainEvolution = function(){
if(!player.evoExplain){
html = "";
html += "<div class='row'><img class='oakImage' src='images/oak/oak.png'</div>";
html += "<div class='row'><p class='oakText'>One of your Pokemon has evolved.<br>When a Pokemon evolves, you capture its evolution, while still keeping the original Pokemon.</p>"
html += "<img class='oakImage' id='evolutionImage' src=images/oak/"+player.starter+"Evolution.png>";
$("#oakBody").html(html);
$("#oakModal").modal('show')
player.evoExplain = 1;
}
}
var oakExplainMap = function(){
if(!player.mapExplain){
html = "";
html += "<div class='row'><img class='oakImage' src='images/oak/oak.png'</div>";
html += "<div class='row'><p class='oakText'>You have defeated enough Pokemon on this route, you can now advance to the next route by clicking on the map.</p>";
html += "<img class='oakImage' src=images/oak/mapExplain.png>";
$("#oakBody").html(html);
$("#oakModal").modal('show')
player.mapExplain = 1;
}
}
var oakExplainTown = function(){
if(!player.townExplain){
html = "";
html += "<div class='row'><img class='oakImage' src='images/oak/oak.png'</div>";
html += "<div class='row'><p class='oakText'>Visit towns to challenge the gym leaders!</p>";
html += "<img class='oakImage' src=images/oak/townExplain.png>";
$("#oakBody").html(html);
$("#oakModal").modal('show')
player.townExplain = 1;
}
}
var oakExplainDungeons = function(){
if(!player.dungeonExplain){
html = "";
html += "<div class='row'><img class='oakImage' src='images/oak/oak.png'</div>";
html += "<div class='row'><p class='oakText'>Move around in the dungeon to explore all the rooms!<br>You complete the dungeon when you have defeated the boss Pokemon!<br>You can click, use WASD or use the arrow keys to navigate in the dungeon.</p>";
html += "<img class='oakImage' src=images/oak/dungeonExplain.png>";
$("#oakBody").html(html);
$("#oakModal").modal('show')
player.dungeonExplain = 1;
}
}
var oakExplainAgain = function () {
if(player.mapExplain || player.townExplain || player.dungeonExplain) {
var html = "<div class='row'><img class='oakImage' src='images/oak/oak.png'</div>";
html +="<div class='row' style='padding-top:20px'>";
html +="<div class='col-sm-offset-4'>";
if (player.mapExplain) {
html += "<button class='leftTownButton btn btn-primary col-sm-2' id='map_tutorial'>Maps</button>";
//html += "</div><div class='row'>";
}
if (player.townExplain) {
html += "<button class='leftTownButton btn btn-primary col-sm-2' id='town_tutorial'>Towns</button>";
//html += "</div><div class='row'>";
}
if (player.dungeonExplain) {
html += "<button class='leftTownButton btn btn-primary col-sm-2' id='dungeon_tutorial'>Dungeons</button>";
//html += "</div><div class='row'>";
}
html += "</div>";
html += "</div>";
$("#tutorialBody").html(html);
$("#tutorialModal").modal('show');
$("#map_tutorial").on("click", function(){
console.log("Hi");
player.mapExplain = 0;
$('#tutorialModal').modal('hide');
oakExplainMap();
});
$("#dungeon_tutorial").click(function () {
player.dungeonExplain = 0;
$('#tutorialModal').modal('hide');
oakExplainDungeons();
});
$("#town_tutorial").click(function () {
player.townExplain = 0;
$('#tutorialModal').modal('hide');
oakExplainTown();
});
}
};
var addOakItem = function(name, image, pokedexReq, flavorText, value){
var temp = {
name: name,
image: image,
earned: 0,
active: 0,
pokedexReq: pokedexReq,
flavorText: flavorText,
value: value
}
if(!alreadyOakItem(temp.name)){
oakItemList.push(temp);
}
}
var checkOakItems = function(suppresnotify){
if(player.oakItemSlots == 1 && player.caughtPokemonList.length > 60){
player.oakItemSlots = 2;
$.notify("You can now have 2 Oak items active at the same time!");
}
for( var i = 0; i< oakItemList.length; i++){
if(player.caughtPokemonList.length >= oakItemList[i].pokedexReq && oakItemList[i].earned === 0){
oakItemList[i].earned = 1;
if(!suppresnotify){
$.notify("Professor Oak has a present for you: " + oakItemList[i].name, "success");
}
}
}
showOakItems();
}
var initOakItems = function(){
addOakItem("Normal Rod", "images/oak/normalRod.png", 20, "With this rod you are able to catch water Pokemon", null);
addOakItem("Magic Ball", "images/oak/magicBall.png", 30, "Get a 10% bonus to your catchRate", 10)
addOakItem("Amulet Coin", "images/oak/amuletCoin.png", 40, "Gain 50% more coins from wild Pokemon", 1.5);
addOakItem("Poison Barb", "images/oak/poisonBarb.png", 50, "Your clicks do 25% more damage!", 1.25);
addOakItem("Exp Share", "images/oak/expShare.png", 60, "Gain 25% more exp from wild Pokemon", 1.25);
addOakItem("Legendary Charm", "images/oak/pokeDoll.png", 70, "50% more chance to encounter a legendary Pokemon", 1.5);
addOakItem("Shiny Charm", "images/oak/shinyCharm.png", 80, "Double the chance to encounter a shiny Pokemon", 2);
addOakItem("Blaze Cassette", "images/oak/blazeCassette.png", 90, "Your eggs will hatch twice as fast!", 2);
addOakItem("Cell Battery", "images/oak/cellBattery.png", 100, "Regenerate 50% more mining energy!", 1.5);
checkOakItems(1);
showOakItems(1);
}
var activateOakItem = function(id){
if(player.oakItemSlots == 1){
deactivateAllOakItems();
oakItemList[id].active = 1;
player.oakItemsEquipped.push(oakItemList[id].name);
}
else if(player.oakItemSlots == 2){
if(oakItemList[id].active == 1){
oakItemList[id].active = 0;
for(var i = 0; i < player.oakItemsEquipped.length; i++){
if(player.oakItemsEquipped[i] === oakItemList[id].name){
player.oakItemsEquipped.splice(i, 1);
i--;
}
}
} else {
if (getTotalActiveOakItems() < player.oakItemSlots){
oakItemList[id].active = 1;
player.oakItemsEquipped.push(oakItemList[id].name);
} else {
$.notify("You can only have " + player.oakItemSlots + " Oak items active at the same time", "error" );
}
}
}
showOakItems(1);
updateAll();
}
var getTotalActiveOakItems = function(){
var count = 0;
for( var i = 0; i< oakItemList.length; i++){
if (oakItemList[i].active == 1){
count++;
}
}
return count;
}
var deactivateAllOakItems = function(){
for( var i = 0; i< oakItemList.length; i++){
oakItemList[i].active = 0;
}
player.oakItemsEquipped = [];
}
var isActive = function(oakItemName){
for( var i = 0; i<oakItemList.length; i++){
if(oakItemList[i].name == oakItemName){
return oakItemList[i].active;
}
}
}
var getOakItemBonus = function(oakItemName){
for( var i = 0; i<oakItemList.length; i++){
if(oakItemList[i].name == oakItemName && oakItemList[i].active){
return oakItemList[i].value;
}
}
}
var showOakItems = function(force){
if(player.oakItemsEquipped.length > 0) {
for (var i = 0; i < player.oakItemsEquipped.length; i++){
for (var j = 0; j < oakItemList.length; j++){
if (player.oakItemsEquipped[i] === oakItemList[j].name){
oakItemList[j].active = 1;
}
}
}
}
if(lastNumberOfPokemon != player.caughtPokemonList.length || force){
lastNumberOfPokemon = player.caughtPokemonList.length;
if(player.caughtPokemonList.length >= 20){
html = "";
html += "<p style='text-align:center; width:47px; font-size:16px'>"+ getTotalActiveOakItems() + "/" + player.oakItemSlots + "</p>";
for( var i = 0; i< oakItemList.length; i++){
if( oakItemList[i].earned === 1){
if( oakItemList[i].active === 1){
html += "<div id=item"+i+" class='oakItem activeOakItem'><img title='"+ oakItemList[i].flavorText+ "' class='oakItemImage tooltipRight' src='"+ oakItemList[i].image +"'' /></div>"
} else {
html += "<div id=item"+i+" class='oakItem'><img title='"+ oakItemList[i].flavorText+ "' class='oakItemImage tooltipRight' src='"+ oakItemList[i].image +"'' /></div>"
}
}
}
$("#oakItemBody").html(html);
$(".tooltipRight").tooltipster({
position: "right"
});
}
}
}
var alreadyOakItem = function(name){
for( var i = 0; i<oakItemList.length;i++){
if( oakItemList[i].name == name){
return true;
}
}
return false;
}