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
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
|
% \section{The \texttt{game} package}
% \label{sec:package}
%
% To make our game components re-usable (in particular when we want to
% make a VASSAL module), we will put our definitions of counters,
% board, and charts into a package file called
% \texttt{game.sty}\footnote{In fact, most of this document is in that
% file, because it allows us to document the code using \LaTeX{}'s
% \texttt{ltxdoc} class.}
%
% Code shown below is in the package.
%
% The first thing we do in the package is to identify the package and
% load the \textsf{wargame} package.
%
% \begin{macrocode}
\ProvidesPackage{game}
\RequirePackage{wargame}
\RequirePackage{colortbl}
% \end{macrocode}
% \section{The units}
% \label{sec:units}
%
% We will set-up our units for the game. As noted above, we will make
% two factions which we will call \emph{A} and \emph{B}.
%
% \begin{quote}
% The NATO
% App6(d)\footnote{\url{https://nso.nato.int/nso/nsdd/main/standards/ap-details/1912/EN}}
% symbology defines that friendly and hostile units should have
% different symbol frames, but as we will make a game for two
% players, and it seems unfair to label one as \emph{hostile} and
% the other \emph{friendly}, we will stick with the
% \texttt{friendly} base frames.
%
% Of course, if we were to make a solitaire or cooperative game, we
% might want to use the \texttt{hostile} base frame for the opponent
% units.
% \end{quote}
%
% \subsection{Faction styles}
% \label{sec:package:factions}
%
% We will start by defining two \Tikz{}\footnote{The \textsf{wargame}
% package relies heavily on \Tikz{}. It is highly recommended that you
% acquaint yourself with \Tikz{}. The manual, including tutorials, is
% available from \url{https://ctan.org/pkg/pgf}.} styles for our two
% factions. We will call these \texttt{a} and \texttt{b} (obviously).
% These will define the colours of all counters of those sides.
%
% \begin{macrocode}
\colorlet{a-bg}{hostile}
\colorlet{b-bg}{friendly}
\tikzset{%
a/.style={fill=a-bg,draw=black},
b/.style={fill=b-bg,draw=black}}
% \end{macrocode}
% Note that we made the colours \texttt{a-bg} and \texttt{b-bg}.
% Since we will use these colours a few times, it makes sense to make
% a single definition which we can then freely change at any point and
% then automatically have that change propagate everywhere.
%
% These styles are shown in \figurename~\ref{fig:faction-colors}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \draw[a] (0,0) rectangle ++(1,1) node[above]{\texttt{a}};%
% \draw[b] (3,0) rectangle ++(1,1) node[above]{\texttt{b}};%
% \end{tikzpicture}
% \caption{Faction colours}
% \label{fig:faction-colors}
% \end{figure}
%
% Here we have used the colours \texttt{friendly} and \texttt{hostile}
% defined by the \textsf{wargame} package, even though we said we
% would not use the corresponding \texttt{hostile} base frame.
% However, we can use any colours we can define in \LaTeX{} with the
% \textsf{xcolor}\footnote{\url{https://ctan.org/pkg/xcolor}} package,
% for example,
%
% \begin{verbatim}
% \definecolor{a-bg}{HTML}{3333ff}
% \end{verbatim}
%
% which will make a light blue colour.
%
% Since we intent to make \emph{double-sided} counters, so that units
% will have two steps (front and back), we also define styles for the
% back side. These will have lighter backgrounds than the front
% side.
%
% \begin{macrocode}
\tikzset{%
a flipped/.style={a,fill=pgffillcolor!50!white},
b flipped/.style={b,fill=pgffillcolor!50!white}}
% \end{macrocode}
% Note that we use the styles \texttt{a} and \texttt{b} as bases for
% these styles. Thus, if we make changes to the base styles, they
% automatically propagate to our flipped styles.
%
% \begin{quote}
% By convention, it is best to name your back-sides of counters and
% so on the same as the front side, but with `\texttt{ flipped}'
% appended. It is therefore also a good idea to use that convention
% for styles and such.
% \end{quote}
%
% The colour \texttt{pgffillcolor} is what ever the current fill
% colour is (i.e., set by the \texttt{a} and \texttt{b} styles).
%
% These styles are shown in
% \figurename~\ref{fig:faction-colors-flipped}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \draw[a flipped] (0,0) rectangle ++(1,1) node[above]{\texttt{a flippped}};%
% \draw[b flipped] (3,0) rectangle ++(1,1) node[above]{\texttt{b flipped}};%
% \end{tikzpicture}
% \caption{Faction flipped colours}
% \label{fig:faction-colors-flipped}
% \end{figure}
%
% \subsection{Unit templates}
% \label{sec:units:templates}
%
% In our game we will have two kinds of units: land, and air.
%
% Land units represent ground types of different kinds (infantry,
% armoured, etc.) and have two \emph{factors}: A combat factor (CF)
% and a movement factor (MF). In addition, for artillery units, we
% will also specify a range. Each unit will also have a unique
% identifier, and possibly parent organisational identifier, starting
% hex, and turn of appearance.
%
% Air units provide different kinds of support for the ground units.
% Since we will make a game on an \emph{operational} level (armies,
% divisions, brigades), we will give air units a single factor --- the
% odds column shift (see the combat resolution table later on).
%
% Let us first define a template for the ground units. We will call
% this \texttt{gu} (for ground unit), and it will take 8\footnote{Yes,
% that's a lot, but we may leave some of them blank. Don't worry,
% we'll make more short-hands.} arguments:
% \begin{enumerate}\tightlist
% \item The unit type
% \item The lower unit type (e.g., airborne)
% \item The unit size (echelon)
% \item The unit identifier
% \item The parent unit identifier
% \item The factors (more on this later)
% \item The starting hex
% \item The turn of appearance
% \end{enumerate}
%
% \begin{macrocode}
\tikzset{
gu/.style args={#1,#2,#3,#4,#5,#6,#7,#8}{%
chit={%
symbol={% Defines the NATO symbol
faction=friendly, % See note
command=land, % Ground units
main={#1},% Unit type(s) (e.g., infantry)
lower=#2,% Lower type
echelon=#3,% Size (e.g., division)
scale line widths,
line width=1pt,
},
unique={chit/small identifier=#4}, % Unit ID
parent={chit/small identifier=#5}, % Parent ID
factors={#6}, % The unit factors
upper left={chit/small identifier=#7}, % Hex
upper right={gu turn=#8} % Turn
} % end of chit
} % end of gu
}
% \end{macrocode}
%
% Note the \texttt{unique}, \texttt{parent}, and \texttt{upper left}
% keys of \texttt{chit} are set to contain a \texttt{chit/identifier}
% (or \texttt{chit/small identifier}) picture. In general, all the
% keys of a \texttt{chit} and (and \texttt{natoapp6c}) \Tikz{} node
% need to be \texttt{pic}\footnote{A small re-usable picture. See the
% \Tikz{} manual, Chapter~18.} objects. The \texttt{chit/identifier}
% picture outputs the text (the argument after the \texttt{=}).
%
% Note that for \texttt{upper left}, we used the \texttt{pic}
% \texttt{gu~turn}, which we have not defined yet. Let us define that
% now. This will be a picture that puts in the turn number when a
% unit appears. Turn number ``0'' is the ``At-start'' turn, and so we
% will deal with that specifically. Other turns should just be done
% normally --- that is, we use another \texttt{chit/small identifier} picture
%
% \begin{macrocode}
\tikzset{
gu turn/.pic={%
\ifx#1\empty\else
\ifnum0=#1\else%
\pic{chit/small identifier={#1}};\fi\fi},
pics/gu turn/.default=0
}
% \end{macrocode}
% Note that we set the default value in case we get no turn number.
%
% We have put the keys \texttt{scale~line~widths} and
% \texttt{line~width=1pt} into the \texttt{symbol} (the NATO symbol)
% part. The latter sets the line width to be a little thicker than
% usual. This is to make the counters more easily read. The former
% ensures that if we scale our counters up or done, then the line
% width will likewise scale\footnote{Other elements scale
% automatically because of \Tikz{}'s \texttt{transform shape} key}.
%
% For the factors, we will use two different \texttt{pic}:
% \texttt{chit/2 factors} for regular ground units, and \texttt{chit/2
% factors artillery} for artillery units.
%
% The template is shown in \figurename~\ref{fig:ground-unit}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \chit[gu={infantry,,division,23,2,
% {chit/2 factors={2,4}},D3,2}];%
% \end{tikzpicture}
% \caption{Ground unit template}
% \label{fig:ground-unit}
% \end{figure}
%
% The image above was made with
%
% \begin{verbatim}
% \begin{tikzpicture}
% \chit[gu={infantry,,division,23,2,
% {chit/2 factors={2,4}},D3,2}];
% \end{tikzpicture}
% \end{verbatim}
%
% As said above, we will have artillery ground units and other kinds
% of ground units. Let us make two templates --- one for
% field-artillery ground units (\texttt{fu}), which has a range, and
% regular combat units (\texttt{cu}).
%
% First the artillery unit type: \texttt{fu}. This takes 8 arguments
%
% \begin{enumerate}\tightlist
% \item The echelon
% \item The identifier
% \item The parent identifier
% \item The combat factor (CF)
% \item The movement factor (MF)
% \item The range
% \item The starting hex
% \item The turn of appearance
%
% \end{enumerate}
% \begin{macrocode}
\tikzset{
fu/.style args={#1,#2,#3,#4,#5,#6,#7,#8}{
gu={%
{{[fill=pgfstrokecolor]artillery}}, % Type
,%lower
#1, % echelon
#2, % ID
#3, % Parent ID
{chit/2 factors artillery={#4,#5,#6}},
#7, % Hex
#8 % Turn
}
}
}
% \end{macrocode}
%
% Note that we pass the options \texttt{[fill=pgfstrokecolor]} to the
% \texttt{pic} \texttt{artillery}\footnote{To be explicit
% \texttt{natoapp6c/s/artillery}.} to fill in the artillery symbol.
% Note that we need to protect this by putting in curly brackets (2 in
% this case). Similarly, we protect the
% \texttt{chit/2~factors~artillery} call.
%
% \begin{quote}
% In general, we may pass options (or keys) to a \texttt{pic} by
% preceeding its name with \oarg{keys}. However, we then
% \emph{must} protect the it as in
% \texttt{\{\oarg{keys}\meta{pic}\}}. Further, if \oarg{keys}
% contains a list of keys, separated by commas, then we need to
% protect \meta{keys} too, as in
% \texttt{\{[\{\oarg{keys}\}]\meta{pic}\}}. A little clunky, but
% that's how \TeX{} works sometimes.
% \end{quote}
%
% And now the combat unit template: \texttt{cu}. This takes 9
% arguments.
%
% \begin{enumerate}\tightlist
% \item The type
% \item The lower type
% \item The echelon
% \item The identifier
% \item The parent identifier
% \item The combat factor (CF)
% \item The movement factor (MF)
% \item The starting hex
% \item The turn of appearance
% \end{enumerate}
% \begin{macrocode}
\tikzset{
cu/.style args={#1,#2,#3,#4,#5,#6,#7,#8,#9}{
gu={%
{#1}, % Type
#2, % lower
#3, % echelon
#4, % ID
#5, % Parent
{chit/2 factors={#6,#7}},
#8, % Hex
#9 % Turn
}
}
}
% \end{macrocode}
%
% Again, let us see what that looks like (\figurename~\ref{fig:fu-cu}).
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \chit[cu={infantry,airborne,regiment,
% 21,2,6,4,E2,}](0,0);%
% \chit[fu={battalion,23,21,1,3,4,E2,}](2,0);%
% \end{tikzpicture}
% \caption{Combat and field artillery templates}
% \label{fig:fu-cu}
% \end{figure}
%
% The above was made with
%
% \begin{verbatim}
% \begin{tikzpicture}
% \chit[fu={battalion,23,21,1,3,4,E2,}](0,0);
% \chit[cu={infantry,airborne,regiment,21,2,6,4,E2,}]
% (2,0);
% \end{tikzpicture}
% \end{verbatim}
%
% Finally, we make a template for air units. We will have
% Close-combat Air Support (CAS \texttt{cas}) and strategic bombers
% (\texttt{sb}). To make things a little easier for us, we first
% define a template for all air units. This takes 7 arguments:
% \begin{enumerate}\tightlist
% \item The unit type (e.g., \texttt{fixed wing}, \texttt{rotary
% wing}).
% \item The upper modifier (e.g., \texttt{F} for fighter)
% \item The lower modifier (e.g., \texttt{H} for `heavy')
% \item The unit identifier
% \item The parent unit identifier
% \item The factor (column shift)
% \item The turn of appearance
% \end{enumerate}
% \begin{macrocode}
\tikzset{
au/.style args={#1,#2,#3,#4,#5,#6,#7}{%
chit={%
symbol={% Defines the NATO symbol
faction=friendly, % See note
command=air, % Air units
main=#1,% Unit type
upper={text=#2},
lower={text=#3},
scale line widths,
line width=1pt,
},
unique={chit/identifier=#4}, % Unit ID
parent={chit/identifier=#5}, % Parent ID
factors={#6}, % The unit factors
upper right={gu turn=#7} % Turn
} % end of chit
} % end of gu
}
% \end{macrocode}
% Here, \texttt{text}\footnote{really \texttt{/natoapp6c/s/text}.} for
% \texttt{lower} and \texttt{upper} is a picture that puts the text
% given as the argument after the \texttt{=}. The template is shown in
% \figurename~\ref{fig:au}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \chit[au={fixed wing,B,,A,1,%
% {chit/1 factor=+2},3}](0,0);%
% \end{tikzpicture}
% \caption{Air unit template}
% \label{fig:au}
% \end{figure}
% %
% The above was made with
%
% \begin{verbatim}
% \begin{tikzpicture}
% \chit[au={fixed wing,B,,A,1,
% {chit/1 factor=+2},3}](0,0);
% \end{tikzpicture}
% \end{verbatim}
%
% As we said, we will have CAS and strategic bomber wings in this
% game, so we make templates for these. Our CAS will be helicopters
% (\texttt{rotery wing}) while the strategic bombers are planes. CAS
% gives a 1 CF, while strategic bombers gives 1 column shift.
% Arguments are
%
% \begin{enumerate}\tightlist
% \item The identifier
% \item The parent identifier
% \item The turn of appearance
% \end{enumerate}
% \begin{macrocode}
\tikzset{
cas/.style args={#1,#2,#3}{ % Close air support
au={% Air unit
rotary wing, % Helicopter
,, % No lower, upper
#1, % ID
#2, % Parent ID
{chit/2 factors={1,0}},
#3 %Turn
}
},
sb/.style args={#1,#2,#3}{% strategic bomber
au={% Air unit
fixed wing, %Planes
B, % Bomber
M, % Medium
#1, % ID
#2, % Parent
{chit/1 factor={+1}},
#3 % Turn
}
}
}
% \end{macrocode}
%
% The templates are shown in \figurename~\ref{fig:cas-sb}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \chit[cas={1,2,10}](0,0);%
% \chit[sb={3,4,}](2,0);%
% \end{tikzpicture}
% \caption{CAS and SB templates}
% \label{fig:cas-sb}
% \end{figure}
%
% The above was made with
%
% \begin{verbatim}
% \begin{tikzpicture}
% \chit[cas={1,2,10}(0,0);
% \chit[sb={3,4,}(2,0);
% \end{tikzpicture}
% \end{verbatim}
%
% \subsection{Specialisations}
% \label{sec:units:specialisations}
%
% We will now make some specialisations of the \texttt{gu} style.
% These represent headquarters \texttt{hq}, mechanised infantry
% \texttt{mi}, infantry \texttt{in}, and so
% on. We do this because we want units of the same kind to have
% similar factors and so on. Since almost all of our units are
% battalions, we also code that in.
%
%
% All of these, except \texttt{ff} for field artillery units, take 4
% arguments
% \begin{enumerate}\tightlist
% \item The identifier
% \item The parent identifier
% \item The starting hex
% \item The turn of appearance
% \end{enumerate}
%
% The style \texttt{ff} precedes these arguments with a single
% argument for the unit size (echelon).
%
% \begin{macrocode}
\tikzset{
in/.style args={#1,#2,#3,#4}{%
cu={infantry,,battalion,#1,#2,2,3,#3,#4}},
mi/.style args={#1,#2,#3,#4}{%
cu={{armoured,infantry},,battalion,#1,#2,4,4,#3,#4}},
ab/.style args={#1,#2,#3,#4}{%
cu={infantry,airborne,battalion,#1,#2,1,3,#3,#4}},
ca/.style args={#1,#2,#3,#4}{%
cu={combined arms,,battalion,#1,#2,3,3,#3,#4}},
ar/.style args={#1,#2,#3,#4}{%
cu={armoured,,battalion,#1,#2,6,4,#3,#4}},
re/.style args={#1,#2,#3,#4}{%
cu={reconnaissance,,battalion,#1,#2,6,5,#3,#4}},
ff/.style args={#1,#2,#3,#4,#5}{%
fu={#1,#2,#3,2,5,3,#4,#5}},
hq/.style args={#1,#2,#3,#4,#5}{
cu={headquarters,,#1,#2,#3,0,1,#4,#5}},%
hqbg/.style args={#1,#2,#3,#4}{
hq={brigade,#1,#2,#3,#4}},
hqregt/.style args={#1,#2,#3,#4}{
hq={regiment,#1,#2,#3,#4}},
}
% \end{macrocode}
% \subsection{The actual units}
% \label{sec:units:actual}
%
% Above we defined templates for the various units. These templates
% saves us a lot of trouble when defining the \emph{actual} units.
% Below we will make the units for each faction in the game. We will
% define them as \Tikz{} styles, just like we did for the templates.
%
% \begin{quote}
% Above we said we want to make double sided counters. We will get
% back to the back-side (flipped) versions of the counters in a
% moment.
% \end{quote}
%
% \subsubsection{Side A}
%
% Below we will define the units without much commentary. Note that
% we use the style \texttt{a} for all our units so that they get the
% right style. Note that we pass the single argument \texttt{\#1} as
% the turn of appearance to all units. This will be used when
% generating an \emph{Order of Battle} later on.
%
% \begin{macrocode}
\tikzset{
a hq/.style ={a,hq={corps,,,A2,#1}},
a 1 hqbg/.style ={a,hqbg={1,,A2,#1}},
a 1 1lg ibn/.style={a,mi={I-LG,1,D3,#1}},
a 1 1gh ibn/.style={a,mi={I-GH,1,C2,#1}},
a 1 2jd ibn/.style={a,mi={II-JD,1,A2,#1}},
a 1 1 abn/.style ={a,ff={battalion,1,1,A1,#1}},
a 2 hqbg/.style ={a,hqbg={2,,C2,#1}},%
a 2 1jd abn/.style={a,ar={I-JD,2,A2,#1}},%
a 2 3gh rbn/.style={a,re={I-JD,2,D2,#1}},%
a aregt/.style={a,ff={regiment,,,A1,#1}},%
a f/.style={a,cas={,,#1}},%VR
a b/.style={a,sb={,,#1}}%SK
}
% \end{macrocode}
% \iffalse
% KA: A2 Karup
% HO: A2 Holsterbro
% HV: D3 Høvelte
% SL: C2 Slagelse
% OK: A1 Oksbøl
% RO: D2 Rønne
% VR: D3 Værløse
% SK: B2 Skydstrup
% \fi
% Let us draw these units in what looks like an organisational
% diagram (\figurename~\ref{fig:a-org}).
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \node[a hq] (a hq) {};
% \node[a aregt, below right=10mm and 10mm of a hq] (a aregt) {};
% \node[a 1 hqbg, below left=10mm and 10mm of a hq] (a 1 hqbg) {};
% \node[a 1 1lg ibn,below right=5mm and -8mm of a 1 hqbg] (a 1 1lg ibn){};
% \node[a 1 1gh ibn,below=5mm of a 1 1lg ibn] (a 1 1gh ibn){};
% \node[a 1 2jd ibn,below=5mm of a 1 1gh ibn] (a 1 2jd ibn){};
% \node[a 1 1 abn, below=5mm of a 1 2jd ibn] (a 1 1 abn) {};
% \node[a 2 hqbg, below=10mm of a hq] (a 2 hqbg) {};
% \node[a 2 1jd abn,below right=5mm and -8mm of a 2 hqbg] (a 2 1jd abn){};
% \node[a 2 3gh rbn,below=5mm of a 2 1jd abn] (a 2 3gh rbn){};
% \node[a f, right=10mm of a aregt] (a f) {};
% \node[a b, below=5mm of a f] (a b) {};
% \draw(a 1 hqbg.south west) |- (a 1 1lg ibn.west);
% \draw(a 1 hqbg.south west) |- (a 1 1gh ibn.west);
% \draw(a 1 hqbg.south west) |- (a 1 2jd ibn.west);
% \draw(a 1 hqbg.south west) |- (a 1 1 abn.west);
% \draw(a 2 hqbg.south west) |- (a 2 1jd abn.west);
% \draw(a 2 hqbg.south west) |- (a 2 3gh rbn.west);
% \coordinate (mid) at ($(a hq.south)+(0,-.5)$) {};
% \coordinate (off) at ($(mid)+(1.5,0)$) {};
% \draw(a hq.south) -- (mid);
% \draw(mid) -| (a 1 hqbg.north);
% \draw(mid) -- (a 2 hqbg.north);
% \draw(mid) -| (a aregt.north);
% \end{tikzpicture}
% \caption{Faction A organisational chart}
% \label{fig:a-org}
% \end{figure}
%
% Before we go on to side B, we will make a macro that contains a list
% of all our A side counters.
%
% \begin{macrocode}
\def\alla{{%
a hq,
a 1 hqbg,
a 1 1lg ibn,
a 1 1gh ibn,
a 1 2jd ibn,
a 1 1 abn,
a 2 hqbg,
a 2 1jd abn,
a 2 3gh rbn,
a aregt,
a f,
a b}}
% \end{macrocode}
%
% \subsubsection{Side B}
%
% Below we will define the units without much commentary. Note that
% we use the style \texttt{b} for all our units so that they get the
% right style. Note that we pass the single argument \texttt{\#1} as
% the turn of appearance to all units. This will be used when
% generating an \emph{Order of Battle} later on.
%`
% \begin{macrocode}
\tikzset{
b hq/.style= {b,hq= {corps,,,F6,#1}},
b lg hqregt/.style= {b,hqregt={LG,,F6,#1}},
b lg ibn/.style= {b,in= {LG,,F6,#1}},
b k3 hqregt/.style= {b,hqregt={K3,,E7,#1}},
b k3 31 abibn/.style= {b,ab= {31,K3,E7,#1}},
b k4 hqregt/.style= {b,hqregt={K4,,F10,#1}},
b k4 abibn/.style= {b,ab= {NL,K4,F10,#1}},
b p4 hqregt/.style= {b,hqregt={P4,,D7,#1}},
b p4 41 cabn/.style= {b,ca= {41,P4,D7,#1}},
b p4 42 cabn/.style= {b,ca= {42,P4,D7,#1}},
b p7 hqregt/.style= {b,hqregt={P7,,D4,#1}},
b p7 71 ibn/.style= {b,mi= {71,P7,D4,#1}},
b p7 72 cabn/.style= {b,ca= {72,P7,D4,#1}},
b i13 hqregt/.style= {b,hqregt={I13,,D8,#1}},
b i13 131 ibn/.style= {b,in= {131,I13,D8,#1}},
b i13 132 ibn/.style= {b,in= {132,I13,D8,#1}},
b p18 hqregt/.style= {b,hqregt={P18,,F5,#1}},
b p18 181 cabn/.style={b,ca= {181,P18,F5,#1}},
b i19 hqregt/.style= {b,hqregt={I19,,F10,#1}},
b i19 191 cabn/.style={b,ca= {191,I19,F10,#1}},
b i19 192 cabn/.style={b,ca= {192,I19,F10,#1}},
b i21 hqregt/.style= {b,hqregt={I21,,D10,#1}},
b i21 211 ibn/.style= {b,in= {211,I21,D10,#1}},
b i21 212 ibn/.style= {b,in= {212,I21,D10,#1}},
b f/.style= {b,cas= {F17,BL,#1}},
b b/.style= {b,sb= {F7,SA,#1}}
}
% \end{macrocode}
% \iffalse
% SH: F6 Stockholm
% KU: F6 Kungsängen near stockholm F6
% KA: E7 Karlsborg
% AR: Off Arvisjaur (top of baltic)
% SK: D7 Skövde
% RE: D3 Revingehed
% FA: D8 Falun
% VI: F5 Visby (delay from island)
% BO: Off Boden (top of baltic)
% SO: Off (D10) Sollefteå
% \fi
% Let us draw these units in what looks like an organisational
% diagram (\figurename~\ref{fig:b-org}).
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \node[b hq] (b hq) {};
% \node[b lg hqregt, below left=10mm and 20mm of b hq] (b lg hqregt){};
% \node[b lg ibn, below right=5mm and -8mm of b lg hqregt] (b lg ibn){};
% \node[b k3 hqregt, below left=10mm and -1mm of b hq] (b k3 hqregt){};
% \node[b k3 31 abibn, below right=5mm and -8mm of b k3 hqregt] (b k3 31 abibn){};
% \node[b k4 hqregt, below right=10mm and -1mm of b hq] (b k4 hqregt){};
% \node[b k4 abibn, below right=5mm and -8mm of b k4 hqregt] (b k4 abibn){};
% \node[b p4 hqregt, below right=10mm and 20mm of b hq] (b p4 hqregt){};
% \node[b p4 41 cabn, below right=5mm and -8mm of b p4 hqregt] (b p4 41 cabn){};
% \node[b p4 42 cabn, below=5mm of b p4 41 cabn] (b p4 42 cabn){};
% \node[b p7 hqregt, below left=65mm and 20mm of b hq] (b p7 hqregt){};
% \node[b p7 71 ibn, below right=5mm and -8mm of b p7 hqregt] (b p7 71 ibn){};
% \node[b p7 72 cabn, below=5mm of b p7 71 ibn] (b p7 72 cabn){};
% \node[b i13 hqregt, below left=65mm and -1mm of b hq] (b i13 hqregt){};
% \node[b i13 131 ibn, below right=5mm and -8mm of b i13 hqregt](b i13 131 ibn){};
% \node[b i13 132 ibn, below=5mm of b i13 131 ibn] (b i13 132 ibn){};
% \node[b p18 hqregt, below right=65mm and -1mm of b hq] (b p18 hqregt){};
% \node[b p18 181 cabn,below right=5mm and -8mm of b p18 hqregt](b p18 181 cabn){};
% \node[b i19 hqregt, below right=65mm and -1mm of b hq] (b i19 hqregt){};
% \node[b i19 191 cabn,below right=5mm and -8mm of b i19 hqregt](b i19 191 cabn){};
% \node[b i19 192 cabn,below=5mm of b i19 191 cabn] (b i19 192 cabn){};
% \node[b i21 hqregt, below right=65mm and 20mm of b hq] (b i21 hqregt){};
% \node[b i21 211 ibn, below right=5mm and -8mm of b i21 hqregt] (b i21 211 ibn){};
% \node[b i21 212 ibn, below=5mm of b i21 211 ibn] (b i21 212 ibn){};
% \node[b f, right=15mm of b hq] (b f){};
% \node[b b, right=5mm of b f] (b b){};
%
% \draw(b lg hqregt.south west) |- (b lg ibn.west);
% \draw(b k3 hqregt.south west) |- (b k3 31 abibn.west);
% \draw(b k4 hqregt.south west) |- (b k4 abibn.west);
% \draw(b p4 hqregt.south west) |- (b p4 41 cabn.west);
% \draw(b p4 hqregt.south west) |- (b p4 42 cabn.west);
% \draw(b p7 hqregt.south west) |- (b p7 71 ibn.west);
% \draw(b p7 hqregt.south west) |- (b p7 72 cabn.west);
% \draw(b p18 hqregt.south west) |- (b p18 181 cabn.west);
% \draw(b i19 hqregt.south west) |- (b i19 191 cabn.west);
% \draw(b i19 hqregt.south west) |- (b i19 192 cabn.west);
% \draw(b i13 hqregt.south west) |- (b i13 131 ibn.west);
% \draw(b i13 hqregt.south west) |- (b i13 132 ibn.west);
% \draw(b i21 hqregt.south west) |- (b i21 211 ibn.west);
% \draw(b i21 hqregt.south west) |- (b i21 212 ibn.west);
%
% \coordinate (mid) at ($(b hq.south)+(0,.-.5)$);
%
% \draw(b hq.south) -- (mid);
% \draw(mid) -| (b lg hqregt.north);
% \draw(mid) -| (b k3 hqregt.north);
% \draw(mid) -| (b k4 hqregt.north);
% \draw(mid) -| (b p4 hqregt.north);
%
% \coordinate (mid2) at ($(b hq.south)+(0,.-6)$);
% \draw(mid) -- (mid2);
% \draw(mid2) -| (b p7 hqregt.north);
% \draw(mid2) -| (b i13 hqregt.north);
% \draw(mid2) -| (b i19 hqregt.north);
% \draw(mid2) -| (b i21 hqregt.north);
%
% \end{tikzpicture}
% \caption{Faction B organisational chart}
% \label{fig:b-org}
% \end{figure}
%
% As before, we will make a macro that contains all B counters.
%
% \begin{macrocode}
\def\allb{{
b hq, b lg hqregt, b lg ibn,
b k3 hqregt, b k3 31 abibn,
b p4 hqregt, b p4 41 cabn, b p4 42 cabn,
b p7 hqregt, b p7 71 ibn, b p7 72 cabn,
b i13 hqregt, b i13 131 ibn,b i13 132 ibn,%
b f, b b%
},{},{},{% Empty turns
b p18 hqregt, b p18 181 cabn%
},{
b i21 hqregt, b i21 211 ibn, b i21 212 ibn%
},{},{
b k4 hqregt, b k4 abibn%
},{
b i19 hqregt, b i19 191 cabn, b i19 192 cabn%
}}
% \end{macrocode}
%
% Note that this is defined as a list of lists, and some of the lists
% are a little special. This is because we will reuse this list over
% and over again, and in particular for the Order of Battle charts.
% The point is that each element of the outer most list correspond to
% a turn, starting with turn ``0'', or ``At start''. Empty elements
% are thus turns where there will be no reinforcements for the faction.
%
% \subsection{The \texttt{flipped} side of things}
% \label{sec:units:flipped}
%
% Well, really the \texttt{flipped} definitions of the units. The
% flipped side of our unit counters will represent a ``spent'' state,
% i.e., a state where the unit cannot attack and only do limited
% manoeuvres. In this state, all units will have a combat factor or
% zero and movement factor of 1. Thus, we define a simple style that
% sets the factors
%
% \begin{macrocode}
\tikzset{
flipped/.style={%
/chit/factors={chit/2 factors={0,1}},
/chit/upper left={},
/chit/upper right={}
}
}
% \end{macrocode}
% Note that we give the \emph{explicit full} path to the chits factors
% key. This is because we want to \emph{monkey patch} our units to
% have these new factors. We also clear the upper left and right
% corners on the flip side.
%
% Now, we'll do a little hack. Previously, we defined the
% \texttt{a~flipped} and \texttt{b~flipped} styles, but if you look
% closely, we can see how we can automatically define the flipped fill
% colours. Thus we make another style that does this.
%
% \begin{macrocode}
\tikzset{%
f/.style={%
flipped,fill=pgffillcolor!50!white}}
% \end{macrocode}
%
% With this, we can define the \texttt{flipped} state of all A
% counters.
%
% \begin{macrocode}
\tikzset{%
a hq flipped/.style= {a hq ,f},
a 1 hqbg flipped/.style= {a 1 hqbg ,f},
a 1 1lg ibn flipped/.style= {a 1 1lg ibn,f},
a 1 1gh ibn flipped/.style= {a 1 1gh ibn,f},
a 1 2jd ibn flipped/.style= {a 1 2jd ibn,f},
a 1 1 abn flipped/.style= {a 1 1 abn ,f},
a 2 hqbg flipped/.style= {a 2 hqbg ,f},
a 2 1jd abn flipped/.style= {a 2 1jd abn,f},
a 2 3gh rbn flipped/.style= {a 2 3gh rbn,f},
a aregt flipped/.style= {a aregt ,f},
a f flipped/.style= {a,f},
a b flipped/.style= {a,f},
}
% \end{macrocode}
%
% Let us draw the A side counters, front and back, using the macro
% \verb+doublechits+ (\figurename~\ref{fig:a-all}).
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \doublechits{\alla}{3}{1.24}
% \end{tikzpicture}
% \caption{All faction A counters, front and back}
% \label{fig:a-all}
% \end{figure}
%
% The above was produced by
%
% \begin{verbatim}
% \begin{tikzpicture}
% \doublechits{\alla}{3}{1.24}
% \end{tikzpicture}
% \end{verbatim}
%
% We will use the macro \verb+\doublechits+ later on to make our chit
% sheets. This works \emph{only} because we define the back sides of
% our chits to have the style `\meta{front} \texttt{flipped}', which
% is why it is \emph{highly} recommended to follow this convention.
%
% We do the same thing for the faction B counters.
%
%
% \begin{macrocode}
\tikzset{%
b hq flipped/.style= {b hq, f},
b lg hqregt flipped/.style= {b lg hqregt, f},
b lg ibn flipped/.style= {b lg ibn, f},
b k3 hqregt flipped/.style= {b k3 hqregt, f},
b k3 31 abibn flipped/.style= {b k3 31 abibn, f},
b k4 hqregt flipped/.style= {b k4 hqregt, f},
b k4 abibn flipped/.style= {b k4 abibn, f},
b p4 hqregt flipped/.style= {b p4 hqregt, f},
b p4 41 cabn flipped/.style= {b p4 41 cabn, f},
b p4 42 cabn flipped/.style= {b p4 42 cabn, f},
b p7 hqregt flipped/.style= {b p7 hqregt, f},
b p7 71 ibn flipped/.style= {b p7 71 ibn, f},
b p7 72 cabn flipped/.style= {b p7 72 cabn, f},
b i13 hqregt flipped/.style= {b i13 hqregt, f},
b i13 131 ibn flipped/.style= {b i13 131 ibn, f},
b i13 132 ibn flipped/.style= {b i13 132 ibn, f},
b p18 hqregt flipped/.style= {b p18 hqregt, f},
b p18 181 cabn flipped/.style={b p18 181 cabn,f},
b i19 hqregt flipped/.style= {b i19 hqregt, f},
b i19 191 cabn flipped/.style={b i19 191 cabn,f},
b i19 192 cabn flipped/.style={b i19 192 cabn,f},
b i21 hqregt flipped/.style= {b i21 hqregt, f},
b i21 211 ibn flipped/.style= {b i21 211 ibn, f},
b i21 212 ibn flipped/.style= {b i21 212 ibn, f},
b f flipped/.style= {b,f},
b b flipped/.style= {b,f}}
% \end{macrocode}
%
% Let us draw the faction B counters, front and back, using the macro
% \verb+doublechits+ (\figurename~\ref{fig:b-all}).
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \doublechits{\allb}{3}{1.24}
% \end{tikzpicture}
% \caption{All faction B counters, front and back}
% \label{fig:b-all}
% \end{figure}
%
% The above was produced by
%
% \begin{verbatim}
% \begin{tikzpicture}
% \doublechits{\allb}{3}{1.24}
% \end{tikzpicture}
% \end{verbatim}
%
% \subsection{Other counters}
% \label{sec:units:other}
%
% In principle one can make as many and different counters and markers
% as needed. Here, we will keep things simple and only define a game
% turn marker. The package \textsf{wargame} already defines one as
% shown in \figurename~\ref{fig:plain-game-turn}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \chit[game turn chit]
% \end{tikzpicture}
% \caption{The \textsf{wargame} game turn counter}
% \label{fig:plain-game-turn}
% \end{figure}
%
% However, this has no flip side and we would like the side to reflect
% the faction currently in turn
%
% \begin{macrocode}
\tikzset{
game turn chit/.append style={a},
game turn chit flipped/.append style={b}
}
% \end{macrocode}
%
% This modified game turn is shown in \figurename~\ref{fig:game-turn}.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \doublechits{{game turn chit}}{1}{1.24}
% \end{tikzpicture}
% \caption{Modified game turn, front and back}
% \label{fig:game-turn}
% \end{figure}
%
% \section{The board}
% \label{sec:board}
%
% Designing the board is probably where one will spend the most time.
% The \textsf{wargame} package is not omnipotent, but tries to make it
% as simple as possible. However, some artistic streak is a good
% thing, and familiarity with \Tikz{} is highly recommended.
%
% The simplest thing one can do is to import an image and superimpose
% hexes on top of that image. While often a good solution, it does
% not always give the most pleasing board.
%
% The \textsf{wargame} package does not, in and of it self, provide
% fancy ``modern'' graphics (though it can be done). Rather, off the
% shelf, it mimics classic wargames of yore (Afrika Korps, D-Day,
% Russian Campaign, and so on). That is, it uses rather simplified
% graphics.
%
% For our game, we will have three kinds of terrain: Clear, woods, and
% mountains. The map will have a lot of coastline, but the scale of
% the game is such that naval units are not really called for.
% Indeed, the game focuses on land combat with abstracted aerial
% support.
%
% The first thing we do, is to decide a few things about the map. We
% want to have the hexes automatically label with alphabetic columns
% and numerical rows. We want to start our rows and columns at 1 (the
% default is starting at 0). By default, we want the hexes to be white
% (for clear terrain). To set this up, we define some more
% keys.
%
% \begin{macrocode}
\tikzset{%
hex/short bottom columns=even,
hex/short top columns=odd,
hex/label is name,
hex/first row and column are=1,
every hex/.style={
/hex/label={auto=alpha column},
fill=white},
}%
% \end{macrocode}
%
% Note how we used the \emph{full} path for the \texttt{/hex/label}
% key. This will be important when we generate a VASSAL module later
% on.
%
% The key \texttt{hex/label is name} makes it so that every hex on the
% board will be a named \texttt{node}. This means we can refer to a
% hex in \Tikz{} simply by its label. In fact, we can use various
% anchors of the hex if we want to --- it is a \texttt{node} like any
% other node in \Tikz{}.
%
% The keys \texttt{hex/short bottom column=even} and
% \texttt{hex/short~top~column=odd} is mainly used by the
% \verb+\boardframe+ macro to generate a proper frame.
%
% Having defined the settings, we can move on to the board itself. We
% will do this in parts. This makes it easier to get an overview of,
% and helps us in this tutorial to explain what is going on.
%
% The first thing we do, is define a macro that defines the coast line
% of our map. We use the hexagonal coordinate system provided by the
% \textsf{wargame} package, but we could also have used general
% Cartesian coordinates.
%
% \begin{quote}
% Defining the coastline of a map can be quite tedious. You may
% want to use some vector graphics editor, say Inkscape, to do
% this. In the \textsf{wargame} package you will find a Python
% script to convert an SVG to \Tikz{} paths.
% \end{quote}
%
% Alright, let's make our macro to define the coastline.
%
% \begin{macrocode}
\newcommand\coastline{%
(hex cs:c=1,r=1,v=SE)
--(hex cs:c=1,r=1,e=SE)
--(hex cs:c=1,r=1,e=NE,o=.5)
--(hex cs:c=1,r=1,v=NW,o=.7)
--(hex cs:c=1,r=2,v=W,o=.6)
--(hex cs:c=1,r=2,v=NW,o=.7)
--(hex cs:c=1,r=3,v=SE,o=.9)
--(hex cs:c=1,r=3,e=SE,o=.9)
--(hex cs:c=2,r=4,e=S,o=.7)
--(hex cs:c=2,r=3,v=NE,o=.4)
--(hex cs:c=2,r=3,e=S,o=.1)
--(hex cs:c=2,r=3,v=E,o=.8)
--(hex cs:c=2,r=3,e=SE,o=.8)
--(hex cs:c=2,r=3,v=SE,o=.6)
--(hex cs:c=2,r=2,v=NW,o=.2)
--(hex cs:c=2,r=2,e=SE)
--(hex cs:c=3,r=1,e=NE)
--(hex cs:c=4,r=2,e=N,o=.3)
--(hex cs:c=5,r=2,e=S,o=.6)
--(hex cs:c=5,r=2,v=SE,o=.9)
--(hex cs:c=7,r=3,v=E)
--(hex cs:c=7,r=1,v=E)
--(hex cs:c=6,r=1,v=E,o=2.5)
--cycle
(hex cs:c=3,r=2,v=W,o=.5)
--(hex cs:c=4,r=3,e=NW,o=.75)
--(hex cs:c=4,r=3,e=SW,o=.3)
--(hex cs:c=4,r=2,e=NW,o=.7)
--(hex cs:c=3,r=2,v=SW,o=.4)
--cycle
(hex cs:c=2,r=4,e=N,o=.8)
--(hex cs:c=2,r=4,v=E,o=.7)
--(hex cs:c=3,r=3,v=E,o=.8)
--(hex cs:c=4,r=3,v=NW,o=.6)
--(hex cs:c=4,r=3,e=NW,o=.1)
--(hex cs:c=4,r=3,v=SE,o=.4)
--(hex cs:c=5,r=3,v=SW,o=.6)
--(hex cs:c=5,r=3,v=NE,o=.2)
--(hex cs:c=5,r=3,e=NE)
--(hex cs:c=6,r=4,v=SW,o=.3)
--(hex cs:c=5,r=4,v=E,o=1.7)
--(hex cs:c=6,r=5,e=N)
--(hex cs:c=6,r=6,v=E)
--(hex cs:c=7,r=6,v=NW,o=.4)
--(hex cs:c=6,r=7,e=S,o=.2)
--(hex cs:c=6,r=7,e=NW)
--(hex cs:c=6,r=8,e=NW,o=.7)
--(hex cs:c=7,r=9,e=NE)
--(hex cs:c=6,r=10,v=E,o=2.5)
--(hex cs:c=7,r=10,v=E)
--(hex cs:c=1,r=10,v=W)
--(hex cs:c=2,r=4,v=W,o=2.5)
--(hex cs:c=2,r=5,v=SW)
--cycle
;
}
% \end{macrocode}
%
% The coast line is shown in \figurename~\ref{fig:coast}\footnote{Any
% resemblance to any actual location is, erhm, accidental?}
%
% \begin{figure}
% \centering
% \begin{tikzpicture}[scale=.7]
% \draw[fill=gray] \coastline;
% \end{tikzpicture}
% \caption{The coast line}
% \label{fig:coast}
% \end{figure}
%
% As you can see, it is pretty simple. Not too many details about the
% nooks and crannies. Now we want to define some colours that we will
% use on the map. As mentioned above, we will have some sea, and we
% will have some surrounding neutral countries. Let us define some
% colours for these things.
%
% \begin{macrocode}
\definecolor{sea}{HTML}{18b5db}
\colorlet{neutral}{gray!25!white}
\colorlet{coast}{black}
% \end{macrocode}
%
% OK, with that out of the way, we start on the hexes in earnest. We
% define the macro \verb+\hexes+ to produce our hexes within our map.
%
% \begin{macrocode}
\newcommand\hexes[1][]{
% \end{macrocode}
%
% We have defined this macro to take a single optional argument. We
% wont use that here, but it might come in handy at some later point.
%
% The first thing we do, is to fill the entire map with \texttt{sea}.
%
% \begin{macrocode}
\fill[sea](-1.000,-0.866) rectangle(10.,15.580);
% \end{macrocode}
%
% Then we use the macro \verb+\coastline+ to define a path that we may
% use over and over again.
%
% \begin{macrocode}
\path[save path=\coast]\coastline;
% \end{macrocode}
%
% Next up, we want to draw hexes that are on the coast line but also
% has land parts in it. This is so that the hexes are complete and
% get a proper label on it. We define the fill to be the sea
% colour, and the lines labels to be white
%
% \begin{macrocode}
\begin{scope}[
every hex/.append style={white,fill=sea},
hex/label/.append style={color=white}]
\hex(c=1,r=1); \hex(c=1,r=2);
\hex(c=1,r=3);
\hex(c=2,r=2); \hex(c=2,r=3);
\hex(c=2,r=4);
\hex(c=3,r=2); \hex(c=3,r=3);
\hex(c=4,r=2); \hex(c=4,r=3);
\hex(c=5,r=3); \hex(c=5,r=7);
\hex(c=6,r=4); \hex(c=6,r=5);
\hex(c=6,r=6); \hex(c=6,r=7);
\hex(c=6,r=8); \hex(c=6,r=9);
\hex(c=7,r=6); \hex(c=7,r=9);
\end{scope}
% \end{macrocode}
% Note that we use the \texttt{.append style} handler so that we get
% the setting from above here too (labels, among other things). These
% amended styles only have effect inside the \texttt{scope}. Once we
% leave the scope, then the old settings are restored.
%
% We draw a compass needle.
%
% \begin{macrocode}
\draw[white,-{Stealth[]},
scale line widths,
line width=1mm]
(hex cs:c=7,r=4,v=SE) -- ++(110:2)
node[midway,
font=\sffamily\bfseries\LARGE,
transform shape,
rotate=-90,sloped]{N};
% \end{macrocode}
%
% Since the areas where we do not add hexes are considered neutral
% countries in this game, we fill the whole coast line with the
% previously defined \texttt{neutral} colour.
%
% \begin{macrocode}
\settosave{\coast}
\fill[neutral];
% \end{macrocode}
%
% Here we have the first use of the saved path \verb+\coast+. We make
% that the current path by calling \verb+\setosave+ --- a small
% utility in the \textsf{wargame} package.
%
% We can now add the actual hexes. Some of the hexes will represent
% different terrain, and that will be clear from the definitions. We
% will put our definitions inside a scope, and the first thing we do
% in that scope is to clip everything to our coast line. This will be
% the second use of \verb+\coast+.
%
% \begin{macrocode}
\begin{scope}
\settosave{\coast}
\clip;
\hex(c=1,r=1);\hex(c=1,r=2);\hex(c=1,r=3);
% \end{macrocode}
%
% Note that we use the \texttt{hex cs} coordinate system. We specify
% the column (\texttt{c}) and the row (\texttt{r}) of each hex. We can
% use longer forms, of the keys if we want.
%
% The southern border of A factions country needs a little special
% attention. We clip the drawn hex, and draw the border. In fact, we
% draw the hex twice, first time with a white outline and the neutral
% fill colour. This is so that the full hex will be drawn, even it is
% only partially within the map area.
%
% \begin{macrocode}
\hex[white,fill=neutral,label=](c=2,r=2);
\begin{scope}
\clip(hex cs:c=2,r=2,v=SW)
--(hex cs:c=2,r=2,v=E)
--(hex cs:c=2,r=2,v=NE)
--(hex cs:c=2,r=2,v=NW)
--(hex cs:c=2,r=2,v=W)
--cycle;
\hex(c=2,r=2);
\end{scope}
\draw[coast] (hex cs:c=2,r=2,v=SW)
--(hex cs:c=2,r=2,v=E);
% \end{macrocode}
% Note that our clipping path is defined in the \texttt{hex cs}
% coordinate system, and how we have retrieved vertex coordinates via
% the key \texttt{v}.
%
% Now we come to some other terrain: woods and mountains.
%
% \begin{macrocode}
\hex(c=2,r=3);\hex(c=2,r=4);\hex(c=2,r=5);
\hex[terrain=mountains](c=2,r=6);
\hex[terrain=mountains](c=2,r=7);
\hex[terrain=mountains](c=2,r=8);
% \end{macrocode}
%
% Again, we do not want to draw the hex in the neutral country to
% the south, so we clip this hex too.
%
%
%
%
% \begin{macrocode}
\hex[white,fill=neutral,label=](c=4,r=2);
\begin{scope}
\clip(hex cs:c=4,r=2,v=W)
--(hex cs:c=4,r=2,v=NE)
--(hex cs:c=4,r=2,v=NW)
--cycle;
\hex(c=4,r=2);
\end{scope}
% \end{macrocode}
%
% \begin{macrocode}
\hex(c=3,r=2); \hex(c=3,r=3);
\hex[terrain=woods](c=3,r=4);
\hex(c=3,r=5);
\hex[terrain=woods](c=3,r=6);
\hex[terrain=woods](c=3,r=7);
\hex[terrain=mountains](c=3,r=8);
\hex[terrain=mountains](c=3,r=9);
% \end{macrocode}
%
% In the next step, we will add a town to the map.
%
% \begin{macrocode}
\hex[town={
place={(hex cs:c=1,r=1,e=SW,o=.5)}}]
(c=4,r=3);
\hex[terrain=woods](c=4,r=4);
\hex(c=4,r=5);
\hex[terrain=woods](c=4,r=6);
\hex[terrain=woods](c=4,r=7);
\hex[terrain=woods](c=4,r=8);
\hex[terrain=woods](c=4,r=9);
\hex(c=4,r=10);
% \end{macrocode}
% The \texttt{place} key specifies the placement of the town relative
% to the hex centre.
%
% For the rest of the map, there isn't much new.
%
% \begin{macrocode}
\hex(c=5,r=3);
\hex[terrain=woods](c=5,r=4);
\hex[](c=5,r=5);
\hex[terrain=woods](c=5,r=6);
\hex[terrain=woods](c=5,r=7);
\hex[terrain=woods](c=5,r=8);
\hex[terrain=woods](c=5,r=9);
\hex[terrain=woods](c=6,r=4);
\hex[terrain=woods](c=6,r=5);
\hex[town={
place={(hex cs:c=1,r=1,v=E,o=.3)}}]
(c=6,r=6);
\hex(c=6,r=7); \hex(c=6,r=8);
\hex[terrain=woods](c=6,r=9);
\hex[terrain=woods](c=6,r=10);
\hex(c=7,r=4); \hex(c=7,r=5);
\hex(c=7,r=6); \hex(c=7,r=7);
\hex(c=7,r=8); \hex(c=7,r=9);
\end{scope}
}
% \end{macrocode}
%
% That concludes our hexes. Let us draw it (\figurename~\ref{fig:hexes}).
%
% \begin{figure}
% \centering
% \begin{tikzpicture}[scale=.7]
% \hexes
% \end{tikzpicture}
% \caption{Our hexes}
% \label{fig:hexes}
% \end{figure}
%
% This only defines the map. Now we would like to make the full
% board. Typically one want to add a turn track and some other stuff.
% Here, we will keep it fairly simple and just add a turn track.
%
% \begin{quote}
% This is where we need to start to consider VASSAL. Essentially,
% VASSAL can split a board into \emph{zones}. These zones can be
% different game specific places, e.g., a place to keep eliminated
% units, a place for the turn track, and so on. We will take
% advantage of this in our board definition by applying some
% specific styles.
% \end{quote}
%
% Below we customise the board frame, and some other things on the
% board.
%
% \begin{macrocode}
\colorlet{framebg}{gray!50!white}
\colorlet{titlefg}{gray!50!black}
\tikzset{
hex/board frame/.style={
scale line widths,
line width=.5pt,
draw=black},
board frame/.style={%
anchor=south west,
transform shape,
scale line widths,
line width=1pt,
draw=black,
fill=framebg,
minimum width=14cm,%
minimum height=19cm
},
turn/.style={
scale line widths,
line width=.5pt,
fill=white,
draw=black,
text=gray,
minimum width=1.4cm,
minimum height=1.4cm,
text width=1.2cm,
align=center,
font=\sffamily\bfseries\huge,
transform shape,
anchor=north east
},
title/.style={
text=titlefg,
font=\sffamily\bfseries\Huge,
scale=1.5,
inner sep=0pt,
outer sep=0pt,
transform shape,
},
sub title/.style={
text=titlefg!75!white,
font=\sffamily\bfseries\normalsize,
scale=1.5,
transform shape,
text width=5cm,
inner sep=0pt,
outer sep=0pt,
align=right
}
}
% \end{macrocode}
%
% Let us start the board. The \textsf{wargame} package has a tool
% \verb+\boardrame+ which will put a frame around the map as defined
% by hex coordinates. It also output the map bounding box to the
% standard log file. So running \LaTeX{} once with this macro in
% effect will give us some useful information.
%
% We will define the board in two steps. First we define an
% \emph{environment} which holds the map, turn track, and title of the
% game, and after that we will add an environment that wraps it in a
% \Tikz{} picture.
%
% We define the board as an environment, so that we may put
% things on the board in our explanations of the rules.
%
% \begin{macrocode}
\newenvironment{innerboard}[1][]{%
\node[board frame] (frame) {};
% \end{macrocode}
%
% This adds in our frame of the whole map as defined by the style
% above.
%
% Also note that we made our outer frame a \texttt{node}. This is so
% that we can refer to its anchors without too much knowledge of its
% size.
%
% We have made our frame a little bigger than the hex, so that we may
% add a turn track. We will at it at the top, and we will add 10
% turns. Here, we make use of \Tikz{} loops, and they do the trick for
% us.
%
% We will make use the style \texttt{zone scope} with the name
% \texttt{Turns}. This will be made into a VASSAL zone that has a
% coordinate system that identifies it (at least by convention) as
% turn track. We will in fact deploy a little trick here to make the
% module even more complete. This is because we add the style
% \texttt{zone~point} to the turn number nodes below, and the first
% one will have the name of the game turn marker. This means that the
% game turn marker will \emph{automatically} be placed there. If the
% below is a little complicated for you, take a look at the
% alternative below the code
%
% \begin{macrocode}
\begin{scope}[
shift={($(frame.south east)+(-0.5,.5)$)}]
\begin{scope}[zone scope=Turns]
\foreach \i in {1,...,10}{%
\pgfmathparse{\i*1.65-.225-.7}
\edef\y{\pgfmathresult}
\ifnum1=\i
\def\tname{game turn}
\else
\def\tname{T\i}
\fi
\node[turn,zone point={\tname}{-.7}{\y}]
at (0,\y+.7) {\i};
}
\end{scope}
\end{scope}
% \end{macrocode}
%
% A simpler alternative would be
%
% \begin{verbatim}
% \begin{scope}[
% shift={($(frame.south east)+(-0.5,.5)$)}]
% \begin{scope}[zone scope=Turns]
% \foreach \i in {1,...,10}{%
% \node[turn] at (0,\i*1.65-.225) {\i};
% }
% \end{scope}
% \end{scope}
% \end{verbatim}
% We also add a title using the styles we defined above. Note,
% consistent use of \Tikz{} styles makes it very easy to change things
% consistently throughout the game.
%
% \begin{macrocode}
\node[below right=5mm and 5mm of
frame.north west,title]{A Game};
\node[below left=5mm and 5mm of
frame.north east,sub title]{A tutorial in the\\
{\color{white}wargame} package};
% \end{macrocode}
%
% With this, we are left with adding in the map.
%
% \begin{macrocode}
\scope[shift={(.5,.5)}]
\scope[shift={(1,0.86603)},
zone scope=Hex]
\hexes
\boardframe(c=1,r=1)(c=7,r=10)
% Reported by the above
% Board Frame:
% BBox: (-1.0,-0.86603)x(10.0,15.5885)
% WxH: (11.0x16.45453)
% NCxNR (1,1)x(7,10)
% \end{macrocode}
%
% Above, we see the output from \verb+\boardframe+. This in turn
% informs us how to set the offset of the inner most scope. We also
% see that the map is $11\times 16.45453\,\textrm{cm}$ big, which means
% our board will easily fit on standard paper (A4 or, less standard,
% Letter).
%
% \begin{quote}
% The offset of $(-1,0.86603)$ is not surprising when you know that
% the radius $r$ of the circumscribed circle of the hexes is 1\,cm,
% and that the first hex centre is placed in $(0,0)$. The horizontal
% offset of -1 is just that radius $r$, and the vertical offset is
% $r\sin60^{\circ}=\sqrt{3}/2=0.86603$.
% \end{quote}
%
% The outer most scope translates the hex 5mm in from both edges so
% that we may draw a nice frame around the map.
%
% The style \texttt{zone scope=Hex} will make this area a zone in
% VASSAL and it will have a hex grid (because its argument contains
% the sub string \texttt{hex}) attached to it.
%
% This end the start of the environment. Next, we define the end of
% it. This simply closes the scopes and the \Tikz{} picture.
%
% \begin{macrocode}
}{
\endscope%
\endscope%
}
% \end{macrocode}
%
% This ends the environment that defines the board proper. Now we
% wrap it in another environment that will put the map inside a
% \Tikz{} picture.
%
% \begin{macrocode}
\newenvironment{board}[1][]{%
\tikzpicture[#1,zoned]
\innerboard}{%
\endinnerboard%
\endtikzpicture}
% \end{macrocode}
%
% The style \texttt{zoned} on the \Tikz{} picture ensures that we will
% get a zoned map when generating the VASSAL module. Note that we
% used the \TeX{}-like form of the environment \verb+\tikzpicture+,
% rather than \verb+\begin{tikzpicture}+, so that the various
% \verb+\end+s does not mess up things.
%
%
% We can draw the final board (\figurename~\ref{fig:board}).
% \begin{figure}
% \centering
% \begin{board}[scale=.5]
% \end{board}
% \caption{The final board}
% \label{fig:board}
% \end{figure}
%
% \subsection{Adding units to the board}
% \label{sec:board:units}
%
% We have defined our board as a environment so we can add units to it
% without much hassle. Let us add the starting units at the starting
% positions. Since we will be \emph{stacking} chits, we will use the
% \verb+\chitstack+ macro for this. Note that this macro expects code
% to produce the chits (rather than the unit styles). Therefore we
% must add in some \verb+\noexpand+ in front of the \verb+\chit+
% command.
%
% \begin{figure}
% \centering
% \begin{board}[scale=.5]%
% \stackchits(A2)(.2,.2){%%
% \noexpand\chit[a hq],%
% \noexpand\chit[a 1 hqbg],%
% \noexpand\chit[a 1 2jd ibn],%
% \noexpand\chit[a 2 1jd abn]}%
% \chit[a 1 1lg ibn](D3);%
% \stackchits(C2)(.2,.2){%%
% \noexpand\chit[a 2 hqbg],%
% \noexpand\chit[a 1 1gh ibn]}%
% \stackchits(A1)(.2,.2){%%
% \noexpand\chit[a aregt],%
% \noexpand\chit[a 1 1 abn]}%
% \chit[a 2 3gh rbn](D2);%
%
% \stackchits(F6)(.2,.2){%%
% \noexpand\chit[b hq],%
% \noexpand\chit[b lg hqregt],%
% \noexpand\chit[b lg ibn]}%
% \stackchits(E7)(.2,.2){%%
% \noexpand\chit[b k3 hqregt],%
% \noexpand\chit[b k3 31 abibn]}%
% \stackchits(D7)(.2,.2){%%
% \noexpand\chit[b p4 hqregt],%
% \noexpand\chit[b p4 41 cabn],%
% \noexpand\chit[b p4 42 cabn]}%
% \stackchits(E3)(.2,.2){%%
% \noexpand\chit[b p7 hqregt],%
% \noexpand\chit[b p7 71 ibn],%
% \noexpand\chit[b p7 72 cabn]}%
% \stackchits(D4)(.2,.2){%%
% \noexpand\chit[b i13 hqregt],%
% \noexpand\chit[b i13 131 ibn],%
% \noexpand\chit[b i13 132 ibn]}%
% \end{board}
% \caption{The board with units at their starting positions}
% \label{fig:board-start}
% \end{figure}
%
% The board with the ``At-start'' units in place are shown in
% \figurename~\ref{fig:board-start}. The first part of this was made
% with
%
% \begin{verbatim}
% \begin{board}
% \stackchits(A2)(.2,.2){%
% \noexpand\chit[a hq],
% \noexpand\chit[a 1 hqbg],
% \noexpand\chit[a 1 2jd ibn],
% \noexpand\chit[a 2 1jd abn]}
% \chit[a 1 1lg ibn](D3);
% \end{verbatim}
%
% The first argument to \verb+\stackchits+ is where to put the
% stack. The second is the offset applied to each stack unit in
% succession (obviously the first offset is $(0,0)$). The third
% argument is the list of chits to add to the stack.
%
% Note that we use the hex labels, rather than the hex coordinates, to
% place the units and stacks of units, thanks to \texttt{hex/label is
% name}.
%
% We have made the counters and board for the game. What remains is
% the various tables (and or of course the rules).
%
% \subsection{Clipped boards}
% \label{sec:board:clipped}
%
% We are not quite done with the board just yet. We want to make
% \emph{another} environment which will clip to a specified area of
% the map. We will reuse our \texttt{innerboard} environment so that
% everything is consistent. Let us go ahead and define the
% environment, and then see later how it is used. We define our
% environment as two macros \verb+\clipped+ and \verb+\endclipped+ so
% that we can use parenthesis for our arguments.
%
% \begin{macrocode}
\tikzset{
clip board/.style={gray,line width=.5pt}}
\newcommand\clipped[1][]{\doclipped[#1]}
\def\doclipped[#1](#2)(#3){
\def\tmp@clip@a{#2}
\def\tmp@clip@b{#3}
\tikzpicture[#1]
\scope
\clip (#2) rectangle (#3);
\scope[shift={(-.5-1,-.5-0.86603)}]
\innerboard}
\def\endclipped{%
\endinnerboard
\endscope
\endscope
\draw[clip board](\tmp@clip@a)
rectangle (\tmp@clip@b);
\endtikzpicture}
% \end{macrocode}
%
% Our environment \texttt{clipped} takes 3 arguments. One is optional
% and is keys to pass to the \Tikz{} picture environment. The two
% others are the coordinates (relative to the hexes) of our clipping
% rectangle. Let us illustrate this with an example --- see
% \figurename~\ref{fig:clipped}.
%
% \begin{figure}
% \centering
% \begin{clipped}(hex cs:c=2,r=2)(hex cs:c=5,r=5)
% \end{clipped}
% \caption{Example of using \texttt{clipped}.}
% \label{fig:clipped}
% \end{figure}
%
% The figure was produced by the code
%
% \begin{verbatim}
% \begin{clipped}(hex cs:c=2,r=2)(hex cs:c=5,r=5)
% \end{clipped}
% \end{verbatim}
%
% Note that we \emph{must} use the hex coordinate system. When we
% make the clipping path, the nodes of the hex map has not yet been
% defined. We can use this to illustrate things on the map. For
% example, \figurename~\ref{fig:clipped-attack} show that B P7/72 CABN
% attacks A 2/1JD ABN with the code
%
% \begin{verbatim}
% \begin{clipped}(hex cs:c=2,r=3)(hex cs:c=5,r=5)
% \chit[b p7 72 cabn](D5);
% \chit[a 2 1jd abn](C4);
% \draw[hex/attack] (D5)--(C4);
% \end{clipped}
% \end{verbatim}
%
% \begin{figure}
% \centering
% \begin{clipped}(hex cs:c=2,r=3)(hex cs:c=5,r=5)
% \chit[b p7 72 cabn](D5);
% \chit[a 2 1jd abn](C4);
% \draw[hex/attack] (D5)--(C4);
% \end{clipped}
% \caption{Example of using \texttt{clipped}.}
% \label{fig:clipped-attack}
% \end{figure}
%
% Note that \emph{inside} the environment we \emph{can} use hex
% labels as coordinates.
%
% \section{The charts}
% \label{sec:charts}
%
% We will not go into details about how to make tables in
% \LaTeX{}. There are plenty of excellent resources out there for that
% purpose. Here we will make three tables: The combat resolution
% table (CRT), the terrain effects chart (TEC), and the Order of Battle
% (OOB) chart\footnote{In some games this is called the Order of
% Appearance (OOA) chart.} --- all of which in some respect uses
% elements of the
% \textsf{wargame} package.
%
% For all the tables, we would like to use the \textsf{colortbl}
% package to colour the rows. Here, we make some short hands for
% doing just that.
%
% \begin{macrocode}
\colorlet{headbg}{gray!50!white}
\colorlet{altbg}{gray!15!white}
\newcommand\headrow{\rowcolor{headbg}}
\newcommand\defrow{\rowcolor{white}}
\newcommand\altrow{\rowcolor{altbg}}
% \end{macrocode}
%
% \subsection{The CRT}
% \label{sec:charts:crt}
%
% The combat resolution table is in some sense a straight forward
% \LaTeX{} table. Here's the definition
%
% \begin{macrocode}
\newcommand\crt{%
\begin{tabular}{|c|cccccc|}
\hline
\headrow
\textbf{Die}
& \multicolumn{6}{c|}{\textbf{Odds}}
\\
\headrow
\textbf{roll}
& \textbf{1:3}
& \textbf{1:2}
& \textbf{1:1}
& \textbf{2:1}
& \textbf{3:1}
& \textbf{4:1}
\\
\hline
\defrow
1 & AE & AR & AR & EX & DR & DR \\
\altrow
2 & AE & AR & EX & EX & DR & DR \\
\defrow
3 & AR & EX & EX & DR & DR & DE \\
\altrow
4 & AR & EX & EX & DR & DR & DE \\
\defrow
5 & EX & EX & DR & DR & DE & DE \\
\altrow
5 & EX & DR & DR & DE & DE & DE \\
\hline
\end{tabular}}
% \end{macrocode}
%
% And what it looks like is shown in \tablename~\ref{tab:crt}
%
% \begin{table}
% \centering
% \crt{}
% \caption{The combat resolution table}
% \label{tab:crt}
% \end{table}
%
% \subsection{The TEC}
% \label{sec:charts:te}
%
% In this table we will use small version of hexes to make a nice
% table. The definition is as follows.
%
% \begin{macrocode}
\newcommand\tec{%
\begin{tabular}{|cl|cc|}
\hline
\headrow
\multicolumn{2}{|c|}{\textbf{Terrain}}
& MF
& CF\textsuperscript{\dag}
\\
\hline
\defrow
\tikz[scale=.5]{\hex[label=]}
& Clear
& 1
& ---
\\
\altrow
\tikz[scale=.5]{\hex[label=,terrain=woods]}
& Woods
& 2
& \texttimes 2\textsuperscript{*}
\\
\defrow
\tikz[scale=.5]{\hex[label=,terrain=mountains]}
& Mountains
& Stop
& \texttimes 2\textsuperscript{*}
\\
\altrow
\tikz[scale=.5]{
\hex[label=,fill=sea](c=1,r=1);
\begin{scope}
\clip
(hex cs:c=1,r=1,v=NW)
--(hex cs:c=1,r=1,v=W)
--(hex cs:c=1,r=1,v=SW)
--(hex cs:c=1,r=1,e=S)
--(hex cs:c=1,r=1,v=W,o=.5)
--cycle
(hex cs:c=1,r=1,e=N)
--(hex cs:c=1,r=1,v=NE)
--(hex cs:c=1,r=1,v=E)
--(hex cs:c=1,r=1,e=SE)
--(hex cs:c=1,r=1,v=E,o=.4)
--cycle
;
\hex[label=](c=1,r=1);
\end{scope}
}
& Coastal
& 2
& \texttimes2\phantom{\textsuperscript{*}}
\\
\hline
\multicolumn{4}{l}{\textsuperscript{\dag}
\emph{Defender} modifier}\\
\multicolumn{4}{l}{\textsuperscript{*}
\infantrymark{}\,\pgmark{} \emph{only},
unless \artillerymark}
\\
\end{tabular}
}
% \end{macrocode}
%
% The result is in \tablename~\ref{tab:te}. Note the use of
% \verb+\infantrymark+ to put in \infantrymark{} in the table. The
% \textsf{wargame} package defines a number of macros like this.
%
% \begin{table}
% \centering
% \tec
% \caption{The terrain effects table}
% \label{tab:te}
% \end{table}
%
% \subsection{The OOB}
% \label{sec:charts:oob}
%
% We like to make an OOB chart that we can place our unit counter on
% so we can keep track of which units are available when. In our
% game, all A faction units start already on the board. The B faction,
% however, has most of its reinforcement troops way up north, and will
% therefore bring them on the map piecemeal.
%
% We will use the \textsf{wargame} macro \verb+\oob+ to make our
% OOBs. This macro uses the \texttt{pic} \texttt{chits/oob~turn} to
% make the turns. The default setting is not what we want, so we
% redefine that picture. In particular, we want turn ``0'' to say
% ``At start''.
%
% We also want to reuse the style \texttt{turn} we used
% to make the turn track on the board, but modify it a bit to fit our
% purposes here. We therefore define the style \texttt{oob~turn}
% which derives from \texttt{turn}, but scale it down 70\%, change the
% anchor, and add some extra space outside of it
% (\texttt{outer~sep}).
%
% \begin{macrocode}
\tikzset{
oob turn/.style={
turn,
transform shape,
anchor=east,
outer sep=2mm,
scale=.7},
}
% \end{macrocode}
%
% Our modified \texttt{chit/oob~turn} picture will check if we get an
% empty turn number, or the special ``0'' turn, and then put in a node
% with the appropriate contents. Note that we define two pictures,
% one which actually puts in the turn, and one that puts in nothing,
% so when we make the combined OOB we only output the turns once. We
% then default \texttt{chit/oob~turn} to the first picture
%
% \begin{macrocode}
\tikzset{
oob turn real/.pic={%
\def\tmp{{\Large At start}}
\ifx|#1|\else%
\ifnum0=#1\else%
\def\tmp{#1}%
\fi%
\fi%
\node[oob turn,transform shape]{\tmp};
},
oob turn empty/.pic={},
}
\newcommand\oobrealturn{%
\tikzset{
pics/chit/oob turn/.style=%
{oob turn real=##1}}}
\newcommand\oobemptyturn{%
\tikzset{
pics/chit/oob turn/.style=%
{oob turn empty=##1}}}
\oobrealturn
% \end{macrocode}
%
% Let us see how this looks for both factions. Factions A and B are
% shown in \figurename~\ref{fig:a-oob} and \ref{fig:b-oob},
% respectively.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}[oob turn/.append style={anchor=west}]
% \oob*{\alla}{4}{1.24}{0}
% \end{tikzpicture}
% \caption{Faction A OOB}
% \label{fig:a-oob}
% \end{figure}
%
% \begin{figure}
% \centering
% \begin{tikzpicture}
% \oob{\allb}{4}{1.24}{0}
% \end{tikzpicture}
% \caption{Faction B OOB}
% \label{fig:b-oob}
% \end{figure}
%
% These were done with
%
% \begin{verbatim}
% \begin{tikzpicture}[oob turn/.append style={anchor=west}]
% \oob*{\alla}{4}{1.24}{0}
% \end{tikzpicture}
% \begin{tikzpicture}
% \oob{\allb}{4}{1.24}{0}
% \end{tikzpicture}
% \end{verbatim}
%
% Note that the stared version \verb+\oob*+ puts out the counters
% right aligned. This is also why we append the style
% \texttt{oob~turn} to be anchored to the west.
%
% The first argument to \verb+\oob+ is the list of lists of counters.
% This is why we defined \verb+\alla+ and \verb+\allb+ in the way we
% did. The second argument is the distance between each counter.
% Since the counters are 1.2\,cm wide, we gave them a little extra
% space between them by setting the second argument to 1.24\,(cm).
% The third argument is the spacing between turn rows. Above we have
% set that to 0\,(cm), but that we will change in the real OOB chart.
%
% And that's what we will do next. This will be rather wide, so we
% when we show it in a minute, we will do so in a wide table (leaving
% the two-column layout for a minute).
%
% \begin{macrocode}
\newcommand\inneroob[1][]{%
\node[board frame,anchor=north] (oob frame)
at (0,2.5) {};%
% Game title
\node[%
below right=5mm and 5mm of oob frame.north west,
title,scale=.8]{A Game};
% Chart title
\node[%
below left=5mm and 5mm of oob frame.north east,
sub title,scale=1.2,transform shape]{%
Order of Battle};
% Turn title
\node[font=\sffamily\bfseries\Large,
anchor=south,
white,transform shape] at (0,1) {Turn};
%
\begin{scope}[%
transform shape,
oob turn/.append style={anchor=west},%
shift={(-1.4,0)},
zone scope=A OOB]%
\oobemptyturn%
\oob*{\alla}{4}{1.4}{.2}%
\end{scope}%
%
\begin{scope}[%
transform shape,
shift={(1.4,0)},
zone scope=B OOB]%
\oobrealturn%
\oob{\allb}{4}{1.4}{.2}%
\end{scope}%
%
}
\newcommand\fulloob[1][]{%
\begin{tikzpicture}[#1,zoned]%
\inneroob
\end{tikzpicture}}
% \end{macrocode}
% A couple of things to note.
%
% We put everything inside a \Tikz{} picture with the option
% \texttt{zoned} so that we will get a zoned
% map in VASSAL. We also add the zones \texttt{A OOB} and \texttt{B
% OOB} via the key \texttt{zone scope}. We will need to adjust the
% grids of the zones later on. Another side effect of using
% \verb+\oob+ is that each turn will be marked as a ``region'' of a
% ``region grid'' in in VASSAL, so that the each counter will be
% automatically placed in its place on the OOB in the VASSAL module.
%
% Secondly, we reuse our \texttt{board frame}, \texttt{title}, and
% \texttt{sub~title} styles to make the OOB come out in similar manner
% as the board. We do adjust the font sizes a bit though. We have
% also made the OOB the same size as the board so that they stack
% nicely.
%
% Finally, when we make the faction A oob, we turn off generation of
% the turn numbers. This is so we do note produce those twice.
%
%
% The final OOB is shown in \figurename~\ref{fig:oob}. This was
% produced with
%
% \begin{verbatim}
% \fulloob
% \end{verbatim}
%
% \begin{figure}
% \centering
% \fulloob[scale=.5]
% \caption{The OOB}
% \label{fig:oob}
% \end{figure}
%
% \section{Ending the package}
% \label{sec:end:package}
%
% At the end of the package we should end with the marker
% \verb+\endinput+.
%
% \begin{macrocode}
\endinput
% \end{macrocode}
%
% This is the end of the package. We will do a little more in the
% main document.
%
%
% \iffalse
% Local Variables:
% mode: docTeX
% TeX-master: "game.tex"
% End:
% \fi
|