pywargame 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. pywargame-0.3.1/LICENSE +5 -0
  2. pywargame-0.3.1/PKG-INFO +353 -0
  3. pywargame-0.3.1/README.md +328 -0
  4. pywargame-0.3.1/pywargame/__init__.py +2 -0
  5. pywargame-0.3.1/pywargame/common/__init__.py +3 -0
  6. pywargame-0.3.1/pywargame/common/collector.py +87 -0
  7. pywargame-0.3.1/pywargame/common/dicedraw.py +363 -0
  8. pywargame-0.3.1/pywargame/common/drawdice.py +40 -0
  9. pywargame-0.3.1/pywargame/common/singleton.py +22 -0
  10. pywargame-0.3.1/pywargame/common/test.py +25 -0
  11. pywargame-0.3.1/pywargame/common/verbose.py +59 -0
  12. pywargame-0.3.1/pywargame/common/verboseguard.py +53 -0
  13. pywargame-0.3.1/pywargame/cyberboard/__init__.py +18 -0
  14. pywargame-0.3.1/pywargame/cyberboard/archive.py +283 -0
  15. pywargame-0.3.1/pywargame/cyberboard/base.py +63 -0
  16. pywargame-0.3.1/pywargame/cyberboard/board.py +462 -0
  17. pywargame-0.3.1/pywargame/cyberboard/cell.py +200 -0
  18. pywargame-0.3.1/pywargame/cyberboard/collect.py +49 -0
  19. pywargame-0.3.1/pywargame/cyberboard/collectgbx0pwd.py +30 -0
  20. pywargame-0.3.1/pywargame/cyberboard/collectgbxext.py +30 -0
  21. pywargame-0.3.1/pywargame/cyberboard/collectgsnexp.py +32 -0
  22. pywargame-0.3.1/pywargame/cyberboard/collectgsnext.py +30 -0
  23. pywargame-0.3.1/pywargame/cyberboard/draw.py +396 -0
  24. pywargame-0.3.1/pywargame/cyberboard/exporter.py +1132 -0
  25. pywargame-0.3.1/pywargame/cyberboard/extractor.py +240 -0
  26. pywargame-0.3.1/pywargame/cyberboard/features.py +17 -0
  27. pywargame-0.3.1/pywargame/cyberboard/gamebox.py +81 -0
  28. pywargame-0.3.1/pywargame/cyberboard/gbxexp.py +76 -0
  29. pywargame-0.3.1/pywargame/cyberboard/gbxext.py +64 -0
  30. pywargame-0.3.1/pywargame/cyberboard/gsnexp.py +147 -0
  31. pywargame-0.3.1/pywargame/cyberboard/gsnext.py +59 -0
  32. pywargame-0.3.1/pywargame/cyberboard/head.py +111 -0
  33. pywargame-0.3.1/pywargame/cyberboard/image.py +76 -0
  34. pywargame-0.3.1/pywargame/cyberboard/main.py +47 -0
  35. pywargame-0.3.1/pywargame/cyberboard/mark.py +102 -0
  36. pywargame-0.3.1/pywargame/cyberboard/palette.py +36 -0
  37. pywargame-0.3.1/pywargame/cyberboard/piece.py +169 -0
  38. pywargame-0.3.1/pywargame/cyberboard/player.py +36 -0
  39. pywargame-0.3.1/pywargame/cyberboard/scenario.py +115 -0
  40. pywargame-0.3.1/pywargame/cyberboard/testgrid.py +156 -0
  41. pywargame-0.3.1/pywargame/cyberboard/tile.py +121 -0
  42. pywargame-0.3.1/pywargame/cyberboard/tray.py +68 -0
  43. pywargame-0.3.1/pywargame/cyberboard/windows.py +41 -0
  44. pywargame-0.3.1/pywargame/cyberboard/zeropwd.py +45 -0
  45. pywargame-0.3.1/pywargame/cyberboard.py +2728 -0
  46. pywargame-0.3.1/pywargame/gbx0pwd.py +2776 -0
  47. pywargame-0.3.1/pywargame/gbxextract.py +2795 -0
  48. pywargame-0.3.1/pywargame/gsnexport.py +16499 -0
  49. pywargame-0.3.1/pywargame/gsnextract.py +2790 -0
  50. pywargame-0.3.1/pywargame/latex/__init__.py +2 -0
  51. pywargame-0.3.1/pywargame/latex/collect.py +34 -0
  52. pywargame-0.3.1/pywargame/latex/latexexporter.py +4010 -0
  53. pywargame-0.3.1/pywargame/latex/main.py +184 -0
  54. pywargame-0.3.1/pywargame/vassal/__init__.py +66 -0
  55. pywargame-0.3.1/pywargame/vassal/base.py +139 -0
  56. pywargame-0.3.1/pywargame/vassal/board.py +243 -0
  57. pywargame-0.3.1/pywargame/vassal/buildfile.py +60 -0
  58. pywargame-0.3.1/pywargame/vassal/chart.py +79 -0
  59. pywargame-0.3.1/pywargame/vassal/chessclock.py +197 -0
  60. pywargame-0.3.1/pywargame/vassal/collect.py +98 -0
  61. pywargame-0.3.1/pywargame/vassal/collectpatch.py +28 -0
  62. pywargame-0.3.1/pywargame/vassal/command.py +21 -0
  63. pywargame-0.3.1/pywargame/vassal/documentation.py +322 -0
  64. pywargame-0.3.1/pywargame/vassal/dumpcollect.py +28 -0
  65. pywargame-0.3.1/pywargame/vassal/dumpvsav.py +28 -0
  66. pywargame-0.3.1/pywargame/vassal/element.py +439 -0
  67. pywargame-0.3.1/pywargame/vassal/exporter.py +89 -0
  68. pywargame-0.3.1/pywargame/vassal/extension.py +101 -0
  69. pywargame-0.3.1/pywargame/vassal/folder.py +103 -0
  70. pywargame-0.3.1/pywargame/vassal/game.py +940 -0
  71. pywargame-0.3.1/pywargame/vassal/gameelements.py +1091 -0
  72. pywargame-0.3.1/pywargame/vassal/globalkey.py +127 -0
  73. pywargame-0.3.1/pywargame/vassal/globalproperty.py +433 -0
  74. pywargame-0.3.1/pywargame/vassal/grid.py +573 -0
  75. pywargame-0.3.1/pywargame/vassal/map.py +1061 -0
  76. pywargame-0.3.1/pywargame/vassal/mapelements.py +1020 -0
  77. pywargame-0.3.1/pywargame/vassal/merge.py +57 -0
  78. pywargame-0.3.1/pywargame/vassal/merger.py +460 -0
  79. pywargame-0.3.1/pywargame/vassal/moduledata.py +275 -0
  80. pywargame-0.3.1/pywargame/vassal/mrgcollect.py +31 -0
  81. pywargame-0.3.1/pywargame/vassal/patch.py +44 -0
  82. pywargame-0.3.1/pywargame/vassal/patchcollect.py +28 -0
  83. pywargame-0.3.1/pywargame/vassal/player.py +83 -0
  84. pywargame-0.3.1/pywargame/vassal/save.py +495 -0
  85. pywargame-0.3.1/pywargame/vassal/skel.py +380 -0
  86. pywargame-0.3.1/pywargame/vassal/trait.py +224 -0
  87. pywargame-0.3.1/pywargame/vassal/traits/__init__.py +36 -0
  88. pywargame-0.3.1/pywargame/vassal/traits/area.py +50 -0
  89. pywargame-0.3.1/pywargame/vassal/traits/basic.py +35 -0
  90. pywargame-0.3.1/pywargame/vassal/traits/calculatedproperty.py +22 -0
  91. pywargame-0.3.1/pywargame/vassal/traits/cargo.py +29 -0
  92. pywargame-0.3.1/pywargame/vassal/traits/click.py +41 -0
  93. pywargame-0.3.1/pywargame/vassal/traits/clone.py +28 -0
  94. pywargame-0.3.1/pywargame/vassal/traits/delete.py +24 -0
  95. pywargame-0.3.1/pywargame/vassal/traits/deselect.py +32 -0
  96. pywargame-0.3.1/pywargame/vassal/traits/dynamicproperty.py +112 -0
  97. pywargame-0.3.1/pywargame/vassal/traits/globalcommand.py +55 -0
  98. pywargame-0.3.1/pywargame/vassal/traits/globalhotkey.py +26 -0
  99. pywargame-0.3.1/pywargame/vassal/traits/globalproperty.py +54 -0
  100. pywargame-0.3.1/pywargame/vassal/traits/hide.py +67 -0
  101. pywargame-0.3.1/pywargame/vassal/traits/label.py +76 -0
  102. pywargame-0.3.1/pywargame/vassal/traits/layer.py +105 -0
  103. pywargame-0.3.1/pywargame/vassal/traits/mark.py +20 -0
  104. pywargame-0.3.1/pywargame/vassal/traits/mask.py +85 -0
  105. pywargame-0.3.1/pywargame/vassal/traits/mat.py +26 -0
  106. pywargame-0.3.1/pywargame/vassal/traits/moved.py +35 -0
  107. pywargame-0.3.1/pywargame/vassal/traits/movefixed.py +51 -0
  108. pywargame-0.3.1/pywargame/vassal/traits/nonrect.py +95 -0
  109. pywargame-0.3.1/pywargame/vassal/traits/nostack.py +55 -0
  110. pywargame-0.3.1/pywargame/vassal/traits/place.py +104 -0
  111. pywargame-0.3.1/pywargame/vassal/traits/prototype.py +20 -0
  112. pywargame-0.3.1/pywargame/vassal/traits/report.py +34 -0
  113. pywargame-0.3.1/pywargame/vassal/traits/restrictaccess.py +28 -0
  114. pywargame-0.3.1/pywargame/vassal/traits/restrictcommand.py +32 -0
  115. pywargame-0.3.1/pywargame/vassal/traits/return.py +40 -0
  116. pywargame-0.3.1/pywargame/vassal/traits/rotate.py +62 -0
  117. pywargame-0.3.1/pywargame/vassal/traits/sendto.py +59 -0
  118. pywargame-0.3.1/pywargame/vassal/traits/sheet.py +129 -0
  119. pywargame-0.3.1/pywargame/vassal/traits/skel.py +9 -0
  120. pywargame-0.3.1/pywargame/vassal/traits/stack.py +28 -0
  121. pywargame-0.3.1/pywargame/vassal/traits/submenu.py +27 -0
  122. pywargame-0.3.1/pywargame/vassal/traits/trail.py +61 -0
  123. pywargame-0.3.1/pywargame/vassal/traits/trigger.py +72 -0
  124. pywargame-0.3.1/pywargame/vassal/turn.py +272 -0
  125. pywargame-0.3.1/pywargame/vassal/upgrade.py +191 -0
  126. pywargame-0.3.1/pywargame/vassal/vmod.py +323 -0
  127. pywargame-0.3.1/pywargame/vassal/vsav.py +100 -0
  128. pywargame-0.3.1/pywargame/vassal/widget.py +358 -0
  129. pywargame-0.3.1/pywargame/vassal/withtraits.py +634 -0
  130. pywargame-0.3.1/pywargame/vassal/xml.py +4 -0
  131. pywargame-0.3.1/pywargame/vassal/zone.py +399 -0
  132. pywargame-0.3.1/pywargame/vassal.py +12500 -0
  133. pywargame-0.3.1/pywargame/vmodpatch.py +12548 -0
  134. pywargame-0.3.1/pywargame/vsavdump.py +12533 -0
  135. pywargame-0.3.1/pywargame/vslmerge.py +13015 -0
  136. pywargame-0.3.1/pywargame/wgexport.py +16689 -0
  137. pywargame-0.3.1/pywargame/ztexport.py +14351 -0
  138. pywargame-0.3.1/pywargame/zuntzu/__init__.py +5 -0
  139. pywargame-0.3.1/pywargame/zuntzu/base.py +82 -0
  140. pywargame-0.3.1/pywargame/zuntzu/collect.py +38 -0
  141. pywargame-0.3.1/pywargame/zuntzu/countersheet.py +250 -0
  142. pywargame-0.3.1/pywargame/zuntzu/dicehand.py +48 -0
  143. pywargame-0.3.1/pywargame/zuntzu/exporter.py +936 -0
  144. pywargame-0.3.1/pywargame/zuntzu/gamebox.py +154 -0
  145. pywargame-0.3.1/pywargame/zuntzu/map.py +36 -0
  146. pywargame-0.3.1/pywargame/zuntzu/piece.py +37 -0
  147. pywargame-0.3.1/pywargame/zuntzu/scenario.py +208 -0
  148. pywargame-0.3.1/pywargame/zuntzu/ztexp.py +115 -0
  149. pywargame-0.3.1/pywargame.egg-info/PKG-INFO +353 -0
  150. pywargame-0.3.1/pywargame.egg-info/SOURCES.txt +154 -0
  151. pywargame-0.3.1/pywargame.egg-info/dependency_links.txt +1 -0
  152. pywargame-0.3.1/pywargame.egg-info/requires.txt +5 -0
  153. pywargame-0.3.1/pywargame.egg-info/top_level.txt +1 -0
  154. pywargame-0.3.1/setup.cfg +41 -0
  155. pywargame-0.3.1/setup.py +20 -0
