Page 1 of 1

game_preferences ignored during replay

Posted: 09 November 2021, 05:08
by User Already Exists
I added a game preference for color blindness to my game, in gameoptions.inc.php like this:

Code: Select all

$game_preferences = array(
    100 => array(
        'name' => totranslate('Game display'),
        'needReload' => true,
        'values' => array(
            1 => array(
                'name' => totranslate('Standard')
            ),
            2 => array(
                'name' => totranslate('Color blindness'),
                'cssPref' => 'colorblind'
            )
        ),
        'default' => 1
    )
);
According to the documentation https://boardgamearena.com/doc/Game_opt ... ns.inc.php, it is supposed to add the "colorblind" class to the <html> element. I use this in CSS to adjust the color scheme to be easier to see for colorblind people.

This works perfectly during game play, but the option is completely ignored during replay (if a user tries to set this option, the page reloads, but the option goes back to "Standard" and the colorblind class is not added to <html>.

I believe this is a bug. The remaining options in the Preferences ("display game logs below player panels" and "display tool tips") work both during game play and during replay. Since these are display options, they should work during replay. The bug is present both on Studio and on the production site.

Are game preferences supposed to be ignored during replay? If not, how can I fix this? Thanks.

Re: game_preferences ignored during replay

Posted: 09 November 2021, 07:44
by Tisaac
This is not a bug. Since you need to refresh your page, then maybe the js code will do something completely different so the replay can't handle that since it's just about replaying basic stuff.
The solution is easy : dont use refresh and handle it directly yourself, there are exemple on the wiki for listening to changes.

Re: game_preferences ignored during replay

Posted: 10 November 2021, 05:35
by User Already Exists
OK, thanks, I will try that. I'll be curious to see if it will remember the user's previous preference. For example, if you're colorblind once, you'll probably remain colorblind in the future, so it would be nice if the user didn't have to set the preference on every reload. I'm not quite sure I understand the comment about JS doing completely different stuff. I thought preferences (as opposed to game options) were only to deal with cosmetic issues, not affect actual game play. But I'll experiment with your suggested solution; hopefully it will work as intended.

Re: game_preferences ignored during replay

Posted: 10 November 2021, 11:47
by robinzig
User preferences do get remembered for the next time you load the game :)