Hello I have been trying out this module and I have been having some problems with the settings.

I have tried to set the "allow undo" to false but it still shows up. I took a look at the code I can see that you're testing the number of moves made and if they are the right viewer but I don't see a test for whether "allow undo" was set in the admin settings.

I have made a few moves and the email are sent but for some reason the moves show your index value for the pieces instead of the piece letter (is 1 for Knight and 5 for Pawn) but in game page the moves are correctly showing the chess notation.

Can you tell me how to fix the emails?

CommentFileSizeAuthor
#2 chess_fix_undo.patch773 bytesTim_O

Comments

Tim_O’s picture

Title: email after moves and can't set "allow undo" to false » "allow undo" option is disfunctional
Assigned: Unassigned » Tim_O

First of all: Thank you for reporting your findings. But in general, please make seperate issues if you have several things to ask/discuss. This will be the issue for this undo-bug now ...

1) Undo
So you want to disable undo-moves in the module-settings under /admin/settings/chess but it still allows to undo? Hm ... will need to look into this, this might well be a bug. I myself never had the desire to dissallow this, so I haven't tested that.

2) Moves in mails
About the mail ... If you send the mail with something like <?php echo $move?> in rules, then the mail will contain the move as it is contained in the database. To change this we would need to change the storage format (kind of a biiiig change). But as you are using PHP here, you could still do this by parsing the resulting string and replacing the number through a string. In case you want to do that, here is the mapping from the code:

define('CHESS_ROOK', 0);   // pieces: rook
define('CHESS_KNIGHT', 1);   // pieces: knight
define('CHESS_BISHOP', 2);   // pieces: bishop
define('CHESS_QUEEN', 3);   // pieces: queen
define('CHESS_KING', 4);   // pieces: king
define('CHESS_PAWN', 5);   // pieces: pawn

If you have a go for this, then please share your results with us. We could incorporate such a solution within the documentation, then.

Tim_O’s picture

Status: Active » Closed (fixed)
StatusFileSize
new773 bytes

Ok, I had a look into it and in fact there was no check for that setting at all :o So thank you again for letting us know.

I added an according check and did a short test that it's not showing the undo-form anymore if the setting is disabled. I just commited that change, so there should be a new version of the module ready for download by tomorrow.

Marking this as fixed & closed for now ...

jenb919’s picture

I used your existing function chess_piece_index and the emails now have the letter for the piece instead of the index.

line 1130
// If the rules module is installed, invoke our move-event
if (module_exists('rules')) {
$move_string = generate_move_pgn_string(array(
'game_id' => $nid,
'move_number' => $move_number,
'piece' => $piece,
'move_from_column' => $column_from,
'move_from_row' => $user_coord_from_row,
'captured_piece' => $captured_piece,
'move_to_column' => $column_to,
'move_to_row' => $user_coord_to_row,
));

to

// If the rules module is installed, invoke our move-event
if (module_exists('rules')) {
$move_string = generate_move_pgn_string(array(
'game_id' => $nid,
'move_number' => $move_number,
'piece' => chess_piece_index($piece),
'move_from_column' => $column_from,
'move_from_row' => $user_coord_from_row,
'captured_piece' => $captured_piece,
'move_to_column' => $column_to,
'move_to_row' => $user_coord_to_row,
));

Tim_O’s picture

Wonder why I didn't notice, that this other issue is so simple to fix. I need to get the new github-system running and will include that then, thank you jenb919!

Tim_O’s picture

Think I got that commited now, also. Thx again!