Coding AJAX-compatible GM scripts

Archival storage to keep things organized and uncluttered. Can't find what you need? Search for old topics here.

Moderators: Global Moderators, Tech Team

Forum rules
Please read the Community Guidelines before posting.

Postby MR. Nate on Thu Sep 13, 2007 10:23 am

Do it! It's totally worth it to all of us who sit here and admire everyone's work!
AAFitz wrote:There will always be cheaters, abusive players, terrible players, and worse. But we have every right to crush them.
MeDeFe wrote:This is a forum on the internet, what do you expect?

End the Flame Wars.
User avatar
Corporal MR. Nate
 
Posts: 951
Joined: Tue Dec 19, 2006 10:59 am
Location: Locked in the warehouse.
Medals: 6
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Cross-Map Achievement (1) Ratings Achievement (1)

Postby Ishiro on Thu Sep 13, 2007 11:26 am

I'm going through the code now making sure it does not over update too much. Colors still may be dropped from map inspect... have to wait and see. Being able to lose color blind options helps a bit.
Image
User avatar
Corporal 1st Class Ishiro
 
Posts: 324
Joined: Mon Jul 17, 2006 5:53 pm
Location: Under the Rainbow
Medals: 10
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Terminator Achievement (1) Assassin Achievement (1)
Cross-Map Achievement (1) Ratings Achievement (1) General Contribution (2)

Postby Ishiro on Thu Sep 13, 2007 1:56 pm

Blah... starting over. Some of the paths I went down were wrong and resulted in a map that never updated during your turn. (Like, you attack 10v1 and win, but the map still shows 10 and 1 even while the action section has moved on to Advancement.)

Its probably going to be next week before I get something that works since I have to return to work tomorrow.
Image
User avatar
Corporal 1st Class Ishiro
 
Posts: 324
Joined: Mon Jul 17, 2006 5:53 pm
Location: Under the Rainbow
Medals: 10
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Terminator Achievement (1) Assassin Achievement (1)
Cross-Map Achievement (1) Ratings Achievement (1) General Contribution (2)

Postby Tyrion81 on Fri Sep 14, 2007 2:16 am

