Commit
·
897b37a
1
Parent(s):
a422892
Upload poke.js
Browse files
poke.js
CHANGED
|
@@ -1,178 +1,73 @@
|
|
| 1 |
-
//Data exceptions (poke-api isn't fully updated)
|
| 2 |
-
const weezingabilities = {
|
| 3 |
-
"abilities": [
|
| 4 |
-
{
|
| 5 |
-
"ability": {
|
| 6 |
-
"name": "levitate",
|
| 7 |
-
"url": "https://pokeapi.co/api/v2/ability/69/"
|
| 8 |
-
},
|
| 9 |
-
"is_hidden": false,
|
| 10 |
-
"slot": 1
|
| 11 |
-
},
|
| 12 |
-
{
|
| 13 |
-
"ability": {
|
| 14 |
-
"name": "neutralizing-gas",
|
| 15 |
-
"url": "https://pokeapi.co/api/v2/ability/5/"
|
| 16 |
-
},
|
| 17 |
-
"is_hidden": false,
|
| 18 |
-
"slot": 2
|
| 19 |
-
},
|
| 20 |
-
{
|
| 21 |
-
"ability": {
|
| 22 |
-
"name": "stench",
|
| 23 |
-
"url": "https://pokeapi.co/api/v2/ability/125/"
|
| 24 |
-
},
|
| 25 |
-
"is_hidden": true,
|
| 26 |
-
"slot": 3
|
| 27 |
-
}
|
| 28 |
-
]
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
const aegislashstats = {
|
| 32 |
-
"stats": [
|
| 33 |
-
{
|
| 34 |
-
"base_stat": 60,
|
| 35 |
-
"effort": 0,
|
| 36 |
-
"stat": {
|
| 37 |
-
"name": "hp",
|
| 38 |
-
"url": "https://pokeapi.co/api/v2/stat/1/"
|
| 39 |
-
}
|
| 40 |
-
},
|
| 41 |
-
{
|
| 42 |
-
"base_stat": 50,
|
| 43 |
-
"effort": 0,
|
| 44 |
-
"stat": {
|
| 45 |
-
"name": "attack",
|
| 46 |
-
"url": "https://pokeapi.co/api/v2/stat/2/"
|
| 47 |
-
}
|
| 48 |
-
},
|
| 49 |
-
{
|
| 50 |
-
"base_stat": 140,
|
| 51 |
-
"effort": 2,
|
| 52 |
-
"stat": {
|
| 53 |
-
"name": "defense",
|
| 54 |
-
"url": "https://pokeapi.co/api/v2/stat/3/"
|
| 55 |
-
}
|
| 56 |
-
},
|
| 57 |
-
{
|
| 58 |
-
"base_stat": 50,
|
| 59 |
-
"effort": 0,
|
| 60 |
-
"stat": {
|
| 61 |
-
"name": "special-attack",
|
| 62 |
-
"url": "https://pokeapi.co/api/v2/stat/4/"
|
| 63 |
-
}
|
| 64 |
-
},
|
| 65 |
-
{
|
| 66 |
-
"base_stat": 140,
|
| 67 |
-
"effort": 1,
|
| 68 |
-
"stat": {
|
| 69 |
-
"name": "special-defense",
|
| 70 |
-
"url": "https://pokeapi.co/api/v2/stat/5/"
|
| 71 |
-
}
|
| 72 |
-
},
|
| 73 |
-
{
|
| 74 |
-
"base_stat": 60,
|
| 75 |
-
"effort": 0,
|
| 76 |
-
"stat": {
|
| 77 |
-
"name": "speed",
|
| 78 |
-
"url": "https://pokeapi.co/api/v2/stat/6/"
|
| 79 |
-
}
|
| 80 |
-
}
|
| 81 |
-
]
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
const types = new Array(
|
| 85 |
-
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.5, 0, 1, 1, 0.5, 1, 1],// Normal
|
| 86 |
-
[1, 0.5, 0.5, 1, 2, 2, 1, 1, 1, 1, 1, 2, 0.5, 1, 0.5, 1, 2, 1, 1],// Fire
|
| 87 |
-
[1, 2, 0.5, 1, 0.5, 1, 1, 1, 2, 1, 1, 1, 2, 1, 0.5, 1, 1, 1, 1],// Water
|
| 88 |
-
[1, 1, 2, 0.5, 0.5, 1, 1, 1, 0, 2, 1, 1, 1, 1, 0.5, 1, 1, 1, 1],// Electric
|
| 89 |
-
[1, 0.5, 2, 1, 0.5, 1, 1, 0.5, 2, 0.5, 1, 0.5, 2, 1, 0.5, 1, 0.5, 1, 1],// Grass
|
| 90 |
-
[1, 0.5, 0.5, 1, 2, 0.5, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 0.5, 1, 1],// Ice
|
| 91 |
-
[2, 1, 1, 1, 1, 2, 1, 0.5, 1, 0.5, 0.5, 0.5, 2, 0, 1, 2, 2, 0.5, 1],// Fighting
|
| 92 |
-
[1, 1, 1, 1, 2, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 0, 2, 1],// Poison
|
| 93 |
-
[1, 2, 1, 2, 0.5, 1, 1, 2, 1, 0, 1, 0.5, 2, 1, 1, 1, 2, 1, 1],// Ground
|
| 94 |
-
[1, 1, 1, 0.5, 2, 1, 2, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 0.5, 1, 1],// Flying
|
| 95 |
-
[1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 0.5, 1, 1, 1, 1, 0, 0.5, 1, 1],// Psychic
|
| 96 |
-
[1, 0.5, 1, 1, 2, 1, 0.5, 0.5, 1, 0.5, 2, 1, 1, 0.5, 1, 2, 0.5, 0.5, 1],// Bug
|
| 97 |
-
[1, 2, 1, 1, 1, 2, 0.5, 1, 0.5, 2, 1, 2, 1, 1, 1, 1, 0.5, 1, 1],// Rock
|
| 98 |
-
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 0.5, 1, 1, 1],// Ghost
|
| 99 |
-
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0.5, 0, 1],// Dragon
|
| 100 |
-
[1, 1, 1, 1, 1, 1, 0.5, 1, 1, 1, 2, 1, 1, 2, 1, 0.5, 1, 0.5, 1],// Dark
|
| 101 |
-
[1, 0.5, 0.5, 0.5, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0.5, 2, 1],// Steel
|
| 102 |
-
[1, 0.5, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 1, 1, 1, 2, 2, 0.5, 1, 1],// Fairy
|
| 103 |
-
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);// None
|
| 104 |
-
|
| 105 |
-
const typeName = ["normal", "fire", "water", "electric", "grass", "ice", "fighting", "poison", "ground", "flying", "psychic", "bug", "rock", "ghost", "dragon", "dark", "steel", "fairy"];
|
| 106 |
var result1 = new Array();
|
| 107 |
var result2 = new Array();
|
| 108 |
-
|
| 109 |
-
var chk = []
|
| 110 |
-
var ids2 = []
|
| 111 |
-
|
| 112 |
-
var saveInit = -1
|
| 113 |
-
var saveBtn = true
|
| 114 |
-
var saveIndex = 0
|
| 115 |
-
var saves = [] //List of fusions made
|
| 116 |
-
|
| 117 |
var typeComp = 0;
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
//Adding options to datalist
|
| 120 |
var box1 = document.getElementById('fname1');
|
| 121 |
var box2 = document.getElementById('fname2');
|
| 122 |
-
var box3 = document.getElementById('fname3');
|
| 123 |
var dl = document.createElement('datalist');
|
| 124 |
dl.id = 'dlPkmn';
|
| 125 |
|
| 126 |
-
for (var i
|
| 127 |
var option = document.createElement('option');
|
| 128 |
//Special name case
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
dl.appendChild(option);
|
| 131 |
}
|
| 132 |
box1.appendChild(dl);
|
| 133 |
box2.appendChild(dl);
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
//Press
|
| 137 |
-
document.
|
| 138 |
-
|
| 139 |
-
if (
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
} else if (box2 === document.activeElement && box2.value.length != 0) {
|
| 143 |
-
box2.value = nameCheck(outputClosest(box2.value))
|
| 144 |
-
}
|
| 145 |
-
if (box1.value.length != 0 && box2.value.length != 0) {
|
| 146 |
-
verifInputs()
|
| 147 |
-
}
|
| 148 |
}
|
| 149 |
});
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
//Empty pokemon text area
|
| 152 |
function resetPoke() {
|
| 153 |
document.getElementById("fname1").value = null;
|
| 154 |
document.getElementById("fname2").value = null;
|
| 155 |
-
document.getElementById("
|
| 156 |
-
document.getElementById("p1").src = "Types/null.png";
|
| 157 |
document.getElementById("p2").style = "display:none";
|
| 158 |
-
document.getElementById("p3").
|
| 159 |
-
document.getElementById("p4").
|
| 160 |
-
document.getElementById("p5").style = "display:none";
|
| 161 |
-
document.getElementById("p6").style = "display:none";
|
| 162 |
-
document.getElementById("p7").src = "Types/null.png";
|
| 163 |
-
document.getElementById("p8").style = "display:none";
|
| 164 |
-
document.getElementById("p9").style = "display:none";
|
| 165 |
document.getElementById("pic1").src = "question.png";
|
| 166 |
document.getElementById("pic2").src = "question.png";
|
| 167 |
-
document.getElementById("pic3").src = "question.png";
|
| 168 |
|
| 169 |
-
|
| 170 |
-
document.getElementById("
|
| 171 |
-
document.getElementById("
|
| 172 |
-
|
| 173 |
-
document.getElementById("FP1").innerHTML = "mon1/
|
| 174 |
-
document.getElementById("FP2").innerHTML = "
|
| 175 |
-
document.getElementById("FP3").innerHTML = "mon2/mon3/mon1";
|
| 176 |
|
| 177 |
document.getElementById("hp1").innerHTML = "HP: ";
|
| 178 |
document.getElementById("atk1").innerHTML = "ATK: ";
|
|
@@ -182,6 +77,7 @@ function resetPoke() {
|
|
| 182 |
document.getElementById("spe1").innerHTML = "SPEED: ";
|
| 183 |
document.getElementById("bs1").innerHTML = "TOTAL: ";
|
| 184 |
document.getElementById("ab1").innerHTML = "ABILITY:";
|
|
|
|
| 185 |
|
| 186 |
document.getElementById("hp2").innerHTML = "HP: ";
|
| 187 |
document.getElementById("atk2").innerHTML = "ATK: ";
|
|
@@ -191,581 +87,623 @@ function resetPoke() {
|
|
| 191 |
document.getElementById("spe2").innerHTML = "SPEED: ";
|
| 192 |
document.getElementById("bs2").innerHTML = "TOTAL: ";
|
| 193 |
document.getElementById("ab2").innerHTML = "ABILITY:";
|
| 194 |
-
|
| 195 |
-
document.getElementById("hp3").innerHTML = "HP: ";
|
| 196 |
-
document.getElementById("atk3").innerHTML = "ATK: ";
|
| 197 |
-
document.getElementById("def3").innerHTML = "DEF: ";
|
| 198 |
-
document.getElementById("spatk3").innerHTML = "SPE.ATK: ";
|
| 199 |
-
document.getElementById("spdef3").innerHTML = "SPE.DEF: ";
|
| 200 |
-
document.getElementById("spe3").innerHTML = "SPEED: ";
|
| 201 |
-
document.getElementById("bs3").innerHTML = "TOTAL: ";
|
| 202 |
-
document.getElementById("ab3").innerHTML = "ABILITY:";
|
| 203 |
|
| 204 |
document.getElementById("weak14").innerHTML = "x4: ";
|
| 205 |
document.getElementById("weak12").innerHTML = "x2: ";
|
| 206 |
-
document.getElementById("weak11").innerHTML = "x1: ";
|
| 207 |
document.getElementById("weak105").innerHTML = "x0.5: ";
|
| 208 |
document.getElementById("weak1025").innerHTML = "x0.25: ";
|
| 209 |
document.getElementById("weak100").innerHTML = "x0: ";
|
| 210 |
|
| 211 |
document.getElementById("weak24").innerHTML = "x4: ";
|
| 212 |
document.getElementById("weak22").innerHTML = "x2: ";
|
| 213 |
-
document.getElementById("weak21").innerHTML = "x1: ";
|
| 214 |
document.getElementById("weak205").innerHTML = "x0.5: ";
|
| 215 |
document.getElementById("weak2025").innerHTML = "x0.25: ";
|
| 216 |
document.getElementById("weak200").innerHTML = "x0: ";
|
| 217 |
|
| 218 |
-
var L0 = ["hp1",
|
| 219 |
-
var L1 = ["hp2",
|
| 220 |
-
var L2 = ["hp3", "atk3", "def3", "spatk3", "spdef3", "spe3", "bs3"];
|
| 221 |
for (var i = 0; i < L0.length; i++) {
|
| 222 |
document.getElementById(L0[i]).style.color = "";
|
| 223 |
document.getElementById(L1[i]).style.color = "";
|
| 224 |
-
document.getElementById(L2[i]).style.color = "";
|
| 225 |
}
|
| 226 |
}
|
| 227 |
|
| 228 |
-
|
| 229 |
-
function
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
var rand1 = Math.floor(Math.random() * (idsRand.length))
|
| 233 |
-
var rand2 = Math.floor(Math.random() * (idsRand.length))
|
| 234 |
-
var rand3 = Math.floor(Math.random() * (idsRand.length))
|
| 235 |
-
document.getElementById("fname1").value = nameCheck(idsRand[rand1][0])
|
| 236 |
-
document.getElementById("fname2").value = nameCheck(idsRand[rand2][0])
|
| 237 |
-
document.getElementById("fname3").value = nameCheck(idsRand[rand3][0])
|
| 238 |
-
document.getElementById("button").click();
|
| 239 |
}
|
| 240 |
|
| 241 |
-
|
| 242 |
-
function
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
}
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
|
|
|
|
| 266 |
//Fusion calculation function
|
| 267 |
function fusePoke() {
|
| 268 |
|
| 269 |
//Pokemon from both text area
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
if ((mon1
|
| 274 |
-
document.
|
|
|
|
|
|
|
|
|
|
| 275 |
alert("Please fill the two text inputs!");
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
if
|
| 285 |
-
|
| 286 |
}
|
|
|
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
txhr.open('GET', poke1, true);
|
| 292 |
-
txhr.send();
|
| 293 |
-
txhr.onload = function () {
|
| 294 |
-
var jsonBody = txhr.responseText;
|
| 295 |
-
if (jsonBody) {
|
| 296 |
-
try {
|
| 297 |
-
a = JSON.parse(jsonBody);
|
| 298 |
-
} catch (e) {
|
| 299 |
-
alert("The first pokemon was misspelled!"); // error in the above string (in this case, yes)!
|
| 300 |
-
}
|
| 301 |
}
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
var num1 = jsonString.id;
|
| 306 |
-
var id1 = num1;
|
| 307 |
-
var idCheck1 = false;
|
| 308 |
-
for (i = 0; i < ids.length; i++) {
|
| 309 |
-
if (ids[i][0] == mon1.charAt(0).toUpperCase() + mon1.slice(1)) {
|
| 310 |
-
idCheck1 = true;
|
| 311 |
-
num1 = ids[i][1];
|
| 312 |
-
}
|
| 313 |
}
|
| 314 |
-
if (idCheck1 == false && id1 >= 252) {
|
| 315 |
-
alert("The first pokemon isn't in the fangame!")
|
| 316 |
-
} else {
|
| 317 |
-
//Type selector for fusion type knowledge of the 1st mon
|
| 318 |
-
var type1 = jsonString.types;
|
| 319 |
-
var poke1 = 'https://pokeapi.co/api/v2/pokemon/' + type1[0].type.name;
|
| 320 |
-
var mon1types = [];
|
| 321 |
-
var compt = 0
|
| 322 |
-
|
| 323 |
-
//Exception mon selected for swapped types
|
| 324 |
-
for (i = 0; i < typeSwap.length; i++) {
|
| 325 |
-
if (typeSwap[i][2] == mon1.charAt(0).toUpperCase() + mon1.slice(1)) {
|
| 326 |
-
mon1types.push(typeSwap[i][0]);
|
| 327 |
-
mon1types.push(typeSwap[i][1]);
|
| 328 |
-
var compt = 1;
|
| 329 |
-
}
|
| 330 |
-
}
|
| 331 |
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
}
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
}
|
| 349 |
}
|
| 350 |
}
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
var mon1stats = [];
|
| 354 |
-
if (mon1 != "aegislash-shield") {
|
| 355 |
-
var stats1 = jsonString.stats;
|
| 356 |
-
} else {
|
| 357 |
-
var stats1 = aegislashstats.stats;
|
| 358 |
-
}
|
| 359 |
-
for (i = 0; i < stats1.length; i++) {
|
| 360 |
-
mon1stats.push(stats1[i].base_stat)
|
| 361 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
|
| 363 |
-
//Ability of 1st mon
|
| 364 |
-
var mon1abilities = [];
|
| 365 |
-
if (mon1 != "weezing") {
|
| 366 |
-
var ab1 = jsonString.abilities;
|
| 367 |
-
} else {
|
| 368 |
-
var ab1 = weezingabilities.abilities;
|
| 369 |
-
}
|
| 370 |
-
for (i = 0; i < ab1.length; i++) {
|
| 371 |
-
mon1abilities.push([ab1[i].ability, ab1[i].is_hidden]);
|
| 372 |
-
}
|
| 373 |
|
| 374 |
-
|
| 375 |
-
var pxhr = new XMLHttpRequest();
|
| 376 |
-
var poke2 = 'https://pokeapi.co/api/v2/pokemon/' + mon2
|
| 377 |
-
pxhr.open('GET', poke2, true);
|
| 378 |
-
pxhr.send();
|
| 379 |
-
pxhr.onload = function () {
|
| 380 |
-
|
| 381 |
-
var jsonBody = pxhr.responseText;
|
| 382 |
-
if (jsonBody) {
|
| 383 |
-
try {
|
| 384 |
-
a = JSON.parse(jsonBody);
|
| 385 |
-
} catch (e) {
|
| 386 |
-
alert("The second pokemon was misspelled!"); // error in the above string (in this case, yes)!
|
| 387 |
-
}
|
| 388 |
-
}
|
| 389 |
-
var jsonString = JSON.parse(jsonBody);
|
| 390 |
-
|
| 391 |
-
//Name of fusion
|
| 392 |
-
if (!nameFix.includes(mon1) && !nameFix.includes(mon2) && !nameFix.includes(mon3)) {
|
| 393 |
-
var fmon1 = mon1.charAt(0).toUpperCase() + mon1.slice(1);
|
| 394 |
-
var fmon2 = mon2.charAt(0).toUpperCase() + mon2.slice(1);
|
| 395 |
-
var fmon3 = mon3.charAt(0).toUpperCase() + mon3.slice(1);
|
| 396 |
-
} else if (nameFix.includes(mon1) && !nameFix.includes(mon2) && !nameFix.includes(mon3)) {
|
| 397 |
-
var fmon1 = nameException[nameFix.indexOf(mon1)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon1)].slice(1);
|
| 398 |
-
var fmon2 = mon2.charAt(0).toUpperCase() + mon2.slice(1);
|
| 399 |
-
var fmon3 = mon3.charAt(0).toUpperCase() + mon3.slice(1);
|
| 400 |
-
} else if (!nameFix.includes(mon1) && nameFix.includes(mon2) && nameFix.includes(mon3)) {
|
| 401 |
-
var fmon1 = mon1.charAt(0).toUpperCase() + mon1.slice(1);
|
| 402 |
-
var fmon2 = nameException[nameFix.indexOf(mon2)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon2)].slice(1);
|
| 403 |
-
} else if (nameFix.includes(mon1) && nameFix.includes(mon2) && nameFix.includes(mon3)) {
|
| 404 |
-
var fmon1 = nameException[nameFix.indexOf(mon1)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon1)].slice(1);
|
| 405 |
-
var fmon2 = nameException[nameFix.indexOf(mon2)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon2)].slice(1);
|
| 406 |
-
}
|
| 407 |
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
if (typeSwap[i][2] == mon2.charAt(0).toUpperCase() + mon2.slice(1)) {
|
| 438 |
-
mon2types.push(typeSwap[i][0]);
|
| 439 |
-
mon2types.push(typeSwap[i][1]);
|
| 440 |
-
var compt = 1;
|
| 441 |
-
}
|
| 442 |
-
}
|
| 443 |
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
for (i = 0; i < stats2.length; i++) {
|
| 472 |
-
mon2stats.push(stats2[i].base_stat)
|
| 473 |
-
}
|
| 474 |
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
}
|
| 481 |
-
var mon2abilities = [];
|
| 482 |
-
for (i = 0; i < ab2.length; i++) {
|
| 483 |
-
mon2abilities.push([ab2[i].ability, ab2[i].is_hidden]);
|
| 484 |
-
}
|
| 485 |
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
document.getElementById(L0[i]).style.color = "green";
|
| 529 |
-
L5.push(" (-" + L4[i] + ")")
|
| 530 |
-
L4[i] = " (+" + L4[i] + ")";
|
| 531 |
-
} else {
|
| 532 |
-
document.getElementById(L1[i]).style.color = "orange";
|
| 533 |
-
document.getElementById(L0[i]).style.color = "orange";
|
| 534 |
-
L4[i] = " (0)"
|
| 535 |
-
L5.push(" (0)");
|
| 536 |
}
|
| 537 |
-
document.getElementById(L0[i]).innerHTML = L0[i].slice(-1) + ": " + L2[i];
|
| 538 |
-
document.getElementById(L1[i]).innerHTML = L1[i].slice(-1) + ": " + L3[i];
|
| 539 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
-
//Writting stat in HTML
|
| 542 |
-
if (mon1 == "shedinja" || mon2 == "shedinja") {
|
| 543 |
-
document.getElementById("hp1").innerHTML = "HP: 1 (0)"
|
| 544 |
-
document.getElementById("hp1").style.color = "orange";
|
| 545 |
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
var fmonres1 = fusType(mon1types, mon2types);
|
| 578 |
-
var fmonres2 = fusType(mon2types, mon1types);
|
| 579 |
-
|
| 580 |
-
//Types effectiveness
|
| 581 |
-
if (typeComp > 0) {
|
| 582 |
-
c = document.getElementsByClassName('monweak');
|
| 583 |
-
for (b = 0; b < c.length; b++) {
|
| 584 |
-
defaultValue = c[b].getAttribute('data-default');
|
| 585 |
-
if (defaultValue) {
|
| 586 |
-
c[b].innerText = defaultValue;
|
| 587 |
-
}
|
| 588 |
-
}
|
| 589 |
-
}
|
| 590 |
|
| 591 |
-
|
| 592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
document.getElementById("weak11").appendChild(image);
|
| 610 |
-
}
|
| 611 |
-
if (result1[i] == 0.5) {
|
| 612 |
-
document.getElementById("weak105").appendChild(image);
|
| 613 |
-
}
|
| 614 |
-
if (result1[i] == 0.25) {
|
| 615 |
-
document.getElementById("weak1025").appendChild(image);
|
| 616 |
-
}
|
| 617 |
-
if (result1[i] == 0) {
|
| 618 |
-
document.getElementById("weak100").appendChild(image);
|
| 619 |
-
}
|
| 620 |
-
}
|
| 621 |
|
| 622 |
-
|
| 623 |
-
|
|
|
|
|
|
|
|
|
|
| 624 |
|
| 625 |
-
|
| 626 |
-
result2[i] = (types[i][tyeffid1[0]] * types[i][tyeffid1[1]]);
|
| 627 |
-
}
|
| 628 |
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
|
| 633 |
-
if (result2[i] == 4) {
|
| 634 |
-
document.getElementById("weak24").appendChild(image);
|
| 635 |
-
}
|
| 636 |
-
if (result2[i] == 2) {
|
| 637 |
-
document.getElementById("weak22").appendChild(image);
|
| 638 |
-
}
|
| 639 |
-
if (result2[i] == 1) {
|
| 640 |
-
document.getElementById("weak21").appendChild(image);
|
| 641 |
-
}
|
| 642 |
-
if (result2[i] == 0.5) {
|
| 643 |
-
document.getElementById("weak205").appendChild(image);
|
| 644 |
-
}
|
| 645 |
-
if (result2[i] == 0.25) {
|
| 646 |
-
document.getElementById("weak2025").appendChild(image);
|
| 647 |
-
}
|
| 648 |
-
if (result2[i] == 0) {
|
| 649 |
-
document.getElementById("weak200").appendChild(image);
|
| 650 |
-
}
|
| 651 |
-
}
|
| 652 |
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 662 |
|
| 663 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
|
| 688 |
-
|
| 689 |
-
|
| 690 |
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
}
|
| 695 |
-
listAb2 = listAb2.slice(0, listAb2.length - 1);
|
| 696 |
-
listAb2 = listAb2.split("-").join(" ")
|
| 697 |
-
listAb2 = listAb2.split(" ")
|
| 698 |
-
for (i = 0, x = listAb2.length; i < x; i++) {
|
| 699 |
-
listAb2[i] = listAb2[i][0].toUpperCase() + listAb2[i].substr(1);
|
| 700 |
-
}
|
| 701 |
-
listAb2 = listAb2.join(" ").slice(0, -2);
|
| 702 |
-
document.getElementById("ab2").innerHTML = " ";
|
| 703 |
-
document.getElementById("ab2").innerHTML = listAb2;
|
| 704 |
-
|
| 705 |
-
/*
|
| 706 |
-
//Fusion is already in Showdown or not
|
| 707 |
-
if (listfusion.includes(fmon1.toLowerCase() + "/" + fmon2.toLowerCase())) {
|
| 708 |
-
document.getElementById("IG1").style.color = "green";
|
| 709 |
-
document.getElementById("IG1").innerHTML = "In Showdown";
|
| 710 |
-
} else {
|
| 711 |
-
document.getElementById("IG1").style.color = "red";
|
| 712 |
-
document.getElementById("IG1").innerHTML = "Not in Showdown";
|
| 713 |
-
}
|
| 714 |
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
document.getElementById("r3").disabled = false
|
| 727 |
-
document.getElementById("random").disabled = false
|
| 728 |
|
| 729 |
-
|
| 730 |
-
|
|
|
|
| 731 |
|
| 732 |
-
|
| 733 |
-
|
|
|
|
| 734 |
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 741 |
|
| 742 |
-
|
| 743 |
-
if (saveIndex > 0) {
|
| 744 |
-
document.getElementById("previous").disabled = false
|
| 745 |
-
} else {
|
| 746 |
-
document.getElementById("previous").disabled = true
|
| 747 |
-
}
|
| 748 |
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
|
|
|
| 755 |
|
| 756 |
-
|
| 757 |
-
saveBtn = false
|
| 758 |
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
}
|
| 765 |
-
}
|
| 766 |
-
}
|
| 767 |
-
}
|
| 768 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
}
|
| 770 |
|
| 771 |
|
|
@@ -779,171 +717,271 @@ function typeId(ftype) {
|
|
| 779 |
return [ty1, ty2];
|
| 780 |
}
|
| 781 |
|
| 782 |
-
//Custom sprite fusion function
|
| 783 |
-
function showFusion(elementId, fusionId) {
|
| 784 |
|
|
|
|
|
|
|
|
|
|
| 785 |
fusionUrl = "https://raw.githubusercontent.com/Aegide/custom-fusion-sprites/main/CustomBattlers/" + fusionId;
|
|
|
|
| 786 |
|
| 787 |
-
if
|
| 788 |
document.getElementById(elementId).src = fusionUrl;
|
|
|
|
| 789 |
}
|
| 790 |
-
else
|
| 791 |
fallbackFusionRepository = "https://raw.githubusercontent.com/Aegide/autogen-fusion-sprites/master/Battlers/"
|
| 792 |
headId = fusionId.split(".")[0];
|
| 793 |
fallbackFusionUrl = fallbackFusionRepository + headId + "/" + fusionId;
|
| 794 |
-
|
| 795 |
document.getElementById(elementId).src = fallbackFusionUrl;
|
|
|
|
| 796 |
}
|
| 797 |
}
|
| 798 |
|
| 799 |
//Error detection
|
| 800 |
-
function doesImageExists(imageUrl)
|
| 801 |
var http = new XMLHttpRequest();
|
| 802 |
http.open('HEAD', imageUrl, false);
|
|
|
|
|
|
|
| 803 |
http.send();
|
| 804 |
return http.status != 404;
|
| 805 |
}
|
| 806 |
|
| 807 |
-
//
|
| 808 |
-
function
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
}
|
| 816 |
-
return saveWrite
|
| 817 |
}
|
| 818 |
|
| 819 |
-
//
|
| 820 |
-
function
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
|
|
|
|
|
|
|
|
|
| 830 |
}
|
| 831 |
-
|
| 832 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 833 |
}
|
| 834 |
-
i += 1
|
| 835 |
-
}
|
| 836 |
-
if (boxbool1 == true && boxbool2 == true) {
|
| 837 |
-
event.preventDefault();
|
| 838 |
-
document.getElementById("button").click();
|
| 839 |
-
} else if (boxbool1 == false && boxbool2 == false) {
|
| 840 |
-
box1.value = ""
|
| 841 |
-
box2.value = ""
|
| 842 |
-
alert("Both pokemons were misspelled or aren't in the fangame!")
|
| 843 |
-
} else if (boxbool1 == false) {
|
| 844 |
-
box1.value = ""
|
| 845 |
-
alert("The first pokemon was misspelled or isn't in the fangame!")
|
| 846 |
-
} else if (boxbool2 == false) {
|
| 847 |
-
box2.value = ""
|
| 848 |
-
alert("The second pokemon misspelled or isn't in the fangame!")
|
| 849 |
}
|
| 850 |
-
}
|
| 851 |
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
val = val[0].toUpperCase() + val.substring(1)
|
| 860 |
} else {
|
| 861 |
-
var
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 862 |
}
|
| 863 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 864 |
}
|
| 865 |
|
| 866 |
-
//
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
} else {
|
| 872 |
-
|
| 873 |
}
|
|
|
|
|
|
|
| 874 |
}
|
| 875 |
|
| 876 |
-
//
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
document.getElementById("fname2").value = nameCheck(saves[saveIndex][1])
|
| 882 |
|
| 883 |
-
|
| 884 |
-
|
|
|
|
|
|
|
|
|
|
| 885 |
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
document.getElementById("fname1").value = nameCheck(saves[saveIndex][0])
|
| 891 |
-
document.getElementById("fname2").value = nameCheck(saves[saveIndex][1])
|
| 892 |
|
| 893 |
-
|
| 894 |
}
|
| 895 |
|
| 896 |
-
|
| 897 |
-
function
|
| 898 |
-
var
|
| 899 |
-
var
|
| 900 |
-
|
| 901 |
-
|
|
|
|
|
|
|
| 902 |
}
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
for (var i = 0; i<ids.length; i++) {
|
| 928 |
-
if (ids[i][2]==4) {
|
| 929 |
-
ids2.push(ids[i])
|
| 930 |
-
}
|
| 931 |
-
}
|
| 932 |
}
|
| 933 |
-
if
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
ids2.push(ids[i])
|
| 937 |
-
}
|
| 938 |
-
}
|
| 939 |
}
|
| 940 |
-
chk = chk2
|
| 941 |
-
} else if (chk2.length == 0) {
|
| 942 |
-
ids2 = ids
|
| 943 |
}
|
| 944 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 945 |
}
|
| 946 |
|
|
|
|
| 947 |
//Ability fusion function
|
| 948 |
function fusAb(mon1, mon2) {
|
| 949 |
var fabs = [];
|
|
@@ -951,155 +989,245 @@ function fusAb(mon1, mon2) {
|
|
| 951 |
if (mon1.length == 3 && mon1[2][1] == true) {
|
| 952 |
var H1 = mon1[1][0].name;
|
| 953 |
var HH = mon1[2][0].name;
|
| 954 |
-
}
|
| 955 |
var HH = mon1[1][0].name;
|
| 956 |
-
} else if (mon1.length == 2 && mon1[1][1] == false)
|
| 957 |
var H1 = mon1[1][0].name;
|
| 958 |
}
|
| 959 |
-
|
| 960 |
var B0 = mon2[0][0].name;
|
| 961 |
if (mon2.length == 3 && mon2[2][1] == true) {
|
| 962 |
var B1 = mon2[1][0].name;
|
| 963 |
-
var BH = mon2[2][0].name;
|
| 964 |
-
}
|
| 965 |
var BH = mon2[1][0].name;
|
| 966 |
-
} else if (mon1.length == 2 && mon1[1][1] == false)
|
| 967 |
var B1 = mon2[1][0].name;
|
| 968 |
}
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
//case H0/H1/null + B0/null/null
|
| 972 |
-
|
| 973 |
-
if ((mon1.length == 1 && mon2.length == 1) || (mon1.length == 2 && mon2.length == 1 && mon1[1][1] == false)) {
|
| 974 |
-
//[H0=B0] -> H0/null/null
|
| 975 |
if (H0 == B0) {
|
| 976 |
fabs.push(H0);
|
| 977 |
-
|
| 978 |
-
} else {
|
| 979 |
fabs.push(H0);
|
| 980 |
fabs.push(B0);
|
| 981 |
}
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
//case H0/H1/HH + B0/null/null
|
| 985 |
-
|
| 986 |
-
} else if ((mon1.length == 2 && mon2.length == 1 && mon1[1][1] == true) || (mon1.length == 3 && mon2.length == 1)) {
|
| 987 |
-
//[H0=B0] -> H0/null/HH
|
| 988 |
if (H0 == B0) {
|
| 989 |
fabs.push(H0);
|
| 990 |
-
fabs.push(
|
| 991 |
-
|
| 992 |
-
} else if (
|
| 993 |
fabs.push(H0);
|
| 994 |
fabs.push(B0);
|
| 995 |
-
|
| 996 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 997 |
fabs.push(H0);
|
| 998 |
fabs.push(B0);
|
| 999 |
fabs.push(HH);
|
| 1000 |
}
|
| 1001 |
-
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
} else if ((mon1.length == 1 && mon2.length == 2 && mon2[1][1] == true) || (mon1.length == 2 && mon2.length == 2 && mon1[1][1] == false && mon2[1][1] == true)) {
|
| 1005 |
-
//[H0=B0] -> H0/null/null
|
| 1006 |
-
if (H0 == B0) {
|
| 1007 |
fabs.push(H0);
|
| 1008 |
-
|
| 1009 |
-
|
|
|
|
|
|
|
| 1010 |
fabs.push(H0);
|
| 1011 |
fabs.push(B0);
|
|
|
|
| 1012 |
}
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
} else if ((mon2.length == 2 && mon2.length == 2 && mon1[1][1] == true && mon2[1][1] == true) || (mon1.length == 3 && mon2.length == 2 && mon2[1][1] == true)) {
|
| 1017 |
-
//[H0=B0] -> H0/null/HH
|
| 1018 |
-
if (H0 == B0) {
|
| 1019 |
fabs.push(H0);
|
| 1020 |
-
fabs.push(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1021 |
}
|
| 1022 |
-
|
| 1023 |
-
|
|
|
|
| 1024 |
fabs.push(H0);
|
| 1025 |
fabs.push(B0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1026 |
}
|
| 1027 |
-
|
| 1028 |
-
|
|
|
|
| 1029 |
fabs.push(H0);
|
| 1030 |
fabs.push(B0);
|
| 1031 |
fabs.push(HH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1032 |
}
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
|
| 1037 |
-
} else if ((mon1.length == 1 && mon2.length == 2 && mon2[1][1] == false) || (mon1.length == 2 && mon2.length == 2 && mon1[1][1] == false && mon2[1][1] == false)) {
|
| 1038 |
-
//[H0=B1] -> H0/B0/null
|
| 1039 |
-
if (H0 == B1) {
|
| 1040 |
fabs.push(H0);
|
| 1041 |
fabs.push(B0);
|
| 1042 |
-
|
| 1043 |
-
|
|
|
|
| 1044 |
fabs.push(H0);
|
| 1045 |
fabs.push(B1);
|
|
|
|
| 1046 |
}
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
if (H0 ==
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1054 |
fabs.push(H0);
|
| 1055 |
fabs.push(B0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1056 |
fabs.push(HH);
|
| 1057 |
-
|
| 1058 |
-
|
|
|
|
|
|
|
| 1059 |
fabs.push(H0);
|
| 1060 |
fabs.push(B1);
|
| 1061 |
-
|
| 1062 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1063 |
fabs.push(H0);
|
| 1064 |
fabs.push(B1);
|
| 1065 |
-
fabs.push(
|
| 1066 |
}
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
|
|
|
| 1074 |
fabs.push(H0);
|
| 1075 |
fabs.push(B0);
|
| 1076 |
-
|
| 1077 |
-
|
|
|
|
| 1078 |
fabs.push(H0);
|
| 1079 |
fabs.push(B1);
|
|
|
|
| 1080 |
}
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
|
|
|
| 1088 |
fabs.push(H0);
|
| 1089 |
fabs.push(B0);
|
| 1090 |
fabs.push(HH);
|
| 1091 |
-
|
| 1092 |
-
} else if (HH ==
|
| 1093 |
fabs.push(H0);
|
| 1094 |
fabs.push(B1);
|
| 1095 |
-
|
| 1096 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1097 |
fabs.push(H0);
|
| 1098 |
fabs.push(B1);
|
| 1099 |
fabs.push(HH);
|
| 1100 |
}
|
| 1101 |
}
|
| 1102 |
-
|
| 1103 |
}
|
| 1104 |
|
| 1105 |
|
|
@@ -1123,7 +1251,6 @@ function fusType(mon1, mon2) {
|
|
| 1123 |
if (mon1[0] != mon2[0]) {
|
| 1124 |
fmon.push(mon1[0]);
|
| 1125 |
fmon.push(mon2[0]);
|
| 1126 |
-
fmon.push(mon3[0]);
|
| 1127 |
|
| 1128 |
// Exception:
|
| 1129 |
// The body will provide its primary type
|
|
@@ -1140,13 +1267,11 @@ function fusType(mon1, mon2) {
|
|
| 1140 |
if (mon1[0] != mon2[1]) {
|
| 1141 |
fmon.push(mon1[0]);
|
| 1142 |
fmon.push(mon2[1]);
|
| 1143 |
-
fmon.push(mon3[2]);
|
| 1144 |
|
| 1145 |
//cas H0/null + B0/B1 [H0=B1] -> H0/B0
|
| 1146 |
} else {
|
| 1147 |
fmon.push(mon1[0])
|
| 1148 |
-
fmon.push(mon2[0])
|
| 1149 |
-
fmon.push(mon3[0]);
|
| 1150 |
}
|
| 1151 |
|
| 1152 |
//cas H0/H1 + B0/B1 [H0=B1] -> H0/B0
|
|
@@ -1154,14 +1279,17 @@ function fusType(mon1, mon2) {
|
|
| 1154 |
if (mon1[0] == mon2[1]) {
|
| 1155 |
fmon.push(mon1[0]);
|
| 1156 |
fmon.push(mon2[0]);
|
| 1157 |
-
fmon.push(mon3[0]);
|
| 1158 |
|
| 1159 |
//cas H0/H1 + B0/B1 [H0#B1] -> H0/B1
|
| 1160 |
} else {
|
| 1161 |
fmon.push(mon1[0]);
|
| 1162 |
fmon.push(mon2[1]);
|
| 1163 |
-
fmon.push(mon3[2]);
|
| 1164 |
}
|
| 1165 |
}
|
| 1166 |
return fmon
|
| 1167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
var result1 = new Array();
|
| 2 |
var result2 = new Array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
var typeComp = 0;
|
| 4 |
|
| 5 |
+
var mon1, mon2;
|
| 6 |
+
var num1, num2;
|
| 7 |
+
var mon1stats, mon2stats;
|
| 8 |
+
var mon1types, mon2types;
|
| 9 |
+
var mon1abilities, mon2abilities;
|
| 10 |
+
var jsonBody;
|
| 11 |
+
|
| 12 |
//Adding options to datalist
|
| 13 |
var box1 = document.getElementById('fname1');
|
| 14 |
var box2 = document.getElementById('fname2');
|
|
|
|
| 15 |
var dl = document.createElement('datalist');
|
| 16 |
dl.id = 'dlPkmn';
|
| 17 |
|
| 18 |
+
for (var i=0 ; i < ids.length; i += 1) {
|
| 19 |
var option = document.createElement('option');
|
| 20 |
//Special name case
|
| 21 |
+
if (nameFix.includes(ids[i][0].toLowerCase())) {
|
| 22 |
+
var val = nameException[nameFix.indexOf(ids[i][0].toLowerCase())]
|
| 23 |
+
option.value = val[0].toUpperCase() + val.substring(1)
|
| 24 |
+
}
|
| 25 |
+
else {
|
| 26 |
+
option.value = ids[i][0];
|
| 27 |
+
}
|
| 28 |
dl.appendChild(option);
|
| 29 |
}
|
| 30 |
box1.appendChild(dl);
|
| 31 |
box2.appendChild(dl);
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
//Press ENTER on text area 1
|
| 35 |
+
var pkmn1 = document.getElementById('fname1');
|
| 36 |
+
pkmn1.addEventListener("keydown", function(event) {
|
| 37 |
+
if (event.keyCode === 13) {
|
| 38 |
+
event.preventDefault();
|
| 39 |
+
document.getElementById("button").click();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
});
|
| 42 |
|
| 43 |
+
|
| 44 |
+
//Press ENTER on text area 2
|
| 45 |
+
var pkmn2 = document.getElementById('fname2');
|
| 46 |
+
pkmn2.addEventListener("keydown", function(event) {
|
| 47 |
+
if (event.keyCode === 13) {
|
| 48 |
+
event.preventDefault();
|
| 49 |
+
document.getElementById("button").click();
|
| 50 |
+
}
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
|
| 54 |
//Empty pokemon text area
|
| 55 |
function resetPoke() {
|
| 56 |
document.getElementById("fname1").value = null;
|
| 57 |
document.getElementById("fname2").value = null;
|
| 58 |
+
document.getElementById("p1").src = "types/unknown.png";
|
|
|
|
| 59 |
document.getElementById("p2").style = "display:none";
|
| 60 |
+
document.getElementById("p3").src = "types/unknown.png";
|
| 61 |
+
document.getElementById("p4").style = "display:none";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
document.getElementById("pic1").src = "question.png";
|
| 63 |
document.getElementById("pic2").src = "question.png";
|
|
|
|
| 64 |
|
| 65 |
+
document.getElementById("dexnumber1").innerHTML = " ";
|
| 66 |
+
document.getElementById("dexnumber2").innerHTML = " ";
|
| 67 |
+
document.getElementById("fusionid1").innerHTML = " ";
|
| 68 |
+
document.getElementById("fusionid2").innerHTML = " ";
|
| 69 |
+
document.getElementById("FP1").innerHTML = "mon1/mon2";
|
| 70 |
+
document.getElementById("FP2").innerHTML = "mon2/mon1";
|
|
|
|
| 71 |
|
| 72 |
document.getElementById("hp1").innerHTML = "HP: ";
|
| 73 |
document.getElementById("atk1").innerHTML = "ATK: ";
|
|
|
|
| 77 |
document.getElementById("spe1").innerHTML = "SPEED: ";
|
| 78 |
document.getElementById("bs1").innerHTML = "TOTAL: ";
|
| 79 |
document.getElementById("ab1").innerHTML = "ABILITY:";
|
| 80 |
+
document.getElementById("hab1").innerHTML = "";
|
| 81 |
|
| 82 |
document.getElementById("hp2").innerHTML = "HP: ";
|
| 83 |
document.getElementById("atk2").innerHTML = "ATK: ";
|
|
|
|
| 87 |
document.getElementById("spe2").innerHTML = "SPEED: ";
|
| 88 |
document.getElementById("bs2").innerHTML = "TOTAL: ";
|
| 89 |
document.getElementById("ab2").innerHTML = "ABILITY:";
|
| 90 |
+
document.getElementById("hab2").innerHTML = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
document.getElementById("weak14").innerHTML = "x4: ";
|
| 93 |
document.getElementById("weak12").innerHTML = "x2: ";
|
| 94 |
+
document.getElementById("weak11").innerHTML = "x1: ";
|
| 95 |
document.getElementById("weak105").innerHTML = "x0.5: ";
|
| 96 |
document.getElementById("weak1025").innerHTML = "x0.25: ";
|
| 97 |
document.getElementById("weak100").innerHTML = "x0: ";
|
| 98 |
|
| 99 |
document.getElementById("weak24").innerHTML = "x4: ";
|
| 100 |
document.getElementById("weak22").innerHTML = "x2: ";
|
| 101 |
+
document.getElementById("weak21").innerHTML = "x1: ";
|
| 102 |
document.getElementById("weak205").innerHTML = "x0.5: ";
|
| 103 |
document.getElementById("weak2025").innerHTML = "x0.25: ";
|
| 104 |
document.getElementById("weak200").innerHTML = "x0: ";
|
| 105 |
|
| 106 |
+
var L0 = ["hp1","atk1","def1","spatk1","spdef1","spe1","bs1"];
|
| 107 |
+
var L1 = ["hp2","atk2","def2","spatk2","spdef2","spe2","bs2"];
|
|
|
|
| 108 |
for (var i = 0; i < L0.length; i++) {
|
| 109 |
document.getElementById(L0[i]).style.color = "";
|
| 110 |
document.getElementById(L1[i]).style.color = "";
|
|
|
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|
| 114 |
+
|
| 115 |
+
function getRandomPokeID(){
|
| 116 |
+
maxPoke = 420
|
| 117 |
+
return Math.floor(Math.random() * Math.floor(maxPoke));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
}
|
| 119 |
|
| 120 |
+
|
| 121 |
+
function randomBothPoke() {randomPoke(true, true)}
|
| 122 |
+
function randomFirstPoke() {randomPoke(true, false)}
|
| 123 |
+
function randomSecondPoke() {randomPoke(false, true)}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
function randomPoke(should_rand1, should_rand2) {
|
| 127 |
+
buttons = document.getElementsByClassName("button");
|
| 128 |
+
for (let i = 0; i < buttons.length; i++) {
|
| 129 |
+
buttons[i].disabled = true;
|
| 130 |
+
};
|
| 131 |
+
|
| 132 |
+
if(should_rand1 || num1 == undefined) {rand1 = getRandomPokeID();}
|
| 133 |
+
else{rand1 = num1 - 1;}
|
| 134 |
+
if(should_rand2 || num2 == undefined) {rand2 = getRandomPokeID();}
|
| 135 |
+
else{rand2 = num2 - 1;}
|
| 136 |
+
|
| 137 |
+
var name = ids[rand1][0].toLowerCase();
|
| 138 |
+
if (nameFix.includes(name)) {
|
| 139 |
+
name = nameException[nameFix.indexOf(name)];
|
| 140 |
+
}
|
| 141 |
+
document.getElementById("fname1").value = name
|
| 142 |
+
|
| 143 |
+
var name2 = ids[rand2][0].toLowerCase();
|
| 144 |
+
if (nameFix.includes(name2)) {
|
| 145 |
+
name2 = nameException[nameFix.indexOf(name2)];
|
| 146 |
}
|
| 147 |
+
document.getElementById("fname2").value = name2
|
| 148 |
+
|
| 149 |
+
fusePoke()
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
function getPokemonName(htmlId){
|
| 154 |
+
var pokemonName = (document.getElementById(htmlId)).value.toLowerCase();
|
| 155 |
+
pokemonName = pokemonName.replace(/\W/g, '');
|
| 156 |
+
return pokemonName;
|
| 157 |
}
|
| 158 |
|
| 159 |
+
|
| 160 |
//Fusion calculation function
|
| 161 |
function fusePoke() {
|
| 162 |
|
| 163 |
//Pokemon from both text area
|
| 164 |
+
mon1 = getPokemonName("fname1");
|
| 165 |
+
mon2 = getPokemonName("fname2");
|
| 166 |
+
|
| 167 |
+
if (isMissingNames(mon1, mon2)) {
|
| 168 |
+
buttons = document.getElementsByClassName("button");
|
| 169 |
+
for (let i = 0; i < buttons.length; i++) {
|
| 170 |
+
buttons[i].disabled = false;
|
| 171 |
+
};
|
| 172 |
alert("Please fill the two text inputs!");
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
// TODO : test if poke is in fangame
|
| 176 |
+
// idCheck
|
| 177 |
+
|
| 178 |
+
else {
|
| 179 |
+
|
| 180 |
+
// Nidoran clause
|
| 181 |
+
if(mon1=="nidoran" || mon2 =="nidoran"){
|
| 182 |
+
alert("Please specify a gender to Nidoran (f or m)");
|
| 183 |
}
|
| 184 |
+
else{
|
| 185 |
|
| 186 |
+
//Special mon selector: Giratina, Deoxys
|
| 187 |
+
if (nameException.includes(mon1)) {
|
| 188 |
+
mon1 = nameFix[nameException.indexOf(mon1)];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
+
|
| 191 |
+
if (nameException.includes(mon2)) {
|
| 192 |
+
mon2 = nameFix[nameException.indexOf(mon2)];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
+
// First request - version A
|
| 196 |
+
var xhr1a = new XMLHttpRequest();
|
| 197 |
+
var url1a = "https://pokeapi.co/api/v2/pokemon/" + mon1;
|
| 198 |
+
xhr1a.open('GET', url1a, true);
|
| 199 |
+
xhr1a.send();
|
| 200 |
+
xhr1a.onload = function() {
|
| 201 |
+
jsonBody = xhr1a.responseText;
|
| 202 |
+
if(jsonBody) {
|
| 203 |
+
if(jsonBody != "Not Found"){
|
| 204 |
+
jp = JSON.parse(jsonBody);
|
| 205 |
+
fuseFirstPoke(jp);
|
| 206 |
}
|
| 207 |
+
else{
|
| 208 |
+
|
| 209 |
+
//First request - version B
|
| 210 |
+
var xhr1b = new XMLHttpRequest();
|
| 211 |
+
var url1b = "https://pokeapi.co/api/v2/pokemon/" + mon1 + "/";
|
| 212 |
+
xhr1b.open('GET', url1b, true);
|
| 213 |
+
xhr1b.send();
|
| 214 |
+
xhr1b.onload = function() {
|
| 215 |
+
jsonBody = xhr1b.responseText;
|
| 216 |
+
if(jsonBody) {
|
| 217 |
+
if(jsonBody != "Not Found"){
|
| 218 |
+
jp = JSON.parse(jsonBody);
|
| 219 |
+
fuseFirstPoke(jp);
|
| 220 |
+
}
|
| 221 |
+
else{
|
| 222 |
+
alert("First pokemon was misspelled ?");
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
else{
|
| 226 |
+
alert("PokeAPI is unreachable (1b)");
|
| 227 |
+
}
|
| 228 |
}
|
| 229 |
}
|
| 230 |
}
|
| 231 |
+
else{
|
| 232 |
+
alert("PokeAPI is unreachable (1a)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
}
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
+
function fuseFirstPoke(jsonString){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
+
//ID selector for sprite showcase of the 1st mon/ Validator for 1st mon
|
| 243 |
+
num1 = jsonString.id;
|
| 244 |
+
var id1 = num1;
|
| 245 |
+
var idCheck1 = false;
|
| 246 |
+
for (var i = 0; i < ids.length; i++){
|
| 247 |
+
if (ids[i][0] == mon1.charAt(0).toUpperCase() + mon1.slice(1)) {
|
| 248 |
+
idCheck1 = true;
|
| 249 |
+
num1 = ids[i][1];
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
if (idCheck1 == false && id1 >= 252) {
|
| 253 |
+
alert("The first pokemon isn't in the fangame!")
|
| 254 |
+
}
|
| 255 |
+
else {
|
| 256 |
+
|
| 257 |
+
//#region Type of 1st mon
|
| 258 |
+
//Type selector for fusion type knowledge of the 1st mon
|
| 259 |
+
var type1 = jsonString.types;
|
| 260 |
+
mon1types = [];
|
| 261 |
+
var compt = 0;
|
| 262 |
+
|
| 263 |
+
//Exception mon selected for swapped types
|
| 264 |
+
for (var i = 0; i < typeSwap.length; i++) {
|
| 265 |
+
if (typeSwap[i][2] == mon1.charAt(0).toUpperCase() + mon1.slice(1)) {
|
| 266 |
+
mon1types.push(typeSwap[i][0]);
|
| 267 |
+
mon1types.push(typeSwap[i][1]);
|
| 268 |
+
var compt = 1;
|
| 269 |
+
}
|
| 270 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
+
//Exception mon selected for one type
|
| 273 |
+
for (var i = 0; i < typeUni.length; i++) {
|
| 274 |
+
if (typeUni[i][1] == mon1.charAt(0).toUpperCase() + mon1.slice(1)) {
|
| 275 |
+
mon1types.push(typeUni[i][0]);
|
| 276 |
+
var compt = 2;
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
|
| 280 |
+
if (compt == 0) {
|
| 281 |
+
mon1types.push(type1[0].type.name);
|
| 282 |
+
if (type1.length == 2 && compt != 2) {
|
| 283 |
+
if (type1[0].type.name == "normal" && type1[1].type.name == "flying") {
|
| 284 |
+
mon1types[0] = "flying";
|
| 285 |
+
} else {
|
| 286 |
+
mon1types.push(type1[1].type.name);
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
}
|
| 290 |
+
//#endregion
|
| 291 |
|
| 292 |
+
//#region Stats of 1st mon
|
| 293 |
+
var stats1;
|
| 294 |
+
if (statsException.includes(mon1)) {
|
| 295 |
+
stats1 = statsFix[statsException.indexOf(mon1)];
|
| 296 |
+
} else {
|
| 297 |
+
stats1 = jsonString.stats;
|
| 298 |
+
}
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
+
mon1stats = [];
|
| 301 |
+
for (var i = 0; i < stats1.length; i++) {
|
| 302 |
+
mon1stats.push(stats1[i].base_stat);
|
| 303 |
+
}
|
| 304 |
+
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
+
//#region Abilities of 1st mon
|
| 307 |
+
var ab1;
|
| 308 |
+
if (abilitiesException.includes(mon1)) {
|
| 309 |
+
ab1 = abilitiesFix[abilitiesException.indexOf(mon1)];
|
| 310 |
+
} else {
|
| 311 |
+
ab1 = jsonString.abilities;
|
| 312 |
+
}
|
| 313 |
+
mon1abilities = [];
|
| 314 |
+
for (var i = 0; i < ab1.length; i++) {
|
| 315 |
+
mon1abilities.push([ab1[i].ability, ab1[i].is_hidden]);
|
| 316 |
+
}
|
| 317 |
+
//#endregion
|
| 318 |
+
|
| 319 |
+
//#region Request
|
| 320 |
+
// Second request - version A
|
| 321 |
+
var xhr2a = new XMLHttpRequest();
|
| 322 |
+
var url2a = "https://pokeapi.co/api/v2/pokemon/" + mon2;
|
| 323 |
+
xhr2a.open('GET', url2a, true);
|
| 324 |
+
xhr2a.send();
|
| 325 |
+
xhr2a.onload = function() {
|
| 326 |
+
jsonBody = xhr2a.responseText;
|
| 327 |
+
if(jsonBody){
|
| 328 |
+
if(jsonBody != "Not Found"){
|
| 329 |
+
jp = JSON.parse(jsonBody);
|
| 330 |
+
fuseSecondPoke(jp);
|
| 331 |
+
}
|
| 332 |
+
else{
|
| 333 |
+
|
| 334 |
+
// Second request - version B
|
| 335 |
+
var xhr2b = new XMLHttpRequest();
|
| 336 |
+
var url2b = "https://pokeapi.co/api/v2/pokemon/" + mon2 + "/";
|
| 337 |
+
xhr2b.open('GET', url2b, true);
|
| 338 |
+
xhr2b.send();
|
| 339 |
+
xhr2b.onload = function() {
|
| 340 |
+
jsonBody = xhr2b.responseText;
|
| 341 |
+
if(jsonBody) {
|
| 342 |
+
if(jsonBody != "Not Found"){
|
| 343 |
+
jp = JSON.parse(jsonBody);
|
| 344 |
+
fuseSecondPoke(jp);
|
| 345 |
+
}
|
| 346 |
+
else{
|
| 347 |
+
alert("Second pokemon was misspelled ?");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
}
|
|
|
|
|
|
|
| 349 |
}
|
| 350 |
+
else{
|
| 351 |
+
alert("PokeAPI is unreachable (2b)");
|
| 352 |
+
}
|
| 353 |
+
}
|
| 354 |
+
}
|
| 355 |
+
}
|
| 356 |
+
else{
|
| 357 |
+
alert("PokeAPI is unreachable (2a)");
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
}
|
| 361 |
+
//#endregion
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
|
| 366 |
+
function fuseSecondPoke(jsonString){
|
| 367 |
+
|
| 368 |
+
//ID selector for sprite showcase of the 2st mon
|
| 369 |
+
num2 = jsonString.id;
|
| 370 |
+
var id2 = num2;
|
| 371 |
+
var idCheck2 = false;
|
| 372 |
+
for (var i = 0; i < ids.length; i++){
|
| 373 |
+
if (ids[i][0] == mon2.charAt(0).toUpperCase() + mon2.slice(1)) {
|
| 374 |
+
idCheck2 = true;
|
| 375 |
+
num2 = ids[i][1];
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
if (idCheck2 == false && id2 >= 252) {
|
| 379 |
+
alert("The second pokemon isn't in the fangame!")
|
| 380 |
+
}
|
| 381 |
+
else {
|
| 382 |
+
|
| 383 |
+
//#region Type of 2nd mon
|
| 384 |
+
//Type selector for fusion type knowledge of the 2nd mon
|
| 385 |
+
var type2 = jsonString.types;
|
| 386 |
+
mon2types = [];
|
| 387 |
+
var compt = 0;
|
| 388 |
+
|
| 389 |
+
//Exception mon selected for swapped types
|
| 390 |
+
for (var i = 0; i < typeSwap.length; i++) {
|
| 391 |
+
if (typeSwap[i][2] == mon2.charAt(0).toUpperCase() + mon2.slice(1)) {
|
| 392 |
+
mon2types.push(typeSwap[i][0]);
|
| 393 |
+
mon2types.push(typeSwap[i][1]);
|
| 394 |
+
var compt = 1;
|
| 395 |
+
}
|
| 396 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
|
| 398 |
+
//Exception mon selected for one type
|
| 399 |
+
for (var i = 0; i < typeUni.length; i++) {
|
| 400 |
+
if (typeUni[i][1] == mon2.charAt(0).toUpperCase() + mon2.slice(1)) {
|
| 401 |
+
mon2types.push(typeUni[i][0]);
|
| 402 |
+
var compt = 2;
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
|
| 406 |
+
//Type of 2nd mon
|
| 407 |
+
if (compt == 0) {
|
| 408 |
+
mon2types.push(type2[0].type.name);
|
| 409 |
+
if (type2.length == 2 && compt != 2) {
|
| 410 |
+
if (type2[0].type.name == "normal" && type2[1].type.name == "flying") {
|
| 411 |
+
mon2types[0] = "flying";
|
| 412 |
+
} else {
|
| 413 |
+
mon2types.push(type2[1].type.name);
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
}
|
| 417 |
+
//#endregion
|
| 418 |
|
| 419 |
+
//#region Stats of 2nd mon
|
| 420 |
+
var stats2;
|
| 421 |
+
if (statsException.includes(mon2)) {
|
| 422 |
+
stats2 = statsFix[statsException.indexOf(mon2)];
|
| 423 |
+
} else {
|
| 424 |
+
stats2 = jsonString.stats;
|
| 425 |
+
}
|
| 426 |
+
mon2stats = [];
|
| 427 |
+
for (var i = 0; i < stats2.length; i++) {
|
| 428 |
+
mon2stats.push(stats2[i].base_stat);
|
| 429 |
+
}
|
| 430 |
+
//#endregion
|
| 431 |
|
| 432 |
+
//#region Abilities of 2nd mon
|
| 433 |
+
var ab2;
|
| 434 |
+
if (abilitiesException.includes(mon2)) {
|
| 435 |
+
ab2 = abilitiesFix[abilitiesException.indexOf(mon2)];
|
| 436 |
+
} else {
|
| 437 |
+
ab2 = jsonString.abilities;
|
| 438 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
+
mon2abilities = [];
|
| 441 |
+
for (var i = 0; i < ab2.length; i++) {
|
| 442 |
+
mon2abilities.push([ab2[i].ability, ab2[i].is_hidden]);
|
| 443 |
+
}
|
| 444 |
+
//#endregion
|
| 445 |
|
| 446 |
+
fuseBothPoke()
|
|
|
|
|
|
|
| 447 |
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
}
|
| 451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
|
| 453 |
+
function fuseBothPoke(){
|
| 454 |
+
|
| 455 |
+
//TODO : factor this
|
| 456 |
+
//Name of fusion
|
| 457 |
+
if (!nameFix.includes(mon1) && !nameFix.includes(mon2)) {
|
| 458 |
+
var fmon1 = mon1.charAt(0).toUpperCase() + mon1.slice(1);
|
| 459 |
+
var fmon2 = mon2.charAt(0).toUpperCase() + mon2.slice(1);
|
| 460 |
+
} else if (nameFix.includes(mon1) && !nameFix.includes(mon2)) {
|
| 461 |
+
var fmon1 = nameException[nameFix.indexOf(mon1)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon1)].slice(1);
|
| 462 |
+
var fmon2 = mon2.charAt(0).toUpperCase() + mon2.slice(1);
|
| 463 |
+
} else if (!nameFix.includes(mon1) && nameFix.includes(mon2)) {
|
| 464 |
+
var fmon1 = mon1.charAt(0).toUpperCase() + mon1.slice(1);
|
| 465 |
+
var fmon2 = nameException[nameFix.indexOf(mon2)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon2)].slice(1);
|
| 466 |
+
} else if (nameFix.includes(mon1) && nameFix.includes(mon2)) {
|
| 467 |
+
var fmon1 = nameException[nameFix.indexOf(mon1)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon1)].slice(1);
|
| 468 |
+
var fmon2 = nameException[nameFix.indexOf(mon2)].charAt(0).toUpperCase() + nameException[nameFix.indexOf(mon2)].slice(1);
|
| 469 |
+
}
|
| 470 |
|
| 471 |
+
//Dex Numbers
|
| 472 |
+
var dexnum1 = Math.floor(num1 + (420 * num2));
|
| 473 |
+
var dexnum2 = Math.floor(num2 + (420 * num1));
|
| 474 |
+
document.getElementById("dexnumber1").innerHTML = dexnum1;
|
| 475 |
+
document.getElementById("dexnumber2").innerHTML = dexnum2;
|
| 476 |
+
document.getElementById("fusionid1").innerHTML = " (" + num1 + "." + num2 + ")";
|
| 477 |
+
document.getElementById("fusionid2").innerHTML = " (" + num2 + "." + num1 + ")";
|
| 478 |
+
|
| 479 |
+
//Name of fusions
|
| 480 |
+
document.getElementById("FP1").innerHTML = fmon1+ "/" + fmon2;
|
| 481 |
+
document.getElementById("FP2").innerHTML = fmon2 + "/" + fmon1;
|
| 482 |
+
|
| 483 |
+
//Name of pictures
|
| 484 |
+
var pic1 = num1 + "." + num2 + ".png";
|
| 485 |
+
var pic2 = num2 + "." + num1 + ".png";
|
| 486 |
+
|
| 487 |
+
//Stats calculation
|
| 488 |
+
var hp1 = (mon2stats[0]/3) + 2*(mon1stats[0]/3);
|
| 489 |
+
var atk1 = 2*(mon2stats[1]/3) + (mon1stats[1]/3);
|
| 490 |
+
var def1 = 2*(mon2stats[2]/3) + (mon1stats[2]/3);
|
| 491 |
+
var spatk1 = (mon2stats[3]/3) + 2*(mon1stats[3]/3);
|
| 492 |
+
var spdef1 = (mon2stats[4]/3) + 2*(mon1stats[4]/3);
|
| 493 |
+
var spe1 = 2*(mon2stats[5]/3) + (mon1stats[5]/3);
|
| 494 |
+
var bs1 = Math.floor(hp1) + Math.floor(atk1) + Math.floor(def1) + Math.floor(spatk1) + Math.floor(spdef1) + Math.floor(spe1);
|
| 495 |
+
|
| 496 |
+
var hp2 = (mon1stats[0]/3) + 2*(mon2stats[0]/3);
|
| 497 |
+
var atk2 = 2*(mon1stats[1]/3) + (mon2stats[1]/3);
|
| 498 |
+
var def2= 2*(mon1stats[2]/3) + (mon2stats[2]/3);
|
| 499 |
+
var spatk2 = (mon1stats[3]/3) + 2*(mon2stats[3]/3);
|
| 500 |
+
var spdef2 = (mon1stats[4]/3) + 2*(mon2stats[4]/3);
|
| 501 |
+
var spe2 = 2*(mon1stats[5]/3) + (mon2stats[5]/3);
|
| 502 |
+
var bs2 = Math.floor(hp2) + Math.floor(atk2) + Math.floor(def2) + Math.floor(spatk2) + Math.floor(spdef2) + Math.floor(spe2);
|
| 503 |
+
|
| 504 |
+
var L0 = ["hp1","atk1","def1","spatk1","spdef1","spe1","bs1"];
|
| 505 |
+
var L1 = ["hp2","atk2","def2","spatk2","spdef2","spe2","bs2"];
|
| 506 |
+
var L2 = [Math.floor(hp1), Math.floor(atk1), Math.floor(def1), Math.floor(spatk1), Math.floor(spdef1), Math.floor(spe1), Math.floor(bs1)];
|
| 507 |
+
var L3 = [Math.floor(hp2), Math.floor(atk2), Math.floor(def2), Math.floor(spatk2), Math.floor(spdef2), Math.floor(spe2), Math.floor(bs2)];
|
| 508 |
+
var L4 = [];
|
| 509 |
+
var L5 = [];
|
| 510 |
+
for (var i = 0; i < L0.length; i++) {
|
| 511 |
+
L4.push(Math.max(L2[i], L3[i])-Math.min(L2[i], L3[i]));
|
| 512 |
+
}
|
| 513 |
|
| 514 |
+
//Color of stats
|
| 515 |
+
for (var i = 0; i < L1.length; i++) {
|
| 516 |
+
if (L2[i] < L3[i]) {
|
| 517 |
+
document.getElementById(L0[i]).style.color = "red";
|
| 518 |
+
document.getElementById(L1[i]).style.color = "green";
|
| 519 |
+
L5.push(" (+" + L4[i] + ")");
|
| 520 |
+
L4[i] = " (-" + L4[i] + ")";
|
| 521 |
+
} else if (L2[i] > L3[i]) {
|
| 522 |
+
document.getElementById(L1[i]).style.color = "red";
|
| 523 |
+
document.getElementById(L0[i]).style.color = "green";
|
| 524 |
+
L5.push(" (-" + L4[i] + ")");
|
| 525 |
+
L4[i] = " (+" + L4[i] + ")";
|
| 526 |
+
} else {
|
| 527 |
+
document.getElementById(L1[i]).style.color = "orange";
|
| 528 |
+
document.getElementById(L0[i]).style.color = "orange";
|
| 529 |
+
L4[i] = " (0)";
|
| 530 |
+
L5.push(" (0)");
|
| 531 |
+
}
|
| 532 |
+
document.getElementById(L0[i]).innerHTML = L0[i].slice(-1) + ": " + L2[i];
|
| 533 |
+
document.getElementById(L1[i]).innerHTML = L1[i].slice(-1) + ": " + L3[i];
|
| 534 |
+
}
|
| 535 |
|
| 536 |
+
//Writting stat in HTML
|
| 537 |
+
|
| 538 |
+
/*
|
| 539 |
+
if (mon1 == "shedinja" || mon2 == "shedinja") {
|
| 540 |
+
document.getElementById("hp1").innerHTML = "HP: 1 (0)";
|
| 541 |
+
document.getElementById("hp1").style.color = "orange";
|
| 542 |
+
} else {*/
|
| 543 |
+
document.getElementById("hp1").innerHTML = "HP: " + Math.floor(hp1) + L4[0];
|
| 544 |
+
/*}*/
|
| 545 |
+
|
| 546 |
+
document.getElementById("atk1").innerHTML = "ATK: " + Math.floor(atk1) + L4[1];
|
| 547 |
+
document.getElementById("def1").innerHTML = "DEF: " + Math.floor(def1) + L4[2];
|
| 548 |
+
document.getElementById("spatk1").innerHTML = "SPE.ATK: " + Math.floor(spatk1) + L4[3];
|
| 549 |
+
document.getElementById("spdef1").innerHTML = "SPE.DEF: " + Math.floor(spdef1) + L4[4];
|
| 550 |
+
document.getElementById("spe1").innerHTML = "SPEED: " + Math.floor(spe1) + L4[5];
|
| 551 |
+
document.getElementById("bs1").innerHTML = "TOTAL: " + Math.floor(bs1) + L4[6];
|
| 552 |
+
|
| 553 |
+
/*
|
| 554 |
+
if (mon1 == "shedinja" || mon2 == "shedinja") {
|
| 555 |
+
document.getElementById("hp2").innerHTML = "HP: 1 (0)";
|
| 556 |
+
document.getElementById("hp2").style.color = "orange";
|
| 557 |
+
} else {*/
|
| 558 |
+
document.getElementById("hp2").innerHTML = "HP: " + Math.floor(hp2) + L5[0];
|
| 559 |
+
/*}*/
|
| 560 |
+
document.getElementById("atk2").innerHTML = "ATK: " + Math.floor(atk2) + L5[1];
|
| 561 |
+
document.getElementById("def2").innerHTML = "DEF: " + Math.floor(def2) + L5[2];
|
| 562 |
+
document.getElementById("spatk2").innerHTML = "SPE.ATK: " + Math.floor(spatk2) + L5[3];
|
| 563 |
+
document.getElementById("spdef2").innerHTML = "SPE.DEF: " + Math.floor(spdef2) + L5[4];
|
| 564 |
+
document.getElementById("spe2").innerHTML = "SPEED: " + Math.floor(spe2) + L5[5];
|
| 565 |
+
document.getElementById("bs2").innerHTML = "TOTAL: " + Math.floor(bs2) + L5[6];
|
| 566 |
+
|
| 567 |
+
//Abilities of fused mons
|
| 568 |
+
if (abilitySwap.includes(mon1)) {
|
| 569 |
+
[mon1abilities[0], mon1abilities[1]] = [mon1abilities[1], mon1abilities[0]];
|
| 570 |
+
}
|
| 571 |
+
if (abilitySwap.includes(mon2)) {
|
| 572 |
+
[mon2abilities[0], mon2abilities[1]] = [mon2abilities[1], mon2abilities[0]];
|
| 573 |
+
}
|
| 574 |
|
| 575 |
+
//Type of fused mons
|
| 576 |
+
var fmonres1 = null;
|
| 577 |
+
var fmonres2 = null;
|
| 578 |
+
if(mon1 == mon2 && selfFusionTypeException.includes(mon1)){
|
| 579 |
+
fmonres1 = selfFusionTypeFix[selfFusionTypeException.indexOf(mon1)];
|
| 580 |
+
fmonres2 = fmonres1
|
| 581 |
+
}
|
| 582 |
+
else{
|
| 583 |
+
fmonres1 = fusType(mon1types, mon2types);
|
| 584 |
+
fmonres2 = fusType(mon2types, mon1types);
|
| 585 |
+
}
|
| 586 |
|
| 587 |
+
//Types effectiveness
|
| 588 |
+
if (typeComp>0) {
|
| 589 |
+
c = document.getElementsByClassName('monweak');
|
| 590 |
+
for( b=0; b < c.length; b++ )
|
| 591 |
+
{
|
| 592 |
+
defaultValue = c[b].getAttribute('data-default');
|
| 593 |
+
if (defaultValue) {
|
| 594 |
+
c[b].innerText = defaultValue;
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
}
|
| 598 |
|
| 599 |
+
tyeffid1 = typeId(fmonres1);
|
| 600 |
+
tyeffid2 = typeId(fmonres1);
|
| 601 |
|
| 602 |
+
for (var i = 0; i < typeName.length; i++) {
|
| 603 |
+
result1[i] = (types[i][tyeffid1[0]] * types[i][tyeffid1[1]]);
|
| 604 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
|
| 606 |
+
for (var i = 0; i < typeName.length; i++) {
|
| 607 |
+
var image = new Image()
|
| 608 |
+
image.src = "types/" + typeName[i] + ".png";
|
| 609 |
+
|
| 610 |
+
if (result1[i] == 4) {
|
| 611 |
+
document.getElementById("weak14").appendChild(image);
|
| 612 |
+
}
|
| 613 |
+
if (result1[i] == 2) {
|
| 614 |
+
document.getElementById("weak12").appendChild(image);
|
| 615 |
+
}
|
| 616 |
+
if (result1[i] == 1) {
|
| 617 |
+
document.getElementById("weak11").appendChild(image);
|
| 618 |
+
}
|
| 619 |
+
if (result1[i] == 0.5) {
|
| 620 |
+
document.getElementById("weak105").appendChild(image);
|
| 621 |
+
}
|
| 622 |
+
if (result1[i] == 0.25) {
|
| 623 |
+
document.getElementById("weak1025").appendChild(image);
|
| 624 |
+
}
|
| 625 |
+
if (result1[i] == 0) {
|
| 626 |
+
document.getElementById("weak100").appendChild(image);
|
| 627 |
+
}
|
| 628 |
+
}
|
| 629 |
|
| 630 |
+
tyeffid1 = typeId(fmonres2);
|
| 631 |
+
tyeffid2 = typeId(fmonres2);
|
|
|
|
|
|
|
| 632 |
|
| 633 |
+
for (var i = 0; i < typeName.length; i++) {
|
| 634 |
+
result2[i] = (types[i][tyeffid1[0]] * types[i][tyeffid1[1]]);
|
| 635 |
+
}
|
| 636 |
|
| 637 |
+
for (var i = 0; i < typeName.length; i++) {
|
| 638 |
+
var image = new Image();
|
| 639 |
+
image.src = "types/" + typeName[i] + ".png";
|
| 640 |
|
| 641 |
+
if (result2[i] == 4) {
|
| 642 |
+
document.getElementById("weak24").appendChild(image);
|
| 643 |
+
}
|
| 644 |
+
if (result2[i] == 2) {
|
| 645 |
+
document.getElementById("weak22").appendChild(image);
|
| 646 |
+
}
|
| 647 |
+
if (result2[i] == 1) {
|
| 648 |
+
document.getElementById("weak21").appendChild(image);
|
| 649 |
+
}
|
| 650 |
+
if (result2[i] == 0.5) {
|
| 651 |
+
document.getElementById("weak205").appendChild(image);
|
| 652 |
+
}
|
| 653 |
+
if (result2[i] == 0.25) {
|
| 654 |
+
document.getElementById("weak2025").appendChild(image);
|
| 655 |
+
}
|
| 656 |
+
if (result2[i] == 0) {
|
| 657 |
+
document.getElementById("weak200").appendChild(image);
|
| 658 |
+
}
|
| 659 |
+
}
|
| 660 |
|
| 661 |
+
typeComp += 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 662 |
|
| 663 |
+
document.getElementById("p1").src = "types/" + fmonres1[0] + ".png";
|
| 664 |
+
if (fmonres1.length!=1 && (fmonres1.length == 2 && fmonres1[0] != fmonres1[1])) {
|
| 665 |
+
document.getElementById("p2").style.display = "inline-block";
|
| 666 |
+
document.getElementById("p2").src = "types/" + fmonres1[1] + ".png";
|
| 667 |
+
} else {
|
| 668 |
+
document.getElementById("p2").style.display = "none";
|
| 669 |
+
}
|
| 670 |
|
| 671 |
+
document.getElementById("p3").src = "types/" + fmonres2[0] + ".png";
|
|
|
|
| 672 |
|
| 673 |
+
if (fmonres2.length!=1 && (fmonres2.length == 2 && fmonres2[0] != fmonres2[1])) {
|
| 674 |
+
document.getElementById("p4").style.display = "inline-block";
|
| 675 |
+
document.getElementById("p4").src = "types/" + fmonres2[1] + ".png";
|
| 676 |
+
} else {
|
| 677 |
+
document.getElementById("p4").style.display = "none";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 678 |
}
|
| 679 |
+
|
| 680 |
+
//Picture of fusions (if inside CustomBattlers)
|
| 681 |
+
showFusion("pic1", pic1, "fusionid1");
|
| 682 |
+
showFusion("pic2", pic2, "fusionid2");
|
| 683 |
+
|
| 684 |
+
//Abilities 1
|
| 685 |
+
var abilities1 = fusionAbilities(mon1abilities, mon2abilities);
|
| 686 |
+
var hiddenAbilities1 = fusionHiddenAbilities(mon1abilities, mon2abilities, abilities1);
|
| 687 |
+
var abilitiesText1 = "ABILITY: " + sanitizeAbilityList(abilities1);
|
| 688 |
+
var hiddenAbilitiesText1 = sanitizeAbilityList(hiddenAbilities1);
|
| 689 |
+
|
| 690 |
+
document.getElementById("ab1").innerHTML = abilitiesText1;
|
| 691 |
+
document.getElementById("hab1").innerHTML = hiddenAbilitiesText1;
|
| 692 |
+
|
| 693 |
+
//Abilities 2
|
| 694 |
+
var abilties2 = fusionAbilities(mon2abilities, mon1abilities);
|
| 695 |
+
var hiddenAbilities2 = fusionHiddenAbilities(mon2abilities, mon1abilities, abilties2);
|
| 696 |
+
var abilitiesText2 = "ABILITY: " + sanitizeAbilityList(abilties2);
|
| 697 |
+
var hiddenAbilitiesText2 = sanitizeAbilityList(hiddenAbilities2);
|
| 698 |
+
|
| 699 |
+
document.getElementById("ab2").innerHTML = abilitiesText2;
|
| 700 |
+
document.getElementById("hab2").innerHTML = hiddenAbilitiesText2;
|
| 701 |
+
|
| 702 |
+
//Fusion done
|
| 703 |
+
buttons = document.getElementsByClassName("button");
|
| 704 |
+
for (let i = 0; i < buttons.length; i++) {
|
| 705 |
+
buttons[i].disabled = false;
|
| 706 |
+
};
|
| 707 |
}
|
| 708 |
|
| 709 |
|
|
|
|
| 717 |
return [ty1, ty2];
|
| 718 |
}
|
| 719 |
|
|
|
|
|
|
|
| 720 |
|
| 721 |
+
//Custom sprite fusion function
|
| 722 |
+
function showFusion(elementId, fusionId, elementFusionId){
|
| 723 |
+
|
| 724 |
fusionUrl = "https://raw.githubusercontent.com/Aegide/custom-fusion-sprites/main/CustomBattlers/" + fusionId;
|
| 725 |
+
document.getElementById(elementId).title = fusionId;
|
| 726 |
|
| 727 |
+
if(doesImageExists(fusionUrl)){
|
| 728 |
document.getElementById(elementId).src = fusionUrl;
|
| 729 |
+
document.getElementById(elementFusionId).style.color = "green";
|
| 730 |
}
|
| 731 |
+
else{//Screenshot of autogen pokemon
|
| 732 |
fallbackFusionRepository = "https://raw.githubusercontent.com/Aegide/autogen-fusion-sprites/master/Battlers/"
|
| 733 |
headId = fusionId.split(".")[0];
|
| 734 |
fallbackFusionUrl = fallbackFusionRepository + headId + "/" + fusionId;
|
|
|
|
| 735 |
document.getElementById(elementId).src = fallbackFusionUrl;
|
| 736 |
+
document.getElementById(elementFusionId).style.color = "red";
|
| 737 |
}
|
| 738 |
}
|
| 739 |
|
| 740 |
//Error detection
|
| 741 |
+
function doesImageExists(imageUrl){
|
| 742 |
var http = new XMLHttpRequest();
|
| 743 |
http.open('HEAD', imageUrl, false);
|
| 744 |
+
|
| 745 |
+
// Can't handle error in an easy way
|
| 746 |
http.send();
|
| 747 |
return http.status != 404;
|
| 748 |
}
|
| 749 |
|
| 750 |
+
// Swaps the head with the body and viceversa
|
| 751 |
+
function swapPoke(){
|
| 752 |
+
let auxId = headId;
|
| 753 |
+
let auxFname = document.getElementById("fname1").value;
|
| 754 |
+
|
| 755 |
+
headId = bodyId;
|
| 756 |
+
document.getElementById("fname1").value = document.getElementById("fname2").value;
|
| 757 |
+
|
| 758 |
+
bodyId = auxId;
|
| 759 |
+
document.getElementById("fname2").value = auxFname;
|
| 760 |
+
|
| 761 |
+
showShinies(false, false);
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
// Let's you pick a image from your machine
|
| 765 |
+
$("input[id='pic1']").click(function() {
|
| 766 |
+
$("input[id='input_file']").click();
|
| 767 |
+
});
|
| 768 |
+
function readURLImage(input) {
|
| 769 |
+
if (typeof headId !== 'undefined' && typeof bodyId !== 'undefined') {
|
| 770 |
+
if (input.files && input.files[0]) {
|
| 771 |
+
var reader = new FileReader();
|
| 772 |
+
reader.onload = function (e) {
|
| 773 |
+
$('#pic1').attr('src', e.target.result);
|
| 774 |
+
$('#pic2').attr('src', e.target.result);
|
| 775 |
+
document.getElementById("pic2").style.filter
|
| 776 |
+
= "hue-rotate(" + calcShinyHue(headId, bodyId, true, false) + "deg)";
|
| 777 |
+
$('#pic3').attr('src', e.target.result);
|
| 778 |
+
document.getElementById("pic3").style.filter
|
| 779 |
+
= "hue-rotate(" + calcShinyHue(headId, bodyId, false, true) + "deg)";
|
| 780 |
+
$('#pic4').attr('src', e.target.result);
|
| 781 |
+
document.getElementById("pic4").style.filter
|
| 782 |
+
= "hue-rotate(" + calcShinyHue(headId, bodyId, true, true) + "deg)";
|
| 783 |
+
};
|
| 784 |
+
reader.readAsDataURL(input.files[0]);
|
| 785 |
+
}
|
| 786 |
+
} else {
|
| 787 |
+
alert("Please fill the two text inputs!");
|
| 788 |
}
|
|
|
|
| 789 |
}
|
| 790 |
|
| 791 |
+
// Shows the images for the mon and it's shinies
|
| 792 |
+
function showShinies(randomHead, randomBody){
|
| 793 |
+
buttons = document.getElementsByClassName("button");
|
| 794 |
+
for (let i = 0; i < buttons.length; i++) {
|
| 795 |
+
buttons[i].disabled = true;
|
| 796 |
+
};
|
| 797 |
+
|
| 798 |
+
document.getElementById("input_file").value = ""; // To make the input work everytime, even if the input image has not changed
|
| 799 |
+
|
| 800 |
+
if (randomHead) {
|
| 801 |
+
headId = getRandomPokeID();
|
| 802 |
+
var name = ids[headId][0].toLowerCase();
|
| 803 |
+
if (nameFix.includes(name)) {
|
| 804 |
+
name = nameException[nameFix.indexOf(name)];
|
| 805 |
}
|
| 806 |
+
document.getElementById("fname1").value = name;
|
| 807 |
+
} else {
|
| 808 |
+
var name = document.getElementById("fname1").value.toLowerCase();
|
| 809 |
+
if (nameException.includes(name)) {
|
| 810 |
+
name = nameFix[nameException.indexOf(name)];
|
| 811 |
+
}
|
| 812 |
+
for (let i = 0; i < ids.length; i++) {
|
| 813 |
+
if (name.toUpperCase() == ids[i][0].toUpperCase()) {
|
| 814 |
+
headId = i;
|
| 815 |
+
break;
|
| 816 |
+
}
|
| 817 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 818 |
}
|
|
|
|
| 819 |
|
| 820 |
+
if (randomBody) {
|
| 821 |
+
bodyId = getRandomPokeID();
|
| 822 |
+
var name2 = ids[bodyId][0].toLowerCase();
|
| 823 |
+
if (nameFix.includes(name2)) {
|
| 824 |
+
name2 = nameException[nameFix.indexOf(name2)];
|
| 825 |
+
}
|
| 826 |
+
document.getElementById("fname2").value = name2;
|
|
|
|
| 827 |
} else {
|
| 828 |
+
var name2 = document.getElementById("fname2").value.toLowerCase();
|
| 829 |
+
if (nameException.includes(name2)) {
|
| 830 |
+
name2 = nameFix[nameException.indexOf(name2)];
|
| 831 |
+
}
|
| 832 |
+
for (let i = 0; i < ids.length; i++) {
|
| 833 |
+
if (name2.toUpperCase() == ids[i][0].toUpperCase()) {
|
| 834 |
+
bodyId = i;
|
| 835 |
+
break;
|
| 836 |
+
}
|
| 837 |
+
}
|
| 838 |
}
|
| 839 |
+
|
| 840 |
+
document.getElementById("dexnumber1").innerHTML = (bodyId + 1) * 420 + headId + 1;
|
| 841 |
+
document.getElementById("fusionid1").innerHTML = " (" + (headId + 1) + "." + (bodyId + 1) + ")"
|
| 842 |
+
document.getElementById("fusionid1").style.color = "green";
|
| 843 |
+
|
| 844 |
+
picShinySrc = "https://raw.githubusercontent.com/Aegide/custom-fusion-sprites/main/CustomBattlers/" + (headId+1) + "." + (bodyId+1) + ".png";
|
| 845 |
+
|
| 846 |
+
if (!doesImageExists(picShinySrc)) {
|
| 847 |
+
picShinySrc = "https://raw.githubusercontent.com/Aegide/autogen-fusion-sprites/master/Battlers/" + (headId+1) + "/" + (headId+1) + "." + (bodyId+1) + ".png";
|
| 848 |
+
document.getElementById("fusionid1").style.color = "red";
|
| 849 |
+
}
|
| 850 |
+
|
| 851 |
+
document.getElementById("pic1").src = picShinySrc;
|
| 852 |
+
|
| 853 |
+
window.hueShift = [];
|
| 854 |
+
hueShift[0] = calcShinyHue(headId, bodyId, true, false)
|
| 855 |
+
let picShiny = document.getElementById("pic2");
|
| 856 |
+
picShiny.title = picShiny.alt = "Hue shift " + Math.trunc(hueShift[0]);
|
| 857 |
+
|
| 858 |
+
hueShift[1] = calcShinyHue(headId, bodyId, false, true)
|
| 859 |
+
picShiny = document.getElementById("pic3");
|
| 860 |
+
picShiny.title = picShiny.alt = "Hue shift " + Math.trunc(hueShift[1]);
|
| 861 |
+
|
| 862 |
+
hueShift[2] = calcShinyHue(headId, bodyId, true, true)
|
| 863 |
+
picShiny = document.getElementById("pic4");
|
| 864 |
+
picShiny.title = picShiny.alt = "Hue shift " + Math.trunc(hueShift[2]);
|
| 865 |
+
|
| 866 |
+
buttons = document.getElementsByClassName("button");
|
| 867 |
+
for (let i = 0; i < buttons.length; i++) {
|
| 868 |
+
buttons[i].disabled = false;
|
| 869 |
+
};
|
| 870 |
}
|
| 871 |
|
| 872 |
+
// Calculates the hue of the shiny and returns it it.
|
| 873 |
+
// This tries to replicate the calculation made in the game itself.
|
| 874 |
+
function calcShinyHue(num1, num2, hasShinyHead, hasShinyBody) {
|
| 875 |
+
let offset = 0;
|
| 876 |
+
|
| 877 |
+
if (hasShinyHead && hasShinyBody && num1 in shinyColorOffsetsDict && num2 in shinyColorOffsetsDict){
|
| 878 |
+
offset = shinyColorOffsetsDict[num1] + shinyColorOffsetsDict[num2];
|
| 879 |
+
} else if (hasShinyHead && num1 in shinyColorOffsetsDict) {
|
| 880 |
+
offset = shinyColorOffsetsDict[num1]
|
| 881 |
+
} else if (hasShinyBody && num2 in shinyColorOffsetsDict) {
|
| 882 |
+
offset = shinyColorOffsetsDict[num2]
|
| 883 |
} else {
|
| 884 |
+
offset = calcShinyHueDeafult(num1, num2, hasShinyHead, hasShinyBody);
|
| 885 |
}
|
| 886 |
+
|
| 887 |
+
return offset;
|
| 888 |
}
|
| 889 |
|
| 890 |
+
// Calculates the hue of the shiny and returns it it.
|
| 891 |
+
// This tries to replicate the calculation made in the game itself.
|
| 892 |
+
function calcShinyHueDeafult(num1, num2, hasShinyHead, hasShinyBody) {
|
| 893 |
+
let dexOffset = num1 + num2 * 420;
|
| 894 |
+
let dexDiff = Math.abs(num2 - num1);
|
|
|
|
| 895 |
|
| 896 |
+
if (hasShinyHead && !hasShinyBody) {
|
| 897 |
+
dexOffset = num1;
|
| 898 |
+
} else if (!hasShinyHead && hasShinyBody) {
|
| 899 |
+
dexOffset = dexDiff > 20 ? num2 : num2 + 40
|
| 900 |
+
}
|
| 901 |
|
| 902 |
+
offset = dexOffset + 75;
|
| 903 |
+
if (offset > 420) offset /= 360;
|
| 904 |
+
if (offset < 40) offset = 40;
|
| 905 |
+
if (Math.abs(360 - offset) < 40) offset = 40;
|
|
|
|
|
|
|
| 906 |
|
| 907 |
+
return offset;
|
| 908 |
}
|
| 909 |
|
| 910 |
+
|
| 911 |
+
function fusionAbilities(headAbilities, bodyAbilities) {
|
| 912 |
+
var B0 = bodyAbilities[0][0].name;
|
| 913 |
+
var H1;
|
| 914 |
+
|
| 915 |
+
//If there is only ability, pick that one
|
| 916 |
+
if(headAbilities.length == 1){
|
| 917 |
+
H1 = headAbilities[0][0].name;
|
| 918 |
}
|
| 919 |
+
|
| 920 |
+
//If the second ability is a hidden ability, pick the first ability
|
| 921 |
+
else if(headAbilities[1][1] == true){
|
| 922 |
+
H1 = headAbilities[0][0].name;
|
| 923 |
+
}
|
| 924 |
+
//Otherwise, actually take the second ability
|
| 925 |
+
else{
|
| 926 |
+
H1 = headAbilities[1][0].name;
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
return [B0, H1];
|
| 930 |
+
}
|
| 931 |
+
|
| 932 |
+
|
| 933 |
+
function fusionHiddenAbilities(headAbilities, bodyAbilities, fusionAbilities){
|
| 934 |
+
|
| 935 |
+
var headAbility, bodyAbility;
|
| 936 |
+
var allAbilities = [];
|
| 937 |
+
|
| 938 |
+
var maxAbilities = 3;//Pokémons can't have more than 3 abilities
|
| 939 |
+
for(var a = 0; a < maxAbilities; a++){
|
| 940 |
+
if( a < headAbilities.length){
|
| 941 |
+
headAbility = ability = headAbilities[a][0].name;
|
| 942 |
+
allAbilities.push(headAbility);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 943 |
}
|
| 944 |
+
if( a < bodyAbilities.length){
|
| 945 |
+
bodyAbility = bodyAbilities[a][0].name;
|
| 946 |
+
allAbilities.push(bodyAbility);
|
|
|
|
|
|
|
|
|
|
| 947 |
}
|
|
|
|
|
|
|
|
|
|
| 948 |
}
|
| 949 |
+
|
| 950 |
+
hiddenAbilities = allAbilities.filter(n => !fusionAbilities.includes(n));
|
| 951 |
+
|
| 952 |
+
return hiddenAbilities;
|
| 953 |
+
}
|
| 954 |
+
|
| 955 |
+
|
| 956 |
+
function removeDuplicates(list){
|
| 957 |
+
return Array.from(new Set(list));
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
|
| 961 |
+
function sanitizeAbilityList(abilityList){
|
| 962 |
+
|
| 963 |
+
if(abilityList.length == 0){
|
| 964 |
+
return abilityList;
|
| 965 |
+
}
|
| 966 |
+
|
| 967 |
+
abilityList = removeDuplicates(abilityList);
|
| 968 |
+
|
| 969 |
+
var listAb1 = "";
|
| 970 |
+
for (var i = 0; i < abilityList.length; i++) {
|
| 971 |
+
listAb1 = listAb1 + abilityList[i].charAt(0).toUpperCase() + abilityList[i].slice(1) + " / ";
|
| 972 |
+
}
|
| 973 |
+
listAb1 = listAb1.slice(0, listAb1.length - 1);
|
| 974 |
+
listAb1 = listAb1.split("-").join(" ")
|
| 975 |
+
listAb1 = listAb1.split(" ")
|
| 976 |
+
for (var i = 0, x = listAb1.length; i < x; i++) {
|
| 977 |
+
listAb1[i] = listAb1[i][0].toUpperCase() + listAb1[i].substr(1);
|
| 978 |
+
}
|
| 979 |
+
listAb1 = listAb1.join(" ").slice(0, -2);
|
| 980 |
+
|
| 981 |
+
return listAb1;
|
| 982 |
}
|
| 983 |
|
| 984 |
+
|
| 985 |
//Ability fusion function
|
| 986 |
function fusAb(mon1, mon2) {
|
| 987 |
var fabs = [];
|
|
|
|
| 989 |
if (mon1.length == 3 && mon1[2][1] == true) {
|
| 990 |
var H1 = mon1[1][0].name;
|
| 991 |
var HH = mon1[2][0].name;
|
| 992 |
+
}else if (mon1.length == 2 && mon1[1][1] == true) {
|
| 993 |
var HH = mon1[1][0].name;
|
| 994 |
+
} else if (mon1.length == 2 && mon1[1][1] == false){
|
| 995 |
var H1 = mon1[1][0].name;
|
| 996 |
}
|
|
|
|
| 997 |
var B0 = mon2[0][0].name;
|
| 998 |
if (mon2.length == 3 && mon2[2][1] == true) {
|
| 999 |
var B1 = mon2[1][0].name;
|
| 1000 |
+
var BH = mon2[2][0].name;
|
| 1001 |
+
}else if (mon2.length == 2 && mon2[1][1] == true) {
|
| 1002 |
var BH = mon2[1][0].name;
|
| 1003 |
+
} else if (mon1.length == 2 && mon1[1][1] == false){
|
| 1004 |
var B1 = mon2[1][0].name;
|
| 1005 |
}
|
| 1006 |
+
//cas H0/null/null + B0/null/null [H0=B0] -> H0/null/null
|
| 1007 |
+
if (mon1.length == 1 && mon2.length == 1 && mon1[0][1] == false && mon2[0][1] == false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1008 |
if (H0 == B0) {
|
| 1009 |
fabs.push(H0);
|
| 1010 |
+
//cas H0/null/null + B0/null/null [H0#B0] -> H0/B0/null
|
| 1011 |
+
} else if (H0 != B0) {
|
| 1012 |
fabs.push(H0);
|
| 1013 |
fabs.push(B0);
|
| 1014 |
}
|
| 1015 |
+
//cas H0/H1/null + B0/null/null [H0=B0] -> H0/H1/null
|
| 1016 |
+
} else if (mon1.length == 2 && mon2.length == 1 && mon1[0][1] == false && mon1[1][1] == false && mon2[0][1] == false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1017 |
if (H0 == B0) {
|
| 1018 |
fabs.push(H0);
|
| 1019 |
+
fabs.push(H1);
|
| 1020 |
+
//cas H0/H1/null + B0/null/null [H0#B0] -> H0/B0/H1
|
| 1021 |
+
} else if (H0 != B0) {
|
| 1022 |
fabs.push(H0);
|
| 1023 |
fabs.push(B0);
|
| 1024 |
+
fabs.push(H1);
|
| 1025 |
+
}
|
| 1026 |
+
//cas H0/null/HH + B0/null/null [H0=B0 | HH=B0] -> H0/null/HH
|
| 1027 |
+
} else if (mon1.length == 2 && mon2.length == 1 && mon1[0][1] == false && mon1[1][1] == true && mon2[0][1] == false) {
|
| 1028 |
+
if (H0 == B0 || HH == B0) {
|
| 1029 |
+
fabs.push(H0);
|
| 1030 |
+
fabs.push(HH);
|
| 1031 |
+
//cas H0/null/HH + B0/null/null [H0#B0 & HH#B0] -> H0/B0/HH
|
| 1032 |
+
} else if (H0 != B0 && HH != B0) {
|
| 1033 |
fabs.push(H0);
|
| 1034 |
fabs.push(B0);
|
| 1035 |
fabs.push(HH);
|
| 1036 |
}
|
| 1037 |
+
//cas H0/H1/HH + B0/null/null [H0=B0 | B0=HH] -> H0/H1/HH
|
| 1038 |
+
} else if (mon1.length == 3 && mon2.length == 1 && mon1[0][1] == false && mon1[1][1] == false && mon1[2][1] == true && mon2[0][1] == false) {
|
| 1039 |
+
if (H0 == B0 || B0 == HH) {
|
|
|
|
|
|
|
|
|
|
| 1040 |
fabs.push(H0);
|
| 1041 |
+
fabs.push(H1);
|
| 1042 |
+
fabs.push(HH);
|
| 1043 |
+
//cas H0/H1/HH + B0/null/null [H0#B0 & HH#B0] -> H0/B0/HH
|
| 1044 |
+
} else if (H0 != B0 && HH != B0) {
|
| 1045 |
fabs.push(H0);
|
| 1046 |
fabs.push(B0);
|
| 1047 |
+
fabs.push(HH);
|
| 1048 |
}
|
| 1049 |
+
//cas H0/null/null + B0/B1/null [H0=B1] -> H0/B0/null
|
| 1050 |
+
} else if (mon1.length == 1 && mon2.length == 2 && mon1[0][1] == false && mon2[0][1] == false && mon2[1][1] == false) {
|
| 1051 |
+
if (H0 == B1) {
|
|
|
|
|
|
|
|
|
|
| 1052 |
fabs.push(H0);
|
| 1053 |
+
fabs.push(B0);
|
| 1054 |
+
//cas H0/null/null + B0/B1/null [H0=B0] -> H0/B1/null
|
| 1055 |
+
} else if (H0 == B0) {
|
| 1056 |
+
fabs.push(H0);
|
| 1057 |
+
fabs.punch(B1);
|
| 1058 |
+
//cas H0/null/null + B0/B1/null [H0#B0 & H0#B1] -> H0/B1/B0
|
| 1059 |
+
} else if (H0 != B0 && H0 != B1) {
|
| 1060 |
+
fabs.push(H0);
|
| 1061 |
+
fabs.push(B1);
|
| 1062 |
+
fabs.push(B0);
|
| 1063 |
}
|
| 1064 |
+
//cas H0/H1/null + B0/B1/null [H0=B1] -> H0/B0/H1
|
| 1065 |
+
} else if (mon1.length == 2 && mon2.length == 2 && mon1[0][1] == false && mon1[1][1] == false && mon2[0][1] == false && mon2[1][1] == false) {
|
| 1066 |
+
if (H0 == B1) {
|
| 1067 |
fabs.push(H0);
|
| 1068 |
fabs.push(B0);
|
| 1069 |
+
fabs.push(H1);
|
| 1070 |
+
//cas H0/H1/null + B0/B1/null [H0=B0] -> H0/B1/H1
|
| 1071 |
+
} else if (H0 == B0) {
|
| 1072 |
+
fabs.push(H0);
|
| 1073 |
+
fabs.push(B1);
|
| 1074 |
+
fabs.push(H1);
|
| 1075 |
+
//cas H0/H1/null + B0/B1/null [H1#B0 & H1#B1] -> H0/B1/H1
|
| 1076 |
+
} else if (H1 != B0 && H1 != B1) {
|
| 1077 |
+
fabs.push(H0);
|
| 1078 |
+
fabs.push(B1);
|
| 1079 |
+
fabs.push(H1);
|
| 1080 |
}
|
| 1081 |
+
//cas H0/null/HH + B0/B01/null [H0=B1 | HH=B1] -> H0/B0/HH
|
| 1082 |
+
} else if (mon1.length == 2 && mon2.length == 2 && mon1[0][1] == false && mon1[1][1] == true && mon2[0][1] == false && mon2[1][1] == false) {
|
| 1083 |
+
if (H0 == B1 || HH == B1) {
|
| 1084 |
fabs.push(H0);
|
| 1085 |
fabs.push(B0);
|
| 1086 |
fabs.push(HH);
|
| 1087 |
+
//cas H0/null/HH + B0/B1/null [H0#B1 & HH#B1] -> H0/B1/HH
|
| 1088 |
+
} else if (H0 != B1 && HH != B1) {
|
| 1089 |
+
fabs.push(H0);
|
| 1090 |
+
fabs.push(B1);
|
| 1091 |
+
fabs.push(H1);
|
| 1092 |
}
|
| 1093 |
+
//cas H0/H1/HH + B0/B1/null [H0=B1 | HH=B1] -> H0/B0/HH
|
| 1094 |
+
} else if (mon1.length == 3 && mon2.length == 2 && mon1[0][1] == false && mon1[1][1] == false && mon1[2][1] == true && mon2[0][1]==false && mon2[1][1] == false) {
|
| 1095 |
+
if (H0 == B1 || HH == B1) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
fabs.push(H0);
|
| 1097 |
fabs.push(B0);
|
| 1098 |
+
fabs.push(HH);
|
| 1099 |
+
//cas H0/H1/HH + B0/B1/null [H0#B1 & HH#B1] -> H0/B1/HH
|
| 1100 |
+
} else if (H0 != B1 && HH != B1) {
|
| 1101 |
fabs.push(H0);
|
| 1102 |
fabs.push(B1);
|
| 1103 |
+
fabs.push(HH);
|
| 1104 |
}
|
| 1105 |
+
//cas H0/null/null + B0/null/BH [H0=BH] -> H0/null/B0
|
| 1106 |
+
} else if (mon1.length == 1 && mon2.length == 2 && mon1[0][1] == false && mon2[0][1] == false && mon2[1][1] == true) {
|
| 1107 |
+
if (H0 == BH) {
|
| 1108 |
+
fabs.push(H0);
|
| 1109 |
+
fabs.push(B0);
|
| 1110 |
+
//cas H0/null/null + B0/null/BH [H0=B0] -> H0/null/BH
|
| 1111 |
+
} else if (H0 == B0) {
|
| 1112 |
+
fabs.push(H0);
|
| 1113 |
+
fabs.push(BH);
|
| 1114 |
+
//cas H0/null/null + B0/null/BH [H0#B0 & H0#BH] -> H0/B0/BH
|
| 1115 |
+
} else if (H0 != B0 && H0 != BH) {
|
| 1116 |
fabs.push(H0);
|
| 1117 |
fabs.push(B0);
|
| 1118 |
+
fabs.push(BH);
|
| 1119 |
+
}
|
| 1120 |
+
//cas H0/H1/null + B0/null/BH [H0=BH] -> H0/B0/H1
|
| 1121 |
+
} else if (mon1.length == 2 && mon2.length == 2 && mon1[0][1] == false && mon1[1][1] == false && mon2[0][1] == false && mon2[1][1] == true) {
|
| 1122 |
+
if (H0 == BH) {
|
| 1123 |
+
fabs.push(H0);
|
| 1124 |
+
fabs.push(B0);
|
| 1125 |
+
fabs.push(H1);
|
| 1126 |
+
//cas H0/H1/null + B0/null/BH [H0=B0] -> H0/BH/H1
|
| 1127 |
+
} else if (H0 == B0) {
|
| 1128 |
+
fabs.push(H0);
|
| 1129 |
+
fabs.push(BH);
|
| 1130 |
+
fabs.push(H1);
|
| 1131 |
+
//cas H0/H1/null + B0/null/BH [H0#BH & H1#BH] -> H0/H1/BH
|
| 1132 |
+
} else if (H0 != BH && H1 != BH) {
|
| 1133 |
+
fabs.push(H0);
|
| 1134 |
+
fabs.push(H1);
|
| 1135 |
+
fabs.push(BH);
|
| 1136 |
+
}
|
| 1137 |
+
//cas H0/null/HH + B0/null/BH [H0=BH | HH=BH] -> H0/B0/HH
|
| 1138 |
+
} else if (mon1.length == 2 && mon2.length == 2 && mon1[0][1] == false && mon1[1][1] == true && mon2[0][1] == false && mon2[1][1]==true) {
|
| 1139 |
+
if (H0 == BH || HH == BH) {
|
| 1140 |
+
fabs.push(H0);
|
| 1141 |
+
fabs.push(B0);
|
| 1142 |
+
fabs.push(HH);
|
| 1143 |
+
//cas H0/null/HH + B0/null/BH [H0#BH & HH#BH] -> H0/BH/HH
|
| 1144 |
+
} else if (H0 != BH && HH != BH) {
|
| 1145 |
+
fabs.push(H0);
|
| 1146 |
+
fabs.push(BH);
|
| 1147 |
+
fabs.push(HH);
|
| 1148 |
+
}
|
| 1149 |
+
//cas H0/H1/HH + B0/null/BH [H0=BH | HH=BH] -> H0/B0/HH
|
| 1150 |
+
} else if (mon1.length == 3 && mon2.length == 2 && mon1[0][1] == false && mon1[1][1] == false && mon1[2][1] == true && mon2[0][1] == false && mon2[1][1] == true) {
|
| 1151 |
+
if (H0 == BH || HH == BH) {
|
| 1152 |
+
fabs.push(H0);
|
| 1153 |
+
fabs.push(B0);
|
| 1154 |
+
fabs.push(HH);
|
| 1155 |
+
//cas H0/H1/HH + B0/null/BH [H0#BH & HH#BH] -> H0/BH/HH
|
| 1156 |
+
} else if (H0 != BH && HH != BH) {
|
| 1157 |
+
fabs.push(H0);
|
| 1158 |
+
fabs.push(BH);
|
| 1159 |
fabs.push(HH);
|
| 1160 |
+
}
|
| 1161 |
+
//cas H0/null/null + B0/B1/BH [H0#B1 & H0#BH] -> H0/B1/BH
|
| 1162 |
+
} else if (mon1.length == 1 && mon2.length == 3 && mon1[0][1] == false && mon2[0][1] == false && mon2[1][1] == false && mon2[2][1] == true) {
|
| 1163 |
+
if (H0 != B1 && H0 != BH) {
|
| 1164 |
fabs.push(H0);
|
| 1165 |
fabs.push(B1);
|
| 1166 |
+
fabs.push(BH);
|
| 1167 |
+
//cas H0/null/null + B0/B1/BH [H0=B1] -> H0/B0/BH
|
| 1168 |
+
} else if (H0 == B1) {
|
| 1169 |
+
fabs.push(H0);
|
| 1170 |
+
fabs.push(B0);
|
| 1171 |
+
fabs.push(BH);
|
| 1172 |
+
//cas H0/null/null + B0/B1/BH [H0=BH] -> H0/B1/B0
|
| 1173 |
+
} else if (H0 == BH) {
|
| 1174 |
fabs.push(H0);
|
| 1175 |
fabs.push(B1);
|
| 1176 |
+
fabs.push(B0);
|
| 1177 |
}
|
| 1178 |
+
//cas H0/H1/null + B0/B1/BH [H0#B1 & H0#BH] -> H0/B1/BH
|
| 1179 |
+
} else if (mon1.length == 2 && mon2.length == 3 && mon1[0][1] == false && mon1[1][1] == false && mon2[0][1] == false && mon2[1][1] == false && mon2[2][1] == true) {
|
| 1180 |
+
if (H0 == B1 || H0 == BH) {
|
| 1181 |
+
fabs.push(H0);
|
| 1182 |
+
fabs.push(B1);
|
| 1183 |
+
fabs.push(BH);
|
| 1184 |
+
//cas H0/H1/null + B0/B1/BH [H0=B1] -> H0/B0/BH
|
| 1185 |
+
} else if (H0 == B1) {
|
| 1186 |
fabs.push(H0);
|
| 1187 |
fabs.push(B0);
|
| 1188 |
+
fabs.push(BH);
|
| 1189 |
+
//cas H0/H1/null + B0/B1/BH [H0=BH] -> H0/B1/B0
|
| 1190 |
+
} else if (H0 == BH) {
|
| 1191 |
fabs.push(H0);
|
| 1192 |
fabs.push(B1);
|
| 1193 |
+
fabs.push(B0);
|
| 1194 |
}
|
| 1195 |
+
//cas H0/null/HH + B0/B1/BH [H0#B1 & HH#B1] -> H0/B1/HH
|
| 1196 |
+
} else if (mon1.length == 2 && mon2.length == 3 && mon1[0][1]==false && mon1[1][1] == true && mon2[0][1] == false && mon2[1][1] == false && mon2[2][1] == true) {
|
| 1197 |
+
if (H0!=B1 && HH!=B1) {
|
| 1198 |
+
fabs.push(H0);
|
| 1199 |
+
fabs.push(B1);
|
| 1200 |
+
fabs.push(HH);
|
| 1201 |
+
//cas H0/null/HH + B0/B1/BH [H0=B1 | HH=B1] -> H0/B0/HH
|
| 1202 |
+
} else if (H0 == B1 || HH == B1) {
|
| 1203 |
fabs.push(H0);
|
| 1204 |
fabs.push(B0);
|
| 1205 |
fabs.push(HH);
|
| 1206 |
+
//cas H0/null/HH + B0/B1/BH [H0=B0 | HH=B0] -> H0/B1/HH
|
| 1207 |
+
} else if (H0 == B0 || HH == B0) {
|
| 1208 |
fabs.push(H0);
|
| 1209 |
fabs.push(B1);
|
| 1210 |
+
fabs.push(HH);
|
| 1211 |
+
}
|
| 1212 |
+
//cas H0/H1/HH + B0/B1/BH [H0#B1 & HH#B1] -> H0/B1/HH
|
| 1213 |
+
} else if (mon1.length == 3 && mon2.length == 3 && mon1[0][1] == false && mon1[1][1] == false && mon1[2][1] == true && mon2[0][1] == false && mon2[1][1] == false && mon2[2][1] == true) {
|
| 1214 |
+
if (H0 != B1 && HH != B1) {
|
| 1215 |
+
fabs.push(H0);
|
| 1216 |
+
fabs.push(B1);
|
| 1217 |
+
fabs.push(HH);
|
| 1218 |
+
//cas H0/H1/HH + B0/B1/BH [H0=B1 | HH=B1] -> H0/B0/HH
|
| 1219 |
+
} else if (H0 == B1 || HH == B1) {
|
| 1220 |
+
fabs.push(H0);
|
| 1221 |
+
fabs.push(B0);
|
| 1222 |
+
fabs.push(HH);
|
| 1223 |
+
//cas H0/H1/HH + B0/B1/BH [H0=B0 | HH=B0] -> H0/B1/HH
|
| 1224 |
+
} else if (H0 == B0 || HH == B0) {
|
| 1225 |
fabs.push(H0);
|
| 1226 |
fabs.push(B1);
|
| 1227 |
fabs.push(HH);
|
| 1228 |
}
|
| 1229 |
}
|
| 1230 |
+
return fabs
|
| 1231 |
}
|
| 1232 |
|
| 1233 |
|
|
|
|
| 1251 |
if (mon1[0] != mon2[0]) {
|
| 1252 |
fmon.push(mon1[0]);
|
| 1253 |
fmon.push(mon2[0]);
|
|
|
|
| 1254 |
|
| 1255 |
// Exception:
|
| 1256 |
// The body will provide its primary type
|
|
|
|
| 1267 |
if (mon1[0] != mon2[1]) {
|
| 1268 |
fmon.push(mon1[0]);
|
| 1269 |
fmon.push(mon2[1]);
|
|
|
|
| 1270 |
|
| 1271 |
//cas H0/null + B0/B1 [H0=B1] -> H0/B0
|
| 1272 |
} else {
|
| 1273 |
fmon.push(mon1[0])
|
| 1274 |
+
fmon.push(mon2[0]);
|
|
|
|
| 1275 |
}
|
| 1276 |
|
| 1277 |
//cas H0/H1 + B0/B1 [H0=B1] -> H0/B0
|
|
|
|
| 1279 |
if (mon1[0] == mon2[1]) {
|
| 1280 |
fmon.push(mon1[0]);
|
| 1281 |
fmon.push(mon2[0]);
|
|
|
|
| 1282 |
|
| 1283 |
//cas H0/H1 + B0/B1 [H0#B1] -> H0/B1
|
| 1284 |
} else {
|
| 1285 |
fmon.push(mon1[0]);
|
| 1286 |
fmon.push(mon2[1]);
|
|
|
|
| 1287 |
}
|
| 1288 |
}
|
| 1289 |
return fmon
|
| 1290 |
}
|
| 1291 |
+
|
| 1292 |
+
|
| 1293 |
+
function isMissingNames(mon1, mon2){
|
| 1294 |
+
return (mon1 == "" || mon1.length == 0 || mon1 == null) || (mon2 == "" || mon2.length == 0 || mon2 == null)
|
| 1295 |
+
}
|