game_preferences ignored during replay

Game development with Board Game Arena Studio
Post Reply
User avatar
User Already Exists
Posts: 30
Joined: 30 January 2020, 05:13

game_preferences ignored during replay

Post 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.
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: game_preferences ignored during replay

Post 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.
User avatar
User Already Exists
Posts: 30
Joined: 30 January 2020, 05:13

Re: game_preferences ignored during replay

Post 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.
User avatar
robinzig
Posts: 461
Joined: 11 February 2021, 18:23

Re: game_preferences ignored during replay

Post by robinzig »

User preferences do get remembered for the next time you load the game :)
Post Reply

Return to “Developers”