Hmmm this has got me interested now.... I already started modifications to BOB to get things working with AJAX... I found testing a real pain in the ass though... Having to wait every time my turn came around sucks. (especially cuz i'm limited to my 4 games)
Corporal 1st Class Tyrion81
 
Posts: 14
Joined: Thu Mar 22, 2007 8:29 pm
Location: Sydney, Australia
Medals: 1
Standard Achievement (1)

Postby Ishiro on Fri Sep 14, 2007 5:15 am

While some things need to wait for turns to test... here is a hint, posting a chat message to yourself in a non-team game goes through the ajax routines to update the chat log.

Starting over reworking the script from the ground up, I've got the clock and player stats working. Text map and map inspect are halfway there.
Image
User avatar
Corporal 1st Class Ishiro
 
Posts: 324
Joined: Mon Jul 17, 2006 5:53 pm
Location: Under the Rainbow
Medals: 10
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Terminator Achievement (1) Assassin Achievement (1)
Cross-Map Achievement (1) Ratings Achievement (1) General Contribution (2)

Postby yeti_c on Fri Sep 14, 2007 5:36 am

Ishiro wrote:While some things need to wait for turns to test... here is a hint, posting a chat message to yourself in a non-team game goes through the ajax routines to update the chat log.

Starting over reworking the script from the ground up, I've got the clock and player stats working. Text map and map inspect are halfway there.


Nice work buddy - I'll leave it to you then...

C.
Image
Highest score : 2297
User avatar
Lieutenant yeti_c
 
Posts: 9670
Joined: Thu Jan 04, 2007 9:02 am
Medals: 46
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (1) Fog of War Achievement (3) Cross-Map Achievement (3) Ratings Achievement (3)
General Achievement (1) Map Contribution (13) Tournament Contribution (1) General Contribution (10)

Postby mfontolan on Fri Sep 14, 2007 6:08 am

Ishiro wrote:While some things need to wait for turns to test... here is a hint, posting a chat message to yourself in a non-team game goes through the ajax routines to update the chat log.
Starting over reworking the script from the ground up, I've got the clock and player stats working. Text map and map inspect are halfway there.

Well, I think you understand what I say before.
Is other way of thinking. You have to put all your necessary stuff at the start and then change using "handleResponse".
Ishiro, we are doing a double job. I will stop my development and help you if you want.
Brazil #3 @ Agu, 2007.
User avatar
Private 1st Class mfontolan
 
Posts: 23
Joined: Wed Feb 21, 2007 5:48 pm
Location: South
Medals: 7
Standard Achievement (3) Terminator Achievement (2) Ratings Achievement (2)

Postby RobinJ on Fri Sep 28, 2007 11:53 am

Just would like to say that even a scaled down version of BOB would be much appreciated if it makes things easier, like TR0Y's first script
nmhunate wrote:Speak English... It is the language that God wrote the bible in.


Highest Score: 2437
Highest Place: 84
User avatar
Sergeant 1st Class RobinJ
 
Posts: 1901
Joined: Mon Aug 21, 2006 1:56 pm
Location: Northern Ireland
Medals: 13
Standard Achievement (3) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (1) Terminator Achievement (2)
Cross-Map Achievement (2) Ratings Achievement (1)

Postby PerkinsRooster on Fri Sep 28, 2007 12:15 pm

I concur. The only thing I really miss is the territory counter. And yes, I do know how to count myself.
Official Member of the Comic Misfits

High score: 2232
Major PerkinsRooster
 
Posts: 89
Joined: Wed Feb 21, 2007 11:05 pm
Location: Canada
Medals: 12
Standard Achievement (3) Doubles Achievement (1) Triples Achievement (2) Fog of War Achievement (1) Speed Achievement (1)
Teammate Achievement (1) Ratings Achievement (3)

Postby RobinJ on Fri Sep 28, 2007 4:59 pm

PerkinsRooster wrote:I concur. The only thing I really miss is the territory counter. And yes, I do know how to count myself.


But, like me, you can't be bothered :wink:
nmhunate wrote:Speak English... It is the language that God wrote the bible in.


Highest Score: 2437
Highest Place: 84
User avatar
Sergeant 1st Class RobinJ
 
Posts: 1901
Joined: Mon Aug 21, 2006 1:56 pm
Location: Northern Ireland
Medals: 13
Standard Achievement (3) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (1) Terminator Achievement (2)
Cross-Map Achievement (2) Ratings Achievement (1)

Postby Aerial Attack on Fri Sep 28, 2007 5:35 pm

If there were no BOB, you would count on your own - you would almost be forced to. The biggest problem is on non-standard maps, trying to figure out what bonuses people are actually earning. Sometimes you don't realize they have a 1 defending a 4+ bonus. At that point, it's almost always worth taking out. Of course, there are those of us who can't actually count properly (or try counting on Pearl Harbor or World 2.1).
User avatar
Sergeant Aerial Attack
 
Posts: 1132
Joined: Mon Jun 04, 2007 7:59 pm
Location: Generation One: The Clan
Medals: 4
Tournament Achievement (2) Tournament Contribution (1) General Contribution (1)

Postby Herakilla on Sat Sep 29, 2007 1:13 pm

i might get chewed out for saying this but the few times i have done some programming or what not and i got stuck i just started all over again, with nothing. starting from scratch
Come join us in Live Chat!
User avatar
Lieutenant Herakilla
 
Posts: 4317
Joined: Fri Jun 09, 2006 8:33 pm
Location: Wandering the world, spreading Conquerism
Medals: 28
Standard Achievement (3) Doubles Achievement (2) Triples Achievement (1) Quadruples Achievement (1) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (3) Fog of War Achievement (3) Speed Achievement (3) Cross-Map Achievement (3)
Ratings Achievement (3) General Achievement (2) General Contribution (2)

Postby chewyman on Thu Oct 04, 2007 3:17 am

First of all I just wanted to say thanks for working on this, I'm really looking forward to being able to use AJAX.

But I was wondering, why is this being made as a separate patch? Wouldn't it be easier to make it part of the website itself?
If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrary wise, what is, it wouldn't be. And what it wouldn't be, it would. You see?
User avatar
Major chewyman
 
Posts: 395
Joined: Sat Feb 17, 2007 12:48 am
Location: By your side, forever
Medals: 6
Standard Achievement (1) Doubles Achievement (2) Triples Achievement (1) Freestyle Achievement (1) Fog of War Achievement (1)

Postby jiminski on Thu Oct 04, 2007 6:49 am

I used to count all the troops up .. count cards, going back through all the game text.... without Bob i can;t see a way i could possibly play more than 20 games at a time.

GM is genius and if i had the knowledge i would be helping out with patches and scripts and cups of Tea.... but i am not that smart!

Thanks! email me if you want a cup of Tea.
User avatar
Major jiminski
 
Posts: 5416
Joined: Tue Feb 20, 2007 3:30 pm
Location: London
Medals: 29
Standard Achievement (3) Doubles Achievement (3) Triples Achievement (3) Quadruples Achievement (1) Terminator Achievement (2)
Freestyle Achievement (2) Fog of War Achievement (2) Speed Achievement (2) Teammate Achievement (2) Cross-Map Achievement (3)
Ratings Achievement (1) Tournament Achievement (3) Clan Achievement (2)

Postby Ishiro on Thu Oct 04, 2007 10:14 am

The biggest problem has been that if I do a traditional function override for GM, the BOB functions execute 5 times per click. It slows down and breaks the functions that otherwise work. So I've been working on how to limit the execution of BOB functions. It ain't easy. Right now, the script works 100% if it is not your turn. Once it is your turn, the overexecution causes the map to stop updating, forcing you to exit and return to the game after every action. Unacceptable.

Still working on it...
Image
User avatar
Corporal 1st Class Ishiro
 
Posts: 324
Joined: Mon Jul 17, 2006 5:53 pm
Location: Under the Rainbow
Medals: 10
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Terminator Achievement (1) Assassin Achievement (1)
Cross-Map Achievement (1) Ratings Achievement (1) General Contribution (2)

Postby Aerial Attack on Mon Oct 08, 2007 9:42 am

Not that you don't already have enough on your hands getting BOB to work with AJAX ...

But, You'll also need to update the way it reads XML. Right now - for maps that use partial bonuses, BOB does not handle "non-explicit" partial pairings.

I'll use Italy as my example map.

New XML
Code: Select all
(you need to talk to whoever wrote the XML for the Italy Map OR Pearl Harbor Map for the new XML)


Old (Explicit Partial Pairings) XML
Code: Select all
(this is only an approximation - not the exact code)
<bonuses>
  <bonus:+1>
    <territory:Napoli>
    <territory:Palermo>
  </bonus>
  <bonus:+1>
    <territory:Napoli>
    <territory:Roma>
  </bonus>
  <bonus:+1>
    <territory:Napoli>
    <territory:Torino>
  </bonus>
  <bonus:+1>
    <territory:Napoli>
    <territory:Venezia>
  </bonus>
  <bonus:+1>
    <territory:Palermo>
    <territory:Roma>
  </bonus>
  <bonus:+1>
    <territory:Palermo>
    <territory:Torino>
  </bonus>
  <bonus:+1>
    <territory:Palermo>
    <territory:Venezia>
  </bonus>
  <bonus:+1>
    <territory:Roma>
    <territory:Torino>
  </bonus>
  <bonus:+1>
    <territory:Roma>
    <territory:Venezia>
  </bonus>
  <bonus:+1>
    <territory:Torino>
    <territory:Venezia>
  </bonus>
// negative because of overlap with 3 terrs
  <bonus:-1>
    <territory:Napoli>
    <territory:Palermo>
    <territory:Roma>
  </bonus>
  <bonus:-1>
    <territory:Napoli>
    <territory:Palermo>
    <territory:Torino>
  </bonus>
  <bonus:-1>
    <territory:Napoli>
    <territory:Palermo>
    <territory:Venezia>
  </bonus>
  <bonus:-1>
    <territory:Napoli>
    <territory:Roma>
    <territory:Torino>
  </bonus>
  <bonus:-1>
    <territory:Napoli>
    <territory:Roma>
    <territory:Venezia>
  </bonus>
  <bonus:-1>
    <territory:Napoli>
    <territory:Torino>
    <territory:Venezia>
  </bonus>
  <bonus:-1>
    <territory:Palermo>
    <territory:Roma>
    <territory:Torino>
  </bonus>
  <bonus:-1>
    <territory:Palermo>
    <territory:Roma>
    <territory:Venezia>
  </bonus>
  <bonus:-1>
    <territory:Palermo>
    <territory:Torino>
    <territory:Venezia>
  </bonus>
  <bonus:-1>
    <territory:Roma>
    <territory:Torino>
    <territory:Venezia>
  </bonus>
// back to positive because of dual overlap with 4 or 5 terrs
  <bonus:+1>
    <territory:Napoli>
    <territory:Palermo>
    <territory:Roma>
    <territory:Torino>
  </bonus>
  <bonus:+1>
    <territory:Napoli>
    <territory:Palermo>
    <territory:Roma>
    <territory:Venezia>
  </bonus>
  <bonus:+1>
    <territory:Napoli>
    <territory:Palermo>
    <territory:Torino>
    <territory:Venezia>
  </bonus>
  <bonus:+1>
    <territory:Palermo>
    <territory:Roma>
    <territory:Torino>
    <territory:Venezia>
  </bonus>


For the Italy map the number of bonus lines are the same, but for Age of Merchants - I know that the new XML would require fewer lines and therefore less processing time.
User avatar
Sergeant Aerial Attack
 
Posts: 1132
Joined: Mon Jun 04, 2007 7:59 pm
Location: Generation One: The Clan
Medals: 4
Tournament Achievement (2) Tournament Contribution (1) General Contribution (1)

Postby yeti_c on Tue Oct 09, 2007 4:32 am

I was looking into this...

I can get the handleResponse() back but I can't manage to override it with a new version - without copy and pasting the contents of the function from the source file...

Code: Select all
//function dave()
//{
//   alert("dave");
//}
//
//var newHandleResponse = unsafeWindow.handleResponse;
//var contents = ""+newHandleResponse;
//alert(newHandleResponse);
//start = contents.substring(0,28);
//middle = "dave();";
//end = contents.substring(28, contents.length);
//alert(start);
//alert(middle);
//alert(end);


This creates a new String that holds the entirety of the function - with my new function in it... (dave();) but I can't override the existing function easily... any ideas?

C.
Image
Highest score : 2297
User avatar
Lieutenant yeti_c
 
Posts: 9670
Joined: Thu Jan 04, 2007 9:02 am
Medals: 46
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (1) Fog of War Achievement (3) Cross-Map Achievement (3) Ratings Achievement (3)
General Achievement (1) Map Contribution (13) Tournament Contribution (1) General Contribution (10)

Postby yeti_c on Tue Oct 09, 2007 6:08 am

In actual fact - what would be better LACK... is if you coded a dummy function...

i.e. refreshGMScript()

which was called from handleResponse() by you...

and then we could override refreshGMScript easily without having to merge your code into it...

Is this something that you could do?

C.
Image
Highest score : 2297
User avatar
Lieutenant yeti_c
 
Posts: 9670
Joined: Thu Jan 04, 2007 9:02 am
Medals: 46
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (1) Fog of War Achievement (3) Cross-Map Achievement (3) Ratings Achievement (3)
General Achievement (1) Map Contribution (13) Tournament Contribution (1) General Contribution (10)

Postby Ishiro on Tue Oct 09, 2007 7:41 am

A dummy function would be great, especially if lack coded it to always be called last as a clean up once he's done all his stuff.

If you want to override lack's handleResponse, you can either:
a) copy his entire function and make the changes you need to it (this is what I'm currently working on).
pros: lets you place new code exactly where it is needed.
cons: it replaces lack's function and so if he makes changes to that function you will be ignoring it until you update your script.

b) make a copy of his function and throw in your own code like this:
Code: Select all
var newhandleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
   //put all your new code here
   return newhandleResponse();
}

