Dear all,
I have encountered the following, what do you think, is that a bug in the platform or some technical limitation ?
I have created a notification to say that someone played a piece somewhere or transfers pieces:
I have setup a format_string_recursive override:
So that tokens are replaced with nice images. It works perfectly when playing. Here are for example the arguments passed to getPieceDiv:
However, when I reload the page, the same code gets called supposedly on the same notification. But only parts of the arguments are kept and sent to the JS code:
As we can see, the "piece_type" and "piece_color" as well as other variables disappear. My best bet is that only the arguments that are actually used in the notification message get stored in the DB. So everything that is not displayed to the log message is lost.
Which means that I cannot use such arguments to display nice sprites.
Is that an expected behavior or just some side effect ?
I think that I can still pack every information I need in a special argument and unpack them using JS, but that would do no good because this would cause unreadable text when the JS is not called (like in the "replay game" page).
I have encountered the following, what do you think, is that a bug in the platform or some technical limitation ?
I have created a notification to say that someone played a piece somewhere or transfers pieces:
Code: Select all
$this -> notifyAllPlayers ( 'piecePlaced', clienttranslate ( '${player_name} places ${piece} at position ${x},${y}' ),
[ 'player_name' => $this -> getActivePlayerName ( ),
'player_id' => $this -> getActivePlayerId ( ),
'x' => $x,
'y' => $y,
'piece' => $type,
'piece_type' => $type,
'piece_color' => $color,
'possible_moves' => $piece->possiblePlaces() ] );Code: Select all
format_string_recursive : function(log, args) {
try {
if (log && args && !args.processed) {
args.processed = true;
if (!this.isSpectator)
args.You = this.divYou(); // will replace ${You} with colored version
// list of other known variables
var keys = [ 'piece' ];
for (var k in keys) {
if (typeof args[keys[k]] == 'string') {
if ( keys[k] == 'piece' )
args[keys[k]] = this.getPieceDiv(keys[k], args);
}
}
}
} catch (e) {
console.error(log,args,"Exception thrown", e.stack);
}
return this.inherited(arguments);
},Code: Select all
You: "<span style=\"font-weight:bold;color:#ff0000;\">You</span>"
piece: "<span id=\"tamere\" class=\"medina-block medina-block-building medina-block-building-maroon \" data-palace-id=\"0\" data-x=\"0\" data-y=\"0\" data-type=\"building\" data-color=\"maroon\" style=\"left:0px;top:0px;z-index:99\"></span>"
piece_color: "maroon"
piece_type: "building"
player_id: "2317321"
player_name: "<!--PNS--><span class=\"playername\"><!--PNS--><span class=\"playername\" style=\"color:#ff0000;\">benj2</span><!--PNE--></span><!--PNE-->"
possible_moves: Array(98) [ (2) […], (2) […], (2) […], … ]
processed: true
x: "9"
y: "2"
Code: Select all
You: "<span style=\"font-weight:bold;color:#ff0000;\">You</span>"
piece: "building"
player_id: "2317321"
player_name: "<!--PNS--><span class=\"playername\"><!--PNS--><span class=\"playername\" style=\"color:#ff0000;\">benj2</span><!--PNE--></span><!--PNE-->"
processed: true
x: "9"
y: "2"
Which means that I cannot use such arguments to display nice sprites.
Is that an expected behavior or just some side effect ?
I think that I can still pack every information I need in a special argument and unpack them using JS, but that would do no good because this would cause unreadable text when the JS is not called (like in the "replay game" page).