Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Game Courier Developer's Guide. Learn how to design and program Chess variants for Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Tue, Feb 16, 2021 10:02 PM UTC:

I have added the pieces system variable. This is the array stored in a set file. Its keys are piece labels, and its values are the filenames of image files. It basically tells which graphics to use for the pieces. I also fixed things so that you can set or get specific values of this array. This is done by following the variable name with a period and the element name. Because this will not work for labels that include periods, I have also added the pieceimg operator. This returns a specific element of the $pieces array.

The point of this is to make it even easier to support multiple sets when matching sets have not been provided. It can also be used to eliminate the need to use aliases. Here is how it may be used:

  1. Set groupsets to an array of the allowed sets. Each should be the basename of a set file:
setsystem groupsets array abstract5 alfaerie-many;
  1. Create an empty array:
set mypieces ();
  1. For any pieces whose images already have the same label in different sets, set the corresponding elements of your array to those pieces:
set mypieces.k $pieces.k;
set mypieces.K $pieces.K;
set mypieces.q $pieces.q;
set mypieces.Q $pieces.Q;
set mypieces.r $pieces.r;
set mypieces.R $pieces.R;
set mypieces.b $pieces.b;
set mypieces.B $pieces.B;
set mypieces.n $pieces.n;
set mypieces.N $pieces.N;
set mypieces.p $pieces.p;
set mypieces.P $pieces.P;

Or just:

foreach label (k K q Q r R b B n N p P):
  setelem mypieces #label pieceimg #label;
next;
  1. For each allowed set, use an if-elseif-else block or a switch-case block to set an individualized value for any pieces that are different between sets:
if == pieceset abstract5:
  set mypieces.s $pieces.s;
  set mypieces.S $pieces.S;
elseif == pieceset alfaerie-many:
  set mypieces.s pieceimg .de;
  set mypieces.S pieceimg .DE;
endif;
  1. Change the value of $pieces to that of the array you created:
setsystem pieces #mypieces;

Although you could have edited $pieces directly, this has the advantage of stripping $pieces of all the pieces you will not be using in your game.