Robo Home | MatchIsOver | Changes | Preferences | AllPages

This is mainly a problem when I want to save state in a perstent file. But I have the same problem when my robot prints statistics at the end of each round. There I've put calls to my printStatistics function inside onWin? and onDeath event handlers. But they sometimes occur both and then I get two prints of statistics. It hasn't been important enough for me to deal with, but this persistence issue is different. So now, can someone tell me how to figure out that the round is over? And the match? Or maybe if I know when a round is over I can just check if it's the final round using getRoundNum()? -- PEZ

You could call a clearAllEvents?() at the end of onWin?() and onDeath() to avoid the second printout. --Dummy

Thanks, I'll do that. So this means that these two events are the only clues to that the game is over? -- PEZ

What about using getRoundNum() and getNumRounds?()? When the first is 1 less than the second then you are in the final round of the battle. --Tad

Perhaps using getOthers?() and checking when it reaches 0 (or 1 if it includes your robot which I don't think it does.) That should do the trick. --Miked0801

It doesn't include the own robot. But if I get killed, then that call will never return 0, will it? Anyhow, I have decided to use the onWin?() and onDeath() calls and not bother if I write the statistics file twice. Tad's suggestion works fine for knowing I'm reaching the end of the match. But I'm not sure I will keep it that way, since then if I stop the game prematurely I wont save the statistics. I still think there is an onGameOver?() event missing. -- PEZ

Robo Home | MatchIsOver | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited March 3, 2003 23:11 EST by PEZ (diff)