pros: doesn't replace lack's code, so when he makes changes you won't be ignoring his new code.
cons: as I've mentioned before, the handleResponse function is called 4 or 5 times per action, so BOB executes 4 or 5 times making it slow and actually breaking the map (it "freezes", stops updating with the AJAX).
Image
User avatar
Corporal 1st Class Ishiro
 
Posts: 324
Joined: Mon Jul 17, 2006 5:53 pm
Location: Under the Rainbow
Medals: 10
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Terminator Achievement (1) Assassin Achievement (1)
Cross-Map Achievement (1) Ratings Achievement (1) General Contribution (2)

Postby yeti_c on Tue Oct 09, 2007 8:07 am

Ishiro wrote:A dummy function would be great, especially if lack coded it to always be called last as a clean up once he's done all his stuff.

If you want to override lack's handleResponse, you can either:
a) copy his entire function and make the changes you need to it (this is what I'm currently working on).
pros: lets you place new code exactly where it is needed.
cons: it replaces lack's function and so if he makes changes to that function you will be ignoring it until you update your script.

b) make a copy of his function and throw in your own code like this:
Code: Select all
var newhandleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
   //put all your new code here
   return newhandleResponse();
}

pros: doesn't replace lack's code, so when he makes changes you won't be ignoring his new code.
cons: as I've mentioned before, the handleResponse function is called 4 or 5 times per action, so BOB executes 4 or 5 times making it slow and actually breaking the map (it "freezes", stops updating with the AJAX).


