1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
|
%%
%% This is file `xskak.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xskak-src.dtx (with options: `xskak')
%%
%% xskak: a package to parse and print chess games
%% Copyright 2006-2015 Ulrike Fischer (chess@nililand.de)
%% -------------------------------------------
%%
%% This file can be redistributed and/or modified under the terms of
%% the LaTeX Project Public License distributed from CTAN archives in
%% the directory macros/latex/base/lppl.txt; either version 1 of the
%% License, or (at your option) any later version.
%%
%% For error reports see documentation.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xskak}[2015/01/02 version v1.4 extended chess typesetting and parsing]
%%$Date: 2015/01/02 13:51:58 $$Version: c80394b06dd1 $
\newif\ifxskakpdfmatch
\ifcsname pdfmatch\endcsname
\xskakpdfmatchtrue
\else
\xskakpdfmatchfalse
\fi
\DeclareOption{nopdfmatch}{\xskakpdfmatchfalse}
\providecommand\xskak@val@skakversion{skak}
\DeclareOption{skak14}{\def\xskak@val@skakversion{skak14}}
\DeclareOption{skak15}{\def\xskak@val@skakversion{skak15}}
\DeclareOption{small}{\AtEndOfClass{\smallboard}}
\ProcessOptions
\RequirePackage{\xskak@val@skakversion}[2005/06/29]
\expandafter\edef\csname ver@skak.sty\endcsname{\csname ver@\xskak@val@skakversion.sty\endcsname}
\RequirePackage{xifthen}
\RequirePackage{etoolbox}
\RequirePackage{chessboard}[2007/12/20]
\RequirePackage{xskak-keys}
\newcommand\chessdiagramname{\ (Diagram)\ }
\RequirePackage{xskak-nagdef}
%%%%%%%%%%%%%%%%%%%%%
%% Naming conventions
%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%%%%% Initialisation
\newcommand\xskak@val@gameid{game}
\newcommand\xskak@val@movenr{1}
\newcommand\xskak@val@player{w}
\newcommand\xskak@val@type{}
\newcommand\xskak@val@defaultmovenr{1}
\newcommand\xskak@val@defaultplayer{w}
\newcommand\xskak@val@defaultmoveid{1w}
\newcommand\xskak@val@defaultid{game}
\newcommand\xskak@val@defaultfen{rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1}
\newcommand\xskak@val@currenttag{}
\newcommand\xskak@list@gametypes{%
initfen,%
initplayer,%
initmovenr,%
initmoveid,%
lastfen,%
lastplayer,%
lastmovenr,%
lastmoveid,%
nextplayer,%
nextmovenr,%
nextmoveid,%
diagramlist,%
gameid,%
parentid%NEW records game id of parent if the game is a variation, the last move of the parent=initmoveid
}
\newcommand\xskak@list@movetypes{%
movenr,%
player,%
moveid,%
pgnpiece,%
piece,%
piecechar,%
castling,%
longcastling,%
capture,%
check,%
mate,%
lostpiece,%
lostpiecechar,%
pgnlostpiece,%
movefrom,%
pgnmovefrom,%
moveto,%
move,%
enpassant,%
enpassantsquare,%
promotion,%
promotionpiece,%
promotionpiecechar,%
addpieces,%
clearfields,%
comments,%
nextfen,%
pastfen,%
nag,%
san,%
lan,%
opennr,%
vars,% NEW, records game id of child variations
varnum% NEW, records number of child variations
}
%% setting pgn infos
\newcommand\xskaknewpgninfo[2][]{%#1 default value, #2 keyname
\ifcsname UFCB@locfill@#2\endcsname
\PackageError{xskak}%
{(pgn) key #1 is already defined! Use another name}{}%
\else
\expandafter\newcommand\csname xskak@val@default#2\endcsname{#1}%
\define@key[UFXS]{setpgn}{#2}[\csname xskak@val@default#2\endcsname]{%
\expandafter\xdef\csname Xskak\xskak@val@gameid #2\endcsname{##1}}%
\define@key[UFCB]{locfill}{#2}[]{}%
\define@key[UFXS]{set}{default#2}{%
\expandafter\xdef\csname xskak@val@default#2\endcsname{##1}}%
\@ifundefined{xskak@list@setpgn}%
{\gdef\xskak@list@setpgn{#2}}%
{\g@addto@macro\xskak@list@setpgn{,#2}}%
\g@addto@macro\xskak@list@gametypes{,#2}%
\fi
}%
\xskaknewpgninfo[*]{result}
\xskaknewpgninfo[]{site}
\xskaknewpgninfo[]{event}
\xskaknewpgninfo[]{date}
\xskaknewpgninfo[]{round}
\xskaknewpgninfo[]{white}
\xskaknewpgninfo[]{black}
\xskaknewpgninfo[]{blackelo}
\xskaknewpgninfo[]{whiteelo}
%%% From skak.sty
\providecommand\CheckTest{}
\providecommand\MateTest{}
%%% For the benefit of texmate
\AtBeginDocument{\providecommand\fenposition[1]{}}
%%% new booleans
\newboolean{xskakboolcastling}
\newboolean{xskakboollongcastling}
\newboolean{xskakboolenpassant}
\newboolean{xskakboolcapture}
\newboolean{xskakboolcheck}
\newboolean{xskakboolmate}
\newboolean{xskakboolpromotion}
\newboolean{xskakboolcomment}
\newboolean{xskakboolnag}
\newboolean{xskakboolvar}
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%% Variables
\newcommand\xskakcomment[1]{{#1}}
\newcommand\xskakmovehyphen{\hbox{--\hspace{1pt}}} %or movehyphen from skak?
\newcommand*\xskakenpassanttext{\,e.p.}
%% set various variables like gameid and move
\newcommand\xskakset[1]{%
\setkeys[UFXS]{set}{#1}}
%% getting the move data
\newcommand*\xskakget[1]{%
\if\xskak@strequal{movenr}{#1}%
\xskak@val@movenr
\else
\if\xskak@strequal{player}{#1}%
\xskak@val@player
\else
\if\xskak@strequal{moveid}{#1}%
\xskak@val@movenr\xskak@val@player
\else
\if\xskak@strequal{level}{#1}%
\xskak@val@curlevel
\else
\ifcsname xskak@tag@\xskak@val@currenttag @#1\endcsname
\csname xskak@tag@\xskak@val@currenttag @#1\endcsname
\else
\ifcsname Xskak.\xskak@val@gameid.\xskak@val@movenr.\xskak@val@player.#1\endcsname
\csname Xskak.\xskak@val@gameid.\xskak@val@movenr.\xskak@val@player.#1\endcsname
\else
\PackageError{xskak}%
{\csname Xskak.\xskak@val@gameid.\xskak@val@movenr.\xskak@val@player.#1\endcsname isn't defined}{}%
\fi
\fi
\fi
\fi
\fi
\fi}
%% getting game data
\newcommand*\xskakgetgame[1]{%
\ifcsname Xskak\xskak@val@gameid#1\endcsname
\csname Xskak\xskak@val@gameid#1\endcsname
\else
\PackageError{xskak}%
{\csname Xskak\xskak@val@gameid#1\endcsname isn't defined}{}%
\fi}
%% getting ref data -> do it through xskakget and xskakgetgame
%% starting a new game
\newcommand\newchessgame[1][]{%
\setkeys*[UFXS]{new}{id,moveid}%
\setkeys*[UFXS]{new}{#1}%
\@for\xskak@temp@gametype:=\xskak@list@gametypes\do
{\expandafter\xdef
\csname Xskak\xskak@val@gameid\xskak@temp@gametype\endcsname{}}%
\expandafter\xdef\csname Xskak\xskak@val@gameid gameid\endcsname{\xskak@val@gameid}%
\toks@=\expandafter{\xskak@list@setpgn}%
\edef\xskak@temp@command{%
\noexpand\setkeys*[UFXS]{setpgn}{\the\toks@}}%
\xskak@temp@command
%\setkeys*[UFXS]{setpgn}{result}%
\setkeys*[UFXS]{setpgn}{#1}%
\chessboard[maxfield=h8,zero=false,print=false,
setfen=\xskak@val@defaultfen,%
#1,
mover=\xskak@val@player,
fullmove=\xskak@val@movenr,
storefen=@tempgame]%
\edef\temp{\csname chessgame.@tempgame\endcsname}%16.10.2008 for skak1.5
\expandafter\fenboard\expandafter{\temp}%16.10.2008 for skak1.5
\storegame{@tempgame}%16.10.2008 for skak1.5
\restoregame{@tempgame}%16.10.2008 for skak1.5
\edef\@tempa{\csname chessgame.@tempgame\endcsname}%
\expandafter\fenposition\expandafter{\@tempa}% for texmate
\expandafter\xdef
\csname Xskak\xskak@val@gameid initfen\endcsname{\csname chessgame.@tempgame\endcsname}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastfen\endcsname{\csname chessgame.@tempgame\endcsname}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pastfen\endcsname
{\csname chessgame.@tempgame\endcsname}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid initplayer\endcsname{\WhiteToMove{w}{b}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid initmovenr\endcsname{\the\c@move}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid initmoveid\endcsname{\the\c@move\WhiteToMove{w}{b}}%
\xskak@do@getpreviousmoveid{\the\c@move}{\WhiteToMove{w}{b}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastplayer\endcsname{\WhiteToMove{b}{w}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastmovenr\endcsname{\xskak@temp@movenr}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastmoveid\endcsname{\xskak@temp@movenr\WhiteToMove{b}{w}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextplayer\endcsname{\WhiteToMove{w}{b}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmovenr\endcsname{\the\c@move}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmoveid\endcsname{\the\c@move\WhiteToMove{w}{b}}%
\expandafter\xdef\csname %new 1.6. Initialization of nag
Xskak.\xskak@val@gameid.%
\csname Xskak\xskak@val@gameid lastmovenr\endcsname.%
\csname Xskak\xskak@val@gameid lastplayer\endcsname.nag\endcsname{}}
%% continuing a game
\newcommand\resumechessgame[1][]{%
\def\xskak@temp@player{%
\csname Xskak\xskak@val@gameid nextplayer\endcsname}%
\def\xskak@temp@movenr{%
\csname Xskak\xskak@val@gameid nextmovenr\endcsname}%
\setkeys*[UFXS]{res}{#1}%
\xdef\xskak@val@player{\xskak@temp@player}%
\xdef\xskak@val@movenr{\xskak@temp@movenr}%
\ifthenelse
{\xskak@test@lessorequal
{\xskak@val@movenr}%
{\xskak@val@player}%
{\csname Xskak\xskak@val@gameid nextmovenr\endcsname}%
{\csname Xskak\xskak@val@gameid nextplayer\endcsname}%
}%
{\chessboard[maxfield=h8,zero=false,print=false,
#1,
setfen=\xskakget{pastfen},
mover=\xskak@val@player,
fullmove=\xskak@val@movenr,
storefen=@tempgame
]%
\restoregame{@tempgame}%
\edef\@tempa{\csname chessgame.@tempgame\endcsname}%
\expandafter\fenposition\expandafter{\@tempa}% for texmate
\xskak@do@getpreviousmoveid{\the\c@move}{\WhiteToMove{w}{b}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastplayer\endcsname{\WhiteToMove{b}{w}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastmovenr\endcsname{\xskak@temp@movenr}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastmoveid\endcsname{\xskak@temp@movenr\WhiteToMove{b}{w}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextplayer\endcsname{\WhiteToMove{w}{b}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmovenr\endcsname{\the\c@move}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmoveid\endcsname{\the\c@move\WhiteToMove{w}{b}}%
}%
{\PackageError{xskak}{Move "\xskak@val@movenr\xskak@val@player" is
not in game \xskak@val@gameid}{}}}
%% export games
\newcommand\xskak@messages{}
\newcommand\xskakexportgames[1][]{%
\begingroup
\def\xskak@messages{}%
\setkeys[UFXS]{export}{file=xskakgames,games=\xskak@val@defaultid,#1}%
\immediate\openout\@unused=\xskak@val@exportfile
\immediate\write\@unused{%
\@percentchar This are games exported with xskak.sty^^J%
\@percentchar The options were: #1 ^^J%
\@percentchar \the\day.\the\month.\the\year}%
\expandafter\xskak@do@sanitizelist\expandafter{\xskak@val@exportgames}%
\@for\xskak@temp@game:=\xskak@temp@list\do
{%
\@ifundefined{Xskak\xskak@temp@game initfen}%
{\expandafter\g@addto@macro\expandafter\xskak@messages\expandafter{\expandafter"\xskak@temp@game"\space}}%
{\immediate\write\@unused{%
\@percentchar ^^J%
\@percentchar Start of game \xskak@temp@game ^^J%
\@percentchar}%
\@for\xskak@temp@gametype:=\xskak@list@gametypes\do
{\toks@=\expandafter\expandafter\expandafter{\csname Xskak\xskak@temp@game\xskak@temp@gametype\endcsname}%
\immediate\write\@unused{%
\unexpanded{\expandafter\def\csname}Xskak%
\xskak@temp@game\xskak@temp@gametype\noexpand\endcsname{\the\toks@}\noexpand\relax}%
}%
\expandafter\let\expandafter\xskak@temp@movenr
\csname Xskak\xskak@temp@game initmovenr\endcsname
\expandafter\let\expandafter\xskak@temp@player
\csname Xskak\xskak@temp@game initplayer\endcsname
\whiledo% loop through moves
{\xskak@test@moveidingame{\xskak@temp@movenr}{\xskak@temp@player}{\xskak@temp@game}}%
{\@for\xskak@temp@movetype:=\xskak@list@movetypes \do
{\toks@=\expandafter\expandafter\expandafter{%
\csname Xskak.\xskak@temp@game.\xskak@temp@movenr.\xskak@temp@player.\xskak@temp@movetype\endcsname}%
\immediate\write\@unused{%
\unexpanded{\expandafter\def\csname}Xskak.%
\xskak@temp@game.\xskak@temp@movenr.\xskak@temp@player.\xskak@temp@movetype
\noexpand\endcsname{\the\toks@}\noexpand\relax}%
}%
%% nextmove
\xskak@do@getnextmoveid{\xskak@temp@movenr}{\xskak@temp@player}%
}%
\immediate\write\@unused{\unexpanded{\def\xskakcurrentgameid}{\xskak@temp@game}\noexpand\xskakendgamedata}%
}}%
%
\immediate\closeout\@unused\relax
\ifx\xskak@messages\@empty
\else
\PackageWarning{xskak}{games \xskak@messages\space didn't exist. I
skipped them}{}%
\fi
\endgroup
}%
\newcommand\xskakendgamedata{}
\newcommand\xskakcurrentgameid{}
%% looping through a game.
\newcommand\xskakloop[2][]{%
%\show\xskakstart
\gdef\xskak@val@loopstep{1}%
\savekeys[UFXS]{loop}{\global{showlast}}%
\setkeys[UFXS]{loop}{showlast=false,#1}% getting the id
\xdef\xskak@val@movenr{%
\csname Xskak\xskak@val@gameid initmovenr\endcsname}%
\xdef\xskak@val@player{%
\csname Xskak\xskak@val@gameid initplayer\endcsname}%
\xdef\xskak@val@stopmovenr{%
\csname Xskak\xskak@val@gameid lastmovenr\endcsname}%
\xdef\xskak@val@stopplayer{%
\csname Xskak\xskak@val@gameid lastplayer\endcsname}%
\setkeys[UFXS]{loop}{#1}% getting the rest.
%%
\whiledo%
{\xskak@test@lessorequal
{\xskak@val@movenr}{\xskak@val@player}%
{\xskak@val@stopmovenr}{\xskak@val@stopplayer}}%
{% test if move in game:
\ifthenelse%
{\xskak@test@moveidingame{\xskak@val@movenr}{\xskak@val@player}{\xskak@val@gameid}}%
{#2%
\count@=\xskak@val@loopstep\relax
\whiledo{\the\count@>0}%
{\xskak@do@getnextmoveid{\xskak@val@movenr}{\xskak@val@player}%
\advance\count@ by -1%
\global\let\xskak@val@movenr\xskak@temp@movenr
\global\let\xskak@val@player\xskak@temp@player}%
}%
{\PackageError{xskak}%
{move {\xskak@val@movenr}{\xskak@val@player} is not in game
\xskak@val@gameid}{}}}%
\ifthenelse{\boolean{\XKV@UFXS@loop@showlast@value}}%
{\ifthenelse
{\equal{\xskak@val@movenr\xskak@val@player}{\xskak@val@stopmovenr\xskak@val@stopplayer}}%
{}%stop already processed.
{\let\xskak@val@movenr\xskak@val@stopmovenr
\let\xskak@val@player\xskak@val@stopplayer
#2}}%
{}}
%%% test if a number/color combination is in the game:
\newtest\xskaktestmoveid[2]{%number, w or b
\xskak@test@lessorequal
{\csname Xskak\xskak@val@gameid initmovenr\endcsname}%
{\csname Xskak\xskak@val@gameid initplayer\endcsname}%
{#1}{#2}%
\AND
\xskak@test@lessorequal
{#1}{#2}%
{\csname Xskak\xskak@val@gameid lastmovenr\endcsname}%
{\csname Xskak\xskak@val@gameid lastplayer\endcsname}}
\newtest\xskak@test@moveidingame[3]{%number, w or b, gameid
\xskak@test@lessorequal
{\csname Xskak#3initmovenr\endcsname}%
{\csname Xskak#3initplayer\endcsname}%
{#1}{#2}%
\AND
\xskak@test@lessorequal
{#1}{#2}%
{\csname Xskak#3lastmovenr\endcsname}%
{\csname Xskak#3lastplayer\endcsname}}
%%%%%%%%%%%%%%%%%%
%% Helper commands
%%%%%%%%%%%%%%%%%%
%%% help command for testing
\newcommand\xskak@matetest{}
\let\xskak@matetest\mate
%%% special fencalculate
%%% Use only inside dothemove to get the correct color and movenumber!}
\def\xskak@specialfencalculate{%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiece\endcsname
\Fen@Rank{8}%%
\Promotion{%
\WhiteToMove{%
\patchcmd{\temp@rank}
{P}
{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiece\endcsname}
{}
{\show\MistMist}}{}%
}{}%
\edef\temp@board{\temp@rank/}%
\Fen@Rank{7}\edef\temp@board{\temp@board\temp@rank/}%
\Fen@Rank{6}\edef\temp@board{\temp@board\temp@rank/}%
\Fen@Rank{5}\edef\temp@board{\temp@board\temp@rank/}%
\Fen@Rank{4}\edef\temp@board{\temp@board\temp@rank/}%
\Fen@Rank{3}\edef\temp@board{\temp@board\temp@rank/}%
\Fen@Rank{2}\edef\temp@board{\temp@board\temp@rank/}%
\Fen@Rank{1}%
\Promotion{%
\WhiteToMove{}
{\patchcmd{\temp@rank}
{p}
{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiece\endcsname}
{}
{\show\MistMist}}{}}{}%
\edef\temp@board{\temp@board\temp@rank}%
\edef\temp@board{\temp@board\space\WhiteToMove{b}{w}}%
\edef\temp@board{\temp@board\space\PrintCastling\space\EnPassantSquare}%
\edef\temp@board{\temp@board\space\arabic{halfmove}\space\the\count@}}
%%% Get the previous movenumber/color.
\newcommand\xskak@do@getpreviousmoveid[2]{%1. move number, 2. color
\if#2w%
\edef\xskak@temp@movenr{\the\numexpr #1-1\relax}%
\def\xskak@temp@player{b}%
\else
\edef\xskak@temp@movenr{#1}%
\def\xskak@temp@player{w}%
\fi}
%%% Get the next movenumber/color.
\newcommand\xskak@do@getnextmoveid[2]{%1. move number, 2. color
\if#2b\relax
\edef\xskak@temp@movenr{\the\numexpr #1+1\relax}%
\def\xskak@temp@player{w}%
\else
\edef\xskak@temp@movenr{#1}%
\def\xskak@temp@player{b}%
\fi}
%%% splits a move id like 10b or 8w:
\def\xskak@do@storeplayer#1\@nnil{\def\xskak@temp@player{#1}}
\def\xskak@split@moveid#1{\afterassignment\xskak@do@storeplayer\count@=#1\@nnil
\edef\xskak@temp@movenr{\the\count@}}
%%% tests
%% moveidA < = moveidB
\newtest\xskak@test@lessorequal[4]{%movenr/playerA movenr/playerB
\(#1<#3\)%
\OR
\(#1=#3%
\AND
\(\equal{#2}{#4}%
\OR
\equal{#4}{b}%
\)%
\)}%
\newcommand\xskak@do@sanitizelist[1]{%
\def\xskak@temp@list{}%
\@for\xskak@temp@listentry:=#1\do
{\edef\xskak@temp@cmd{%
\noexpand\setkeys[UFXS]{inner}{stripspace=\xskak@temp@listentry}}%
\xskak@temp@cmd
\ifx\xskak@temp@list\@empty
\expandafter\def\expandafter\xskak@temp@list\expandafter{\xskak@temp@output}%
\else
\expandafter\board@do@l@addto@macro\expandafter\xskak@temp@list\expandafter{\expandafter,\xskak@temp@output}%
\fi}}
\define@key[UFXS]{inner}{stripspace}{\def\xskak@temp@output{#1}}
\def\xskak@strequal#1{\number\xskak@strequalstart{}{}#1\relax}
\def\xskak@strequalstart#1#2#3{\if#3\relax\xskak@strequalstop\fi
\xskak@strequalstart{\if#3#1}{#2\fi}}
\def\xskak@strequalstop\fi\xskak@strequalstart#1#2#3{\fi#1#3\relax'#213 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Core: Store Move Informations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% move related informations
%%%% <type> <value>
%%%% vars list of game id of variations. Is set to empty by \xskak@do@dothemove. Can be
%%%% change by variation games to notify the "parent" about its "child"
%%%% varnum record the number of variations of the move. Set to 0 by \xskak@do@dothemove.
%%%% pgnpiece K,Q,R,B or N (independent from language). Is empty for Pawn and Castling moves
%%%% piece K,Q,R,B,N or P or k,q,r,b,n or p (for black). Is empty for Castling
%%%% piecechar K,Q,R,B,N or p. Is empty for Castling
%%%% castling sets the boolean xskakboolcastling, is true for short *and* long castling
%%%% longcastling sets the boolean xskakboollongcastling
%%%% capture sets the boolean xskakboolcapture
%%%% check sets the boolean xskakboolcheck
%%%% mate sets the boolean xskakboolmate
%%%% lostpiece In case of a capture move: K,Q,R,B,N or P or k,q,r,b,n or p(independent from language).
%%%% lostpiecechar In case of a capture move: K,Q,R,B,N or p, empty else
%%%% pgnlostpiece in case of a capture move: K,Q,R,B, or N (independent from language)
%%%% movefrom a field, in case of castling: field of king and rook (e.g. e1,h1)
%%%% pgnmovefrom the additional movefrom description in the pgn-notation for ambiguous
%%%% moves and pawn captures.
%%%% moveto a field, in case of castling empty
%%%% move movefrom-moveto, in case of castling two moves: e.g. e1-f1,h1-f1
%%%% enpassant sets the boolean xskakboolenpassant to true
%%%% if the current move is an ep, else to false
%%%% enpassantsquare a field, after e.g. e4 the value is e3. Indicates if the next
%%%% pawn move can be a ep.
%%%% promotion sets the boolean xskakboolpromotion
%%%% promotionpiece Q,R,B,N or q,r,b,n (undependant from language) or empty
%%%% promotionpiecechar Q,R,B,N (undependant from language) or empty
%%%% addpieces contains the (list of) piece(s) that should be put on the board
%%%% e.g. {kg8,rf8} in case of black short castling
%%%% clearfields the list of fields that should be emptied on board
%%%% comments contains the short comments after a move (!,? \withattack{} etc)
%%%% nextfen the fen position after the current move (halfmoves, castling are perhaps wrong)
%%%% pastfen the fen position *before* the current move (identical to the fen after the previous move)
%%%% nag larger comments after (between) move.
%%%% san standard algebraic notation of the move.
%%%% e.g. \textsymfigsymbol{R}a2, e\capturesymbol d5,
%%%% \castlingchar\castlinghyphen\castlingchar
%%%% lan long algebraic notation of the move.
%%%% opennr The number representation for an open move e.g. 2...
%%% Game related informations. Don't use @ or "." to simplify use by the user
%%%% gameid stores the gameid (for easier retrieving)
%%%% initfen The fen before the first move. Set by \newchessgame
%%%% initplayer w or b, The color of the next (first) player.
%%%% (must be identical to the color in the initfen).
%%%% Also set by \newchessgame
%%%% initmovenr The number of the first move (must be identical to the fullmove number in the initfen)
%%%% Also set by \newchessgame
%%%% lastfen The fen after the last move, set during parsing.
%%%% lastplayer The fen color of the last move, set during parsing
%%%% = color of the fen before the last move!
%%%% not identical to color in fen!
%%%% lastmovenr The number of the last move, set during parsing.
%%%% lastmoveid combination of lastmovenr+lastplayer
%%%% nextplayer The fen color of the player which should move next, set during parsing
%%%% = color of the fen
%%%% nextmovenr The number of the next move, identical to number in fen
%%%% nextmoveid combination of nextmovenr+nextmoveplayer
%%%% diagramlist A comma separated list of MovenrPlayer (e.g. 3b,20w). Records the moves with an $d or $D after the move
%% save the original skak definition
\let\xskak@oriDoTheMove\DoTheMove
%% define a new DoTheMove:
\def\xskak@do@dothemove#1{% move the piece from #1 to \MoveToFile\MoveToRank
%%%%% Store the move and board informations, will be used to retrieve the pieces deleted
\Fen@calculate
\setkeys[UFCB]{locinit}{maxfield=h8,zero=false}%
\setkeys[UFCB]{locfill}{setfen=\temp@board}%
%\expandafter\show\csname board@val@f4r4@piecechar\endcsname
%===========%
%% vars + varnum
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.vars\endcsname{}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.vars\endcsname
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.varnum\endcsname{0}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.varnum\endcsname
%===========%
%% pgnpiece
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnpiece\endcsname{%
\EqStr{\PieceNameToMove}{Z}{}{\PieceNameToMove}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnpiece\endcsname
%===========%
%% piece
\edef\@tempa{\PieceNameToMove}%
\expandafter\board@conv@chartolowerchar\@tempa
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piece\endcsname{%
\Castling%
{}%
{\EqStr{\PieceNameToMove}{Z}%
{\WhiteToMove{P}{p}}%
{\WhiteToMove%
{\PieceNameToMove}%
{\board@temp@char}}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piece\endcsname
%===========%
%% piecechar
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piecechar\endcsname{%
\Castling%
{}%
{\EqStr{\PieceNameToMove}{Z}%
{p}%
{\PieceNameToMove}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piecechar\endcsname
%===========%
%% lostpiece
% the values for enpassant move are corrected in the enpassant commands!
\expandafter\board@conv@filechartonumber\MoveToFile{cnt@board@file}%
\def\@tempa{empty}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname{%
\expandafter\ifx
\csname board@val@f\the\c@cnt@board@file r\MoveToRank @piecechar\endcsname
\@tempa
\else
\expandafter\ifx
\csname board@val@f\the\c@cnt@board@file r\MoveToRank @piecechar\endcsname
\relax
\else
\csname board@val@f\the\c@cnt@board@file r\MoveToRank @piecechar\endcsname
\fi
\fi}%
%===========%
%% pgnlostpiece
\def\board@temp@char{P}%
\edef\@tempa{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname}%
\expandafter\if
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname\@empty
\else
\expandafter\board@conv@chartoupperchar\@tempa%
\fi
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnlostpiece\endcsname{%
\if\board@temp@char P%
\else
\board@temp@char
\fi}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnlostpiece\endcsname
%===========%
%% Opennr
%%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.opennr\endcsname{%
\the\c@move\WhiteToMove
{\noexpand\whiteopen\noexpand\beforewhite}%
{\noexpand\blackopen\noexpand\beforeblack}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.opennr\endcsname
%===========%
%% MoveFrom-field
%% expanded to set also castling from fields e.g. e1,h1 for short white castling
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.movefrom\endcsname{%
\Castling
{\LongCastling%
{\WhiteToMove{e1,a1}{e8,a8}}%
{\WhiteToMove{e1,h1}{e8,h8}}}%
{#1}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.movefrom\endcsname
%===========%
%% pgnmovefrom
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnmovefrom\endcsname{%
\EqStr{\FileDiscriminator}{Z}%
{}{\FileDiscriminator}%
\EqStr{\RankDiscriminator}{Z}%
{}{\RankDiscriminator}%
}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnmovefrom\endcsname
%===========%
%% MoveTo-field
%% added castling test: White O-O -> g1,f1
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.moveto\endcsname{%
\Castling
{\LongCastling
{\WhiteToMove{c1,d1}{c8,d8}}%
{\WhiteToMove{g1,f1}{g8,f8}}}%
{\MoveToFile\MoveToRank}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.moveto\endcsname
%===========%
%% Move
%% two moves for castling
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.move\endcsname{%
\Castling
{\LongCastling%
{\WhiteToMove{e1-c1,a1-d1}{e8-c8,a8-d8}}%
{\WhiteToMove{e1-g1,h1-f1}{e8-g8,h8-f8}}}%
{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.movefrom\endcsname
-\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.moveto\endcsname}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.move\endcsname
%===========%
%% Castling
% new naming
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.castling\endcsname{%
\Castling{\noexpand\setboolean{xskakboolcastling}{true}}%
{\noexpand\setboolean{xskakboolcastling}{false}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.castling\endcsname
%===========%
%% Longcastling
% new naming
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.longcastling\endcsname{%
\LongCastling{\noexpand\setboolean{xskakboollongcastling}{true}}%
{\noexpand\setboolean{xskakboollongcastling}{false}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.longcastling\endcsname
%% Capture
%% new naming, changed to boolean!
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.capture\endcsname{%
\Capture{\noexpand\setboolean{xskakboolcapture}{true}}%
{\noexpand\setboolean{xskakboolcapture}{false}}}%
%===========%
%% Check?
%%new naming, changed to boolean
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.check\endcsname{%
\ifx\CheckTest\@empty
\noexpand\setboolean{xskakboolcheck}{false}%
\else
\noexpand\setboolean{xskakboolcheck}{true}%
\fi}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.check\endcsname
%===========%
%% Mate?
%%new naming, changed to boolean
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.mate\endcsname{%
\ifx\MateTest\xskak@matetest\relax
\noexpand\setboolean{xskakboolmate}{true}%
\else
\noexpand\setboolean{xskakboolmate}{false}%
\fi}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.mate\endcsname
%===========%
%% Enpassantsquare
%%new naming
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassantsquare\endcsname
{\EnPassantSquare}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassantsquare\endcsname
%===========%
%% Enpassantcheck
%% new naming, changed to boolean
\begingroup
\WhiteToMove%
{\ifthenelse%
{\equal{\csname Xskak.\xskak@val@gameid.\the\c@move.w.piecechar\endcsname}{p}}
{% pawn move:
\ifthenelse%white enpassant
{\equal
{\csname Xskak.\xskak@val@gameid.\the\c@move.w.moveto\endcsname}%
{\csname Xskak.\xskak@val@gameid.\the\numexpr\the\c@move-1\relax.b.enpassantsquare\endcsname}}%
{\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
{\noexpand\setboolean{xskakboolenpassant}{true}}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname{p}}%
{\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
{\noexpand\setboolean{xskakboolenpassant}{false}}}}%
{\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
{\noexpand\setboolean{xskakboolenpassant}{false}}}%
}%
{\ifthenelse
{\equal{\csname Xskak.\xskak@val@gameid.\the\c@move.b.moveto\endcsname}{p}}
{%pawn move:
\ifthenelse%black enpassant
{\equal
{\csname Xskak.\xskak@val@gameid.\the\c@move.b.moveto\endcsname}%
{\csname Xskak.\xskak@val@gameid.\the\c@move.w.enpassantsquare\endcsname}}%
{\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
{\noexpand\setboolean{xskakboolenpassant}{true}}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname{P}}%
{\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
{\noexpand\setboolean{xskakboolenpassant}{false}}}}%
{\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
{\noexpand\setboolean{xskakboolenpassant}{false}}}}%
%
\endgroup
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname
%===========%
%% lostpiecechar
\edef\@tempa{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiece\endcsname}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiecechar\endcsname{%
\if\@tempa P%
p%
\else
\if\@tempa p%
p%
\else
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnlostpiece\endcsname
\fi
\fi}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lostpiecechar\endcsname
%===========%
%% Promotion
%%new naming, added boolean
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiecechar\endcsname{%
\Promotion{\PromotionPieceName}{}}%
\edef\@tempa{\PromotionPieceName}%
\if\@tempa\@empty\else
\WhiteToMove{\let\board@temp@char\@tempa}{\expandafter\board@conv@chartolowerchar\@tempa}%
\fi
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiece\endcsname{%
\Promotion{\board@temp@char}{}}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotion\endcsname{%
\Promotion%
{\noexpand\setboolean{xskakboolpromotion}{true}}%
{\noexpand\setboolean{xskakboolpromotion}{false}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotion\endcsname
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiece\endcsname
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiecechar\endcsname
%=============%
%% san
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.check\endcsname
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.mate\endcsname
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotion\endcsname
\expandafter\protected@xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.san\endcsname{%
\Castling
{\LongCastling
{\unexpanded{\castlingchar\castlinghyphen\castlingchar\castlinghyphen\castlingchar}}%
{\unexpanded{\castlingchar\castlinghyphen\castlingchar}}}%
{\if\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piecechar\endcsname p\else
\noexpand\textsymfigsymbol{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piecechar\endcsname}%
\fi
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.pgnmovefrom\endcsname
\Capture{\noexpand\capturesymbol}{}%
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.moveto\endcsname
\ifxskakboolpromotion
\noexpand\textsymfigsymbol{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiecechar\endcsname}%
\fi
\ifxskakboolenpassant
\noexpand\xskakenpassanttext
\fi}%move from below 2008-10-10
\ifxskakboolcheck
\noexpand\checksymbol
\fi
\ifxskakboolmate
\noexpand\mate
\fi
}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.san\endcsname
%=============%
%% lan
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.check\endcsname
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.mate\endcsname
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotion\endcsname
\expandafter\protected@xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lan\endcsname{%
\Castling
{\LongCastling
{\unexpanded{\castlingchar\castlinghyphen\castlingchar\castlinghyphen\castlingchar}}%
{\unexpanded{\castlingchar\castlinghyphen\castlingchar}}}%
{\if\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piecechar\endcsname p\else
\noexpand\textsymfigsymbol{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piecechar\endcsname}%
\fi
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.movefrom\endcsname
\Capture{\noexpand\capturesymbol}{\noexpand\xskakmovehyphen}%
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.moveto\endcsname
\ifxskakboolpromotion
\noexpand\textsymfigsymbol{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.promotionpiecechar\endcsname}%
\fi
\ifxskakboolenpassant
\noexpand\xskakenpassanttext
\fi}%move from below 2008-10-10
\ifxskakboolcheck
\noexpand\checksymbol
\fi
\ifxskakboolmate
\noexpand\mate
\fi
}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.lan\endcsname
%===========%
%% addpieces
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.addpieces\endcsname{%
\Castling%
{\LongCastling%
{\WhiteToMove{Kc1,Re1}{kc8,re8}}%
{\WhiteToMove{Kg1,Rf1}{kg8,rf8}}}%
{\Promotion%
{\PromotionPieceName\MoveToFile\MoveToRank}%
{\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.piece\endcsname
\MoveToFile\MoveToRank}%
}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.addpieces\endcsname
%===========%
%% clearfields
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.enpassant\endcsname
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.clearfields\endcsname{%
\Castling%
{\LongCastling%
{e\WhiteToMove{1}{8},a\WhiteToMove{1}{8}}%
{e\WhiteToMove{1}{8},h\WhiteToMove{1}{8}}}%
{\ifxskakboolenpassant%
\WhiteToMove
{\csname Xskak.\xskak@val@gameid.\the\numexpr\the\c@move-1\relax.b.moveto\endcsname,#1}%
{\csname Xskak.\xskak@val@gameid.\the\c@move.w.moveto\endcsname,#1}%
\else
#1%
\fi}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.clearfields\endcsname
%============%
%% comments
\toks@=\expandafter{\MoveRest}%
\expandafter\xdef
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.comments\endcsname{%
\the\toks@}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.comments\endcsname
%============%
%% lastplayer, nextplayer, lastmovenr, nextmovenr
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastplayer\endcsname{\WhiteToMove{w}{b}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextplayer\endcsname{\WhiteToMove{b}{w}}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastmovenr\endcsname{\the\c@move}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid lastmoveid\endcsname{\the\c@move\WhiteToMove{w}{b}}%
\WhiteToMove{%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmovenr\endcsname{\the\c@move}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmoveid\endcsname{\the\c@move b}}%
{\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmovenr\endcsname{\the\numexpr\the\c@move+1\relax}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid nextmoveid\endcsname{\the\numexpr\the\c@move+1\relax w}}%
%=============%
% Initialization of the nag-commands (are filled later by \Mainline)%
\expandafter\xdef\csname
Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.nag\endcsname{}%
\edef\oldpiece{\Get{\MoveToFile\MoveToRank}}%
\Set{\MoveTo}{\Get{#1}}\Set{#1}{E}%
\gdef\MoveFrom{#1}%
%===========%
%%fen position _after_ the move
\count@=\value{move}%
\WhiteToMove{}{\advance\count@ by 1\relax}%
\xskak@specialfencalculate
\expandafter\global\expandafter\let
\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.nextfen\endcsname\temp@board
\xskak@do@getnextmoveid{\the\c@move}{\WhiteToMove{w}{b}}%
%% fen before next move
\expandafter\xdef
\csname
Xskak.\xskak@val@gameid.\xskak@temp@movenr.\xskak@temp@player.pastfen\endcsname{\temp@board}%
%% current last fen of game
\expandafter\xdef
\csname
Xskak\xskak@val@gameid lastfen\endcsname{\temp@board}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.\WhiteToMove{w}{b}.nextfen\endcsname
}
%% overwrite the original skak definition:
\let\DoTheMove\xskak@do@dothemove
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% enabling parsing of comments
%%% comments a NAG ($<number>) or text in \xskakcomment{...}
%%% NAG and comments must have spaces between them!
%% tests is the argument is a NAG
\def\xskak@test@nag#1#2XX{%
\ifthenelse{\equal{#1}{$}}%
{\setboolean{xskakboolnag}{true}}{\setboolean{xskakboolnag}{false}}}
%% tests if the argument is \xskakcomment{...}
\def\xskak@test@comment#1=\xskakcomment#2=={%
\def\@tempa{#1}%
\ifx\@tempa\empty%#1 beginnt mit \xskakcomment
\setboolean{xskakboolcomment}{true}%
\else
\setboolean{xskakboolcomment}{false}%
\fi}
%% saving old version of \Mainline:
\let\xskak@oriMainline\Mainline
%% define a new own Mainline command
\def\xskak@do@parsemainline(#1 #2){%
\let\xskak@save@nag\gdef
\ifxskakboolnag
\let\xskak@save@nag\g@addto@macro
\fi
\ifxskakboolcomment
\let\xskak@save@nag\g@addto@macro
\fi
\xskak@test@comment=#1=\xskakcomment==%
\ifxskakboolcomment
\ExecuteMoves{% mainline
\WhiteToMove
{\expandafter\xskak@save@nag
\csname Xskak.\xskak@val@gameid.\the\numexpr\the\c@move-1\relax.b.nag\endcsname
{{\xskak@beforecomment{#1}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\numexpr\the\c@move-1\relax.b.nag\endcsname
}%
{%
\expandafter\xskak@save@nag
\csname Xskak.\xskak@val@gameid.\the\c@move.w.nag\endcsname
{{\xskak@beforecomment{#1}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.w.nag\endcsname
}}%
{}%variation
\PrintMoves{{\xskak@beforecomment{#1}}}{}%
\xskak@do@parsemainline(#2)%
\else
\xskak@test@nag#1YXX%
\ifthenelse%
{\boolean{xskakboolnag}}%
{\ExecuteMoves{% mainline%
\WhiteToMove
{\ifthenelse{\equal{#1}{$D} \OR \equal{#1}{$d}}%
{\expandafter\ifx
\csname Xskak\xskak@val@gameid diagramlist\endcsname\@empty
\expandafter\xdef
\csname Xskak\xskak@val@gameid diagramlist\endcsname
{\the\numexpr\the\c@move-1\relax b}%
\else
\toks@=\expandafter\expandafter\expandafter{%
\csname Xskak\xskak@val@gameid diagramlist\endcsname}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid diagramlist\endcsname
{\the\toks@,\the\numexpr\the\c@move-1\relax b}%
\fi
}%
{\expandafter\xskak@save@nag
\csname Xskak.\xskak@val@gameid.\the\numexpr\the\c@move-1\relax.b.nag\endcsname
{{\xskak@beforeNAG{\csname#1\endcsname}}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\numexpr\the\c@move-1\relax.b.nag\endcsname
}%
{\ifthenelse{\equal{#1}{$D} \OR \equal{#1}{$d}}%
{\expandafter\ifx
\csname Xskak\xskak@val@gameid diagramlist\endcsname\@empty
\expandafter\xdef
\csname Xskak\xskak@val@gameid diagramlist\endcsname
{\the\c@move w}%
\else
\toks@=\expandafter\expandafter\expandafter{%
\csname Xskak\xskak@val@gameid diagramlist\endcsname}%
\expandafter\xdef
\csname Xskak\xskak@val@gameid diagramlist\endcsname
{\the\toks@,\the\c@move w}%
\fi
}%
{\expandafter\xskak@save@nag
\csname Xskak.\xskak@val@gameid.\the\c@move.w.nag\endcsname
{{\xskak@beforeNAG{\csname#1\endcsname}}}}%
%\expandafter\show\csname Xskak.\xskak@val@gameid.\the\c@move.w.nag\endcsname
}}%
{}%variation
\PrintMoves{{\xskak@beforeNAG{\csname#1\endcsname}}}{}%
\xskak@do@parsemainline(#2)}%
{\EqStr{ }{#1}%
{\xskak@do@parsemainline(#2)}%
{%
\EqStr{Z}{#1}%
{}%
{\NumberNext%
{\EatNumber{#1}% sets \NumberOK, \ExpectedColour
% executes a move not separated from the
% number with a space, eg, 1.e4
%{\gdef\NumberNext{\False}\Mainline(#2)}%
%\gdef\NumberNext{\False}%
\xskak@do@parsemainline(#2)}%
{\Fen@calculate% 16.10.2008 skak1.5
\expandafter\xdef\csname chessgame.skak.temp.previous\endcsname{\temp@board}%16.10.2008 skak1.5
\MakeMoveMainline{#1}%
\xskak@do@parsemainline(#2)}}}}%
\fi}
%% overwrite the skak version:
%% currently needed as \runmoves use \Mainline
\let\Mainline\xskak@do@parsemainline
%% Printing
%%% Styles
%% helper command. Copies the commands around
\newcommand\xskak@do@copystyleitem[2]{% #1<type> to #2<type>
%use empty #2 to copy to the skak original commands
%use empty #1 to copy from the original skak commands
%use xskak@styleitem@<name>@ to copy a named style item
\ifcsname #1beforeblack\endcsname
\expandafter\global\expandafter\let
\csname #2whiteopen\expandafter\endcsname
\csname #1whiteopen\endcsname
\expandafter\global\expandafter\let
\csname #2blackopen\expandafter\endcsname
\csname #1blackopen\endcsname
\expandafter\global\expandafter\let
\csname #2beforewhite\expandafter\endcsname
\csname #1beforewhite\endcsname
\expandafter\global\expandafter\let
\csname #2beforeblack\expandafter\endcsname
\csname #1beforeblack\endcsname
\expandafter\global\expandafter\let
\csname #2afterwhite\expandafter\endcsname
\csname #1afterwhite\endcsname
\expandafter\global\expandafter\let
\csname #2afterblack\expandafter\endcsname
\csname #1afterblack\endcsname
\expandafter\global\expandafter\let
\csname #2beforenumber\expandafter\endcsname
\csname #1beforenumber\endcsname
\expandafter\global\expandafter\let
\csname #2opencommands\expandafter\endcsname
\csname #1opencommands\endcsname
\expandafter\global\expandafter\let
\csname #2closecommands\expandafter\endcsname
\csname #1closecommands\endcsname
%% two specific xskak command for the comments:
\expandafter\global\expandafter\let
\csname #2xskak@beforecomment\expandafter\endcsname
\csname #1xskak@beforecomment\endcsname
\expandafter\global\expandafter\let
\csname #2xskak@beforeNAG\expandafter\endcsname
\csname #1xskak@beforeNAG\endcsname
\else
\PackageError{xskak}{style template #1 doesn't exist!}{}%
\fi}
%% new style items
\def\xskak@temp@name{xskak@styleitem@@empty@}%
\setkeys[UFXS]{styleitem}{%
opencommands={},
beforenumber={},
whiteopen={},
blackopen={},
beforewhite={},
afterwhite={},
beforeblack={},
afterblack={},
closecommands={},
beforecomment={},
beforeNAG={}}
\newcommand\xskak@beforeNAG{}
\newcommand\xskaknewstyleitem[2][]{%
\ifcsname xskak@styleitem@#2@beforeblack\endcsname
\PackageWarning{xskak}{Style item #2 already exists.
I overwrite it!}{}%
\fi
\def\xskak@temp@name{xskak@styleitem@#2@}%
\setkeys*[UFXS]{styleiteminit}{%
template=@empty, %empty everything
#1}% %use a possible template.
\setrmkeys[UFXS]{styleitem}}
%%% styles
\newcommand*\xskak@do@splitlevel[1]{%
\def\xskak@temp@levelprefix{#1}%
\def\xskak@temp@levelpostfix{}%
\def\xskak@temp@levelnumber{0}}
\ifxskakpdfmatch
\renewcommand*\xskak@do@splitlevel[1]{%
\ifnum\pdfmatch {([^0-9]*)([0-9]+)(.*)}{#1}=1 %
\edef\xskak@temp@levelprefix{\expandafter\strip@prefix\pdflastmatch1}%
\edef\xskak@temp@levelpostfix{\expandafter\strip@prefix\pdflastmatch3}%
\edef\xskak@temp@levelnumber{\expandafter\strip@prefix\pdflastmatch2}%
\else
\edef\xskak@temp@levelprefix{#1}%
\edef\xskak@temp@levelpostfix{}%
\edef\xskak@temp@levelnumber{0}%
\fi}%
\fi
\newcommand\xskaknewstyle[2][]{%
\begingroup
\def\xskak@temp@name{xskak@style@#2@}%
\ifcsname\xskak@temp@name 1@item\endcsname
\PackageError{xskak}{style #2 already exists}{}%
\else
\setkeys[UFXS]{style}{level=1,styleitem=@empty,#1}%
\fi
\endgroup
}
\newcommand\xskakaddtostyle[2][]{%
\def\xskak@temp@name{xskak@style@#2@}%
\ifcsname\xskak@temp@name 1@item\endcsname
\setkeys[UFXS]{style}{#1}%
\else
\PackageError{xskak}{style #2 doesn't exist}{}%
\fi
}
%% using and setting styles:
\newcommand\xskak@use@varstyle[1]{%
\ifcsname xskak@style@\xskak@val@stylename @#1@item\endcsname
%use xskak@styleitem@<name>@ to copy a named style item
\edef\@tempa{%
xskak@styleitem@%
\csname xskak@style@\xskak@val@stylename @#1@item\endcsname%=<name>
@}%
\xskak@do@copystyleitem{%
\@tempa}{}%
\else
\ifxskakpdfmatch
\xskak@do@splitlevel{#1}%
\ifnum\xskak@temp@levelnumber>0\relax
\ifnum\xskak@temp@levelnumber=1\relax
\xskak@use@varstyle{1}%
\else
\xskak@use@varstyle{%
\xskak@temp@levelprefix
\the\numexpr\xskak@temp@levelnumber-1\relax
\xskak@temp@levelpostfix}%
\fi
\else
\PackageError{xskak}{Unknown level #1}{}%
\fi
\else
\ifnum#1=1\relax
\xskak@use@varstyle{1}%
\else
\xskak@use@varstyle{%
\the\numexpr#1-1\relax}%
\fi
\fi
\fi
}
%% default styles A,B,C,@empty
\xskaknewstyleitem[%
whiteopen=\space,
blackopen=\ldots,
afterwhite=\space,
afterblack=\space]{styleB}
\xskaknewstyleitem[%
whiteopen=.,
blackopen=. -,
beforewhite=\space,
beforeblack={,\space}]{styleA}
\xskaknewstyleitem[%
opencommands={\begin{tabbing}%
\hspace{.2\linewidth}\=\hspace{.2\linewidth}\=%
\hspace{.2\linewidth}\= \kill},
closecommands={\end{tabbing}},
blackopen=\>\ldots,
beforenumber=\>,
beforewhite=\>,
beforeblack=\>,
afterblack=\\]{styleC}
\xskaknewstyleitem[%
whiteopen={.\,},
blackopen={\ldots\,},
afterwhite={\ },
afterblack={\ }]{UF}
\xskaknewstyleitem[%
opencommands =\begingroup\normalcolor\ttfamily\textbackslash opencommands\endgroup\ ,
closecommands=\begingroup\normalcolor\ttfamily\textbackslash closecommands\endgroup\ ,
whiteopen =\begingroup\normalcolor\ttfamily\textbackslash whiteopen\endgroup\ ,
blackopen =\begingroup\normalcolor\ttfamily\textbackslash blackopen\endgroup\ ,
beforenumber =\begingroup\normalcolor\ttfamily\textbackslash beforenumber\endgroup\ ,
beforewhite =\begingroup\normalcolor\ttfamily\textbackslash beforewhite\endgroup\ ,
afterwhite =\begingroup\normalcolor\ttfamily\textbackslash afterwhite\endgroup\ ,
beforeblack =\begingroup\normalcolor\ttfamily\textbackslash beforeblack\endgroup\ ,
afterblack =\begingroup\normalcolor\ttfamily\textbackslash afterblack\endgroup\ ,
beforecomment=\begingroup\normalcolor\ttfamily\textbackslash beforecomment\endgroup\ ,
beforeNAG=\color{green}\begingroup\normalcolor\ttfamily\textbackslash beforeNAG\endgroup\ ,
]{showcommands}
\xskaknewstyle[level= 1,styleitem=styleB,font=\bfseries,
level= 3,font=\itshape]{styleB}
\xskaknewstyle[level= 1,styleitem=styleA,font=\bfseries,
level= 3,font=\itshape]{styleA}
\xskaknewstyle[level= 1,styleitem=styleC,font=\bfseries,
level= 2,styleitem=styleB,
level= 3,font=\itshape]{styleC}
\xskaknewstyle[level= 1,styleitem=@empty,font=\bfseries]{@empty}
\xskaknewstyle[level= 1,styleitem=UF,font=\bfseries,
level= 3,font=\itshape]{UF}
\xskaknewstyle[level= 1,styleitem=showcommands,font=\begingroup\ttfamily\textbackslash mainlinestyle\endgroup\ ,
level= 2,font=\begingroup\ttfamily\textbackslash variationstyle\endgroup\ ]{test}
%% default level and style
\xskakset{style=styleB,level=1}
%%%%%%%%%%%%%%%%%%%%%
\gdef\xskak@do@printmove{\xskakget{san}}
\newcommand\printchessgame[1][]{%
\setkeys*[UFXS]{print}{#1}%set style and level
\leavevmode%UF 2012-09-10 to allow wrapping around wrapfigure
\begingroup
\setkeys*[UFXS]{xprint}{#1}%% getting the id
\xdef\xskak@val@movenr{%
\csname Xskak\xskak@val@gameid initmovenr\endcsname}%
\xdef\xskak@val@player{%
\csname Xskak\xskak@val@gameid initplayer\endcsname}%
\xdef\xskak@val@stopmovenr{%
\csname Xskak\xskak@val@gameid lastmovenr\endcsname}%
\xdef\xskak@val@stopplayer{%
\csname Xskak\xskak@val@gameid lastplayer\endcsname}%
\setkeys*[UFXS]{xprint}{#1}%% using the rest of the keys
\ifthenelse%
{\xskak@test@moveidingame{\xskak@val@movenr}{\xskak@val@player}{\xskak@val@gameid}}%
{}%
{\PackageWarning{xskak}{init move
\xskak@val@movenr\xskak@val@player\space
is not in the game.%
\MessageBreak The first move is used instead.}{}%
\xdef\xskak@val@movenr{%
\csname Xskak\xskak@val@gameid initmovenr\endcsname}%
\xdef\xskak@val@player{%
\csname Xskak\xskak@val@gameid initplayer\endcsname}}%
%%
\ifthenelse%
{\xskak@test@moveidingame{\xskak@val@stopmovenr}{\xskak@val@stopplayer}{\xskak@val@gameid}}%
{}%
{\PackageWarning{xskak}{stop move
\xskak@val@stopmovenr\xskak@val@stopplayer\space
is not in the game.\MessageBreak The last move is used instead.}{}%
\xdef\xskak@val@stopmovenr{%
\csname Xskak\xskak@val@gameid lastmovenr\endcsname}%
\xdef\xskak@val@stopplayer{%
\csname Xskak\xskak@val@gameid lastplayer\endcsname}}%
%%
\ifthenelse%
{\xskak@test@lessorequal
{\xskak@val@movenr}{\xskak@val@player}%
{\xskak@val@stopmovenr}{\xskak@val@stopplayer}}%
%at least one move to print:
{\mainlinestyle
\opencommands
%% handle the first move
\ifthenelse{\equal{\xskak@val@player}{w}}%
%first move is a white move. Will be handled in the loop
{\beforenumber
\xskak@val@movenr
\whiteopen
\beforewhite
\xskak@do@printmove%
\xdef\xskak@val@player{b}}%
%first move is a black one:
{\beforenumber
\xskak@val@movenr
\blackopen
\beforeblack
\xskak@do@printmove
% \afterblack
\xdef\xskak@val@movenr{\the\numexpr\xskak@val@movenr +1\relax}%
\xdef\xskak@val@player{w}}%
%% loop through the res
\whiledo
{\xskak@test@lessorequal
{\xskak@val@movenr}{\xskak@val@player}%
{\xskak@val@stopmovenr}{\xskak@val@stopplayer}}%
{\ifthenelse
{\equal{\xskak@val@player}{w}}%
{\afterblack
\beforenumber
\xskak@val@movenr
\whiteopen
\beforewhite
\xskak@do@printmove
}
{\afterwhite
\beforeblack
\xskak@do@printmove
%\afterblack
}%
\xskak@do@getnextmoveid{\xskak@val@movenr}{\xskak@val@player}%
\global\let\xskak@val@movenr\xskak@temp@movenr
\global\let\xskak@val@player\xskak@temp@player}%
\closecommands
}%
{}% no move
\endgroup
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Corrections/changes of skak commands %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% changed \mainline and \variation for style/level handling
%%% (added optional argument)
\renewcommand\mainline[1][]{%
\setkeys[UFXS]{print}{#1}%
\begingroup\catcode`\#=12 \@mainline}
\DeclareRobustCommand{\variation}[1][]{%
\setkeys[UFXS]{print}{#1}%
\begingroup\catcode`\#=12 \@variation}
\newcommand\variationmovemode{\shortmoves}
\def\@variation#1{\endgroup\gdef\NumberNext{\True}%
\gdef\AfterBlack{\False}%
\gdef\PrintMoves{\True}%
\gdef\ExecuteMoves{\False}%
\gdef\StoreLastMove{\False}%
{\variationstyle\opencommands%
\variationmovemode
\xskak@do@parsemainline(#1 Z )%
\closecommands}}
%%% Read/store commands
%% changed to avoid the use of to much write/read registers
%% ?? What did I mean? changed \FenBoard to \fenboard in \loadgame/restoregame
%% ?? What did I mean? to avoid problems with the redefinition in texmate
\def\savegame#1{% writes the board as fen to #1.fen
\immediate\openout0=#1.fen%
\Fen@calculate%
\immediate\write0{\temp@board}%
\immediate\closeout0}
\def\loadgame#1{%
\def\load@read{}%
\openin0=#1.fen\relax%
\read0 to \load@read%
\closein0%
\expandafter\fenboard\expandafter{\load@read}}
%%% ParseCastlingA changed so that comments are no longer lost:
%%% -> bug report 2008-10-10
\def\@setmoverestcastling(#1ZVW){\gdef\MoveRest{#1}}
\def\ParseCastlingA(#1#2#3){%
\MyEqualB{#1#2}{-O}%
{\gdef\LongCastling{\True}%
\ParseCastlingAA(#3)}%
{\ParseCastlingAA(#1#2#3)}}
\newcommand\ParseCastlingAA{}
\def\ParseCastlingAA(#1#2#3){%
\EqStr{Z}{#1}%
{}% we are done!
{\EqStr{#1}{+}% chess ?
{\protected@xdef\CheckTest{\checksymbol}%
\ParseCastlingAA(#2#3)}%
{\EqStr{#1}{##}% mate?
{\protected@xdef\MateTest{\mate}%
\ParseCastlingAA(#2#3)}%
{\@setmoverestcastling(#1#2#3)}}}}
%%%% ExecutePawnMove changed:
%%%% moved \xdef of EnPassantSquare before DoTheMove
%%%% I hope it doesn't break something
\def\ExecutePawnMove{% relies on the info obtained by ParseMove
\setcounter{halfmove}{0}%
\Capture%
{\EqPiece{E}{\Get{\MoveTo}}%
{\Set{\MoveToFile\FromRank}{E}}%
{}%
\xdef\EnPassantSquare{-}% U.F. moved before \DoTheMove
\DoTheMove{\FileDiscriminator\FromRank}%
}%
{\EqPiece{E}{\Get{\MoveToFile\FromRank}}%
{\xdef\EnPassantSquare{\MoveToFile\FromRank}% two square move
\DoTheMove{\MoveToFile\InitialRank}}%
{\xdef\EnPassantSquare{-}%
\DoTheMove{\MoveToFile\FromRank}% one square move
}}%
\Promotion%
{\Set{\MoveTo}{\PieceNameToPiece{\PromotionPieceName}{\WhiteToMove}}}%
{}}
%%% the internal longmove command changed to get correct pawn moves:
\def\xskak@do@printmove@algebraic{%
\csname Xskak.\xskak@val@gameid.%
\WhiteToMove{\the\numexpr\the\c@move-1\relax}{\the\c@move}.%
\WhiteToMove{b}{w}.lan\endcsname
\csname Xskak.\xskak@val@gameid.%
\WhiteToMove{\the\numexpr\the\c@move-1\relax}{\the\c@move}.%
\WhiteToMove{b}{w}.comments\endcsname{}}
\let\skaklongmoves\longmoves %added 16.10.2008
\def\longmoves{%
\let\printmove=\xskak@do@printmove@algebraic
\gdef\xskak@do@printmove{\xskakget{lan}}}
\def\shortmoves{%
\let\printmove=\printmove@san
\gdef\xskak@do@printmove{\xskakget{san}}}
\endinput
%%
%% End of file `xskak.sty'.
|