Page 1 of 1
How to clear the game history log during the game?
Posted: 10 November 2020, 03:34
by GoDodyGo
Is there a way for my game (the PHP side) to clear the game/history log during the game? My card game consists of 7 hands which are completing independent of each other. I want to empty the game history (e.g. "Bill has drawn a card." "Joe played the Ace of Spades.") so that the clients use less memory, reloading the webpage is faster, etc...
Re: How to clear the game history log during the game?
Posted: 10 November 2020, 07:28
by Tisaac
Not a good idea, the log is needed to replay the game.
What you can do instead is hiding it using js.
Re: How to clear the game history log during the game?
Posted: 10 November 2020, 09:10
by GoDodyGo
I see. How do I hide log entries in the JS, and the sound too? I see the elements #logs and #logs_wrap in the HTML page. And each of the log elements is numbered #log_4.log for example.
Are you suggesting that, at the end of each hand, I can somehow capture which log numbers have been shown and then hide older ones that are no longer relevant to the players, and avoid them from being presented to the user during the game? But they would still be there for later replay if necessary. They just wouldn't be loaded during play? That could work...
After the game has been going on a long time, when the user refreshes the page it loads REALLY SLOWLY and making that 'whooshing' sound each time a message appears. So I'd like to reduce it to just the relevant messages.
Re: How to clear the game history log during the game?
Posted: 10 November 2020, 09:54
by Tisaac
GoDodyGo wrote: ↑10 November 2020, 09:10
I see. How do I hide log entries in the JS, and the sound too? I see the elements
#logs and
#logs_wrap in the HTML page. And each of the log elements is numbered
#log_4.log for example.
Are you suggesting that, at the end of each hand, I can somehow capture which log numbers have been shown and then hide older ones that are no longer relevant to the players, and avoid them from being presented to the user during the game? But they would still be there for later replay if necessary. They just wouldn't be loaded during play? That could work...
After the game has been going on a long time, when the user refreshes the page it loads REALLY SLOWLY and making that 'whooshing' sound each time a message appears. So I'd like to reduce it to just the relevant messages.
I am not sure to understand what you are saying. Reloading the page does not reload every log, instead it's using the getAllDatas that should always be enough to resume. When I was talking about replays, I meant the "replay functionnality" that allows you to replay the game from the start once the game is over for instance.
On the other hand, if you are out of the table for a while, then you will get all the notifications you missed in between. But it's going to be slow only if these notifications are synchronous, but that's usually because you want to display nice animation.
Re: How to clear the game history log during the game?
Posted: 10 November 2020, 15:13
by Een
Just confirming that it's something that goes with the framework. At this time there is no way to not send everything to the client or to prevent reloading it. Maybe something to improve in the future, but not something we have planned at the moment.
We usually have a message "A new round start" between rounds/hands to separate, but we generally don't hide logs (even in some games for which usually you can only look back at the last trick, because anyway people could take notes so everyone can have perfect memory on the internet if they want to).
Re: How to clear the game history log during the game?
Posted: 10 November 2020, 16:02
by Lunalol
This is my hack in setup: function (gamedatas):
setInterval(function ()
{
N = 500;
if (dojo.query('.log_replayable').length > N)
dojo.query('.log_replayable').slice(-N / 2).forEach(dojo.destroy)
}, 250);
I use that because I have more than 5000 entries in log for long game.
It's really bad but game loading is faster.
You can tune how many logs you keep (500 here) and at what interval you clean logs (here 250ms).
Lunalol
Re: How to clear the game history log during the game?
Posted: 10 November 2020, 16:30
by Tisaac
If you want to be hacky, there is a better way, you can overwrite the onPlaceLogOnChannel function :
Code: Select all
function override_onPlaceLogOnChannel(msg) {
// [Undocumented] Called by BGA framework on any notification message
// Handle cancelling log messages for restart turn
var currentLogId = this.next_log_id;
this.inherited(override_onPlaceLogOnChannel, arguments);
if (msg.move_id && this.next_log_id != currentLogId) {
var moveId = +msg.move_id;
dockedlog_to_move_id[currentLogId] = moveId;
if (this.gamedatas.cancelMoveIds != null && this.gamedatas.cancelMoveIds.includes(moveId)) {
this.cancelLogs([moveId]);
}
}
}