pywargame 0.3.1__py3-none-any.whl

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 (150) hide show
  1. pywargame/__init__.py +2 -0
  2. pywargame/common/__init__.py +3 -0
  3. pywargame/common/collector.py +87 -0
  4. pywargame/common/dicedraw.py +363 -0
  5. pywargame/common/drawdice.py +40 -0
  6. pywargame/common/singleton.py +22 -0
  7. pywargame/common/test.py +25 -0
  8. pywargame/common/verbose.py +59 -0
  9. pywargame/common/verboseguard.py +53 -0
  10. pywargame/cyberboard/__init__.py +18 -0
  11. pywargame/cyberboard/archive.py +283 -0
  12. pywargame/cyberboard/base.py +63 -0
  13. pywargame/cyberboard/board.py +462 -0
  14. pywargame/cyberboard/cell.py +200 -0
  15. pywargame/cyberboard/collect.py +49 -0
  16. pywargame/cyberboard/collectgbx0pwd.py +30 -0
  17. pywargame/cyberboard/collectgbxext.py +30 -0
  18. pywargame/cyberboard/collectgsnexp.py +32 -0
  19. pywargame/cyberboard/collectgsnext.py +30 -0
  20. pywargame/cyberboard/draw.py +396 -0
  21. pywargame/cyberboard/exporter.py +1132 -0
  22. pywargame/cyberboard/extractor.py +240 -0
  23. pywargame/cyberboard/features.py +17 -0
  24. pywargame/cyberboard/gamebox.py +81 -0
  25. pywargame/cyberboard/gbxexp.py +76 -0
  26. pywargame/cyberboard/gbxext.py +64 -0
  27. pywargame/cyberboard/gsnexp.py +147 -0
  28. pywargame/cyberboard/gsnext.py +59 -0
  29. pywargame/cyberboard/head.py +111 -0
  30. pywargame/cyberboard/image.py +76 -0
  31. pywargame/cyberboard/main.py +47 -0
  32. pywargame/cyberboard/mark.py +102 -0
  33. pywargame/cyberboard/palette.py +36 -0
  34. pywargame/cyberboard/piece.py +169 -0
  35. pywargame/cyberboard/player.py +36 -0
  36. pywargame/cyberboard/scenario.py +115 -0
  37. pywargame/cyberboard/testgrid.py +156 -0
  38. pywargame/cyberboard/tile.py +121 -0
  39. pywargame/cyberboard/tray.py +68 -0
  40. pywargame/cyberboard/windows.py +41 -0
  41. pywargame/cyberboard/zeropwd.py +45 -0
  42. pywargame/cyberboard.py +2728 -0
  43. pywargame/gbx0pwd.py +2776 -0
  44. pywargame/gbxextract.py +2795 -0
  45. pywargame/gsnexport.py +16499 -0
  46. pywargame/gsnextract.py +2790 -0
  47. pywargame/latex/__init__.py +2 -0
  48. pywargame/latex/collect.py +34 -0
  49. pywargame/latex/latexexporter.py +4010 -0
  50. pywargame/latex/main.py +184 -0
  51. pywargame/vassal/__init__.py +66 -0
  52. pywargame/vassal/base.py +139 -0
  53. pywargame/vassal/board.py +243 -0
  54. pywargame/vassal/buildfile.py +60 -0
  55. pywargame/vassal/chart.py +79 -0
  56. pywargame/vassal/chessclock.py +197 -0
  57. pywargame/vassal/collect.py +98 -0
  58. pywargame/vassal/collectpatch.py +28 -0
  59. pywargame/vassal/command.py +21 -0
  60. pywargame/vassal/documentation.py +322 -0
  61. pywargame/vassal/dumpcollect.py +28 -0
  62. pywargame/vassal/dumpvsav.py +28 -0
  63. pywargame/vassal/element.py +439 -0
  64. pywargame/vassal/exporter.py +89 -0
  65. pywargame/vassal/extension.py +101 -0
  66. pywargame/vassal/folder.py +103 -0
  67. pywargame/vassal/game.py +940 -0
  68. pywargame/vassal/gameelements.py +1091 -0
  69. pywargame/vassal/globalkey.py +127 -0
  70. pywargame/vassal/globalproperty.py +433 -0
  71. pywargame/vassal/grid.py +573 -0
  72. pywargame/vassal/map.py +1061 -0
  73. pywargame/vassal/mapelements.py +1020 -0
  74. pywargame/vassal/merge.py +57 -0
  75. pywargame/vassal/merger.py +460 -0
  76. pywargame/vassal/moduledata.py +275 -0
  77. pywargame/vassal/mrgcollect.py +31 -0
  78. pywargame/vassal/patch.py +44 -0
  79. pywargame/vassal/patchcollect.py +28 -0
  80. pywargame/vassal/player.py +83 -0
  81. pywargame/vassal/save.py +495 -0
  82. pywargame/vassal/skel.py +380 -0
  83. pywargame/vassal/trait.py +224 -0
  84. pywargame/vassal/traits/__init__.py +36 -0
  85. pywargame/vassal/traits/area.py +50 -0
  86. pywargame/vassal/traits/basic.py +35 -0
  87. pywargame/vassal/traits/calculatedproperty.py +22 -0
  88. pywargame/vassal/traits/cargo.py +29 -0
  89. pywargame/vassal/traits/click.py +41 -0
  90. pywargame/vassal/traits/clone.py +28 -0
  91. pywargame/vassal/traits/delete.py +24 -0
  92. pywargame/vassal/traits/deselect.py +32 -0
  93. pywargame/vassal/traits/dynamicproperty.py +112 -0
  94. pywargame/vassal/traits/globalcommand.py +55 -0
  95. pywargame/vassal/traits/globalhotkey.py +26 -0
  96. pywargame/vassal/traits/globalproperty.py +54 -0
  97. pywargame/vassal/traits/hide.py +67 -0
  98. pywargame/vassal/traits/label.py +76 -0
  99. pywargame/vassal/traits/layer.py +105 -0
  100. pywargame/vassal/traits/mark.py +20 -0
  101. pywargame/vassal/traits/mask.py +85 -0
  102. pywargame/vassal/traits/mat.py +26 -0
  103. pywargame/vassal/traits/moved.py +35 -0
  104. pywargame/vassal/traits/movefixed.py +51 -0
  105. pywargame/vassal/traits/nonrect.py +95 -0
  106. pywargame/vassal/traits/nostack.py +55 -0
  107. pywargame/vassal/traits/place.py +104 -0
  108. pywargame/vassal/traits/prototype.py +20 -0
  109. pywargame/vassal/traits/report.py +34 -0
  110. pywargame/vassal/traits/restrictaccess.py +28 -0
  111. pywargame/vassal/traits/restrictcommand.py +32 -0
  112. pywargame/vassal/traits/return.py +40 -0
  113. pywargame/vassal/traits/rotate.py +62 -0
  114. pywargame/vassal/traits/sendto.py +59 -0
  115. pywargame/vassal/traits/sheet.py +129 -0
  116. pywargame/vassal/traits/skel.py +9 -0
  117. pywargame/vassal/traits/stack.py +28 -0
  118. pywargame/vassal/traits/submenu.py +27 -0
  119. pywargame/vassal/traits/trail.py +61 -0
  120. pywargame/vassal/traits/trigger.py +72 -0
  121. pywargame/vassal/turn.py +272 -0
  122. pywargame/vassal/upgrade.py +191 -0
  123. pywargame/vassal/vmod.py +323 -0
  124. pywargame/vassal/vsav.py +100 -0
  125. pywargame/vassal/widget.py +358 -0
  126. pywargame/vassal/withtraits.py +634 -0
  127. pywargame/vassal/xml.py +4 -0
  128. pywargame/vassal/zone.py +399 -0
  129. pywargame/vassal.py +12500 -0
  130. pywargame/vmodpatch.py +12548 -0
  131. pywargame/vsavdump.py +12533 -0
  132. pywargame/vslmerge.py +13015 -0
  133. pywargame/wgexport.py +16689 -0
  134. pywargame/ztexport.py +14351 -0
  135. pywargame/zuntzu/__init__.py +5 -0
  136. pywargame/zuntzu/base.py +82 -0
  137. pywargame/zuntzu/collect.py +38 -0
  138. pywargame/zuntzu/countersheet.py +250 -0
  139. pywargame/zuntzu/dicehand.py +48 -0
  140. pywargame/zuntzu/exporter.py +936 -0
  141. pywargame/zuntzu/gamebox.py +154 -0
  142. pywargame/zuntzu/map.py +36 -0
  143. pywargame/zuntzu/piece.py +37 -0
  144. pywargame/zuntzu/scenario.py +208 -0
  145. pywargame/zuntzu/ztexp.py +115 -0
  146. pywargame-0.3.1.dist-info/METADATA +353 -0
  147. pywargame-0.3.1.dist-info/RECORD +150 -0
  148. pywargame-0.3.1.dist-info/WHEEL +5 -0
  149. pywargame-0.3.1.dist-info/licenses/LICENSE +5 -0
  150. pywargame-0.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,399 @@
