Sie sind auf Seite 1von 11

document.

oldat = false;
document.oldit = false;
function showAttacks()
{
if (!document.oldat)
{
document.getElementById("items").style.display = "none";
document.getElementById("items").innerHTML = "";
document.oldit = true;
document.oldit = true;
document.getElementById("moves").style.display = "block";
}
}

function battle()
{
battle99();
}

function battle99()
{
document.getElementById("items").style.display = "none";
document.getElementById("items").innerHTML = "";
document.oldit = true;
document.oldit = true;
if (document.oldat)
{

document.oldat = null;
}
showAttacks();
}

function item2(str,str2,str3)
{
document.getElementById("moves").style.display = "none";
document.oldat = true;

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ('Browser does not support HTTP Request')
return
}
var url='items.php'
url=url+'?item='+str

url=url+'&sid='+Math.random()

xmlHttp.onreadystatechange =
function()
{
if(xmlHttp.readyState == 4)
{

document.getElementById("items").innerHTML = xmlHttp.responseText;
if
(xmlHttp.responseText.match(/gained/))
{
var m =
xmlHttp.responseText.match(/gained.*/);
var c =
m[0].replace("gained","");
var d =
parseInt(c.replace(/ hp.*/,""));
thing =
(parseInt(document.getElementById('hp').innerHTML.split(" / ")[0]) + parseInt(d))

thing = (thing >


document.getElementById('hp').innerHTML.split(" /
")[1]?document.getElementById('hp').innerHTML.split(" / ")[1]:thing);

document.getElementById("hp").innerHTML = thing + " / " +


document.getElementById('hp').innerHTML.split(" / ")[1];
}
}
else

document.getElementById("items").innerHTML = "<img src='images/loading.gif'


/>";
}
xmlHttp.open('GET',url,true)
xmlHttp.send(null)
}

function item(str,str2,str3,str4,str5)
{

document.getElementById("moves").style.display = "none";
document.oldat = true;

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ('Browser does not support HTTP Request')
return
}
var url='items.php'
url=url+'?item='+str
url=url+'&wild='+str3
url=url+'&hp='+str4
url=url+'&hp_wild='+str5
url=url+'&sid='+Math.random()
if (str2!=0)
{
xmlHttp.onreadystatechange =
function()
{
if(xmlHttp.readyState == 4)
{

document.getElementById("items").innerHTML = xmlHttp.responseText;

if
(xmlHttp.responseText.match(/gained/))
{
var m =
xmlHttp.responseText.match(/gained.*/);
var c =
m[0].replace("gained","");
var d =
parseInt(c.replace(/ hp.*/,""));
thing =
(parseInt(document.getElementById('hp').innerHTML.split(" / ")[0]) + parseInt(d))

thing = (thing >


document.getElementById('hp').innerHTML.split(" /
")[1]?document.getElementById('hp').innerHTML.split(" / ")[1]:thing);

document.getElementById("hp").innerHTML = thing + " / " +


document.getElementById('hp').innerHTML.split(" / ")[1];
}
}
else

document.getElementById("items").innerHTML = "<img src='images/loading.gif'


/>";
}
xmlHttp.open('GET',url,true)
xmlHttp.send(null)
}
else
alert ("You can't use an item if you don't have it!");
}

function dead(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ('Browser does not support HTTP Request')
return
}
var url='continue.php'
url=url+'?dead='+str
url=url+'&sid='+Math.random()
xmlHttp.onreadystatechange =
function()
{

document.getElementById("Battle").style.display = "block";
if (xmlHttp.readyState == 4)
document.getElementById("Battle").innerHTML =
xmlHttp.responseText;
else
document.getElementById("Battle").innerHTML =
"<img src='images/loading.gif' />";
}
xmlHttp.open('GET',url,true)
xmlHttp.send(null)
}
function showItems()
{
if (!document.oldit)
{
document.getElementById("moves").style.display = "none";
document.oldat = true;

xmlHttp=GetXmlHttpObject();
var url='battle3.php?a=items';
document.getElementById("items").style.display="block";
if (xmlHttp==null)
{
alert ('Browser does not support HTTP
Request');
return;
}

xmlHttp.onreadystatechange=function()
{
if (xmlHttp.readyState == 4)
{

document.getElementById("items").innerHTML = xmlHttp.responseText;
}

else
{

document.getElementById("items").innerHTML = "<img src='images/loading.gif'


/>";
}
}
xmlHttp.open('GET',url,true);
xmlHttp.send(null);
}
}

function req()
{
xmlHttp=GetXmlHttpObject();
var url='battle_test.php';
if (xmlHttp==null)
{
alert ('Browser does not support HTTP Request');
return;
}

xmlHttp.onreadystatechange=function()
{
if (xmlHttp.readyState == 4)
{
document.getElementById("txtHint1").innerHTML =
xmlHttp.responseText;
}
else
{
if (!document.getElementById('waitimg'))
{
waitimg = document.createElement("img");
waitimg.src = "images/loading.gif";
waitimg.alt = "wait";
waitimg.id = "waitimg";
waitimg.style.position = "absolute";
waitimg.style.zIndex = 99999;
waitimg.style.top = "100px";
waitimg.style.left = "300px";

document.getElementById("txtHint1").appendChild(waitimg);
}
}
}
xmlHttp.open('GET',url,true);
xmlHttp.send(null);
}
function use(mv)
{
document.oldat = true;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ('Browser does not support HTTP Request')
return
}
var url='battle_test.php?mv=' + mv + '&mode=1'
xmlHttp.onreadystatechange=function()
{
document.getElementById("moves").style.display = "none";
if (document.getElementById("mm"))

document.getElementById("txtHint1").removeChild(document.getElementById("mm"));
if (document.getElementById("mm2"))

document.getElementById("txtHint1").removeChild(document.getElementById("mm2"));
if (xmlHttp.readyState == 4)
{

if (document.getElementById('waitimg'))

document.getElementById("txtHint1").removeChild(document.getElementById('waitimg')
);
if (xmlHttp.responseText == "wtf again")
return 0;

fnd = "";
spltd = xmlHttp.responseText.split("~");
if (spltd)
{

splts = spltd[0].split("****");
fnd = spltd[2];
}
else
splts =
xmlHttp.responseText.split("****");
splt = splts[0].split("/");

setTimeout(function()
{ document.getElementById("wimg").style.display = "none"; },500);
setTimeout(function()
{ document.getElementById("wimg").style.display = "block"; },1000);
setTimeout(function() {
tp = splts[splts.length - 2];
if (tp == 1)
strext = "";
else if (tp == 2)
strext = " The attack
was super effective!";
else if (tp == 4)
strext = " The attack
was ultra effective!";
else if (tp == 0.5)
strext = " The attack
was not very effective...";
else if (tp == 0.25)
strext = " The attack
was extremly ineffective...";
else if (tp == 0)
strext = " The attack
had no effect!";
co = (getCookie("im") ==
"battle2.jpg"?"green":"white");
var sp =
document.createElement("span");

sp.style.fontFamily = "Comic Sans


MS";
sp.style.fontSize = "10pt";
sp.style.color = co;
sp.style.position = "absolute";
sp.style.top = "100px";
sp.style.left = "0px";
sp.style.zIndex = 999;
sp.setAttribute("id","mm");
sp.innerHTML = splt[0] + " used "
+ splt[1] + " and dealt " + splt[2] + " damage!" + strext;

document.getElementById("txtHint1").appendChild(sp);

//val =
document.getElementById('hpw').innerHTML.split(" / ");
//hp = parseInt(val[0],10);
//maxhp = parseInt(val[1],10);
//hp -= splt[2];

document.getElementById("hpw").innerHTML =(
document.getElementById('hpw').innerHTML.split(" / ")[0] - splt[2]) + " / " +
document.getElementById('hpw').innerHTML.split(" / ")[1];
//document.getElementById("hpw").innerHTML = hp + " / " + maxhp;
},1500);

if
(xmlHttp.responseText.match("wildfainted"))
{
co = (getCookie("im") ==
"battle2.jpg"?"green":"white");

setTimeout(function() {

var sp2 =
document.createElement("span");

sp2.style.fontFamily = "Comic Sans


MS";
sp2.style.fontSize = "10pt";
sp2.style.color = co;
sp2.style.position = "absolute";
sp2.style.top = "120px";
sp2.style.left = "0px";
sp2.style.zIndex = 999;
sp2.setAttribute("id","mm6");
sp2.innerHTML = splt[7] + "
fainted! " + splt[9] + " gained " + splt[10+10000000] + " exp!" + (splt[11] ==
"lvld"?"<br />Your pokemon leveled up.":"") + (spltd[1]?" You earned $" + spltd[1]
+ ".":"") + "<br />" + (fnd?"You found a " + fnd + ".":"") + " Click <a
style='color:" + co + ";' href='javascript:void(reloadPage())'
onclick='reloadPage()'>here</a> to go back.";

document.getElementById("wimg").style.display="none";

document.getElementById("txtHint1").appendChild(sp2);
},3000);

document.getElementById("moves").style.display="none";

document.getElementById("items").style.display = "none";
document.oldit = true;

return 0;
}
setTimeout(function()
{ document.getElementById("pimg").style.display = "none"; },2000);
setTimeout(function()
{ document.getElementById("pimg").style.display = "block"; },2500);
setTimeout(function() {
tp = splts[splts.length - 1];
if (tp == 1)
strext = "";
else if (tp == 2)
strext = " The attack
was super effective!";
else if (tp == 4)
strext = " The attack
was ultra effective!";
else if (tp == 0.5)
strext = " The attack
was not very effective...";
else if (tp == 0.25)
strext = " The attack
was extremly ineffective...";
else if (tp == 0)
strext = " The attack
had no effect!";
co = (getCookie("im") ==
"battle2.jpg"?"green":"white");
var sp3 =
document.createElement("span");

sp3.style.fontFamily = "Comic Sans


MS";
sp3.style.fontSize = "10pt";
sp3.style.color = co;
sp3.style.position = "absolute";
sp3.style.left = "0px";
sp3.style.top = "120px";
sp3.style.zIndex = 999;
sp3.setAttribute("id","mm2");
sp3.innerHTML = splt[3] + " used "
+ splt[4] + " and dealt " + splt[5] + " damage!" + strext

document.getElementById("txtHint1").appendChild(sp3);

document.oldat = false;
document.oldit = false;

//val =
document.getElementById('hp').innerHTML.split(" / ");

//alert(document.getElementById('hp').innerHTML.split(" / ")[0] - splt[5]);

//hp = parseInt(val[0],10);
//maxhp = parseInt(val[1],10);
//hp -= splt[5];

document.getElementById("hp").innerHTML =(
document.getElementById('hp').innerHTML.split(" / ")[0] - splt[5]) + " / " +
document.getElementById('hp').innerHTML.split(" / ")[1];
},3000);

if
(xmlHttp.responseText.match("pfainted"))
{

document.getElementById("moves").innerHTML = "";
// alert("Fsda");
setTimeout(function()
{

document.getElementById("pimg").parentNode.removeChild(document.getElementById("pi
mg"));

document.getElementById("items").style.display = "none";
document.oldit = true;
dead(splts[1]);
},
4500);
}

else
{
if (!document.getElementById('waitimg'))
{
waitimg =
document.createElement("img");
waitimg.src = "images/loading.gif";
waitimg.alt = "wait";
waitimg.id = "waitimg";
waitimg.style.position =
"absolute";
waitimg.style.zIndex = 999;
waitimg.style.top = "100px";
waitimg.style.left = "300px";

document.getElementById("txtHint1").appendChild(waitimg);
}
}
}
xmlHttp.open('GET',url,true)
xmlHttp.send(null)
}

function GetXmlHttpObject()
{
xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e)
{
xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
}
}
return xmlHttp;
}

function showpoke (id,map,mode)


{

document.oldat = false;
document.oldit = false;
xmlHttp = false;
xmlHttp = GetXmlHttpObject();
url = "battle_test.php";
parameters = "id=" + id + (map?"&map=" + map:"") + (mode?"&mode=" +
mode:"");
if (!xmlHttp)
{
alert('Get a proper browser please ;)');
return false;
}

xmlHttp.onreadystatechange =
function()
{
if (xmlHttp.readyState == 4)
{
if
(document.getElementById('waitimg'))

document.getElementById("txtHint1").removeChild(document.getElementById('waitimg')
);
if
(xmlHttp.responseText.match("Ok"))
{

req();
}
}
else
{
if
(!document.getElementById('waitimg'))
{
waitimg =
document.createElement("img");
waitimg.src =
"images/loading.gif";
waitimg.alt = "wait";
waitimg.id = "waitimg";
waitimg.style.position =
"absolute";
waitimg.style.zIndex = 99999;
waitimg.style.top = "100px";
waitimg.style.left = "0px";

document.getElementById("txtHint1").appendChild(waitimg);
}
}

}
xmlHttp.open('POST', url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
xmlHttp.setRequestHeader("Content-length", parameters.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parameters);
}

Das könnte Ihnen auch gefallen