Check out Alice Chess, our featured variant for June, 2024.

Enter Your Reply

The Comment You're Replying To
🕸Fergus Duniho wrote on Fri, May 24 04:22 PM UTC in reply to H. G. Muller from 08:42 AM:

The code for continuemove is just a series of variable assignments, which by itself doesn't give much hint about how it should be used.

case "continuemove": // Allow multi-part move to be made with mouse/touch
case "redomove": // Allow player to redo illegal move
  if ($submit == "Preview")
    $submit = "";
  $pastmovesfield = ($args[0] == "redomove") ? "" : $moves;
  $movelist = $oldmovelist;
  $movenum = max($movenum - 1, 0);
  if (!$switchsides) {
    $side = $turnorder[$movenum % $sidecnt];
  }
  else
    $side = $turnorder[($sidecnt - 1) - ($movenum % $sidecnt)];
  break;

So, the main thing to consider is which variables are changing and how they are used. Changing the value of $submit changes which form_* script it includes when it loads the page after submitting a move. With a value of "Preview", it would include form_verify.php for showing a preview of the move and asking the player to confirm it. With an empty value, it will include form_move.php again. If you were playing by yourself in solitaire mode, it would not have to change the script it includes.

$pastmovesfield is for populating a form field that gets used for multi-part moves. So that the moves field works the same as it would for single moves, it starts out empty, and the previously entered moves go in a different form field.

$movelist is a string listing every move in the game on a separate line, sometimes with comments interspersed. $oldmovelist was set to $movelist just before appending the latest move to it. So this sets $movelist to what it was before the partial move that was already made was made. Once the full multi-part move has been made, it will be appended to $movelist as a single string.

$movenum is the number of the latest move. Since it would normally be incremented at the end of a complete move, it is decremented to keep it the same, though it is not allowed to go below zero.

$side indicates the side of the player who can move. This would normally switch to the other player at the end of a turn. But when continuing a move, it should not change to the other player. It gets the value of $side from a list of players whose identifiers in the game are values in the $turnorder array. It does this instead of switching a flag back and forth, because I wanted to add support for multi-player games and games with alternate turn orders, but that project is not complete, because some code in Game Courier just assumes a two-player game with alternating turns.

$switchsides has to do with the orientation of the board. It defaults to 0, which means that the board should be shown from the perspective of the player whose turn it is to move. Setting it to a non-zero value would cause the board to stay in the same position no matter whose turn it is. Since this is only a cosmetic difference, I'm not sure why it should have any bearing on whose side it is. So I'll experiment with whether giving $switchsides a non-zero value will mess up how a multi-move game operates.

The assigned variables mainly affect the form the player gets after completing the first part of a multi-part move, and they have nothing to do with the evaluation of a move, which is what the Post-Move code is supposed to handle. Given the purpose of this command, it should not be executed more than once during a whole series of moves, and it should not be executed for any past moves. In fact, calling it more than once could result in the wrong value for $movenum. So, it makes sense to reserve its use for the Post-Game code. In my code for Extra Move Chess, it is used after calculating the legal moves for the second part of the turn.


Edit Form

Comment on the page Game Courier

Conduct Guidelines
This is a Chess variants website, not a general forum.
Please limit your comments to Chess variants or the operation of this site.
Keep this website a safe space for Chess variant hobbyists of all stripes.
Because we want people to feel comfortable here no matter what their political or religious beliefs might be, we ask you to avoid discussing politics, religion, or other controversial subjects here. No matter how passionately you feel about any of these subjects, just take it someplace else.
Avoid Inflammatory Comments
If you are feeling anger, keep it to yourself until you calm down. Avoid insulting, blaming, or attacking someone you are angry with. Focus criticisms on ideas rather than people, and understand that criticisms of your ideas are not personal attacks and do not justify an inflammatory response.
Quick Markdown Guide

By default, new comments may be entered as Markdown, simple markup syntax designed to be readable and not look like markup. Comments stored as Markdown will be converted to HTML by Parsedown before displaying them. This follows the Github Flavored Markdown Spec with support for Markdown Extra. For a good overview of Markdown in general, check out the Markdown Guide. Here is a quick comparison of some commonly used Markdown with the rendered result:

Top level header: <H1>

Block quote

Second paragraph in block quote

First Paragraph of response. Italics, bold, and bold italics.

Second Paragraph after blank line. Here is some HTML code mixed in with the Markdown, and here is the same <U>HTML code</U> enclosed by backticks.

Secondary Header: <H2>

  • Unordered list item
  • Second unordered list item
  • New unordered list
    • Nested list item

Third Level header <H3>

  1. An ordered list item.
  2. A second ordered list item with the same number.
  3. A third ordered list item.
Here is some preformatted text.
  This line begins with some indentation.
    This begins with even more indentation.
And this line has no indentation.

Alt text for a graphic image

A definition list
A list of terms, each with one or more definitions following it.
An HTML construct using the tags <DL>, <DT> and <DD>.
A term
Its definition after a colon.
A second definition.
A third definition.
Another term following a blank line
The definition of that term.