Page 1 of 1
Access $stats_type from gamename.game.php
Posted: 05 October 2013, 11:25
by pikiou
Is there a way to access $stats_type in stats.inc.php from gamename.game.php ?
Since in my game it's possible to undo most player actions, I needed an alternative way of handling stats, and I need read access to this variable not to duplicate it by copy/pasting it in gamename.game.php.
Re: Access $stats_type from gamename.game.php
Posted: 05 October 2013, 11:39
by sourisdudesert
Hi,
I'm interested to know in which case this is needed, to check if something is missing in the framework or if I can advise you another manner to do this thing.
In theory you can use
self::getStatTypes()
... that do the job. But this is not documented because this is not supposed to be useful.
Cheers,
Re: Access $stats_type from gamename.game.php
Posted: 05 October 2013, 12:23
by pikiou
I keep track of statistics in an array I save after each player action in a new history entry. When a player undoes his action, I get the previous history entry stats. (Keep in mind you can then undo again, and again...)
At the end of the game, I place these stats in the official ones with self::setStat().
I needed access to $stats_type to copy them in my own statistics track for history entries.
Re: Access $stats_type from gamename.game.php
Posted: 05 October 2013, 12:55
by sourisdudesert
Hi,
Okay. The thing is as a rule of thumb you are not supposed to give the possibility to undo actions with BGA. This can conduct to show private information to other players (which can ruins the game) or this can allow unfair players to do/undo an action a huge number of time to get rid of the the 1 move time limit. This is why we recommend to allow "cancel" in a very restricted number of case.
So basically: it's okay to proceed the way you do it, but this is not really in the spirit of the framework and I don't recommend other developers to follow this approach.
Thanks for your work on this game
Cheers,
Re: Access $stats_type from gamename.game.php
Posted: 05 October 2013, 15:08
by pikiou
I've been careful on the subject of cheating: when an action leads to showing private information, you can't undo it. And undoing can't lead to get rid of the time limit since in my game you only get extra time at the beginning of your turn.
I hope this feature was worth developing; I really enjoyed working on the history and reverse animation systems. Can't wait to see what you'll think of it !
And dully noted, I won't overuse it in next devs.