Ah yes - that's a nice way of doing it - nice work Ishiro...

With regards to the 5 times calling...

I think you need to examine the parameters that are being called upon it... that way you could pick and choose which ones update your data...

--------------

I was thinking the best way for BOB to run is to hold all the data in arrays - and then only modify the data based on this turns action (Frist time init will be slow (as per) but each auto-refresh will be quicker... (You can hold the index of this)... this way you'll not have to do so much work... what do you reckon? (If a proper F5 is done though then a slow re-init will be run but that could be mentioned in the docs?)

n.b. for freestyle - will have to be this round... for sequential can be limited to the players turn.

The time consuming stuff of BOB is the Log parsing.

C.
Image
Highest score : 2297
User avatar
Lieutenant yeti_c
 
Posts: 9670
Joined: Thu Jan 04, 2007 9:02 am
Medals: 46
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (1) Fog of War Achievement (3) Cross-Map Achievement (3) Ratings Achievement (3)
General Achievement (1) Map Contribution (13) Tournament Contribution (1) General Contribution (10)

Postby Twill on Tue Oct 09, 2007 8:28 am

You guys amaze me :)

Thanks for working so hard to get the monkey back up and running!
User avatar
Corporal 1st Class Twill
Retired Administrator
 
Posts: 3677
Joined: Fri Jan 20, 2006 10:54 pm
Medals: 11
Standard Achievement (3) Freestyle Achievement (2) Fog of War Achievement (1) Speed Achievement (1) Random Map Achievement (1)
Cross-Map Achievement (1) General Achievement (1) General Contribution (1)

