Hi, I'm making small changes in BOB just to see how things work a little bit (I've never developed in greasemonkey before, and I haven't done javascript in years).
Anyway, occasionally I come back to a game being surprised by the board. When one of your territories are attacked and your armies are nicked, but your territory is not conquered, it can be hard to tease out of the log what happened. Sometimes I'm left thinking I had more armies in a territory, but I can't be sure if I've been attacked or I just don't remember right. Of course a log of attack attempts would resolve this.
But what I've been fooling with is having a setting to automatically take a snapshot after you end each turn. I've hacked in the menu setting and that seems to work ok. Taking the actual snapshot isn't working though. It is calling the existing 'takeSnapshot' function where I want it to. It is even adding a menu for the new snapshot taken. But when I refresh the game page or leave and come back to it, the end turn snapshot is no longer on the menu.
Here's the part that is not working:
_________________________________________________________
- Code: Select all
// ENDTURN SNAPSHOT MOD ***********************
var newhandleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
var ret = newhandleResponse();
if (lastCommand == 'End Reinforcement' || (lastCommand == 'Reinforce' && gameSettings.fortifications != eFortifications.UNLIMITED)) {
confirm("ENDTURN SNAPSHOT MOD 1:");
if (!gameSettings.speed && myOptions["endTurnSnapshot"]=="On") {
confirm("ENDTURN SNAPSHOT MOD 2: about to attempt to take snapshot");
takeSnapshot(); //THIS IS DEFINITELY BEING CALLED
}
lastCommand = '';
}
return ret;
}
_____________________________________________________________________
After the turn is completed, this is being run - I see both confirms. And the snapshot shows up in the snapshot menu. But it then goes away when the game is refreshed or reloaded.
I suspect I'm not calling 'takesnapshot' at the right time. If anybody can give me any ideas on where to call it, or any other pointers in general, I'd appreciate it.