preserveArgsInHistory argument to notifyAllPlayers

Game development with Board Game Arena Studio
Post Reply
User avatar
Elliot K
Posts: 11
Joined: 26 August 2020, 23:15

preserveArgsInHistory argument to notifyAllPlayers

Post by Elliot K »

Hi, folks. I'm using format_string_recursive in my Javascript code to replace text in the game log with images. I'm encountering a common problem - not all of the information in the original notifications is replayed when the game interface reloads. The problem and its solution are discussed here:

https://en.doc.boardgamearena.com/BGA_S ... in_the_log

In short, it recommends passing an array key called preserveArgsInHistory in the third parameter to notifyAllPlayers() in your PHP code. Arguments listed there will supposedly be saved and provided to format_string_recursive during the replay. However, that doesn't seem to be happening for me. I'm doing something like this:

Code: Select all

$ret = array(
     'i18n' => array ('tile_name'),
     'tile_name' => $this->tile_values[$type],
     'player_name' => self::getActivePlayerName(),
     'player_id' => $player_id,
     'location' => $location,
     'tile_type' => $type,
     'deckcount' => $deckcount,
     'groups' => $groups,
     'protected' => $this->findProtectedTiles($groups),
     'capture_target_id' => $capture_target,
     'preserveArgsInHistory' => array('capture_target_id')
);
self::notifyAllPlayers('playTile', $message, $ret);
During live play, capture_target_id shows up in the args parameter to format_string_recursive. You can even see preserveArgsInHistory populated correctly.

Code: Select all

{
    "i18n": [
        "tile_name",
        "captured_tile_name"
    ],
    "tile_name": "<div  class=\"uptown_log_icon\" style=\"background-position: -400% -400%;\"></div>",
    "player_name": "<!--PNS--><span class=\"playername\" style=\"color:#ffff8b;\">spottedshroom1</span><!--PNE-->",
    "player_id": "2337233",
    "location": 40,
    "tile_type": "4",
    "deckcount": 22,
    "groups": {
        "2337233": [
            [
                40
            ]
        ]
    },
    "protected": [],
    "capture_target_id": "2337232",
    "preserveArgsInHistory": [
        "capture_target_id"
    ],
    "capture_target_name": "spottedshroom0",
    "captured_tile_name": "<div  class=\"uptown_log_icon\" style=\"background-position: -1300% -0%;\"></div>",
    "processed": true
}
But in the replay, it's gone:

Code: Select all

{
    "i18n": [
        "tile_name",
        "captured_tile_name"
    ],
    "tile_name": "<div  class=\"uptown_log_icon\" style=\"background-position: -400% -400%;\"></div>",
    "player_name": "<!--PNS--><span class=\"playername\" style=\"color:#ffff8b;\">spottedshroom1</span><!--PNE-->",
    "player_id": "2337233",
    "capture_target_name": "spottedshroom0",
    "captured_tile_name": "<div  class=\"uptown_log_icon\" style=\"background-position: --1500% --100%;\"></div>",
    "originalType": "playTile",
    "processed": true
}
For some reason, phpbb won't let me search for preserveArgsInHistory, but I don't think there's been any discussion of that parameter here. Is anyone else using it? Does it work at all? Thanks.
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: preserveArgsInHistory argument to notifyAllPlayers

Post by Tisaac »

This feature is 2 days old, give it some time to be tested and used more :)
User avatar
Benoit314
Posts: 82
Joined: 02 April 2020, 22:12

Re: preserveArgsInHistory argument to notifyAllPlayers

Post by Benoit314 »

As Tisaac mentioned, this feature is really new.

I tried yesterday and had the same issue, args were not preserved, so maybe it is not deployed yet...
User avatar
Elliot K
Posts: 11
Joined: 26 August 2020, 23:15

Re: preserveArgsInHistory argument to notifyAllPlayers

Post by Elliot K »

Lol, that would do it ;)

Is there a good way to keep up with changes to the API? Thanks.
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: preserveArgsInHistory argument to notifyAllPlayers

Post by Tisaac »

Elliot K wrote: 24 March 2021, 01:42 Lol, that would do it ;)

Is there a good way to keep up with changes to the API? Thanks.
Best is to join the discord server, link is in the wiki
Post Reply

Return to “Developers”