Postby RiskTycoon on Tue Oct 09, 2007 10:56 am

I second that Twill...just wish I was smart enough to help lol but alas I am not......so I thank you code savvy people from the bottom of my CC heart!
Image
"How do you like that? Even among misfits you're a misfit!"
User avatar
Major RiskTycoon
 
Posts: 974
Joined: Wed Nov 29, 2006 3:29 pm
Location: Massachusetts, USA
Medals: 31
Standard Achievement (1) Doubles Achievement (3) Triples Achievement (4) Quadruples Achievement (2) Freestyle Achievement (1)
Nuclear Spoils Achievement (1) Fog of War Achievement (2) Teammate Achievement (2) Random Map Achievement (1) Cross-Map Achievement (3)
Ratings Achievement (2) Tournament Achievement (1) Clan Achievement (8)

Postby lackattack on Tue Oct 09, 2007 11:55 am

yeti_c wrote:In actual fact - what would be better LACK... is if you coded a dummy function...

i.e. refreshGMScript()

which was called from handleResponse() by you...

and then we could override refreshGMScript easily without having to merge your code into it...

Is this something that you could do?

C.


Done. Hope it helps..
User avatar
Private 1st Class lackattack
Retired Administrator
 
Posts: 6112
Joined: Sun Jan 01, 2006 10:34 pm
Location: Montreal, QC
Medals: 9
Standard Achievement (1) Doubles Achievement (1) Triples Achievement (1) Freestyle Achievement (1) Speed Achievement (1)
Teammate Achievement (1) Cross-Map Achievement (1) General Achievement (2)

Postby yeti_c on Wed Oct 10, 2007 3:02 am

Perfect... this should help the coding effort a great deal...

Ta,

C.
Image
Highest score : 2297
User avatar
Lieutenant yeti_c
 
Posts: 9670
Joined: Thu Jan 04, 2007 9:02 am
Medals: 46
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (1) Fog of War Achievement (3) Cross-Map Achievement (3) Ratings Achievement (3)
General Achievement (1) Map Contribution (13) Tournament Contribution (1) General Contribution (10)

Postby yeti_c on Wed Oct 10, 2007 9:58 am

Righto - here's an update for now...

My new BOB is working quite well... all the stats update themselves per turn... and that all works really well...

The only problem that I have is that my BOB script breaks the Map updates from AJAX!!

I will work on this Friday and see if I can stop that from happening... then will try and reintegrate the map inspectors and so forth...

Also I need to improve the parsing of the XML to read <required> tags and <bombardments>

But we're making good progress I think.

C.
Image
Highest score : 2297
User avatar
Lieutenant yeti_c
 
Posts: 9670
Joined: Thu Jan 04, 2007 9:02 am
Medals: 46
Standard Achievement (2) Doubles Achievement (2) Triples Achievement (2) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Freestyle Achievement (1) Fog of War Achievement (3) Cross-Map Achievement (3) Ratings Achievement (3)
General Achievement (1) Map Contribution (13) Tournament Contribution (1) General Contribution (10)

PreviousNext

Return to Tool Archives

Who is online

Users browsing this forum: No registered users

Login