1
+ ## BEGIN_IMPORT
2
+ from common import VerboseGuard
3
+ from . base import *
4
+ from . element import Element
5
+ from . grid import *
6
+ ## END_IMPORT
7
+
8
+ # --------------------------------------------------------------------
9
+ class ZonedGrid(Element):
10
+ TAG=Element.BOARD+'ZonedGrid'
11
+ def __init__(self,board,node=None):
12
+ super(ZonedGrid,self).__init__(board,self.TAG,node=node)
13
+
14
+ def getBoard(self):
15
+ ## BEGIN_IMPORT
16
+ from . board import Board
17
+ ## END_IMPORT
18
+ b = self.getParent(Board)
19
+ # print(f'Get Board of Zoned: {b}')
20
+ return b
21
+ def getPicker(self):
22
+ z = self.getBoard()
23
+ if z is not None:
24
+ return z.getPicker()
25
+ return None
26
+ def getMap(self):
27
+ z = self.getPicker()
28
+ if z is not None:
29
+ return z.getMap()
30
+ return None
31
+ def addHighlighter(self,**kwargs):
32
+ '''Add a `Highlighter` element to this
33
+
34
+ Parameters
35
+ ----------
36
+ kwargs : dict
37
+ Dictionary of attribute key-value pairs
38
+
39
+ Returns
40
+ -------
41
+ element : Highlighter
42
+ The added element
43
+ '''
44
+ return self.add(ZonedGridHighlighter,**kwargs)
45
+ def getHighlighters(self,single=True):
46
+ '''Get all or a sole `ZonedGridHighlighter` element(s) from this
47
+
48
+ Parameters
49
+ ----------
50
+ single : bool
51
+ If `True`, there can be only one `Highligter` child, otherwise fail.
52
+ If `False` return all `Highligter` children in this element
53
+
54
+ Returns
55
+ -------
56
+ children : list
57
+ List of `Highligter` children (even if `single=True`)
58
+ '''
59
+ return self.getAllElements(ZonedGridHighlighter,single=single)
60
+ def addZone(self,**kwargs):
61
+ '''Add a `Zone` element to this
62
+
63
+ Parameters
64
+ ----------
65
+ kwargs : dict
66
+ Dictionary of attribute key-value pairs
67
+
68
+ Returns
69
+ -------
70
+ element : Zone
71
+ The added element
72
+ '''
73
+ return self.add(Zone,**kwargs)
74
+ def getZones(self,asdict=True):
75
+ '''Get all Zone element(s) from this
76
+
77
+ Parameters
78
+ ----------
79
+ asdict : bool
80
+ If `True`, return a dictonary that maps key to `Zone` elements. If `False`, return a list of all Zone` children.
81
+
82
+ Returns
83
+ -------
84
+ children : dict or list
85
+ Dictionary or list of `Zone` children
86
+ '''
87
+ return self.getElementsByKey(Zone,'name',asdict=asdict)
88
+
89
+ registerElement(ZonedGrid)
90
+
91
+ # --------------------------------------------------------------------
92
+ class ZonedGridHighlighter(Element):
93
+ TAG=Element.BOARD+'mapgrid.ZonedGridHighlighter'
94
+ def __init__(self,zoned,node=None):
95
+ super(ZonedGridHighlighter,self).__init__(zoned,self.TAG,node=node)
96
+ def getZonedGrid(self): return self.getParent(ZonedGrid)
97
+
98
+ def addZoneHighlight(self,**kwargs):
99
+ '''Add a `ZoneHighlight` element to this
100
+
101
+ Parameters
102
+ ----------
103
+ kwargs : dict
104
+ Dictionary of attribute key-value pairs
105
+
106
+ Returns
107
+ -------
108
+ element : ZoneHighlight
109
+ The added element
110
+ '''
111
+ return self.add(ZoneHighlight,**kwargs)
112
+ def getZoneHighlights(self,asdict=True):
113
+ '''Get all ZoneHighlight element(s) from this
114
+
115
+ Parameters
116
+ ----------
117
+ asdict : bool
118
+ If `True`, return a dictonary that maps key to `Zone` elements. If `False`, return a list of all Zone` children.
119
+
120
+ Returns
121
+ -------
122
+ children : dict or list
123
+ Dictionary or list of `Zone` children
124
+ '''
125
+ return self.getElementsByKey(ZoneHighlight,'name',asdict=asdict)
126
+
127
+ registerElement(ZonedGridHighlighter)
128
+
129
+ # --------------------------------------------------------------------
130
+ class ZoneHighlight(Element):
131
+ TAG=Element.BOARD+'mapgrid.ZoneHighlight'
132
+ FULL = 'Entire Zone',
133
+ BORDER = 'Zone Border',
134
+ PLAIN = 'Plain',
135
+ STRIPED = 'Striped'
136
+ CROSS = 'Crosshatched',
137
+ TILES = 'Tiled Image'
138
+ UNIQUE = ['name']
139
+ def __init__(self,
140
+ highlighters,
141
+ node = None,
142
+ name = '',
143
+ color = rgb(255,0,0),
144
+ coverage = FULL,
145
+ width = 1,
146
+ style = PLAIN,
147
+ image = '',
148
+ opacity = 50):
149
+ super(ZoneHighlight,self).__init__(highlighters,
150
+ self.TAG,
151
+ node = node,
152
+ name = name,
153
+ color = color,
154
+ coverage = coverage,
155
+ width = width,
156
+ style = style,
157
+ image = image,
158
+ opacity = int(opacity))
159
+ def getZonedGridHighlighter(self):
160
+ return self.getParent(ZonedGridHighlighter)
161
+
162
+
163
+ registerElement(ZoneHighlight)
164
+
165
+
166
+ # --------------------------------------------------------------------
167
+ class ZoneProperty(Element):
168
+ TAG = Element.MODULE+'properties.ZoneProperty'
169
+ UNIQUE = ['name']
170
+ def __init__(self,zone,node=None,
171
+ name = '',
172
+ initialValue = '',
173
+ isNumeric = False,
174
+ min = "null",
175
+ max = "null",
176
+ wrap = False,
177
+ description = ""):
178
+ super(ZoneProperty,self).__init__(zone,self.TAG,
179
+ node = node,
180
+ name = name,
181
+ initialValue = initialValue,
182
+ isNumeric = isNumeric,
183
+ min = min,
184
+ max = max,
185
+ wrap = wrap,
186
+ description = description)
187
+
188
+ def getZone(self):
189
+ return self.getParent(Zone)
190
+
191
+ registerElement(ZoneProperty)
192
+
193
+ # --------------------------------------------------------------------
194
+ class Zone(Element):
195
+ TAG = Element.BOARD+'mapgrid.Zone'
196
+ UNIQUE = ['name']
197
+ def __init__(self,zoned,node=None,
198
+ name = "",
199
+ highlightProperty = "",
200
+ locationFormat = "$gridLocation$",
201
+ path = "0,0;976,0;976,976;0,976",
202
+ useHighlight = False,
203
+ useParentGrid = False):
204
+ super(Zone,self).\
205
+ __init__(zoned,self.TAG,node=node,
206
+ name = name,
207
+ highlightProperty = highlightProperty,
208
+ locationFormat = locationFormat,
209
+ path = path,
210
+ useHighlight = useHighlight,
211
+ useParentGrid = useParentGrid)
212
+
213
+ def getZonedGrid(self):
214
+ z = self.getParent(ZonedGrid)
215
+ # print(f'Get Zoned of Zone {self["name"]}: {z}')
216
+ return z
217
+
218
+ def getBoard(self):
219
+ z = self.getZonedGrid()
220
+ if z is not None:
221
+ return z.getBoard()
222
+ return None
223
+ def getPicker(self):
224
+ z = self.getBoard()
225
+ if z is not None:
226
+ return z.getPicker()
227
+ return None
228
+ def getMap(self):
229
+ z = self.getPicker()
230
+ if z is not None:
231
+ return z.getMap()
232
+ return None
233
+ def addHexGrid(self,**kwargs):
234
+ '''Add a `HexGrid` element to this
235
+
236
+ Parameters
237
+ ----------
238
+ kwargs : dict
239
+ Dictionary of attribute key-value pairs
240
+
241
+ Returns
242
+ -------
243
+ element : HexGrid
244
+ The added element
245
+ '''
246
+ return self.add(HexGrid,**kwargs)
247
+ def addSquareGrid(self,**kwargs):
248
+ '''Add a `SquareGrid` element to this
249
+
250
+ Parameters
251
+ ----------
252
+ kwargs : dict
253
+ Dictionary of attribute key-value pairs
254
+
255
+ Returns
256
+ -------
257
+ element : SquareGrid
258
+ The added element
259
+ '''
260
+ return self.add(SquareGrid,**kwargs)
261
+ def addRegionGrid(self,**kwargs):
262
+ '''Add a `RegionGrid` element to this
263
+
264
+ Parameters
265
+ ----------
266
+ kwargs : dict
267
+ Dictionary of attribute key-value pairs
268
+
269
+ Returns
270
+ -------
271
+ element : RegionGrid
272
+ The added element
273
+ '''
274
+ return self.add(RegionGrid,**kwargs)
275
+ def addProperty(self,**kwargs):
276
+ '''Add a `Property` element to this
277
+
278
+ Parameters
279
+ ----------
280
+ kwargs : dict
281
+ Dictionary of attribute key-value pairs
282
+
283
+ Returns
284
+ -------
285
+ element : Property
286
+ The added element
287
+ '''
288
+ return self.add(ZoneProperty,**kwargs)
289
+ def getHexGrids(self,single=True):
290
+ '''Get all or a sole `HexGrid` element(s) from this
291
+
292
+ Parameters
293
+ ----------
294
+ single : bool
295
+ If `True`, there can be only one `HexGrid` child, otherwise fail.
296
+ If `False` return all `HexGrid` children in this element
297
+
298
+ Returns
299
+ -------
300
+ children : list
301
+ List of `HexGrid` children (even if `single=True`)
302
+ '''
303
+ return self.getAllElements(HexGrid,single=single)
304
+ def getSquareGrids(self,single=True):
305
+ '''Get all or a sole `SquareGrid` element(s) from this
306
+
307
+ Parameters
308
+ ----------
309
+ single : bool
310
+ If `True`, there can be only one `SquareGrid` child, otherwise fail.
311
+ If `False` return all `SquareGrid` children in this element
312
+
313
+ Returns
314
+ -------
315
+ children : list
316
+ List of `SquareGrid` children (even if `single=True`)
317
+ '''
318
+ return self.getAllElements(SquareGrid,single=single)
319
+ def getRegionGrids(self,single=True):
320
+ '''Get all or a sole `RegionGrid` element(s) from this
321
+
322
+ Parameters
323
+ ----------
324
+ single : bool
325
+ If `True`, there can be only one `RegionGrid` child, otherwise fail.
326
+ If `False` return all `RegionGrid` children in this element
327
+
328
+ Returns
329
+ -------
330
+ children : list
331
+ List of `RegionGrid` children (even if `single=True`)
332
+ '''
333
+ return self.getAllElements(RegionGrid,single=single)
334
+ def getGrids(self,single=True):
335
+ '''Get all or a sole `Grid` element(s) from this
336
+
337
+ Parameters
338
+ ----------
339
+ single : bool
340
+ If `True`, there can be only one `Grid` child, otherwise fail.
341
+ If `False` return all `Grid` children in this element
342
+
343
+ Returns
344
+ -------
345
+ children : list
346
+ List of `Grid` children (even if `single=True`)
347
+ '''
348
+ g = self.getHexGrids(single=single)
349
+ if g is not None: return g
350
+
351
+ g = self.getSquareGrids(single=single)
352
+ if g is not None: return g
353
+
354
+ g = self.getRegionGrids(single=single)
355
+ if g is not None: return g
356
+
357
+ return g
358
+ def getProperties(self):
359
+ '''Get all `Property` element from this
360
+
361
+ Returns
362
+ -------
363
+ children : dict
364
+ dict of `Property` children
365
+ '''
366
+ return getElementsByKey(ZoneProperty,'name')
367
+
368
+ def getPath(self):
369
+ p = self['path'].split(';')
370
+ r = []
371
+ for pp in p:
372
+ c = pp.split(',')
373
+ r.append([int(c[0]),int(c[1])])
374
+ return r
375
+
376
+ def getBB(self):
377
+ from functools import reduce
378
+ path = self.getPath()
379
+ llx = reduce(lambda old,point:min(point[0],old),path,100000000000)
380
+ lly = reduce(lambda old,point:min(point[1],old),path,100000000000)
381
+ urx = reduce(lambda old,point:max(point[0],old),path,-1)
382
+ ury = reduce(lambda old,point:max(point[1],old),path,-1)
383
+ return llx,lly,urx,ury
384
+ def getWidth(self):
385
+ llx,_,urx,_ = self.getBB()
386
+ return urx-llx
387
+ def getHeight(self):
388
+ _,lly,_,ury = self.getBB()
389
+ return ury-lly
390
+ def getXOffset(self):
391
+ return self.getBB()[0]
392
+ def getYOffset(self):
393
+ return self.getBB()[1]
394
+
395
+ registerElement(Zone)
396
+
397
+ #
398
+ # EOF
399
+ #