@@ -0,0 +1,5 @@
1
+ This work is licensed under the Creative Commons
2
+ Attribution-ShareAlike 4.0 International License. To view a copy of
3
+ this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or
4
+ send a letter to Creative Commons, PO Box 1866, Mountain View, CA
5
+ 94042, USA.
@@ -0,0 +1,353 @@
1
+ Metadata-Version: 2.4
2
+ Name: pywargame
3
+ Version: 0.3.1
4
+ Summary: Python library to manipulate wargame modules
5
+ Home-page: https://wargames_tex.gitlab.io/pywargame/
6
+ Author: Christian Holm Christensen
7
+ Author-email: cholmcc@gmail.com
8
+ License: CC-BY-SA-4.0
9
+ Project-URL: Documentation, https://wargames_tex.gitlab.io/pywargame
10
+ Project-URL: Source Code, https://gitlab.com/wargmes_tex/pywargame
11
+ Keywords: Boardgame,Wargame,VASSAL,ZunTzu,CyberBoard,LaTeX
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Other Audience
15
+ Classifier: Topic :: Games/Entertainment :: Board Games
16
+ Requires-Python: >=3.6
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: numpy>=1.16
20
+ Requires-Dist: pillow>=10.0.0
21
+ Requires-Dist: svgwrite>=1.3.0
22
+ Requires-Dist: wand>=0.6.0
23
+ Requires-Dist: myst-parser>=4.0.0
24
+ Dynamic: license-file
25
+
26
+ # Python utilities for Wargames
27
+
28
+ This is a collection of various utilities to make things for Computer
29
+ Aided Wargaming (CAW).
30
+
31
+ ## Content
32
+
33
+ - [`pywargame`](pywargame) Top of package
34
+ - [`common`](pywargame/common) Common utilities used by other code.
35
+ - [`vassal`](pywargame/vassal) Read or write
36
+ [VASSAL](https://vassalengine.org)
37
+ ([GitHub](https://github.com/vassalengine/vassal)) modules,
38
+ including
39
+ - merging modules and extensions,
40
+ - patching modules with a Python script, and
41
+ - inspecting content of save and log files.
42
+ - [`cyberboard`](pywargame/cyberboard) Read
43
+ [CyberBoard](http://cyberboard.norsesoft.com/)
44
+ ([GitHub](https://github.com/CyberBoardPBEM/cbwindows)) GameBox
45
+ files.
46
+ - [`zuntzu`](pywargame/zuntzu) Convert [ZunTzu](https://zuntzu.com)
47
+ ([GitHub](https://github.com/ZunTzu-Software/ZunTzu)) GameBox to
48
+ VASSAL module.
49
+ - [`latex`](pywargame/latex) Create (draft) VASSAL module from LaTeX
50
+ sources using the package
51
+ [`wargame`](https://gitlab.com/wargames_tex/wargame_tex).
52
+
53
+
54
+ ## Changes
55
+
56
+ The code isn't versioned yet, and therefore the changes are given by
57
+ date.
58
+
59
+ - 2nd of February, 2024
60
+ - Fix problem with background of maps exported from CyberBoard
61
+ gamebox. Thanks to @zovs66 for pointing this out.
62
+ - `cyberboard.py` now supports file format version 4+ (but not 5, as
63
+ that will introduce the saving for features and other stuff).
64
+
65
+ ## Scripts
66
+
67
+ - [`vslmerge.py`](vassal/merge.py) merges VASSAL modules and
68
+ extensions together into one module. This is work in progress.
69
+ Please report any problems you see.
70
+
71
+ - [`vmodpatch.py`](vassal/patch.py) patches a VASSAL modules by
72
+ running a Python script on it. The input module file is
73
+ overwritten.
74
+
75
+ - [`vsavdump.py`](vassal/dumpsave.py) dumps the content of a VASSAL
76
+ save or log file to standard output.
77
+
78
+ - [`gbxextract.py`](cyberboard/gbxext.py) reads in a CyberBoard
79
+ GameBox file (`.gbx`) and writes out a ZIP file with images and a
80
+ JSON file with information about the GameBox and the images.
81
+
82
+ Pieces (units and markers) are saved as PNGs, while the boards are
83
+ saves as SVGs.
84
+
85
+ - [`gsnextract.py`](cyberboard/gsnext.py) reads in a CyberBoard
86
+ Scenario file (`.gsn`) and writes out a ZIP file with images and a
87
+ JSON file with information about the Scenario, GameBox, and the
88
+ images.
89
+
90
+ Pieces (units and markers) are saved as PNGs, while the boards are
91
+ saves as SVGs.
92
+
93
+ - [`gsnexport.py`](cyberboard/gsnexp.py) reads in a
94
+ CyberBoard Scenario file (`.gsn`) and generates a (draft) VASSAL
95
+ module. A Python script can be supplied to patch up the module.
96
+
97
+ - [`ztexport.py`](zuntzu/ztexp.py) reads in a ZunTzu game box file
98
+ (`.ztb`) and generates a (draft) VASSAL module. A Python script can
99
+ be supplied to patch up the module.
100
+
101
+ - [`wgexport.py`](latex/main.py) reads in a PDF and JSON file created
102
+ from LaTeX sources using the
103
+ [`wargame`](https://gitlab.com/wargames_tex/wargame_tex) package,
104
+ and generates a (draft) VASSAL module. A Python script can be
105
+ supplied to patch up the module.
106
+
107
+ ## Download
108
+
109
+ You can get the scripts in ZIP file
110
+
111
+ - [artifacts.zip][]
112
+
113
+ or individually
114
+
115
+ - [vassal.py][]
116
+ - [vslmerge.py][]
117
+ - [vmodpatch.py][]
118
+ - [vsavdump.py][]
119
+ - [cyberboard.py][]
120
+ - [gbxextract.py][]
121
+ - [gsnextract.py][]
122
+ - [gsnexport.py][]
123
+ - [ztexport.py][]
124
+ - [wgexport.py][]
125
+ - [requirements.txt][]
126
+ - [README.md][]
127
+
128
+ or [browse][] the files.
129
+
130
+ ## Build
131
+
132
+ You need
133
+
134
+ - `numpy` - some numerics
135
+ - `pillow` - PNG image creation
136
+ - `svgwrite` - SVG image creation
137
+ - `wand` - SVG rendering to PNG
138
+
139
+ for these scripts. Do
140
+
141
+ pip install -r requirements.txt
142
+
143
+ to ensure you have those installed.
144
+
145
+ To generate these scripts, do
146
+
147
+ cd pywargame/vassal && ./collect.py
148
+ cd pywargame/cyberboard && ./collect.py
149
+ cd pywargame/cyberboard && ./collectgbxext.py
150
+ cd pywargame/cyberboard && ./collectgsnext.py
151
+ cd pywargame/cyberboard && ./collectgsnexp.py
152
+ cd pywargame/latex && ./collect.py
153
+ cp pywargame/cyberboard/gbxextract.py .
154
+ cp pywargame/cyberboard/gsnextract.py .
155
+ cp pywargame/cyberboard/gsnexport.py .
156
+ cp pywargame/latex/wgexport.py .
157
+
158
+ or simply, on most modern operating systems,
159
+
160
+ make
161
+
162
+ ### Usage
163
+
164
+ ./vslmerge.py <VMOD and VMDX files> [<OPTIONS>]
165
+ ./vmodpath.py <VMOD> <SCRIPT> [<OPTIONS>]
166
+ ./vsavdump.py <VSAV or VLOG> [<OPTIONS>]
167
+ ./gbxextract.py <GBX> [<OPTIONS>]
168
+ ./gsnextract.py <GSN> [<OPTIONS>]
169
+ ./gsnexport.py <GSN> [<OPTIONS>]
170
+ ./ztexport.py <ZTB> [<OPTIONS>]
171
+ ./wgexport.py <PDF> <JSON> [<OPTIONS>]
172
+
173
+
174
+ Pass `-h` or `--help` as an option for a summery of available options
175
+
176
+ ### Note on `vslmerge.py`
177
+
178
+ The _first_ input file should be a module (_not_ an extension).
179
+
180
+ The script is _work-in-progress_ - please report any problems you may
181
+ have.
182
+
183
+ ### Note on `gsnexport.py`
184
+
185
+ Converting a CyberBoard scenario to a VASSAL module may take a _long_
186
+ time. If you are not sure anything is happening, try passing the
187
+ option `-V` (or `--verbose`) to see what is going on. The speed of
188
+ the conversion depends a lot on the graphics used in the game box.
189
+
190
+ The default is to add pieces in their starting positions directly in
191
+ the module. However, with the option `-S` the initial placement of
192
+ units will be put in a save file (`.vsav`). This is useful if there
193
+ are two or more scenario files associated with a game box, and you
194
+ want to merge all these into a single module.
195
+
196
+ The script can only convert one gamebox and scenario at a time. As
197
+ mentioned above, without the `-S` option, all pieces are placed
198
+ directly in their starting position. This makes for a nice standalone
199
+ module. However, if the game box as two or more scenario files
200
+ associated with it, we should add the option `-S` and convert each
201
+ scenario by it self. The generated module files - one for each
202
+ scenario - can then be merged into one using the
203
+ [`vslmerge.py`](vassal/merge.py) script.
204
+
205
+ CyberBoard game boxes and scenarios made with CyberBoard prior to
206
+ version 3.0 are _not_ supported. You may have some luck opening first
207
+ the game box and then the scenario with `CBDesign.exe` and
208
+ `CBPlay.exe`, respectively, and saving anew. Of course, this requires
209
+ an installation of CyberBoard (on Linux, use
210
+ [wine](https://winehq.org)).
211
+
212
+ Some CyberBoard game boxes and scenarios do not define the title or
213
+ version of the game. In that case, you may pass the options `--title`
214
+ and `--version` to set the title or version, respectively.
215
+
216
+ If the game box file (`.gbx`) cannot directly be found, use the option
217
+ `--gamebox` to specify the game box file.
218
+
219
+ Another common problem with Cyberboard scenarios is that they do not
220
+ specify a starting map, or that the starting map is not the actual
221
+ board. In that case, one can write a small Python script that patches
222
+ up the VASSAL module. For example, the file
223
+ [`misc/PortStanley.py`](misc/PortStanley.py) will patch up the
224
+ scenario [_Port
225
+ Stanley_](http://limeyyankgames.co.uk/cyberboard/port-stanley) game
226
+ box, so that the VASSAL module will show the right board. Other
227
+ options for this patch script could be to change the piece names to
228
+ something more appropriate than the auto-generated names, add charts
229
+ and tables, set the splash image, and so on. Please refer to the
230
+ [`vassal`](vassal) module API for more.
231
+
232
+ If you find that the board SVGs are not rendering as expected, you may
233
+ want to run `gsnexporter` first, and turn run `gsnexport.py` as
234
+
235
+ ./gsnexport.py <ZIP FILE> [<OPTIONS>]
236
+
237
+ possibly after editing SVGs
238
+
239
+ ./gsnextract.py <GSN FILE> [<OPTIONS>]
240
+ unzip MyModule.zip board_0_0,svg
241
+ <Edit board_0_0.svg> # E.g. using Inkscape
242
+ zip -u board_0_0.png
243
+ ./gsnexport.py <ZIP FILE> [<OPTIONS>]
244
+
245
+ A good SVG editor is [Inkscape](https://inkscape.org).
246
+
247
+ ### Note on `ztexport.py`
248
+
249
+ Converting a ZunTzu scenario to a VASSAL module may take a _some_
250
+ time. If you are not sure anything is happening, try passing the
251
+ option `-V` (or `--verbose`) to see what is going on. The speed of
252
+ the conversion depends a lot on the graphics used in the game box.
253
+
254
+ If you get the error `cache resources exhausted` try lowering the
255
+ resolution (`-r`).
256
+
257
+ If the ZunTzu gamebox does not use selectable boards, pass the option
258
+ `-a` to generate maps for all defined maps. Otherwise, the script
259
+ will assume that all maps are alternatives for the default map.
260
+
261
+ The generated VASSAL module is pretty close to the input, but should
262
+ be considered a draft. Use the VASSAL editor to flesh out details.
263
+ For example, ZunTzu gameboxes has no notion of "sides" of play.
264
+
265
+ The generated module contains the scenarios that are in the gamebox.
266
+ There's no provision for converting other saves. However, you can
267
+ always add your favourite save the to game box, before conversion,
268
+ using your favourite ZIP-file manager.
269
+
270
+ Terrain tiles (or counters) can be selected by Ctrl-click.
271
+
272
+ The script is not omnipotent, and may fail on some ZunTzu gameboxes.
273
+ Open an Issue against this project, providing all the necessary
274
+ details, if that happens to you.
275
+
276
+ ## API
277
+
278
+ The module [`vassal`](vassal) allows one to generate a VASSAL module
279
+ programmatically, or to read in a VASSAL module and manipulate it
280
+ programmatically. It also has features for defining a _save_
281
+ (`.vsav`) file programmatically.
282
+
283
+ The module [`cyberboard`](cyberboard) allows one to read in a
284
+ CyberBoard GameBox file and retrieve information from it - such as
285
+ piece and board images.
286
+
287
+ ## License
288
+
289
+ This is distributed on the GPL-3 license.
290
+
291
+ ## A word about copyright
292
+
293
+ Caveat: _I am not a lawyer_.
294
+
295
+ Note, if you use these tools to convert a CyberBoard or ZunTzu GameBox
296
+ to say a VASSAL module, then you are creating a derived product from
297
+ the originally copyrighted product (the GameBox). Thus, if you want
298
+ to distribute, even to friends, the generated VASSAL module, you
299
+ _must_ make sure that you are licensed to do so.
300
+
301
+ If the GameBox is licensed under an
302
+ [_Open Source_](https://opensource.org/) license, like
303
+ [Creative-Commons Attribution, Share-Alike](https://creativecommons.org/licenses/by-sa/4.0/), GPL-3,
304
+ or similar, you are explicitly permitted to distribute your derived
305
+ work.
306
+
307
+ If, on the other hand, the license states _all rights reserved_ then
308
+ you cannot redistribute without explicit permission by the copyright
309
+ holder.
310
+
311
+ If no license is explicitly given, then the default is akin to
312
+ _all rights reserved_.
313
+
314
+ Note, if the converted data contains graphics or the like, it may not
315
+ be the module developer that holds the copyright to the materials.
316
+ The developer may (or may not) have obtained permission to distribute
317
+ the materials, but that does not imply that permission is given to
318
+ third party.
319
+
320
+ However, what is copyrightable and what isn't [is not
321
+ obvious](https://boardgamegeek.com/thread/493249/). Only _original_
322
+ and _artistic_ forms of _expression_ can be copyrighted. Ideas, and
323
+ similar, cannot. That means that the mechanics of a game cannot be
324
+ copyrighted. The exact graphics and phrasing of the rules _can_.
325
+ However, if you make distinctive new graphics and rephrase the rules,
326
+ it is _not_ subject the original copyright. Note, however, that it is
327
+ not enough to change a colour or font here or there - it has to be
328
+ _original_.
329
+
330
+ Note that you are free to make your own copy, as long as you obtained
331
+ the original legally. Copyright only matters if you plan to
332
+ _redistribute_, irrespective of whether or not you monetise the
333
+ redistribution, or if the redistribution is private or public.
334
+
335
+
336
+
337
+ [artifacts.zip]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/download?job=dist
338
+ [vassal.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vassal.py?job=dist
339
+ [vslmerge.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vslmerge.py?job=dist
340
+ [vmodpatch.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vmodpatch.py?job=dist
341
+ [vsavdump.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vsavdump.py?job=dist
342
+ [cyberboard.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/cyberboard.py?job=dist
343
+ [gbxextract.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/gbxextract.py?job=dist
344
+ [gsnextract.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/gsnextract.py?job=dist
345
+ [gsnexport.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/gsnexport.py?job=dist
346
+ [ztexport.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/ztexport.py?job=dist
347
+ [wgexport.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/wgexport.py?job=dist
348
+ [requirements.txt]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/requirements.txt?job=dist
349
+ [README.md]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/README.md?job=dist
350
+ [browse]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/browse/public?job=dist
351
+
352
+
353
+
@@ -0,0 +1,328 @@
1
+ # Python utilities for Wargames
2
+
3
+ This is a collection of various utilities to make things for Computer
4
+ Aided Wargaming (CAW).
5
+
6
+ ## Content
7
+
8
+ - [`pywargame`](pywargame) Top of package
9
+ - [`common`](pywargame/common) Common utilities used by other code.
10
+ - [`vassal`](pywargame/vassal) Read or write
11
+ [VASSAL](https://vassalengine.org)
12
+ ([GitHub](https://github.com/vassalengine/vassal)) modules,
13
+ including
14
+ - merging modules and extensions,
15
+ - patching modules with a Python script, and
16
+ - inspecting content of save and log files.
17
+ - [`cyberboard`](pywargame/cyberboard) Read
18
+ [CyberBoard](http://cyberboard.norsesoft.com/)
19
+ ([GitHub](https://github.com/CyberBoardPBEM/cbwindows)) GameBox
20
+ files.
21
+ - [`zuntzu`](pywargame/zuntzu) Convert [ZunTzu](https://zuntzu.com)
22
+ ([GitHub](https://github.com/ZunTzu-Software/ZunTzu)) GameBox to
23
+ VASSAL module.
24
+ - [`latex`](pywargame/latex) Create (draft) VASSAL module from LaTeX
25
+ sources using the package
26
+ [`wargame`](https://gitlab.com/wargames_tex/wargame_tex).
27
+
28
+
29
+ ## Changes
30
+
31
+ The code isn't versioned yet, and therefore the changes are given by
32
+ date.
33
+
34
+ - 2nd of February, 2024
35
+ - Fix problem with background of maps exported from CyberBoard
36
+ gamebox. Thanks to @zovs66 for pointing this out.
37
+ - `cyberboard.py` now supports file format version 4+ (but not 5, as
38
+ that will introduce the saving for features and other stuff).
39
+
40
+ ## Scripts
41
+
42
+ - [`vslmerge.py`](vassal/merge.py) merges VASSAL modules and
43
+ extensions together into one module. This is work in progress.
44
+ Please report any problems you see.
45
+
46
+ - [`vmodpatch.py`](vassal/patch.py) patches a VASSAL modules by
47
+ running a Python script on it. The input module file is
48
+ overwritten.
49
+
50
+ - [`vsavdump.py`](vassal/dumpsave.py) dumps the content of a VASSAL
51
+ save or log file to standard output.
52
+
53
+ - [`gbxextract.py`](cyberboard/gbxext.py) reads in a CyberBoard
54
+ GameBox file (`.gbx`) and writes out a ZIP file with images and a
55
+ JSON file with information about the GameBox and the images.
56
+
57
+ Pieces (units and markers) are saved as PNGs, while the boards are
58
+ saves as SVGs.
59
+
60
+ - [`gsnextract.py`](cyberboard/gsnext.py) reads in a CyberBoard
61
+ Scenario file (`.gsn`) and writes out a ZIP file with images and a
62
+ JSON file with information about the Scenario, GameBox, and the
63
+ images.
64
+
65
+ Pieces (units and markers) are saved as PNGs, while the boards are
66
+ saves as SVGs.
67
+
68
+ - [`gsnexport.py`](cyberboard/gsnexp.py) reads in a
69
+ CyberBoard Scenario file (`.gsn`) and generates a (draft) VASSAL
70
+ module. A Python script can be supplied to patch up the module.
71
+
72
+ - [`ztexport.py`](zuntzu/ztexp.py) reads in a ZunTzu game box file
73
+ (`.ztb`) and generates a (draft) VASSAL module. A Python script can
74
+ be supplied to patch up the module.
75
+
76
+ - [`wgexport.py`](latex/main.py) reads in a PDF and JSON file created
77
+ from LaTeX sources using the
78
+ [`wargame`](https://gitlab.com/wargames_tex/wargame_tex) package,
79
+ and generates a (draft) VASSAL module. A Python script can be
80
+ supplied to patch up the module.
81
+
82
+ ## Download
83
+
84
+ You can get the scripts in ZIP file
85
+
86
+ - [artifacts.zip][]
87
+
88
+ or individually
89
+
90
+ - [vassal.py][]
91
+ - [vslmerge.py][]
92
+ - [vmodpatch.py][]
93
+ - [vsavdump.py][]
94
+ - [cyberboard.py][]
95
+ - [gbxextract.py][]
96
+ - [gsnextract.py][]
97
+ - [gsnexport.py][]
98
+ - [ztexport.py][]
99
+ - [wgexport.py][]
100
+ - [requirements.txt][]
101
+ - [README.md][]
102
+
103
+ or [browse][] the files.
104
+
105
+ ## Build
106
+
107
+ You need
108
+
109
+ - `numpy` - some numerics
110
+ - `pillow` - PNG image creation
111
+ - `svgwrite` - SVG image creation
112
+ - `wand` - SVG rendering to PNG
113
+
114
+ for these scripts. Do
115
+
116
+ pip install -r requirements.txt
117
+
118
+ to ensure you have those installed.
119
+
120
+ To generate these scripts, do
121
+
122
+ cd pywargame/vassal && ./collect.py
123
+ cd pywargame/cyberboard && ./collect.py
124
+ cd pywargame/cyberboard && ./collectgbxext.py
125
+ cd pywargame/cyberboard && ./collectgsnext.py
126
+ cd pywargame/cyberboard && ./collectgsnexp.py
127
+ cd pywargame/latex && ./collect.py
128
+ cp pywargame/cyberboard/gbxextract.py .
129
+ cp pywargame/cyberboard/gsnextract.py .
130
+ cp pywargame/cyberboard/gsnexport.py .
131
+ cp pywargame/latex/wgexport.py .
132
+
133
+ or simply, on most modern operating systems,
134
+
135
+ make
136
+
137
+ ### Usage
138
+
139
+ ./vslmerge.py <VMOD and VMDX files> [<OPTIONS>]
140
+ ./vmodpath.py <VMOD> <SCRIPT> [<OPTIONS>]
141
+ ./vsavdump.py <VSAV or VLOG> [<OPTIONS>]
142
+ ./gbxextract.py <GBX> [<OPTIONS>]
143
+ ./gsnextract.py <GSN> [<OPTIONS>]
144
+ ./gsnexport.py <GSN> [<OPTIONS>]
145
+ ./ztexport.py <ZTB> [<OPTIONS>]
146
+ ./wgexport.py <PDF> <JSON> [<OPTIONS>]
147
+
148
+
149
+ Pass `-h` or `--help` as an option for a summery of available options
150
+
151
+ ### Note on `vslmerge.py`
152
+
153
+ The _first_ input file should be a module (_not_ an extension).
154
+
155
+ The script is _work-in-progress_ - please report any problems you may
156
+ have.
157
+
158
+ ### Note on `gsnexport.py`
159
+
160
+ Converting a CyberBoard scenario to a VASSAL module may take a _long_
161
+ time. If you are not sure anything is happening, try passing the
162
+ option `-V` (or `--verbose`) to see what is going on. The speed of
163
+ the conversion depends a lot on the graphics used in the game box.
164
+
165
+ The default is to add pieces in their starting positions directly in
166
+ the module. However, with the option `-S` the initial placement of
167
+ units will be put in a save file (`.vsav`). This is useful if there
168
+ are two or more scenario files associated with a game box, and you
169
+ want to merge all these into a single module.
170
+
171
+ The script can only convert one gamebox and scenario at a time. As
172
+ mentioned above, without the `-S` option, all pieces are placed
173
+ directly in their starting position. This makes for a nice standalone
174
+ module. However, if the game box as two or more scenario files
175
+ associated with it, we should add the option `-S` and convert each
176
+ scenario by it self. The generated module files - one for each
177
+ scenario - can then be merged into one using the
178
+ [`vslmerge.py`](vassal/merge.py) script.
179
+
180
+ CyberBoard game boxes and scenarios made with CyberBoard prior to
181
+ version 3.0 are _not_ supported. You may have some luck opening first
182
+ the game box and then the scenario with `CBDesign.exe` and
183
+ `CBPlay.exe`, respectively, and saving anew. Of course, this requires
184
+ an installation of CyberBoard (on Linux, use
185
+ [wine](https://winehq.org)).
186
+
187
+ Some CyberBoard game boxes and scenarios do not define the title or
188
+ version of the game. In that case, you may pass the options `--title`
189
+ and `--version` to set the title or version, respectively.
190
+
191
+ If the game box file (`.gbx`) cannot directly be found, use the option
192
+ `--gamebox` to specify the game box file.
193
+
194
+ Another common problem with Cyberboard scenarios is that they do not
195
+ specify a starting map, or that the starting map is not the actual
196
+ board. In that case, one can write a small Python script that patches
197
+ up the VASSAL module. For example, the file
198
+ [`misc/PortStanley.py`](misc/PortStanley.py) will patch up the
199
+ scenario [_Port
200
+ Stanley_](http://limeyyankgames.co.uk/cyberboard/port-stanley) game
201
+ box, so that the VASSAL module will show the right board. Other
202
+ options for this patch script could be to change the piece names to
203
+ something more appropriate than the auto-generated names, add charts
204
+ and tables, set the splash image, and so on. Please refer to the
205
+ [`vassal`](vassal) module API for more.
206
+
207
+ If you find that the board SVGs are not rendering as expected, you may
208
+ want to run `gsnexporter` first, and turn run `gsnexport.py` as
209
+
210
+ ./gsnexport.py <ZIP FILE> [<OPTIONS>]
211
+
212
+ possibly after editing SVGs
213
+
214
+ ./gsnextract.py <GSN FILE> [<OPTIONS>]
215
+ unzip MyModule.zip board_0_0,svg
216
+ <Edit board_0_0.svg> # E.g. using Inkscape
217
+ zip -u board_0_0.png
218
+ ./gsnexport.py <ZIP FILE> [<OPTIONS>]
219
+
220
+ A good SVG editor is [Inkscape](https://inkscape.org).
221
+
222
+ ### Note on `ztexport.py`
223
+
224
+ Converting a ZunTzu scenario to a VASSAL module may take a _some_
225
+ time. If you are not sure anything is happening, try passing the
226
+ option `-V` (or `--verbose`) to see what is going on. The speed of
227
+ the conversion depends a lot on the graphics used in the game box.
228
+
229
+ If you get the error `cache resources exhausted` try lowering the
230
+ resolution (`-r`).
231
+
232
+ If the ZunTzu gamebox does not use selectable boards, pass the option
233
+ `-a` to generate maps for all defined maps. Otherwise, the script
234
+ will assume that all maps are alternatives for the default map.
235
+
236
+ The generated VASSAL module is pretty close to the input, but should
237
+ be considered a draft. Use the VASSAL editor to flesh out details.
238
+ For example, ZunTzu gameboxes has no notion of "sides" of play.
239
+
240
+ The generated module contains the scenarios that are in the gamebox.
241
+ There's no provision for converting other saves. However, you can
242
+ always add your favourite save the to game box, before conversion,
243
+ using your favourite ZIP-file manager.
244
+
245
+ Terrain tiles (or counters) can be selected by Ctrl-click.
246
+
247
+ The script is not omnipotent, and may fail on some ZunTzu gameboxes.
248
+ Open an Issue against this project, providing all the necessary
249
+ details, if that happens to you.
250
+
251
+ ## API
252
+
253
+ The module [`vassal`](vassal) allows one to generate a VASSAL module
254
+ programmatically, or to read in a VASSAL module and manipulate it
255
+ programmatically. It also has features for defining a _save_
256
+ (`.vsav`) file programmatically.
257
+
258
+ The module [`cyberboard`](cyberboard) allows one to read in a
259
+ CyberBoard GameBox file and retrieve information from it - such as
260
+ piece and board images.
261
+
262
+ ## License
263
+
264
+ This is distributed on the GPL-3 license.
265
+
266
+ ## A word about copyright
267
+
268
+ Caveat: _I am not a lawyer_.
269
+
270
+ Note, if you use these tools to convert a CyberBoard or ZunTzu GameBox
271
+ to say a VASSAL module, then you are creating a derived product from
272
+ the originally copyrighted product (the GameBox). Thus, if you want
273
+ to distribute, even to friends, the generated VASSAL module, you
274
+ _must_ make sure that you are licensed to do so.
275
+
276
+ If the GameBox is licensed under an
277
+ [_Open Source_](https://opensource.org/) license, like
278
+ [Creative-Commons Attribution, Share-Alike](https://creativecommons.org/licenses/by-sa/4.0/), GPL-3,
279
+ or similar, you are explicitly permitted to distribute your derived
280
+ work.
281
+
282
+ If, on the other hand, the license states _all rights reserved_ then
283
+ you cannot redistribute without explicit permission by the copyright
284
+ holder.
285
+
286
+ If no license is explicitly given, then the default is akin to
287
+ _all rights reserved_.
288
+
289
+ Note, if the converted data contains graphics or the like, it may not
290
+ be the module developer that holds the copyright to the materials.
291
+ The developer may (or may not) have obtained permission to distribute
292
+ the materials, but that does not imply that permission is given to
293
+ third party.
294
+
295
+ However, what is copyrightable and what isn't [is not
296
+ obvious](https://boardgamegeek.com/thread/493249/). Only _original_
297
+ and _artistic_ forms of _expression_ can be copyrighted. Ideas, and
298
+ similar, cannot. That means that the mechanics of a game cannot be
299
+ copyrighted. The exact graphics and phrasing of the rules _can_.
300
+ However, if you make distinctive new graphics and rephrase the rules,
301
+ it is _not_ subject the original copyright. Note, however, that it is
302
+ not enough to change a colour or font here or there - it has to be
303
+ _original_.
304
+
305
+ Note that you are free to make your own copy, as long as you obtained
306
+ the original legally. Copyright only matters if you plan to
307
+ _redistribute_, irrespective of whether or not you monetise the
308
+ redistribution, or if the redistribution is private or public.
309
+
310
+
311
+
312
+ [artifacts.zip]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/download?job=dist
313
+ [vassal.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vassal.py?job=dist
314
+ [vslmerge.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vslmerge.py?job=dist
315
+ [vmodpatch.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vmodpatch.py?job=dist
316
+ [vsavdump.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/vsavdump.py?job=dist
317
+ [cyberboard.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/cyberboard.py?job=dist
318
+ [gbxextract.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/gbxextract.py?job=dist
319
+ [gsnextract.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/gsnextract.py?job=dist
320
+ [gsnexport.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/gsnexport.py?job=dist
321
+ [ztexport.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/ztexport.py?job=dist
322
+ [wgexport.py]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/wgexport.py?job=dist
323
+ [requirements.txt]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/requirements.txt?job=dist
324
+ [README.md]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/file/public/README.md?job=dist
325
+ [browse]: https://gitlab.com/wargames_tex/pywargame/-/jobs/artifacts/master/browse/public?job=dist
326
+
327
+
328
+
@@ -0,0 +1,2 @@
1
+ '''Top-level of module'''
2
+ version = '0.3.0'