domingo, abril 06, 2008

travian

Ohhh H! You're reading web page's script code again! Damn girl! Well... I just thought this was hilarious and had to share it with you. The following bit of code was taken from unx.js at http://s3.travian.pt/.

function T_Load(url,id)
{
g=false;
if(window.XMLHttpRequest)
{
g=new XMLHttpRequest();
if(g.overrideMimeType)
{
g.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject)
{
try
{
g=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
g=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){}
}
}
if(!g)
{
alert('Can not create XMLHTTP-instance');
return false;
}
g.onreadystatechange=function(){al(id);};
g.open('GET',url,true);
g.send(null);
};

What's so funny in it, is the use of variable g. Which starts as boolean and ends up as an object. This could only be allowed in a language like javascript. And why? Well there's no type declaration, it's optional to do that. Now just how does it reach binary? How can you tell the size? Are they all the same size like in java? Javascript wonders!

Now the reason why I'm reading this:
This travian thing, it's a game. An online, strategy game. Make a village, get an army, attack neighbors kind of thing. But it's real time, things take for ever to evolve. I'd just love to leave some actions recorded to be done in the future. I imagine this would add considerable volume of data in to the server... not to mention that it could be programed so that my soldiers would leave the village and go visit some looser player that can't possibly have an army, while bringing back some resources anytime an attack is coming in. And then again there is the incentive of the “in control” feeling. I just can't bear the infinite number of tabs open one to each field (resources, village, future victims of attacks). I want a frame that lists previous attacks with distance to my village and resources taken, I want to know how long before I have resources to evolve something, I want to be able to put on an “agenda” any build, attack, market action I feel like so I can have my life back. LOL I mean.. I got other things to do!

Sem comentários :