Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/dnd35.py @ 152:6081bdc2b8d5 beta
Traipse Beta 'OpenRPG' {091125-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go.
Traipse also makes it easy for developers to work on code without fear of
sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the
code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the
productivity of the user.
Update Summary (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
Pretty important update that can help remove thousands of dead children from your
gametree.
Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height
/>, etc... are all tags now. Check your gametree and look for dead children!!
New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops
return error instead of freezing the software!
New Syntax added for custom PC sheets
Tip of the Day added, from Core and community
Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to
prevent non updated clients from ruining the fix.
author | sirebral |
---|---|
date | Wed, 25 Nov 2009 06:16:35 -0600 |
parents | dcf4fbe09b70 |
children | bf799efe7a8a |
comparison
equal
deleted
inserted
replaced
150:6c5f46a5924b | 152:6081bdc2b8d5 |
---|---|
1 #from orpg.tools.orpg_settings import settings #Settings used? | |
2 #import orpg.minidom | |
3 from core import * | 1 from core import * |
4 from containers import * | 2 from containers import * |
5 from string import * #a 1.6003 | 3 from string import * #a 1.6003 |
6 from inspect import * #a 1.9001 | 4 from inspect import * #a 1.9001 |
7 from orpg.dirpath import dir_struct | 5 from orpg.dirpath import dir_struct |
23 | 21 |
24 #a 1.6 convinience function added safeGetAttr | 22 #a 1.6 convinience function added safeGetAttr |
25 def safeGetAttr(node, label, defRetV=None): | 23 def safeGetAttr(node, label, defRetV=None): |
26 cna=node.attrib | 24 cna=node.attrib |
27 for key in cna: | 25 for key in cna: |
28 if key == label: | 26 if key == label: return cna[key] |
29 return cna[key] | |
30 #retV=node.get(lable) # get does not distingish between | |
31 # the attribute not being present vs it having a value of "" | |
32 # This is bad for this routine, thus not used. | |
33 return defRetV | 27 return defRetV |
34 #a 1.6... safeGetAttr end. | 28 #a 1.6... safeGetAttr end. |
35 | 29 |
36 ########End of My global Stuff######## | 30 ########End of My global Stuff######## |
37 ########Start of Main Node Handlers####### | 31 ########Start of Main Node Handlers####### |
40 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' /> | 34 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' /> |
41 """ | 35 """ |
42 def __init__(self,xml_dom,tree_node): | 36 def __init__(self,xml_dom,tree_node): |
43 node_handler.__init__(self,xml_dom,tree_node) | 37 node_handler.__init__(self,xml_dom,tree_node) |
44 self.Version = "v1.000" #a 1.6000 general documentation, usage. | 38 self.Version = "v1.000" #a 1.6000 general documentation, usage. |
45 | |
46 print "dnd35char_handler - version:",self.Version #m 1.6000 | 39 print "dnd35char_handler - version:",self.Version #m 1.6000 |
47 | |
48 self.hparent = None #a 1.5002 allow ability to run up tree, this is the | 40 self.hparent = None #a 1.5002 allow ability to run up tree, this is the |
49 | |
50 self.frame = component.get('frame') | 41 self.frame = component.get('frame') |
51 self.child_handlers = {} | 42 self.child_handlers = {} |
52 self.new_child_handler('general','GeneralInformation',dnd35general,'gear') | 43 self.new_child_handler('general','GeneralInformation',dnd35general,'gear') |
53 self.new_child_handler('inventory','MoneyAndInventory',dnd35inventory,'money') | 44 self.new_child_handler('inventory','MoneyAndInventory',dnd35inventory,'money') |
54 self.new_child_handler('character','ClassesAndStats',dnd35classnstats,'knight') | 45 self.new_child_handler('character','ClassesAndStats',dnd35classnstats,'knight') |
55 self.new_child_handler('snf','SkillsAndFeats',dnd35skillsnfeats,'book') | 46 self.new_child_handler('snf','SkillsAndFeats',dnd35skillsnfeats,'book') |
56 self.new_child_handler('combat','Combat',dnd35combat,'spears') | 47 self.new_child_handler('combat','Combat',dnd35combat,'spears') |
57 | |
58 self.myeditor = None | 48 self.myeditor = None |
59 | |
60 | 49 |
61 def new_child_handler(self,tag,text,handler_class,icon='gear'): | 50 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
62 node_list = self.xml.findall(tag) | 51 node_list = self.xml.findall(tag) |
63 tree = self.tree | 52 tree = self.tree |
64 i = self.tree.icons[icon] | 53 i = self.tree.icons[icon] |
67 tree.SetPyData(new_tree_node,handler) | 56 tree.SetPyData(new_tree_node,handler) |
68 self.child_handlers[tag] = handler | 57 self.child_handlers[tag] = handler |
69 | 58 |
70 def get_design_panel(self,parent): | 59 def get_design_panel(self,parent): |
71 return tabbed_panel(parent,self,1) | 60 return tabbed_panel(parent,self,1) |
72 | |
73 | 61 |
74 def get_use_panel(self,parent): | 62 def get_use_panel(self,parent): |
75 return tabbed_panel(parent,self,2) | 63 return tabbed_panel(parent,self,2) |
76 | 64 |
77 def tohtml(self): | 65 def tohtml(self): |
84 html_str += "<P>" + self.feats.tohtml() | 72 html_str += "<P>" + self.feats.tohtml() |
85 html_str += "<P>" + self.inventory.tohtml() +"</td>" | 73 html_str += "<P>" + self.inventory.tohtml() +"</td>" |
86 html_str += "<td width='50%' valign=top >"+self.classes.tohtml() | 74 html_str += "<td width='50%' valign=top >"+self.classes.tohtml() |
87 html_str += "<P>" + self.hp.tohtml() | 75 html_str += "<P>" + self.hp.tohtml() |
88 html_str += "<P>" + self.skills.tohtml() +"</td>" | 76 html_str += "<P>" + self.skills.tohtml() +"</td>" |
89 #a block for 1.6009 end | |
90 | |
91 html_str += "</tr></table>" | 77 html_str += "</tr></table>" |
92 return html_str | 78 return html_str |
93 | 79 |
94 def about(self): | 80 def about(self): |
95 html_str = "<img src='" + dir_struct["icon"] | 81 """html_str = "<img src='" + dir_struct["icon"] |
96 html_str += "dnd3e_logo.gif' ><br /><b>dnd35 Character Tool " | 82 html_str += "dnd3e_logo.gif' ><br /><b>dnd35 Character Tool " |
97 html_str += self.Version+"</b>" #m 1.6000 was hard coded. | 83 html_str += self.Version+"</b>" #m 1.6000 was hard coded. |
98 html_str += "<br />by Dj Gilcrease<br />digitalxero@gmail.com" | 84 html_str += "<br />by Dj Gilcrease<br />digitalxero@gmail.com" |
99 return html_str | 85 return html_str""" |
86 text = 'dnd35 Character Tool' + self.Version +'\n' | |
87 text += 'by Dj Gilcrease digitalxero@gmail.com' | |
88 return text | |
100 | 89 |
101 ########Core Handlers are done now############ | 90 ########Core Handlers are done now############ |
102 ########Onto the Sub Nodes######## | 91 ########Onto the Sub Nodes######## |
103 ##Primary Sub Node## | 92 ##Primary Sub Node## |
104 | 93 |
123 self.char_hander = parent | 112 self.char_hander = parent |
124 self.drag = False | 113 self.drag = False |
125 self.frame = component.get('frame') | 114 self.frame = component.get('frame') |
126 self.myeditor = None | 115 self.myeditor = None |
127 | 116 |
128 | |
129 def on_drop(self,evt): | 117 def on_drop(self,evt): |
130 pass | 118 pass |
131 | 119 |
132 def on_rclick(self,evt): | 120 def on_rclick(self,evt): |
133 pass | 121 pass |
179 def on_name_change(self,name): | 167 def on_name_change(self,name): |
180 self.char_hander.rename(name) | 168 self.char_hander.rename(name) |
181 #o 1.5002 self.char_hander = parent in this case. | 169 #o 1.5002 self.char_hander = parent in this case. |
182 self.charName = name #a 1.5002 make getting name easier. | 170 self.charName = name #a 1.5002 make getting name easier. |
183 | 171 |
184 | |
185 def get_char_name( self ): | 172 def get_char_name( self ): |
186 node = self.xml.findall( 'name' )[0] | 173 node = self.xml.findall( 'name' )[0] |
187 return node.text | 174 return node.text |
188 | 175 |
189 class gen_grid(wx.grid.Grid): | 176 class gen_grid(wx.grid.Grid): |
190 """grid for gen info""" | 177 """grid for gen info""" |
191 def __init__(self, parent, handler): | 178 def __init__(self, parent, handler): |
192 pname = handler.xml.set("name", 'General') | 179 pname = handler.xml.set("name", 'General') |
193 self.hparent = handler #a 1.5002 allow ability to run up tree, needed | 180 self.hparent = handler #a 1.5002 allow ability to run up tree, needed |
194 # a 1.5002 parent is functional parent, not invoking parent. | 181 # a 1.5002 parent is functional parent, not invoking parent. |
195 | |
196 | |
197 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 182 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
198 #self.Bind(wx.EVT_SIZE, self.on_size) | |
199 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 183 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
200 self.handler = handler | 184 self.handler = handler |
201 n_list = handler.xml.getchildren() | 185 n_list = handler.xml.getchildren() |
202 self.CreateGrid(len(n_list),2) | 186 self.CreateGrid(len(n_list),2) |
203 self.SetRowLabelSize(0) | 187 self.SetRowLabelSize(0) |
204 self.SetColLabelSize(0) | 188 self.SetColLabelSize(0) |
205 self.n_list = n_list | 189 self.n_list = n_list |
206 i = 0 | 190 i = 0 |
207 for i in range(len(n_list)): | 191 for i in range(len(n_list)): self.refresh_row(i) |
208 self.refresh_row(i) | |
209 | 192 |
210 def on_cell_change(self,evt): | 193 def on_cell_change(self,evt): |
211 row = evt.GetRow() | 194 row = evt.GetRow() |
212 col = evt.GetCol() | 195 col = evt.GetCol() |
213 value = self.GetCellValue(row,col) | 196 value = self.GetCellValue(row,col) |
214 t_node = self.n_list[row] | 197 t_node = self.n_list[row] |
215 t_node.text = value | 198 t_node.text = value |
216 if row==0: | 199 if row==0: self.handler.on_name_change(value) |
217 self.handler.on_name_change(value) | |
218 #self.AutoSizeColumn(1) | |
219 | 200 |
220 def refresh_row(self, rowi): | 201 def refresh_row(self, rowi): |
221 self.SetCellValue(rowi, 0, self.n_list[rowi].tag) | 202 self.SetCellValue(rowi, 0, self.n_list[rowi].tag) |
222 self.SetReadOnly(rowi, 0) | 203 self.SetReadOnly(rowi, 0) |
223 self.SetCellValue(rowi, 1, self.n_list[rowi].text) | 204 self.SetCellValue(rowi, 1, self.n_list[rowi].text) |
248 return html_str | 229 return html_str |
249 | 230 |
250 class inventory_pane(wx.Panel): | 231 class inventory_pane(wx.Panel): |
251 def __init__(self, parent, handler): | 232 def __init__(self, parent, handler): |
252 wx.Panel.__init__(self, parent, wx.ID_ANY) | 233 wx.Panel.__init__(self, parent, wx.ID_ANY) |
253 | |
254 self.n_list = handler.xml.getchildren() | 234 self.n_list = handler.xml.getchildren() |
255 self.autosize = False | 235 self.autosize = False |
256 | 236 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventory"), wx.VERTICAL) |
257 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventroy"), wx.VERTICAL) | |
258 | |
259 self.lang = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Languages") | 237 self.lang = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Languages") |
260 self.gear = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Gear") | 238 self.gear = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Gear") |
261 self.magic = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Magic") | 239 self.magic = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Magic") |
262 self.grid = wx.grid.Grid(self, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 240 self.grid = wx.grid.Grid(self, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
263 | |
264 self.grid.CreateGrid(len(self.n_list)-3,2) | 241 self.grid.CreateGrid(len(self.n_list)-3,2) |
265 self.grid.SetRowLabelSize(0) | 242 self.grid.SetRowLabelSize(0) |
266 self.grid.SetColLabelSize(0) | 243 self.grid.SetColLabelSize(0) |
267 | 244 for i in xrange(len(self.n_list)): self.refresh_row(i) |
268 for i in xrange(len(self.n_list)): | |
269 self.refresh_row(i) | |
270 | |
271 sizer1 = wx.BoxSizer(wx.HORIZONTAL) | 245 sizer1 = wx.BoxSizer(wx.HORIZONTAL) |
272 sizer1.Add(self.grid, 1, wx.EXPAND) | 246 sizer1.Add(self.grid, 1, wx.EXPAND) |
273 sizer1.Add(self.lang, 1, wx.EXPAND) | 247 sizer1.Add(self.lang, 1, wx.EXPAND) |
274 | |
275 self.sizer.Add(sizer1, 0, wx.EXPAND) | 248 self.sizer.Add(sizer1, 0, wx.EXPAND) |
276 | |
277 sizer2 = wx.BoxSizer(wx.HORIZONTAL) | 249 sizer2 = wx.BoxSizer(wx.HORIZONTAL) |
278 sizer2.Add(self.gear, 1, wx.EXPAND) | 250 sizer2.Add(self.gear, 1, wx.EXPAND) |
279 sizer2.Add(self.magic, 1, wx.EXPAND) | 251 sizer2.Add(self.magic, 1, wx.EXPAND) |
280 | |
281 self.sizer.Add(sizer2, 1, wx.EXPAND) | 252 self.sizer.Add(sizer2, 1, wx.EXPAND) |
282 | |
283 self.SetSizer(self.sizer) | 253 self.SetSizer(self.sizer) |
284 self.SetAutoLayout(True) | 254 self.SetAutoLayout(True) |
285 self.Fit() | 255 self.Fit() |
286 | |
287 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.lang) | 256 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.lang) |
288 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.gear) | 257 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.gear) |
289 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.magic) | 258 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.magic) |
290 self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.on_cell_change, self.grid) | 259 self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.on_cell_change, self.grid) |
291 | 260 |
292 | |
293 def fillTextNode(self, name, value): | 261 def fillTextNode(self, name, value): |
294 if name == 'Languages': | 262 if name == 'Languages': self.lang.SetValue(value) |
295 self.lang.SetValue(value) | 263 elif name == 'Gear': self.gear.SetValue(value) |
296 elif name == 'Gear': | 264 elif name == 'Magic': self.magic.SetValue(value) |
297 self.gear.SetValue(value) | |
298 elif name == 'Magic': | |
299 self.magic.SetValue(value) | |
300 | 265 |
301 def onTextNodeChange(self, event): | 266 def onTextNodeChange(self, event): |
302 id = event.GetId() | 267 id = event.GetId() |
303 | |
304 if id == self.gear.GetId(): | 268 if id == self.gear.GetId(): |
305 nodeName = 'Gear' | 269 nodeName = 'Gear' |
306 value = self.gear.GetValue() | 270 value = self.gear.GetValue() |
307 elif id == self.magic.GetId(): | 271 elif id == self.magic.GetId(): |
308 nodeName = 'Magic' | 272 nodeName = 'Magic' |
309 value = self.magic.GetValue() | 273 value = self.magic.GetValue() |
310 elif id == self.lang.GetId(): | 274 elif id == self.lang.GetId(): |
311 nodeName = 'Languages' | 275 nodeName = 'Languages' |
312 value = self.lang.GetValue() | 276 value = self.lang.GetValue() |
313 | |
314 for node in self.n_list: | 277 for node in self.n_list: |
315 if node._get_tagName() == nodeName: | 278 if node._get_tagName() == nodeName: node.text = value |
316 node.text = value | |
317 | 279 |
318 def saveMoney(self, row, col): | 280 def saveMoney(self, row, col): |
319 value = self.grid.GetCellValue(row, col) | 281 value = self.grid.GetCellValue(row, col) |
320 self.n_list[row].text = value | 282 self.n_list[row].text = value |
321 | 283 |
323 row = evt.GetRow() | 285 row = evt.GetRow() |
324 col = evt.GetCol() | 286 col = evt.GetCol() |
325 self.grid.AutoSizeColumn(col) | 287 self.grid.AutoSizeColumn(col) |
326 wx.CallAfter(self.saveMoney, row, col) | 288 wx.CallAfter(self.saveMoney, row, col) |
327 | 289 |
328 | |
329 | |
330 def refresh_row(self, row): | 290 def refresh_row(self, row): |
331 tagname = self.n_list[row].tag | 291 tagname = self.n_list[row].tag |
332 value = self.n_list[row].text | 292 value = self.n_list[row].text |
333 if tagname == 'Gear': | 293 if tagname == 'Gear': self.fillTextNode(tagname, value) |
334 self.fillTextNode(tagname, value) | 294 elif tagname == 'Magic': self.fillTextNode(tagname, value) |
335 elif tagname == 'Magic': | 295 elif tagname == 'Languages': self.fillTextNode(tagname, value) |
336 self.fillTextNode(tagname, value) | |
337 elif tagname == 'Languages': | |
338 self.fillTextNode(tagname, value) | |
339 else: | 296 else: |
340 self.grid.SetCellValue(row, 0, tagname) | 297 self.grid.SetCellValue(row, 0, tagname) |
341 self.grid.SetReadOnly(row, 0) | 298 self.grid.SetReadOnly(row, 0) |
342 self.grid.SetCellValue(row, 1, value) | 299 self.grid.SetCellValue(row, 1, value) |
343 self.grid.AutoSize() | 300 self.grid.AutoSize() |
356 self.new_child_handler('abilities','Abilities Scores',dnd35ability,'gear') | 313 self.new_child_handler('abilities','Abilities Scores',dnd35ability,'gear') |
357 self.new_child_handler('classes','Classes',dnd35classes,'knight') | 314 self.new_child_handler('classes','Classes',dnd35classes,'knight') |
358 self.new_child_handler('saves','Saves',dnd35saves,'skull') | 315 self.new_child_handler('saves','Saves',dnd35saves,'skull') |
359 self.myeditor = None | 316 self.myeditor = None |
360 | 317 |
361 | |
362 def new_child_handler(self,tag,text,handler_class,icon='gear'): | 318 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
363 node_list = self.xml.findall(tag) | 319 node_list = self.xml.findall(tag) |
364 tree = self.tree | 320 tree = self.tree |
365 i = self.tree.icons[icon] | 321 i = self.tree.icons[icon] |
366 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i) | 322 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i) |
368 tree.SetPyData(new_tree_node,handler) | 324 tree.SetPyData(new_tree_node,handler) |
369 self.child_handlers[tag] = handler | 325 self.child_handlers[tag] = handler |
370 | 326 |
371 def get_design_panel(self,parent): | 327 def get_design_panel(self,parent): |
372 return tabbed_panel(parent,self,1) | 328 return tabbed_panel(parent,self,1) |
373 | |
374 | 329 |
375 def get_use_panel(self,parent): | 330 def get_use_panel(self,parent): |
376 return tabbed_panel(parent,self,2) | 331 return tabbed_panel(parent,self,2) |
377 | 332 |
378 class class_char_child(node_handler): | 333 class class_char_child(node_handler): |
429 for n in node_list: | 384 for n in node_list: |
430 name = n.get('abbr') | 385 name = n.get('abbr') |
431 self.abilities[name] = n | 386 self.abilities[name] = n |
432 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] ) | 387 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] ) |
433 tree.SetPyData( new_tree_node, self ) | 388 tree.SetPyData( new_tree_node, self ) |
434 #print "dnd35ability - init self.abilities",self.abilities #a (debug) 1.5002 | |
435 | 389 |
436 def on_rclick( self, evt ): | 390 def on_rclick( self, evt ): |
437 item = self.tree.GetSelection() | 391 item = self.tree.GetSelection() |
438 name = self.tree.GetItemText( item ) | 392 name = self.tree.GetItemText( item ) |
439 #if item == self.mytree_node: #d 1.6016 | |
440 # dnd35_char_child.on_ldclick( self, evt ) #d 1.6016 | |
441 if not item == self.mytree_node: #a 1.6016 | 393 if not item == self.mytree_node: #a 1.6016 |
442 #else: #d 1.6016 | |
443 mod = self.get_mod( name ) | 394 mod = self.get_mod( name ) |
444 if mod >= 0: | 395 if mod >= 0: mod1 = "+" |
445 mod1 = "+" | 396 else: mod1 = "" |
446 else: | |
447 mod1 = "" | |
448 chat = self.chat | 397 chat = self.chat |
449 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) | 398 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod ) |
450 chat.ParsePost( txt, True, True ) | 399 chat.ParsePost( txt, True, True ) |
451 | 400 |
452 def get_mod(self,abbr): | 401 def get_mod(self,abbr): |
454 mod = (score - 10) / 2 | 403 mod = (score - 10) / 2 |
455 mod = int(mod) | 404 mod = int(mod) |
456 return mod | 405 return mod |
457 | 406 |
458 def set_score(self,abbr,score): | 407 def set_score(self,abbr,score): |
459 if score >= 0: | 408 if score >= 0: self.abilities[abbr].set("base",str(score)) |
460 self.abilities[abbr].set("base",str(score)) | |
461 | 409 |
462 def get_design_panel(self,parent): | 410 def get_design_panel(self,parent): |
463 wnd = outline_panel(parent,self,abil_grid,"Abilities") | 411 wnd = outline_panel(parent,self,abil_grid,"Abilities") |
464 wnd.title = "Abilities (edit)" | 412 wnd.title = "Abilities (edit)" |
465 return wnd | 413 return wnd |
471 for n in node_list: | 419 for n in node_list: |
472 name = n.get('name') | 420 name = n.get('name') |
473 abbr = n.get('abbr') | 421 abbr = n.get('abbr') |
474 base = n.get('base') | 422 base = n.get('base') |
475 mod = str(self.get_mod(abbr)) | 423 mod = str(self.get_mod(abbr)) |
476 if int(mod) >= 0: #m 1.6013 added "int(" and ")" | 424 if int(mod) >= 0: mod1 = "+" |
477 mod1 = "+" | 425 else: mod1 = "" |
478 else: | |
479 mod1 = "" | |
480 html_str = (html_str + "<tr ALIGN='center'><td>"+ | 426 html_str = (html_str + "<tr ALIGN='center'><td>"+ |
481 name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod)) | 427 name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod)) |
482 html_str = html_str + "</table>" | 428 html_str = html_str + "</table>" |
483 return html_str | 429 return html_str |
484 | 430 |
486 """grid for abilities""" | 432 """grid for abilities""" |
487 def __init__(self, parent, handler): | 433 def __init__(self, parent, handler): |
488 pname = handler.xml.set("name", 'Stats') | 434 pname = handler.xml.set("name", 'Stats') |
489 self.hparent = handler #a 1.5002 allow ability to run up tree. | 435 self.hparent = handler #a 1.5002 allow ability to run up tree. |
490 self.root = getRoot(self) | 436 self.root = getRoot(self) |
491 #a 1.5002 in this case, we need the functional parent, not the invoking parent. | |
492 | |
493 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 437 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
494 self.Bind(wx.EVT_SIZE, self.on_size) | 438 self.Bind(wx.EVT_SIZE, self.on_size) |
495 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 439 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
496 self.handler = handler | 440 self.handler = handler |
497 stats = handler.xml.findall('stat') | 441 stats = handler.xml.findall('stat') |
498 self.CreateGrid(len(stats),3) | 442 self.CreateGrid(len(stats),3) |
499 self.SetRowLabelSize(0) | 443 self.SetRowLabelSize(0) |
500 col_names = ['Ability','Score','Modifier'] | 444 col_names = ['Ability','Score','Modifier'] |
501 for i in range(len(col_names)): | 445 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
502 self.SetColLabelValue(i,col_names[i]) | |
503 self.stats = stats | 446 self.stats = stats |
504 i = 0 | 447 i = 0 |
505 for i in range(len(stats)): | 448 for i in range(len(stats)): self.refresh_row(i) |
506 self.refresh_row(i) | |
507 self.char_wnd = None | 449 self.char_wnd = None |
508 | 450 |
509 def on_cell_change(self,evt): | 451 def on_cell_change(self,evt): |
510 row = evt.GetRow() | 452 row = evt.GetRow() |
511 col = evt.GetCol() | 453 col = evt.GetCol() |
512 value = self.GetCellValue(row,col) | 454 value = self.GetCellValue(row,col) |
513 #print value | |
514 try: | 455 try: |
515 int(value) | 456 int(value) |
516 self.stats[row].set('base',value) | 457 self.stats[row].set('base',value) |
517 self.refresh_row(row) | 458 self.refresh_row(row) |
518 except: | 459 except: |
519 self.SetCellValue(row,col,"0") | 460 self.SetCellValue(row,col,"0") |
520 if self.char_wnd: | 461 if self.char_wnd: self.char_wnd.refresh_data() |
521 self.char_wnd.refresh_data() | |
522 | |
523 #mark5 | |
524 | 462 |
525 def refresh_row(self,rowi): | 463 def refresh_row(self,rowi): |
526 s = self.stats[rowi] | 464 s = self.stats[rowi] |
527 | |
528 name = s.get('name') | 465 name = s.get('name') |
529 abbr = s.get('abbr') | 466 abbr = s.get('abbr') |
530 self.SetCellValue(rowi,0,name) | 467 self.SetCellValue(rowi,0,name) |
531 self.SetReadOnly(rowi,0) | 468 self.SetReadOnly(rowi,0) |
532 self.SetCellValue(rowi,1,s.get('base')) | 469 self.SetCellValue(rowi,1,s.get('base')) |
533 self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr))) | 470 self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr))) |
534 self.SetReadOnly(rowi,2) | 471 self.SetReadOnly(rowi,2) |
535 #if self.root.saves.saveGrid: #a 1.6018 d 1.9002 whole if clause | |
536 #print getmembers(self.root.saves.saveGrid) | |
537 #self.root.saves.saveGrid.refresh_data() #a 1.6018 | |
538 #print "skipping saving throw update, put back in later" | |
539 self.root.saves.refresh_data() #a 1.9002 | 472 self.root.saves.refresh_data() #a 1.9002 |
540 self.root.attacks.refreshMRdata() #a 1.9001 ` | 473 self.root.attacks.refreshMRdata() #a 1.9001 ` |
541 | 474 |
542 def on_size(self,evt): | 475 def on_size(self,evt): |
543 (w,h) = self.GetClientSizeTuple() | 476 (w,h) = self.GetClientSizeTuple() |
544 cols = self.GetNumberCols() | 477 cols = self.GetNumberCols() |
545 col_w = w/(cols+2) | 478 col_w = w/(cols+2) |
546 self.SetColSize(0,col_w*3) | 479 self.SetColSize(0,col_w*3) |
547 for i in range(1,cols): | 480 for i in range(1,cols): self.SetColSize(i,col_w) |
548 self.SetColSize(i,col_w) | |
549 evt.Skip() | 481 evt.Skip() |
550 self.Refresh() | 482 self.Refresh() |
551 | 483 |
552 def refresh_data(self): | 484 def refresh_data(self): |
553 for r in range(self.GetNumberRows()-1): | 485 for r in range(self.GetNumberRows()-1): self.refresh_row(r) |
554 self.refresh_row(r) | |
555 | 486 |
556 class dnd35classes(class_char_child): | 487 class dnd35classes(class_char_child): |
557 """ Node Handler for classes. This handler will be | 488 """ Node Handler for classes. This handler will be |
558 created by dnd35char_handler. | 489 created by dnd35char_handler. |
559 """ | 490 """ |
560 def __init__(self,xml_dom,tree_node,parent): | 491 def __init__(self,xml_dom,tree_node,parent): |
561 class_char_child.__init__(self,xml_dom,tree_node,parent) | 492 class_char_child.__init__(self,xml_dom,tree_node,parent) |
562 self.hparent = parent #a 1.5002 allow ability to run up tree. | 493 self.hparent = parent #a 1.5002 allow ability to run up tree. |
563 self.root = getRoot(self) | 494 self.root = getRoot(self) |
564 self.root.classes = self | 495 self.root.classes = self |
565 #a 1.5002 in this case, we need the functional parent, not the invoking parent. | |
566 | 496 |
567 def get_design_panel(self,parent): | 497 def get_design_panel(self,parent): |
568 wnd = outline_panel(parent,self,class_panel,"Classes") | 498 wnd = outline_panel(parent,self,class_panel,"Classes") |
569 wnd.title = "Classes" | 499 wnd.title = "Classes" |
570 return wnd | 500 return wnd |
571 | 501 |
572 def tohtml(self): | 502 def tohtml(self): |
573 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>" | 503 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>" |
574 n_list = self.xml.getchildren() | 504 n_list = self.xml.getchildren() |
575 for n in n_list: | 505 for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), " |
576 html_str += n.get('name') + " ("+n.get('level')+"), " | |
577 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 506 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
578 return html_str | 507 return html_str |
579 | 508 |
580 def get_char_lvl( self, attr ): | 509 def get_char_lvl( self, attr ): |
581 node_list = self.xml.findall('class') | 510 node_list = self.xml.findall('class') |
582 # print "eclasses - get_char_lvl node_list",node_list | |
583 tot = 0 #a 1.5009 actually, slipping in a quick enhancement ;-) | 511 tot = 0 #a 1.5009 actually, slipping in a quick enhancement ;-) |
584 for n in node_list: | 512 for n in node_list: |
585 lvl = n.get('level') #o 1.5009 not sure of the value of this | 513 lvl = n.get('level') |
586 tot += int(lvl) #a 1.5009 | 514 tot += int(lvl) |
587 type = n.get('name') #o 1.5009 not sure of the value of this | 515 type = n.get('name') |
588 #print type,lvl #a (debug) 1.5009 | 516 if attr == "level": return lvl |
589 if attr == "level": | 517 elif attr == "class": return type |
590 return lvl #o 1.5009 this returns the level of someone's first class. ??? | 518 if attr == "lvl": return tot |
591 elif attr == "class": | 519 |
592 return type #o 1.5009 this returns one of the char's classes. ??? | 520 def get_class_lvl( self, classN ): |
593 if attr == "lvl": #a 1.5009 this has value, adding this. | |
594 return tot #a 1.5009 return character's "overall" level. | |
595 | |
596 def get_class_lvl( self, classN ): #a 1.5009 need to be able to get monk lvl | |
597 #a 1.5009 this function is new. | |
598 node_list = self.xml.findall('class') | 521 node_list = self.xml.findall('class') |
599 #print "eclasses - get_class_lvl node_list",node_list | |
600 for n in node_list: | 522 for n in node_list: |
601 lvl = n.get('level') | 523 lvl = n.get('level') |
602 type = n.get('name') | 524 type = n.get('name') |
603 if classN == type: | 525 if classN == type: return lvl |
604 return lvl | |
605 | 526 |
606 class class_panel(wx.Panel): | 527 class class_panel(wx.Panel): |
607 def __init__(self, parent, handler): | 528 def __init__(self, parent, handler): |
608 pname = handler.xml.set("name", 'Class') | 529 pname = handler.xml.set("name", 'Class') |
609 | |
610 wx.Panel.__init__(self, parent, -1) | 530 wx.Panel.__init__(self, parent, -1) |
611 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 531 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
612 sizer = wx.BoxSizer(wx.VERTICAL) | 532 sizer = wx.BoxSizer(wx.VERTICAL) |
613 sizer.Add(self.grid, 1, wx.EXPAND) | 533 sizer.Add(self.grid, 1, wx.EXPAND) |
614 | 534 |
633 self.grid.CreateGrid(len(n_list),3,1) | 553 self.grid.CreateGrid(len(n_list),3,1) |
634 self.grid.SetRowLabelSize(0) | 554 self.grid.SetRowLabelSize(0) |
635 self.grid.SetColLabelValue(0,"Class") | 555 self.grid.SetColLabelValue(0,"Class") |
636 self.grid.SetColLabelValue(1,"Level") | 556 self.grid.SetColLabelValue(1,"Level") |
637 self.grid.SetColLabelValue(2,"Refrence") | 557 self.grid.SetColLabelValue(2,"Refrence") |
638 for i in range(len(n_list)): | 558 for i in range(len(n_list)): self.refresh_row(i) |
639 self.refresh_row(i) | |
640 self.temp_dom = None | 559 self.temp_dom = None |
641 | 560 |
642 def on_cell_change(self,evt): | 561 def on_cell_change(self,evt): |
643 row = evt.GetRow() | 562 row = evt.GetRow() |
644 col = evt.GetCol() | 563 col = evt.GetCol() |
645 value = self.grid.GetCellValue(row,col) | 564 value = self.grid.GetCellValue(row,col) |
646 try: | 565 try: |
647 int(value) | 566 int(value) |
648 self.n_list[row].set('level',value) | 567 self.n_list[row].set('level',value) |
649 except: | 568 except: self.grid.SetCellValue(row,col,"1") |
650 self.grid.SetCellValue(row,col,"1") | |
651 | 569 |
652 | 570 |
653 def refresh_row(self,i): | 571 def refresh_row(self,i): |
654 n = self.n_list[i] | 572 n = self.n_list[i] |
655 | |
656 name = n.get('name') | 573 name = n.get('name') |
657 level = n.get('level') | 574 level = n.get('level') |
658 book = n.get('book') | 575 book = n.get('book') |
659 self.grid.SetCellValue(i,0,name) | 576 self.grid.SetCellValue(i,0,name) |
660 self.grid.SetReadOnly(i,0) | 577 self.grid.SetReadOnly(i,0) |
677 tree = parse(dir_struct["dnd35"]+"dnd35classes.xml") | 594 tree = parse(dir_struct["dnd35"]+"dnd35classes.xml") |
678 xml_dom = tree.getroot() | 595 xml_dom = tree.getroot() |
679 self.temp_dom = xml_dom | 596 self.temp_dom = xml_dom |
680 f_list = self.temp_dom.findall('class') | 597 f_list = self.temp_dom.findall('class') |
681 opts = [] | 598 opts = [] |
682 for f in f_list: | 599 for f in f_list: opts.append(f.get('name')) |
683 opts.append(f.get('name')) | |
684 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) | 600 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts) |
685 if dlg.ShowModal() == wx.ID_OK: | 601 if dlg.ShowModal() == wx.ID_OK: |
686 i = dlg.GetSelection() | 602 i = dlg.GetSelection() |
687 new_node = self.xml.append(f_list[i]) | 603 new_node = self.xml.append(f_list[i]) |
688 self.grid.AppendRows(1) | 604 self.grid.AppendRows(1) |
689 self.refresh_row(self.grid.GetNumberRows()-1) | 605 self.refresh_row(self.grid.GetNumberRows()-1) |
690 dlg.Destroy() | 606 dlg.Destroy() |
691 | 607 |
692 | |
693 def on_size(self,event): | 608 def on_size(self,event): |
694 s = self.GetClientSizeTuple() | 609 s = self.GetClientSizeTuple() |
695 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 610 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
696 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 611 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
697 (w,h) = self.grid.GetClientSizeTuple() | 612 (w,h) = self.grid.GetClientSizeTuple() |
698 cols = self.grid.GetNumberCols() | 613 cols = self.grid.GetNumberCols() |
699 col_w = w/(cols) | 614 col_w = w/(cols) |
700 for i in range(0,cols): | 615 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
701 self.grid.SetColSize(i,col_w) | |
702 | 616 |
703 | 617 |
704 class dnd35saves(class_char_child): | 618 class dnd35saves(class_char_child): |
705 """ Node Handler for saves. This handler will be | 619 """ Node Handler for saves. This handler will be |
706 created by dnd35char_handler. | 620 created by dnd35char_handler. |
707 """ | 621 """ |
708 def __init__(self,xml_dom,tree_node,parent): | 622 def __init__(self,xml_dom,tree_node,parent): |
709 class_char_child.__init__(self,xml_dom,tree_node,parent) | 623 class_char_child.__init__(self,xml_dom,tree_node,parent) |
710 self.hparent = parent #a 1.5002 allow ability to run up tree. | 624 self.hparent = parent #a 1.5002 allow ability to run up tree. |
711 #self.saveGrid = None #a 1.6018 d 1.9002 | |
712 self.saveGridFrame = [] #a 1.9002 handle list, check frame for close. | 625 self.saveGridFrame = [] #a 1.9002 handle list, check frame for close. |
713 | 626 |
714 tree = self.tree | 627 tree = self.tree |
715 icons = self.tree.icons | 628 icons = self.tree.icons |
716 | 629 |
728 def refresh_data(self): # refresh the data in the melee/ranged section | 641 def refresh_data(self): # refresh the data in the melee/ranged section |
729 # of the attack chart. | 642 # of the attack chart. |
730 # count backwards, maintains context despite "removes" | 643 # count backwards, maintains context despite "removes" |
731 for i in range(len(self.saveGridFrame)-1,-1,-1): | 644 for i in range(len(self.saveGridFrame)-1,-1,-1): |
732 x = self.saveGridFrame[i] | 645 x = self.saveGridFrame[i] |
733 if x == None: | 646 if x == None: x.refresh_data() |
734 x.refresh_data() | 647 else: self.saveGridFrame.remove(x) |
735 else: | |
736 self.saveGridFrame.remove(x) | |
737 | 648 |
738 def get_mod(self,name): | 649 def get_mod(self,name): |
739 save = self.saves[name] | 650 save = self.saves[name] |
740 stat = save.get('stat') | 651 stat = save.get('stat') |
741 #print "dnd35saves, get_mod: self,root",self,self.root #a (debug) 1.5002 | 652 stat_mod = self.root.abilities.get_mod(stat) |
742 #print "and abilities",self.root.abilities #a (debug) 1.5002 | |
743 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 | |
744 base = int(save.get('base')) | 653 base = int(save.get('base')) |
745 miscmod = int(save.get('miscmod')) | 654 miscmod = int(save.get('miscmod')) |
746 magmod = int(save.get('magmod')) | 655 magmod = int(save.get('magmod')) |
747 total = stat_mod + base + miscmod + magmod | 656 total = stat_mod + base + miscmod + magmod |
748 return total | 657 return total |
752 item = self.tree.GetSelection() | 661 item = self.tree.GetSelection() |
753 name = self.tree.GetItemText(item) | 662 name = self.tree.GetItemText(item) |
754 if item == self.mytree_node: | 663 if item == self.mytree_node: |
755 pass #a 1.5003 syntatic place holder | 664 pass #a 1.5003 syntatic place holder |
756 return #a 1.5003 | 665 return #a 1.5003 |
757 #print "failure mode!" | |
758 #dnd35_char_child.on_ldclick(self,evt) #d 1.5003 this busted | |
759 #wnd = save_grid(self.frame.note,self) | |
760 #wnd.title = "Saves" | |
761 #self.frame.add_panel(wnd) | |
762 else: | 666 else: |
763 mod = self.get_mod(name) | 667 mod = self.get_mod(name) |
764 if mod >= 0: | 668 if mod >= 0: mod1 = "+" |
765 mod1 = "+" | 669 else: mod1 = "" |
766 else: | |
767 mod1 = "" | |
768 chat = self.chat | 670 chat = self.chat |
769 txt = '%s save: [1d20%s%s]' % (name, mod1, mod) | 671 txt = '%s save: [1d20%s%s]' % (name, mod1, mod) |
770 chat.ParsePost( txt, True, True ) | 672 chat.ParsePost( txt, True, True ) |
771 | 673 |
772 def get_design_panel(self,parent): | 674 def get_design_panel(self,parent): |
783 for n in node_list: | 685 for n in node_list: |
784 name = n.get('name') | 686 name = n.get('name') |
785 stat = n.get('stat') | 687 stat = n.get('stat') |
786 base = n.get('base') | 688 base = n.get('base') |
787 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>" | 689 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>" |
788 #stat_mod = str(dnd_globals["stats"][stat]) #d 1.5002 | |
789 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 | 690 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 |
790 | |
791 mag = n.get('magmod') | 691 mag = n.get('magmod') |
792 misc = n.get('miscmod') | 692 misc = n.get('miscmod') |
793 mod = str(self.get_mod(name)) | 693 mod = str(self.get_mod(name)) |
794 if mod >= 0: | 694 if mod >= 0: mod1 = "+" |
795 mod1 = "+" | 695 else: mod1 = "" |
796 else: | |
797 mod1 = "" | |
798 #m 1.5009 next line. added str() around stat_mod | |
799 html_str = html_str + "<td>"+str(stat_mod)+"</td><td>"+mag+"</td>" | 696 html_str = html_str + "<td>"+str(stat_mod)+"</td><td>"+mag+"</td>" |
800 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) | 697 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod) |
801 html_str = html_str + "</table>" | 698 html_str = html_str + "</table>" |
802 return html_str | 699 return html_str |
803 | 700 |
807 def __init__(self, parent, handler): | 704 def __init__(self, parent, handler): |
808 pname = handler.xml.set("name", 'Saves') | 705 pname = handler.xml.set("name", 'Saves') |
809 self.hparent = handler #a 1.5002 allow ability to run up tree. | 706 self.hparent = handler #a 1.5002 allow ability to run up tree. |
810 #a 1.5002 in this case, we need the functional parent, not the invoking parent. | 707 #a 1.5002 in this case, we need the functional parent, not the invoking parent. |
811 self.root = getRoot(self) | 708 self.root = getRoot(self) |
812 | |
813 #self.hparent.saveGrid = self #a 1.6018 d 1.9001 | |
814 | |
815 | |
816 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 709 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
817 self.Bind(wx.EVT_SIZE, self.on_size) | 710 self.Bind(wx.EVT_SIZE, self.on_size) |
818 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 711 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
819 self.handler = handler | 712 self.handler = handler |
820 saves = handler.xml.findall('save') | 713 saves = handler.xml.findall('save') |
821 self.CreateGrid(len(saves),7) | 714 self.CreateGrid(len(saves),7) |
822 self.SetRowLabelSize(0) | 715 self.SetRowLabelSize(0) |
823 col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] | 716 col_names = ['Save','Key','base','Abil','Magic','Misc','Total'] |
824 for i in range(len(col_names)): | 717 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
825 self.SetColLabelValue(i,col_names[i]) | |
826 self.saves = saves | 718 self.saves = saves |
827 i = 0 | 719 i = 0 |
828 for i in range(len(saves)): | 720 for i in range(len(saves)): self.refresh_row(i) |
829 self.refresh_row(i) | |
830 | |
831 | |
832 #a 1.9002 remainder of code in this method. | |
833 climber = parent | 721 climber = parent |
834 nameNode = climber.GetClassName() | 722 nameNode = climber.GetClassName() |
835 while nameNode != 'wxFrame': | 723 while nameNode != 'wxFrame': |
836 climber = climber.parent | 724 climber = climber.parent |
837 nameNode = climber.GetClassName() | 725 nameNode = climber.GetClassName() |
838 masterFrame=climber | 726 masterFrame=climber |
839 masterFrame.refresh_data=self.refresh_data | 727 masterFrame.refresh_data=self.refresh_data |
840 #print getmembers(masterFrame) | |
841 | |
842 handler.saveGridFrame.append(masterFrame) | 728 handler.saveGridFrame.append(masterFrame) |
843 | 729 |
844 def on_cell_change(self,evt): | 730 def on_cell_change(self,evt): |
845 row = evt.GetRow() | 731 row = evt.GetRow() |
846 col = evt.GetCol() | 732 col = evt.GetCol() |
847 value = self.GetCellValue(row,col) | 733 value = self.GetCellValue(row,col) |
848 try: | 734 try: |
849 int(value) | 735 int(value) |
850 if col == 2: | 736 if col == 2: self.saves[row].set('base',value) |
851 self.saves[row].set('base',value) | 737 elif col == 4: self.saves[row].set('magmod',value) |
852 elif col ==4: | 738 elif col == 5: self.saves[row].set('miscmod',value) |
853 self.saves[row].set('magmod',value) | |
854 elif col ==5: # 1.5001 | |
855 self.saves[row].set('miscmod',value) | |
856 self.refresh_row(row) | 739 self.refresh_row(row) |
857 except: | 740 except: self.SetCellValue(row,col,"0") |
858 self.SetCellValue(row,col,"0") | |
859 | 741 |
860 def refresh_row(self,rowi): | 742 def refresh_row(self,rowi): |
861 s = self.saves[rowi] | 743 s = self.saves[rowi] |
862 | |
863 name = s.get('name') | 744 name = s.get('name') |
864 self.SetCellValue(rowi,0,name) | 745 self.SetCellValue(rowi,0,name) |
865 self.SetReadOnly(rowi,0) | 746 self.SetReadOnly(rowi,0) |
866 stat = s.get('stat') | 747 stat = s.get('stat') |
867 self.SetCellValue(rowi,1,stat) | 748 self.SetCellValue(rowi,1,stat) |
878 def on_size(self,evt): | 759 def on_size(self,evt): |
879 (w,h) = self.GetClientSizeTuple() | 760 (w,h) = self.GetClientSizeTuple() |
880 cols = self.GetNumberCols() | 761 cols = self.GetNumberCols() |
881 col_w = w/(cols+2) | 762 col_w = w/(cols+2) |
882 self.SetColSize(0,col_w*3) | 763 self.SetColSize(0,col_w*3) |
883 for i in range(1,cols): | 764 for i in range(1,cols): self.SetColSize(i,col_w) |
884 self.SetColSize(i,col_w) | |
885 evt.Skip() | 765 evt.Skip() |
886 self.Refresh() | 766 self.Refresh() |
887 | 767 |
888 def refresh_data(self): | 768 def refresh_data(self): |
889 for r in range(self.GetNumberRows()): | 769 for r in range(self.GetNumberRows()): self.refresh_row(r) |
890 self.refresh_row(r) | |
891 | 770 |
892 class dnd35skillsnfeats(dnd35_char_child): | 771 class dnd35skillsnfeats(dnd35_char_child): |
893 """ Node handler for a dnd35 charactor | 772 """ Node handler for a dnd35 charactor |
894 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' /> | 773 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' /> |
895 """ | 774 """ |
896 def __init__(self,xml_dom,tree_node,parent): | 775 def __init__(self,xml_dom,tree_node,parent): |
897 self.hparent = parent #a 1.5002 allow ability to run up tree. | 776 self.hparent = parent #a 1.5002 allow ability to run up tree. |
898 self.root = getRoot(self) #a 1.6009 | 777 self.root = getRoot(self) #a 1.6009 |
899 | |
900 node_handler.__init__(self,xml_dom,tree_node) | 778 node_handler.__init__(self,xml_dom,tree_node) |
901 dnd35_char_child.__init__(self,xml_dom,tree_node,parent) | 779 dnd35_char_child.__init__(self,xml_dom,tree_node,parent) |
902 self.frame = component.get('frame') | 780 self.frame = component.get('frame') |
903 self.child_handlers = {} | 781 self.child_handlers = {} |
904 self.new_child_handler('skills','Skills',dnd35skill,'book') | 782 self.new_child_handler('skills','Skills',dnd35skill,'book') |
905 self.new_child_handler('feats','Feats',dnd35feats,'book') | 783 self.new_child_handler('feats','Feats',dnd35feats,'book') |
906 self.myeditor = None | 784 self.myeditor = None |
907 | |
908 | 785 |
909 def new_child_handler(self,tag,text,handler_class,icon='gear'): | 786 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
910 node_list = self.xml.findall(tag) | 787 node_list = self.xml.findall(tag) |
911 tree = self.tree | 788 tree = self.tree |
912 i = self.tree.icons[icon] | 789 i = self.tree.icons[icon] |
915 tree.SetPyData(new_tree_node,handler) | 792 tree.SetPyData(new_tree_node,handler) |
916 self.child_handlers[tag] = handler | 793 self.child_handlers[tag] = handler |
917 | 794 |
918 def get_design_panel(self,parent): | 795 def get_design_panel(self,parent): |
919 return tabbed_panel(parent,self,1) | 796 return tabbed_panel(parent,self,1) |
920 | |
921 | 797 |
922 def get_use_panel(self,parent): | 798 def get_use_panel(self,parent): |
923 return tabbed_panel(parent,self,2) | 799 return tabbed_panel(parent,self,2) |
924 | 800 |
925 class skills_char_child(node_handler): | 801 class skills_char_child(node_handler): |
931 self.char_hander = parent | 807 self.char_hander = parent |
932 self.drag = False | 808 self.drag = False |
933 self.frame = component.get('frame') | 809 self.frame = component.get('frame') |
934 self.myeditor = None | 810 self.myeditor = None |
935 | 811 |
936 | |
937 | |
938 def on_drop(self,evt): | 812 def on_drop(self,evt): |
939 pass | 813 pass |
940 | 814 |
941 def on_rclick(self,evt): | 815 def on_rclick(self,evt): |
942 pass | 816 pass |
981 name = n.get('name') | 855 name = n.get('name') |
982 self.skills[name] = n | 856 self.skills[name] = n |
983 skill_check = self.skills[name] | 857 skill_check = self.skills[name] |
984 ranks = int(skill_check.get('rank')) | 858 ranks = int(skill_check.get('rank')) |
985 trained = int(skill_check.get('untrained')) | 859 trained = int(skill_check.get('untrained')) |
986 | |
987 if ranks > 0 or trained == 1: | 860 if ranks > 0 or trained == 1: |
988 new_tree_node = tree.AppendItem(self.mytree_node,name, | 861 new_tree_node = tree.AppendItem(self.mytree_node,name, |
989 icons['gear'],icons['gear']) | 862 icons['gear'],icons['gear']) |
990 else: | 863 else: continue |
991 continue | |
992 | |
993 tree.SetPyData(new_tree_node,self) | 864 tree.SetPyData(new_tree_node,self) |
994 | |
995 | |
996 | 865 |
997 def refresh_skills(self): | 866 def refresh_skills(self): |
998 #Adding this so when you update the grid the tree will reflect | 867 #Adding this so when you update the grid the tree will reflect |
999 #The change. -mgt | 868 #The change. -mgt |
1000 tree = self.tree | 869 tree = self.tree |
1007 name = n.get('name') | 876 name = n.get('name') |
1008 self.skills[name] = n | 877 self.skills[name] = n |
1009 skill_check = self.skills[name] | 878 skill_check = self.skills[name] |
1010 ranks = int(skill_check.get('rank')) | 879 ranks = int(skill_check.get('rank')) |
1011 trained = int(skill_check.get('untrained')) | 880 trained = int(skill_check.get('untrained')) |
1012 | |
1013 if ranks > 0 or trained == 1: | 881 if ranks > 0 or trained == 1: |
1014 new_tree_node = tree.AppendItem(self.mytree_node,name, | 882 new_tree_node = tree.AppendItem(self.mytree_node,name, |
1015 icons['gear'],icons['gear']) | 883 icons['gear'],icons['gear']) |
1016 else: | 884 else: continue |
1017 continue | |
1018 | |
1019 tree.SetPyData(new_tree_node,self) | 885 tree.SetPyData(new_tree_node,self) |
1020 | 886 |
1021 def get_mod(self,name): | 887 def get_mod(self,name): |
1022 skill = self.skills[name] | 888 skill = self.skills[name] |
1023 stat = skill.get('stat') | 889 stat = skill.get('stat') |
1024 #stat_mod = int(dnd_globals["stats"][stat]) #d 1.5002 | |
1025 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 | 890 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 |
1026 rank = int(skill.get('rank')) | 891 rank = int(skill.get('rank')) |
1027 misc = int(skill.get('misc')) | 892 misc = int(skill.get('misc')) |
1028 total = stat_mod + rank + misc | 893 total = stat_mod + rank + misc |
1029 return total | 894 return total |
1030 | 895 |
1031 def on_rclick(self,evt): | 896 def on_rclick(self,evt): |
1032 item = self.tree.GetSelection() | 897 item = self.tree.GetSelection() |
1033 name = self.tree.GetItemText(item) | 898 name = self.tree.GetItemText(item) |
1034 #print "skill rc self",self #a 1.6004 | 899 if item == self.mytree_node: return |
1035 #print "skill rc tree",self.mytree_node #a 1.6004 | |
1036 #print "skill rc item",item #a 1.6004 | |
1037 if item == self.mytree_node: | |
1038 return | |
1039 # following line fails, | |
1040 #dnd35_char_child.on_ldclick(self,evt) #d 1.6014 | |
1041 # it's what it used to try to do. | |
1042 ac = self.root.ac.get_check_pen() #a 1.5002 for 1.5004 verify fix. | 900 ac = self.root.ac.get_check_pen() #a 1.5002 for 1.5004 verify fix. |
1043 | |
1044 skill = self.skills[name] | 901 skill = self.skills[name] |
1045 | |
1046 untr = skill.get('untrained') #a 1.6004 | 902 untr = skill.get('untrained') #a 1.6004 |
1047 rank = skill.get('rank') #a 1.6004 | 903 rank = skill.get('rank') #a 1.6004 |
1048 if eval('%s == 0' % (untr)): #a 1.6004 | 904 if eval('%s == 0' % (untr)): #a 1.6004 |
1049 if eval('%s == 0' % (rank)): #a 1.6004 | 905 if eval('%s == 0' % (rank)): #a 1.6004 |
1050 res = 'You fumble around, accomplishing nothing' #a 1.6004 | 906 res = 'You fumble around, accomplishing nothing' #a 1.6004 |
1051 txt = '%s Skill Check: %s' % (name, res) #a 1.6004 | 907 txt = '%s Skill Check: %s' % (name, res) #a 1.6004 |
1052 chat = self.chat #a 1.6004 | 908 chat = self.chat #a 1.6004 |
1053 chat.Post(txt,True,True) #a 1.6004 | 909 chat.Post(txt,True,True) #a 1.6004 |
1054 return #a 1.6004 | 910 return #a 1.6004 |
1055 | |
1056 armor = '' | 911 armor = '' |
1057 acCp = '' | 912 acCp = '' |
1058 if ac < 0: #acCp >= 1 #m 1.5004 this is stored as negatives. | 913 if ac < 0: #acCp >= 1 #m 1.5004 this is stored as negatives. |
1059 armorCheck = int(skill.get('armorcheck')) | 914 armorCheck = int(skill.get('armorcheck')) |
1060 #print "ac,armorCheck",ac,armorCheck | |
1061 if armorCheck == 1: | 915 if armorCheck == 1: |
1062 acCp=ac | 916 acCp=ac |
1063 armor = '(includes Armor Penalty of %s)' % (acCp) | 917 armor = '(includes Armor Penalty of %s)' % (acCp) |
1064 if item == self.mytree_node: | 918 if item == self.mytree_node: |
1065 dnd35_char_child.on_ldclick(self,evt) | 919 dnd35_char_child.on_ldclick(self,evt) |
1066 #wnd = skill_grid(self.frame.note,self) | |
1067 #wnd.title = "Skills" | |
1068 #self.frame.add_panel(wnd) | |
1069 else: | 920 else: |
1070 mod = self.get_mod(name) | 921 mod = self.get_mod(name) |
1071 if mod >= 0: | 922 if mod >= 0: mod1 = "+" |
1072 mod1 = "+" | 923 else: mod1 = "" |
1073 else: | |
1074 mod1 = "" | |
1075 chat = self.chat | 924 chat = self.chat |
1076 txt = '%s Skill Check: [1d20%s%s%s] %s' % ( | 925 txt = '%s Skill Check: [1d20%s%s%s] %s' % ( |
1077 name, mod1, mod, acCp, armor) | 926 name, mod1, mod, acCp, armor) |
1078 chat.ParsePost(txt,True,True) | 927 chat.ParsePost(txt,True,True) |
1079 | 928 |
1095 untr = n.get('untrained') #a 1.6004 | 944 untr = n.get('untrained') #a 1.6004 |
1096 #Filter unsuable skills out of pretty print -mgt | 945 #Filter unsuable skills out of pretty print -mgt |
1097 if eval('%s > 0' % (rank)) or eval('%s == 1' % (untr)): | 946 if eval('%s > 0' % (rank)) or eval('%s == 1' % (untr)): |
1098 if eval('%s >=1' % (rank)): | 947 if eval('%s >=1' % (rank)): |
1099 html_str += "<tr ALIGN='center' bgcolor='#CCCCFF'><td>" #a 1.6004 | 948 html_str += "<tr ALIGN='center' bgcolor='#CCCCFF'><td>" #a 1.6004 |
1100 #html_str += "<tr ALIGN='center' bgcolor='green'><td>" #d 1.6004 | |
1101 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>" | 949 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>" |
1102 elif eval('%s == 1' % (untr)): #a 1.6004 | 950 elif eval('%s == 1' % (untr)): #a 1.6004 |
1103 html_str += "<tr ALIGN='center' bgcolor='#C0FF40'><td>" #a 1.6004 | 951 html_str += "<tr ALIGN='center' bgcolor='#C0FF40'><td>" #a 1.6004 |
1104 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>" #a 1.6004 | 952 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>" #a 1.6004 |
1105 else: | 953 else: |
1106 html_str += "<tr ALIGN='center'><td>"+name+"</td><td>" | 954 html_str += "<tr ALIGN='center'><td>"+name+"</td><td>" |
1107 html_str += stat+"</td><td>"+rank+"</td>" | 955 html_str += stat+"</td><td>"+rank+"</td>" |
1108 else: | 956 else: continue |
1109 continue | |
1110 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 | 957 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 |
1111 #stat_mod = str(dnd_globals["stats"][stat]) #d 1.5002 | |
1112 misc = n.get('misc') | 958 misc = n.get('misc') |
1113 mod = str(self.get_mod(name)) | 959 mod = str(self.get_mod(name)) |
1114 if mod >= 0: | 960 if mod >= 0: mod1 = "+" |
1115 mod1 = "+" | 961 else: mod1 = "" |
1116 else: | |
1117 mod1 = "" | |
1118 html_str += "<td>"+str(stat_mod)+"</td><td>"+misc #m 1.6009 str() | 962 html_str += "<td>"+str(stat_mod)+"</td><td>"+misc #m 1.6009 str() |
1119 html_str += '</td><td>%s%s</td></tr>' % (mod1, mod) | 963 html_str += '</td><td>%s%s</td></tr>' % (mod1, mod) |
1120 html_str = html_str + "</table>" | 964 html_str = html_str + "</table>" |
1121 return html_str | 965 return html_str |
1122 | 966 |
1131 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 975 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
1132 self.Bind(wx.EVT_SIZE, self.on_size) | 976 self.Bind(wx.EVT_SIZE, self.on_size) |
1133 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 977 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
1134 self.handler = handler | 978 self.handler = handler |
1135 skills = handler.xml.findall('skill') | 979 skills = handler.xml.findall('skill') |
1136 #xelf.stats = dnd_globals["stats"] #d 1.5002 | |
1137 | |
1138 self.CreateGrid(len(skills),6) | 980 self.CreateGrid(len(skills),6) |
1139 self.SetRowLabelSize(0) | 981 self.SetRowLabelSize(0) |
1140 col_names = ['Skill','Key','Rank','Abil','Misc','Total'] | 982 col_names = ['Skill','Key','Rank','Abil','Misc','Total'] |
1141 for i in range(len(col_names)): | 983 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
1142 self.SetColLabelValue(i,col_names[i]) | |
1143 rowi = 0 | 984 rowi = 0 |
1144 self.skills = skills | 985 self.skills = skills |
1145 for i in range(len(skills)): | 986 for i in range(len(skills)): self.refresh_row(i) |
1146 self.refresh_row(i) | |
1147 | 987 |
1148 def on_cell_change(self,evt): | 988 def on_cell_change(self,evt): |
1149 row = evt.GetRow() | 989 row = evt.GetRow() |
1150 col = evt.GetCol() | 990 col = evt.GetCol() |
1151 value = self.GetCellValue(row,col) | 991 value = self.GetCellValue(row,col) |
1152 #print value | |
1153 try: | 992 try: |
1154 int(value) | 993 int(value) |
1155 if col == 2: | 994 if col == 2: self.skills[row].set('rank',value) |
1156 self.skills[row].set('rank',value) | 995 elif col == 4: self.skills[row].set('misc',value) |
1157 elif col ==4: | |
1158 self.skills[row].set('misc',value) | |
1159 self.refresh_row(row) | 996 self.refresh_row(row) |
1160 except: | 997 except: self.SetCellValue(row,col,"0") |
1161 self.SetCellValue(row,col,"0") | |
1162 | |
1163 #call refresh_skills | |
1164 self.handler.refresh_skills() | 998 self.handler.refresh_skills() |
1165 | 999 |
1166 def refresh_row(self,rowi): | 1000 def refresh_row(self,rowi): |
1167 s = self.skills[rowi] | 1001 s = self.skills[rowi] |
1168 name = s.get('name') | 1002 name = s.get('name') |
1171 stat = s.get('stat') | 1005 stat = s.get('stat') |
1172 self.SetCellValue(rowi,1,stat) | 1006 self.SetCellValue(rowi,1,stat) |
1173 self.SetReadOnly(rowi,1) | 1007 self.SetReadOnly(rowi,1) |
1174 self.SetCellValue(rowi,2,s.get('rank')) | 1008 self.SetCellValue(rowi,2,s.get('rank')) |
1175 #self.SetCellValue(rowi,3,str(dnd_globals["stats"][stat])) #d 1.5002 | 1009 #self.SetCellValue(rowi,3,str(dnd_globals["stats"][stat])) #d 1.5002 |
1176 if self.root.abilities: #a 1.5002 sanity check. | 1010 if self.root.abilities: stat_mod=self.root.abilities.get_mod(stat) #a 1.5002 |
1177 stat_mod=self.root.abilities.get_mod(stat) #a 1.5002 | 1011 else: |
1178 else: #a 1.5002 | |
1179 stat_mod = -6 #a 1.5002 this can happen if code is changed so | 1012 stat_mod = -6 #a 1.5002 this can happen if code is changed so |
1180 #a 1.5002 that abilities are not defined prior invokation of init. | |
1181 print "Please advise dnd35 maintainer alert 1.5002 raised" | 1013 print "Please advise dnd35 maintainer alert 1.5002 raised" |
1182 | 1014 |
1183 self.SetCellValue(rowi,3,str(stat_mod)) #a 1.5002 | 1015 self.SetCellValue(rowi,3,str(stat_mod)) #a 1.5002 |
1184 self.SetReadOnly(rowi,3) | 1016 self.SetReadOnly(rowi,3) |
1185 self.SetCellValue(rowi,4,s.get('misc')) | 1017 self.SetCellValue(rowi,4,s.get('misc')) |
1190 def on_size(self,evt): | 1022 def on_size(self,evt): |
1191 (w,h) = self.GetClientSizeTuple() | 1023 (w,h) = self.GetClientSizeTuple() |
1192 cols = self.GetNumberCols() | 1024 cols = self.GetNumberCols() |
1193 col_w = w/(cols+2) | 1025 col_w = w/(cols+2) |
1194 self.SetColSize(0,col_w*3) | 1026 self.SetColSize(0,col_w*3) |
1195 for i in range(1,cols): | 1027 for i in range(1,cols): self.SetColSize(i,col_w) |
1196 self.SetColSize(i,col_w) | |
1197 evt.Skip() | 1028 evt.Skip() |
1198 self.Refresh() | 1029 self.Refresh() |
1199 | 1030 |
1200 def refresh_data(self): | 1031 def refresh_data(self): |
1201 | 1032 for r in range(self.GetNumberRows()): self.refresh_row(r) |
1202 for r in range(self.GetNumberRows()): | |
1203 self.refresh_row(r) | |
1204 | |
1205 | |
1206 | 1033 |
1207 | 1034 |
1208 class dnd35feats(skills_char_child): | 1035 class dnd35feats(skills_char_child): |
1209 """ Node Handler for classes. This handler will be | 1036 """ Node Handler for classes. This handler will be |
1210 created by dnd35char_handler. | 1037 created by dnd35char_handler. |
1217 | 1044 |
1218 | 1045 |
1219 def get_design_panel(self,parent): | 1046 def get_design_panel(self,parent): |
1220 setTitle="Feats - " + self.root.general.charName #a 1.5010 | 1047 setTitle="Feats - " + self.root.general.charName #a 1.5010 |
1221 wnd = outline_panel(parent,self,feat_panel,setTitle) #a 1.5010 | 1048 wnd = outline_panel(parent,self,feat_panel,setTitle) #a 1.5010 |
1222 #wnd = outline_panel(parent,self,feat_panel,"Feats") #d 1.5010 | |
1223 wnd.title = "Feats" #d 1.5010 | 1049 wnd.title = "Feats" #d 1.5010 |
1224 #wnd.title = "Feats - " + self.charName | |
1225 return wnd | 1050 return wnd |
1226 | 1051 |
1227 def tohtml(self): | 1052 def tohtml(self): |
1228 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>" | 1053 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>" |
1229 n_list = self.xml.getchildren() | 1054 n_list = self.xml.getchildren() |
1230 for n in n_list: | 1055 for n in n_list: html_str += n.get('name')+ ", " |
1231 html_str += n.get('name')+ ", " | |
1232 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" | 1056 html_str = html_str[:len(html_str)-2] + "</td></tr></table>" |
1233 return html_str | 1057 return html_str |
1234 | 1058 |
1235 class feat_panel(wx.Panel): | 1059 class feat_panel(wx.Panel): |
1236 def __init__(self, parent, handler): | 1060 def __init__(self, parent, handler): |
1237 | 1061 |
1238 self.hparent = handler #a 1.5002 allow ability to run up tree. | 1062 self.hparent = handler #a 1.5002 allow ability to run up tree. |
1239 #a 1.5002 in this case, we need the functional parent, not the invoking parent. | 1063 |
1240 self.root = getRoot(self) #a 1.5002 | 1064 self.root = getRoot(self) #a 1.5002 |
1241 #tempTitle= 'Feats - ' + self.root.general.charName #a 1.5010 | |
1242 #pname = handler.xml.set("name", tempTitle) #a 1.5010 | |
1243 pname = handler.xml.set("name", 'Feats') #d 1.5010 | 1065 pname = handler.xml.set("name", 'Feats') #d 1.5010 |
1244 | |
1245 wx.Panel.__init__(self, parent, -1) | 1066 wx.Panel.__init__(self, parent, -1) |
1246 self.grid = wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 1067 self.grid = wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
1247 sizer = wx.BoxSizer(wx.VERTICAL) | 1068 sizer = wx.BoxSizer(wx.VERTICAL) |
1248 sizer.Add(self.grid, 1, wx.EXPAND) | 1069 sizer.Add(self.grid, 1, wx.EXPAND) |
1249 | 1070 |
1257 | 1078 |
1258 self.SetSizer(self.sizer) | 1079 self.SetSizer(self.sizer) |
1259 self.SetAutoLayout(True) | 1080 self.SetAutoLayout(True) |
1260 self.Fit() | 1081 self.Fit() |
1261 | 1082 |
1262 #self.Bind(wx.EVT_SIZE, self.on_size) | |
1263 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) | 1083 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) |
1264 self.Bind(wx.EVT_BUTTON, self.on_add, id=20) | 1084 self.Bind(wx.EVT_BUTTON, self.on_add, id=20) |
1265 | 1085 |
1266 n_list = handler.xml.getchildren() | 1086 n_list = handler.xml.getchildren() |
1267 self.n_list = n_list | 1087 self.n_list = n_list |
1273 self.grid.SetColLabelValue(2,"Description") #m 1.6 typo correction. | 1093 self.grid.SetColLabelValue(2,"Description") #m 1.6 typo correction. |
1274 wrap = wx.grid.GridCellAutoWrapStringRenderer() | 1094 wrap = wx.grid.GridCellAutoWrapStringRenderer() |
1275 attr = wx.grid.GridCellAttr() | 1095 attr = wx.grid.GridCellAttr() |
1276 attr.SetRenderer(wrap) | 1096 attr.SetRenderer(wrap) |
1277 self.grid.SetColAttr(2, attr) | 1097 self.grid.SetColAttr(2, attr) |
1278 for i in range(len(n_list)): | 1098 for i in range(len(n_list)): self.refresh_row(i) |
1279 self.refresh_row(i) | |
1280 self.temp_dom = None | 1099 self.temp_dom = None |
1281 | 1100 |
1282 def refresh_row(self,i): | 1101 def refresh_row(self,i): |
1283 feat = self.n_list[i] | 1102 feat = self.n_list[i] |
1284 | |
1285 name = feat.get('name') | 1103 name = feat.get('name') |
1286 type = feat.get('type') | 1104 type = feat.get('type') |
1287 desc = feat.get('desc') #m 1.6 correct typo | 1105 desc = feat.get('desc') #m 1.6 correct typo |
1288 self.grid.SetCellValue(i,0,name) | 1106 self.grid.SetCellValue(i,0,name) |
1289 self.grid.SetReadOnly(i,0) | 1107 self.grid.SetReadOnly(i,0) |
1329 self.grid.SetDimensions(0,0,s[0],s[1]-25) | 1147 self.grid.SetDimensions(0,0,s[0],s[1]-25) |
1330 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 1148 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
1331 (w,h) = self.grid.GetClientSizeTuple() | 1149 (w,h) = self.grid.GetClientSizeTuple() |
1332 cols = self.grid.GetNumberCols() | 1150 cols = self.grid.GetNumberCols() |
1333 col_w = w/(cols) | 1151 col_w = w/(cols) |
1334 for i in range(0,cols): | 1152 for i in range(0,cols): self.grid.SetColSize(i,col_w) |
1335 self.grid.SetColSize(i,col_w) | |
1336 | 1153 |
1337 class dnd35combat(dnd35_char_child): | 1154 class dnd35combat(dnd35_char_child): |
1338 """ Node handler for a dnd35 charactor | 1155 """ Node handler for a dnd35 charactor |
1339 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' /> | 1156 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' /> |
1340 """ | 1157 """ |
1341 def __init__(self,xml_dom,tree_node,parent): | 1158 def __init__(self,xml_dom,tree_node,parent): |
1342 | 1159 |
1343 node_handler.__init__(self,xml_dom,tree_node) | 1160 node_handler.__init__(self,xml_dom,tree_node) |
1344 | |
1345 self.hparent = parent #a 1.5002 allow ability to run up tree. | 1161 self.hparent = parent #a 1.5002 allow ability to run up tree. |
1346 self.root = getRoot(self) #a 1.5012 | 1162 self.root = getRoot(self) #a 1.5012 |
1347 | |
1348 | |
1349 | |
1350 #mark3 | 1163 #mark3 |
1351 dnd35_char_child.__init__(self,xml_dom,tree_node,parent) | 1164 dnd35_char_child.__init__(self,xml_dom,tree_node,parent) |
1352 self.frame = component.get('frame') | 1165 self.frame = component.get('frame') |
1353 self.child_handlers = {} | 1166 self.child_handlers = {} |
1354 self.new_child_handler('hp','Hit Points',dnd35hp,'gear') | 1167 self.new_child_handler('hp','Hit Points',dnd35hp,'gear') |
1355 self.new_child_handler('attacks','Attacks',dnd35attacks,'spears') | 1168 self.new_child_handler('attacks','Attacks',dnd35attacks,'spears') |
1356 self.new_child_handler('ac','Armor',dnd35armor,'spears') | 1169 self.new_child_handler('ac','Armor',dnd35armor,'spears') |
1357 #print "combat",self.child_handlers #a (debug) 1.5002 | |
1358 #wxMenuItem(self.tree.std_menu, dnd35_EXPORT, "Export...", "Export") | |
1359 self.myeditor = None | 1170 self.myeditor = None |
1360 | |
1361 | 1171 |
1362 def new_child_handler(self,tag,text,handler_class,icon='gear'): | 1172 def new_child_handler(self,tag,text,handler_class,icon='gear'): |
1363 node_list = self.xml.findall(tag) | 1173 node_list = self.xml.findall(tag) |
1364 tree = self.tree | 1174 tree = self.tree |
1365 i = self.tree.icons[icon] | 1175 i = self.tree.icons[icon] |
1384 self.char_hander = parent | 1194 self.char_hander = parent |
1385 self.drag = False | 1195 self.drag = False |
1386 self.frame = component.get('frame') | 1196 self.frame = component.get('frame') |
1387 self.myeditor = None | 1197 self.myeditor = None |
1388 | 1198 |
1389 | |
1390 def on_drop(self,evt): | 1199 def on_drop(self,evt): |
1391 pass | 1200 pass |
1392 | 1201 |
1393 def on_rclick(self,evt): | 1202 def on_rclick(self,evt): |
1394 pass | 1203 pass |
1444 return html_str | 1253 return html_str |
1445 | 1254 |
1446 class hp_panel(wx.Panel): | 1255 class hp_panel(wx.Panel): |
1447 def __init__(self, parent, handler): | 1256 def __init__(self, parent, handler): |
1448 wx.Panel.__init__(self, parent, -1) | 1257 wx.Panel.__init__(self, parent, -1) |
1449 self.hparent = handler #a 1.5002 allow ability to run up tree. In this | 1258 self.hparent = handler |
1450 #a 1.5002 case, we need the functional parent, not the invoking parent. | |
1451 | |
1452 pname = handler.xml.set("name", 'HitPoints') | 1259 pname = handler.xml.set("name", 'HitPoints') |
1453 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap | 1260 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap |
1454 self.xml = handler.xml | 1261 self.xml = handler.xml |
1455 self.sizer.AddMany([ (wx.StaticText(self, -1, "HP Current:"), 0, | 1262 self.sizer.AddMany([ (wx.StaticText(self, -1, "HP Current:"), 0, |
1456 wx.ALIGN_CENTER_VERTICAL), | 1263 wx.ALIGN_CENTER_VERTICAL), |
1463 self.sizer.AddGrowableCol(1) | 1270 self.sizer.AddGrowableCol(1) |
1464 self.SetSizer(self.sizer) | 1271 self.SetSizer(self.sizer) |
1465 self.SetAutoLayout(True) | 1272 self.SetAutoLayout(True) |
1466 self.Fit() | 1273 self.Fit() |
1467 | 1274 |
1468 #self.Bind(wx.EVT_SIZE, self.on_size) | |
1469 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX) | 1275 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX) |
1470 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR) | 1276 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR) |
1471 | 1277 |
1472 def on_text(self,evt): | 1278 def on_text(self,evt): |
1473 id = evt.GetId() | 1279 id = evt.GetId() |
1474 if id == HP_CUR: | 1280 if id == HP_CUR: self.xml.set('current',evt.GetString()) |
1475 self.xml.set('current',evt.GetString()) | 1281 elif id == HP_MAX: self.xml.set('max',evt.GetString()) |
1476 elif id == HP_MAX: | |
1477 self.xml.set('max',evt.GetString()) | |
1478 | 1282 |
1479 def on_size(self,evt): | 1283 def on_size(self,evt): |
1480 s = self.GetClientSizeTuple() | 1284 s = self.GetClientSizeTuple() |
1481 self.sizer.SetDimension(0,0,s[0],s[1]) | 1285 self.sizer.SetDimension(0,0,s[0],s[1]) |
1482 | 1286 |
1488 combat_char_child.__init__(self,xml_dom,tree_node,parent) | 1292 combat_char_child.__init__(self,xml_dom,tree_node,parent) |
1489 self.hparent = parent #a 1.5002 allow ability to run up tree. | 1293 self.hparent = parent #a 1.5002 allow ability to run up tree. |
1490 self.root = getRoot(self) #a 1.5002 | 1294 self.root = getRoot(self) #a 1.5002 |
1491 self.root.attacks = self #a 1.6009 so others can find me. | 1295 self.root.attacks = self #a 1.6009 so others can find me. |
1492 self.mrFrame = [] #a 1.9001 | 1296 self.mrFrame = [] #a 1.9001 |
1493 | |
1494 #a 1.5012 start a1b | |
1495 | |
1496 self.updateFootNotes = False | 1297 self.updateFootNotes = False |
1497 self.updateFootNotes = False | 1298 self.updateFootNotes = False |
1498 self.html_str = "<html><body>" | 1299 self.html_str = "<html><body>" |
1499 self.html_str += ("<br /> This character has weapons with no "+ | 1300 self.html_str += ("<br /> This character has weapons with no "+ |
1500 "footnotes. This program will "+ | 1301 "footnotes. This program will "+ |
1510 "<br /><br />Update to character:"+self.root.general.charName+ | 1311 "<br /><br />Update to character:"+self.root.general.charName+ |
1511 "<br /><br />"+ | 1312 "<br /><br />"+ |
1512 """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 > | 1313 """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 > |
1513 <th width='80%'>Weapon Name</th><th>Added Footnote</th></tr>\n""") | 1314 <th width='80%'>Weapon Name</th><th>Added Footnote</th></tr>\n""") |
1514 self.temp_dom={} | 1315 self.temp_dom={} |
1515 #a 1.5012 end a1b | |
1516 | |
1517 node_list = self.xml.findall('melee') | 1316 node_list = self.xml.findall('melee') |
1518 self.melee = node_list[0] | 1317 self.melee = node_list[0] |
1519 node_list = self.xml.findall('ranged') | 1318 node_list = self.xml.findall('ranged') |
1520 self.ranged = node_list[0] | 1319 self.ranged = node_list[0] |
1521 self.refresh_weapons() # this causes self.weapons to be loaded. | 1320 self.refresh_weapons() |
1522 | |
1523 #a 1.5012 this whole if clause. | |
1524 if self.updateFootNotes == True: | 1321 if self.updateFootNotes == True: |
1525 self.updateFootNotes = False | 1322 self.updateFootNotes = False |
1526 name = self.root.general.charName | 1323 name = self.root.general.charName |
1527 self.html_str += "</table>" | 1324 self.html_str += "</table>" |
1528 self.html_str += "</body> </html> " | 1325 self.html_str += "</body> </html> " |
1529 masterFrame = self.root.frame | 1326 masterFrame = self.root.frame |
1530 | |
1531 title = name+"'s weapons' update to have footnotes" | 1327 title = name+"'s weapons' update to have footnotes" |
1532 fnFrame = wx.Frame(masterFrame, -1, title) | 1328 fnFrame = wx.Frame(masterFrame, -1, title) |
1533 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) | 1329 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) |
1534 fnFrame.panel.SetPage(self.html_str) | 1330 fnFrame.panel.SetPage(self.html_str) |
1535 fnFrame.Show() | 1331 fnFrame.Show() |
1536 | |
1537 #weaponsH = self.xml.findall('attacks') | |
1538 #mark7 | |
1539 | 1332 |
1540 #a 1.9001 this whole method | 1333 #a 1.9001 this whole method |
1541 def refreshMRdata(self): # refresh the data in the melee/ranged section | 1334 def refreshMRdata(self): # refresh the data in the melee/ranged section |
1542 # of the attack chart. | 1335 # of the attack chart. |
1543 # count backwards, maintains context despite "removes" | 1336 # count backwards, maintains context despite "removes" |
1544 for i in range(len(self.mrFrame)-1,-1,-1): #a 1.9001 | 1337 for i in range(len(self.mrFrame)-1,-1,-1): #a 1.9001 |
1545 x = self.mrFrame[i] | 1338 x = self.mrFrame[i] |
1546 if x == None: | 1339 if x == None: x.refreshMRdata() #a 1.9001 |
1547 x.refreshMRdata() #a 1.9001 | 1340 else: self.mrFrame.remove(x) |
1548 else: | |
1549 self.mrFrame.remove(x) | |
1550 | 1341 |
1551 def refresh_weapons(self): | 1342 def refresh_weapons(self): |
1552 self.weapons = {} | 1343 self.weapons = {} |
1553 | 1344 |
1554 tree = self.tree | 1345 tree = self.tree |
1556 tree.CollapseAndReset(self.mytree_node) | 1347 tree.CollapseAndReset(self.mytree_node) |
1557 node_list = self.xml.findall('weapon') | 1348 node_list = self.xml.findall('weapon') |
1558 for n in node_list: | 1349 for n in node_list: |
1559 name = n.get('name') | 1350 name = n.get('name') |
1560 fn = safeGetAttr(n,'fn') #a 1.5012 can be removed when | 1351 fn = safeGetAttr(n,'fn') #a 1.5012 can be removed when |
1561 #a 1.5012 confident all characters in the world have footnotes. | |
1562 #if self.updateFootNotes: | |
1563 if fn == None:#a 1.5012 | 1352 if fn == None:#a 1.5012 |
1564 self.updateFootNotes=True | 1353 self.updateFootNotes=True |
1565 self.updateFootN(n) #a 1.5012 | 1354 self.updateFootN(n) #a 1.5012 |
1566 new_tree_node = tree.AppendItem( | 1355 new_tree_node = tree.AppendItem( |
1567 self.mytree_node,name,icons['sword'],icons['sword']) | 1356 self.mytree_node,name,icons['sword'],icons['sword']) |
1579 if nameF == w.get('name'): | 1368 if nameF == w.get('name'): |
1580 found = True | 1369 found = True |
1581 fnN = safeGetAttr(n,'fn') | 1370 fnN = safeGetAttr(n,'fn') |
1582 if fnN == None or fnN == 'None': | 1371 if fnN == None or fnN == 'None': |
1583 fnW = w.get('fn') | 1372 fnW = w.get('fn') |
1584 #print "weapon",nameF,"footnotes are updated to",fnW | |
1585 self.html_str += ("<tr ALIGN='center'><td>"+nameF+"</td>"+ | 1373 self.html_str += ("<tr ALIGN='center'><td>"+nameF+"</td>"+ |
1586 "<td>"+fnW+"</td></tr>\n") | 1374 "<td>"+fnW+"</td></tr>\n") |
1587 n.set('fn',fnW) | 1375 n.set('fn',fnW) |
1588 break | 1376 break |
1589 if not found: | 1377 if not found: |
1606 else: | 1394 else: |
1607 stat = 'Dex' #m was dnd_globals["stats"]['Dex'] 1.5002 | 1395 stat = 'Dex' #m was dnd_globals["stats"]['Dex'] 1.5002 |
1608 temp = self.ranged | 1396 temp = self.ranged |
1609 stat_mod = -7 | 1397 stat_mod = -7 |
1610 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 | 1398 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002 |
1611 #print "Big test - stat_mod",stat_mod #a (debug) 1.6000 | |
1612 base = int(temp.get('base')) | 1399 base = int(temp.get('base')) |
1613 base2 = int(temp.get('second')) | 1400 base2 = int(temp.get('second')) |
1614 base3 = int(temp.get('third')) | 1401 base3 = int(temp.get('third')) |
1615 base4 = int(temp.get('forth')) | 1402 base4 = int(temp.get('forth')) |
1616 base5 = int(temp.get('fifth')) | 1403 base5 = int(temp.get('fifth')) |
1618 misc = int(temp.get('misc')) | 1405 misc = int(temp.get('misc')) |
1619 return (base, base2, base3, base4, base5, base6, stat_mod ,misc) | 1406 return (base, base2, base3, base4, base5, base6, stat_mod ,misc) |
1620 | 1407 |
1621 def on_rclick(self,evt): | 1408 def on_rclick(self,evt): |
1622 item = self.tree.GetSelection() | 1409 item = self.tree.GetSelection() |
1623 | |
1624 name = self.tree.GetItemText(item) | 1410 name = self.tree.GetItemText(item) |
1625 if item == self.mytree_node: | 1411 if item == self.mytree_node: return |
1626 #print "bail due to FUD" | |
1627 return #a 1.6015 | |
1628 #dnd35_char_child.on_ldclick(self,evt)#d 1.6015 | |
1629 #self.frame.add_panel(self.get_design_panel(self.frame.note)) | |
1630 else: | 1412 else: |
1631 #print "entering attack phase" | |
1632 mod = int(self.weapons[name].get('mod')) | 1413 mod = int(self.weapons[name].get('mod')) |
1633 wepMod = mod #a 1.5008 | 1414 wepMod = mod #a 1.5008 |
1634 footNotes = safeGetAttr(self.weapons[name],'fn','') | 1415 footNotes = safeGetAttr(self.weapons[name],'fn','') |
1635 cat = self.weapons[name].get('category') #a1.6001 | 1416 cat = self.weapons[name].get('category') #a1.6001 |
1636 result = split(cat,"-",2) #a 1.6001 | 1417 result = split(cat,"-",2) #a 1.6001 |
1640 print "the hyphen. Assuming Melee" | 1421 print "the hyphen. Assuming Melee" |
1641 print "weapon name: ",name | 1422 print "weapon name: ",name |
1642 tres="Melee" | 1423 tres="Melee" |
1643 else: | 1424 else: |
1644 tres=result[1] | 1425 tres=result[1] |
1645 #print "print FootNotes,tres",footNotes,tres | 1426 if tres == 'Melee': rangeOrMelee = 'm' |
1646 if tres == 'Melee': #a 1.6001 #m 1.6022 use of tres here and... | 1427 elif tres == 'Ranged': rangeOrMelee = 'r' |
1647 #if self.weapons[name].get('range') == '0':#d 1.6001 | 1428 else: |
1648 rangeOrMelee = 'm' #a 1.5008 code demote for next comment block | |
1649 elif tres == 'Ranged': #m 1.6001 (was just else) #m 1.6022 here | |
1650 rangeOrMelee = 'r' #a 1.5008 | |
1651 else:#a 1.6001 add this whole else clause. | |
1652 print "warning: 1.6001 unable to interpret weapon category" | 1429 print "warning: 1.6001 unable to interpret weapon category" |
1653 print "treating weapon as Melee, please correct xml" | 1430 print "treating weapon as Melee, please correct xml" |
1654 print "weapon name:",name | 1431 print "weapon name:",name |
1655 rangeOrMelee ='m' | 1432 rangeOrMelee ='m' |
1656 mod = mod + self.get_mod(rangeOrMelee) #a 1.5008 | 1433 mod = mod + self.get_mod(rangeOrMelee) #a 1.5008 |
1658 dmg = self.weapons[name].get('damage') | 1435 dmg = self.weapons[name].get('damage') |
1659 | 1436 |
1660 #a 1.6003 start code fix instance a | 1437 #a 1.6003 start code fix instance a |
1661 result = split(dmg,"/",2) | 1438 result = split(dmg,"/",2) |
1662 dmg = result[0] | 1439 dmg = result[0] |
1663 #print "1.6003 check:dmg",dmg,";result",result | |
1664 #o currently, only picking out dmg; rest are simply ignored. | |
1665 #o May be usefull | |
1666 #o later for two weapon attack correction. | |
1667 #a 1.6003 end code fix instance a | |
1668 | |
1669 monkLvl = self.root.classes.get_class_lvl('Monk') # a 1.5002 | 1440 monkLvl = self.root.classes.get_class_lvl('Monk') # a 1.5002 |
1670 #print "monkLvl",monkLvl #a (debug) 1.5002 | |
1671 # monkLvl = dnd_globals["class"]["lvl"] #d 1.5002 | |
1672 if find(dmg, "Monk Med") > -1: | 1441 if find(dmg, "Monk Med") > -1: |
1673 if monkLvl == None: #a 1.5009 | 1442 if monkLvl == None: #a 1.5009 |
1674 txt = 'Attempting to use monk attack, but has no monk ' | 1443 txt = 'Attempting to use monk attack, but has no monk ' |
1675 txt += 'levels, please choose a different attack.' | 1444 txt += 'levels, please choose a different attack.' |
1676 chat.ParsePost( txt, True, True ) #a 1.5009 | 1445 chat.ParsePost( txt, True, True ) #a 1.5009 |
1677 return #a 1.5009 | 1446 return #a 1.5009 |
1678 else: #a 1.5009 | 1447 else: #a 1.5009 |
1679 lvl=int(monkLvl) | 1448 lvl=int(monkLvl) |
1680 if lvl <= 3: #m 1.6022 reversed the order of checks. | 1449 if lvl <= 3: dmg = dmg.replace("Monk Med", "1d6") |
1681 dmg = dmg.replace("Monk Med", "1d6") | 1450 elif lvl <= 7: dmg = dmg.replace("Monk Med", "1d8") |
1682 elif lvl <= 7: | 1451 elif lvl <= 11: dmg = dmg.replace("Monk Med", "1d10") |
1683 dmg = dmg.replace("Monk Med", "1d8") | 1452 elif lvl <= 15: dmg = dmg.replace("Monk Med", "2d6") |
1684 elif lvl <= 11: | 1453 elif lvl <= 19: dmg = dmg.replace("Monk Med", "2d8") |
1685 dmg = dmg.replace("Monk Med", "1d10") | 1454 elif lvl <= 20: dmg = dmg.replace("Monk Med", "2d10") |
1686 elif lvl <= 15: | |
1687 dmg = dmg.replace("Monk Med", "2d6") | |
1688 elif lvl <= 19: | |
1689 dmg = dmg.replace("Monk Med", "2d8") | |
1690 elif lvl <= 20: | |
1691 dmg = dmg.replace("Monk Med", "2d10") | |
1692 if find(dmg, "Monk Small") > -1: | 1455 if find(dmg, "Monk Small") > -1: |
1693 if monkLvl == None: #a 1.5009 | 1456 if monkLvl == None: #a 1.5009 |
1694 txt = 'Attempting to use monk attack, but has no monk ' | 1457 txt = 'Attempting to use monk attack, but has no monk ' |
1695 txt += 'levels, please choose a different attack.' | 1458 txt += 'levels, please choose a different attack.' |
1696 chat.ParsePost( txt, True, True ) #a 1.5009 | 1459 chat.ParsePost( txt, True, True ) #a 1.5009 |
1697 return #a 1.5009 | 1460 return #a 1.5009 |
1698 else: #a 1.5009 | 1461 else: #a 1.5009 |
1699 lvl=int(monkLvl) | 1462 lvl=int(monkLvl) |
1700 if lvl <= 3: #m 1.6022 reversed the order of the checks | 1463 if lvl <= 3: dmg = dmg.replace("Monk Small", "1d4") |
1701 dmg = dmg.replace("Monk Small", "1d4") | 1464 elif lvl <= 7: dmg = dmg.replace("Monk Small", "1d6") |
1702 elif lvl <= 7: | 1465 elif lvl <= 11: dmg = dmg.replace("Monk Small", "1d8") |
1703 dmg = dmg.replace("Monk Small", "1d6") | 1466 elif lvl <= 15: dmg = dmg.replace("Monk Small", "1d10") |
1704 elif lvl <= 11: | 1467 elif lvl <= 19: dmg = dmg.replace("Monk Small", "2d6") |
1705 dmg = dmg.replace("Monk Small", "1d8") | 1468 elif lvl <= 20: dmg = dmg.replace("Monk Small", "2d8") |
1706 elif lvl <= 15: | |
1707 dmg = dmg.replace("Monk Small", "1d10") | |
1708 elif lvl <= 19: | |
1709 dmg = dmg.replace("Monk Small", "2d6") | |
1710 elif lvl <= 20: | |
1711 dmg = dmg.replace("Monk Small", "2d8") | |
1712 if find(dmg, "Monk Large") > -1: | 1469 if find(dmg, "Monk Large") > -1: |
1713 if monkLvl == None: #a 1.5009 | 1470 if monkLvl == None: #a 1.5009 |
1714 txt = 'Attempting to use monk attack, but has no monk ' | 1471 txt = 'Attempting to use monk attack, but has no monk ' |
1715 txt += 'levels, please choose a different attack.' | 1472 txt += 'levels, please choose a different attack.' |
1716 chat.ParsePost( txt, True, True ) #a 1.5009 | 1473 chat.ParsePost( txt, True, True ) #a 1.5009 |
1717 return #a 1.5009 | 1474 return #a 1.5009 |
1718 else: #a 1.5009 | 1475 else: #a 1.5009 |
1719 lvl=int(monkLvl) | 1476 lvl=int(monkLvl) |
1720 if lvl <= 3: #m 1.6022 reversed the order of the checks | 1477 if lvl <= 3: dmg = dmg.replace("Monk Large", "1d8") |
1721 dmg = dmg.replace("Monk Large", "1d8") | 1478 elif lvl <= 7: dmg = dmg.replace("Monk Large", "2d6") |
1722 elif lvl <= 7: | 1479 elif lvl <= 11: dmg = dmg.replace("Monk Large", "2d8") |
1723 dmg = dmg.replace("Monk Large", "2d6") | 1480 elif lvl <= 15: dmg = dmg.replace("Monk Large", "3d6") |
1724 elif lvl <= 11: | 1481 elif lvl <= 19: dmg = dmg.replace("Monk Large", "3d8") |
1725 dmg = dmg.replace("Monk Large", "2d8") | 1482 elif lvl <= 20: dmg = dmg.replace("Monk Large", "4d8") |
1726 elif lvl <= 15: | |
1727 dmg = dmg.replace("Monk Large", "3d6") | |
1728 elif lvl <= 19: | |
1729 dmg = dmg.replace("Monk Large", "3d8") | |
1730 elif lvl <= 20: | |
1731 dmg = dmg.replace("Monk Large", "4d8") | |
1732 flurry = False | 1483 flurry = False |
1733 #print "adjusted weapon damage is:",dmg | |
1734 #o 1.5007 str bow | |
1735 #o 1.5011 start looking about here str dam bonus missed for thrown? | |
1736 #o 1.5012 start looking about here str penalty missed for bow/sling? | |
1737 #o 1.5013 off-hand attacks.? dam and all affects? | |
1738 str_mod = self.root.abilities.get_mod('Str') #a 1.5007,11,12,13 | 1484 str_mod = self.root.abilities.get_mod('Str') #a 1.5007,11,12,13 |
1739 if rangeOrMelee == 'r': #a 1.5008 | 1485 if rangeOrMelee == 'r': #a 1.5008 |
1740 #if off_hand == True then stat_mod = stat_mod/2 #o 1.5013 | 1486 #if off_hand == True then stat_mod = stat_mod/2 #o 1.5013 |
1741 #c 1.5007 ranged weapons normally get no str mod | 1487 #c 1.5007 ranged weapons normally get no str mod |
1742 if find(footNotes,'b') > -1:#a 1.5012 if it's a bow | 1488 if find(footNotes,'b') > -1:#a 1.5012 if it's a bow |
1743 if str_mod >= 0: #a 1.5012 never a str bonus | 1489 if str_mod >= 0: str_mod = 0 |
1744 str_mod = 0 #a 1.5012 penalty, | 1490 else: str_mod = 0 |
1745 else: #a 1.5012 if appropriate | 1491 mod2 = "" |
1746 str_mod = 0 | 1492 if str_mod >= 0: mod2 = "+" #1.6 tidy up code. |
1747 # c 1.5007 (must adjust for str bows later and thown weapons) | |
1748 #o 1.5007 include + for str bows | |
1749 #o 1.5012 include any str penalty for bows/slings. | |
1750 mod2 = "" #a 1.5007,11-13 | |
1751 if str_mod >= 0: #1.6 tidy up code. | |
1752 mod2 = "+" #1.6 tidy up code. | |
1753 aStrengthMod = mod2 + str(str_mod) #a 1.5008 applicable strength mod | 1493 aStrengthMod = mod2 + str(str_mod) #a 1.5008 applicable strength mod |
1754 | 1494 if find(name ,"Flurry of Blows") > -1: flurry = True |
1755 #if name == "Flurry of Blows(Monk Med)": #d 1.6012 | |
1756 if find(name ,"Flurry of Blows") > -1: #a 1.6012 | |
1757 flurry = True | |
1758 | |
1759 (base, base2, base3, base4, base5, base6, stat_mod, misc) = self.get_attack_data(rangeOrMelee) #a 1.5008 | 1495 (base, base2, base3, base4, base5, base6, stat_mod, misc) = self.get_attack_data(rangeOrMelee) #a 1.5008 |
1760 name = name.replace('(Monk Med)', '') | 1496 name = name.replace('(Monk Med)', '') |
1761 name = name.replace('(Monk Small)', '') | 1497 name = name.replace('(Monk Small)', '') |
1762 if not flurry: | 1498 if not flurry: |
1763 if name == 'Shuriken': | 1499 if name == 'Shuriken': |
1796 flu = '' | 1532 flu = '' |
1797 atks = True | 1533 atks = True |
1798 | 1534 |
1799 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) | 1535 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) |
1800 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) | 1536 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) |
1801 if atks: | 1537 if atks: self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) |
1802 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True) | |
1803 self.sendRoll(base2, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) | 1538 self.sendRoll(base2, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) |
1804 self.sendRoll(base3, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) | 1539 self.sendRoll(base3, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) |
1805 self.sendRoll(base4, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) | 1540 self.sendRoll(base4, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) |
1806 self.sendRoll(base5, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) | 1541 self.sendRoll(base5, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) |
1807 self.sendRoll(base6, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) | 1542 self.sendRoll(base6, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod) |
1808 | 1543 |
1809 | |
1810 | |
1811 def sendRoll(self, base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=False): | 1544 def sendRoll(self, base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=False): |
1812 if base != 0 or rollAnyWay: | 1545 if base != 0 or rollAnyWay: |
1813 base = base + int(stat_mod) + misc + wepMod #m 1.5008 | 1546 base = base + int(stat_mod) + misc + wepMod #m 1.5008 |
1814 if base >= 0: | 1547 if base >= 0: mod1 = "+" |
1815 mod1 = "+" | 1548 else: mod1 = "" |
1816 else: | |
1817 mod1 = "" | |
1818 txt = ' %s Attack Roll: <b>[1d20%s%s%s]</b>' % (name, mod1, base, flu) | 1549 txt = ' %s Attack Roll: <b>[1d20%s%s%s]</b>' % (name, mod1, base, flu) |
1819 txt += ' ===> Damage: <b>[%s%s]</b>' % (dmg, aStrengthMod) | 1550 txt += ' ===> Damage: <b>[%s%s]</b>' % (dmg, aStrengthMod) |
1820 self.chat.ParsePost( txt, True, True ) | 1551 self.chat.ParsePost( txt, True, True ) |
1821 | 1552 |
1822 def get_design_panel(self,parent): | 1553 def get_design_panel(self,parent): |
1843 html_str += "<td>"+str(ranged[2])+"</td></tr></table>" | 1574 html_str += "<td>"+str(ranged[2])+"</td></tr></table>" |
1844 | 1575 |
1845 n_list = self.xml.findall('weapon') | 1576 n_list = self.xml.findall('weapon') |
1846 for n in n_list: | 1577 for n in n_list: |
1847 mod = n.get('mod') | 1578 mod = n.get('mod') |
1848 if mod >= 0: | 1579 if mod >= 0: mod1 = "+" |
1849 mod1 = "+" | 1580 else: mod1 = "" |
1850 else: | |
1851 mod1 = "" | |
1852 ran = n.get('range') | 1581 ran = n.get('range') |
1853 total = str(int(mod) + self.get_mod(ran)) | 1582 total = str(int(mod) + self.get_mod(ran)) |
1854 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 > | 1583 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 > |
1855 <th colspan=2>Weapon</th> | 1584 <th colspan=2>Weapon</th> |
1856 <th>Attack</th><th >Damage</th><th>Critical</th></tr>""" | 1585 <th>Attack</th><th >Damage</th><th>Critical</th></tr>""" |
1863 html_str += "<tr ALIGN='center'><td>"+ran+"</td><td>" | 1592 html_str += "<tr ALIGN='center'><td>"+ran+"</td><td>" |
1864 html_str += n.get('weight')+"</td>" | 1593 html_str += n.get('weight')+"</td>" |
1865 html_str += "<td>"+n.get('type')+"</td><td>" | 1594 html_str += "<td>"+n.get('type')+"</td><td>" |
1866 html_str += n.get('size')+"</td>" | 1595 html_str += n.get('size')+"</td>" |
1867 html_str += '<td>%s%s</td></tr>' % (mod1, mod) | 1596 html_str += '<td>%s%s</td></tr>' % (mod1, mod) |
1868 #a 1.5012 add next two lines to pretty print footnotes. | |
1869 html_str += """<tr><th BGCOLOR=#E9E9E9 colspan=2>Footnotes:</th>""" | 1597 html_str += """<tr><th BGCOLOR=#E9E9E9 colspan=2>Footnotes:</th>""" |
1870 html_str += "<th colspan=3>"+safeGetAttr(n,'fn','')+"</th></tr>" | 1598 html_str += "<th colspan=3>"+safeGetAttr(n,'fn','')+"</th></tr>" |
1871 html_str += '</table>' | 1599 html_str += '</table>' |
1872 return html_str | 1600 return html_str |
1873 | 1601 |
1874 class attack_grid(wx.grid.Grid): | 1602 class attack_grid(wx.grid.Grid): |
1875 """grid for attacks""" | 1603 """grid for attacks""" |
1876 def __init__(self, parent, handler): | 1604 def __init__(self, parent, handler): |
1877 pname = handler.xml.set("name", 'Melee') | 1605 pname = handler.xml.set("name", 'Melee') |
1878 self.hparent = handler #a 1.5002 allow ability to run up tree. | 1606 self.hparent = handler |
1879 #a 1.5002 we need the functional parent, not the invoking parent. | |
1880 | |
1881 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 1607 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
1882 | |
1883 self.root = getRoot(self) #a 1.9001 | 1608 self.root = getRoot(self) #a 1.9001 |
1884 self.parent = parent | 1609 self.parent = parent |
1885 self.handler = handler | 1610 self.handler = handler |
1886 self.rows = (self.handler.melee,self.handler.ranged) | 1611 self.rows = (self.handler.melee,self.handler.ranged) |
1887 self.CreateGrid(2,10) | 1612 self.CreateGrid(2,10) |
1888 self.SetRowLabelSize(0) | 1613 self.SetRowLabelSize(0) |
1889 col_names = ['Type','base','base 2','base 3','base 4','base 5', | 1614 col_names = ['Type','base','base 2','base 3','base 4','base 5', |
1890 'base 6','abil','misc','Total'] | 1615 'base 6','abil','misc','Total'] |
1891 for i in range(len(col_names)): | 1616 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i]) |
1892 self.SetColLabelValue(i,col_names[i]) | |
1893 self.SetCellValue(0,0,"Melee") | 1617 self.SetCellValue(0,0,"Melee") |
1894 self.SetCellValue(1,0,"Ranged") | 1618 self.SetCellValue(1,0,"Ranged") |
1895 self.refresh_data() | 1619 self.refresh_data() |
1896 self.Bind(wx.EVT_SIZE, self.on_size) | 1620 self.Bind(wx.EVT_SIZE, self.on_size) |
1897 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 1621 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
1898 #print "looking for containing frame" | |
1899 | |
1900 #a 1.9001 remainder of code in this method. | |
1901 climber = parent | 1622 climber = parent |
1902 nameNode = climber.GetClassName() | 1623 nameNode = climber.GetClassName() |
1903 while nameNode != 'wxFrame': | 1624 while nameNode != 'wxFrame': |
1904 climber = climber.parent | 1625 climber = climber.parent |
1905 nameNode = climber.GetClassName() | 1626 nameNode = climber.GetClassName() |
1913 row = evt.GetRow() | 1634 row = evt.GetRow() |
1914 col = evt.GetCol() | 1635 col = evt.GetCol() |
1915 value = self.GetCellValue(row,col) | 1636 value = self.GetCellValue(row,col) |
1916 try: | 1637 try: |
1917 int(value) | 1638 int(value) |
1918 if col==1: | 1639 if col==1: self.rows[row].set('base',value) |
1919 self.rows[row].set('base',value) | 1640 elif col== 2: self.rows[row].set('second',value) |
1920 elif col==2: | 1641 elif col== 3: self.rows[row].set('third',value) |
1921 self.rows[row].set('second',value) | 1642 elif col== 4: self.rows[row].set('forth',value) |
1922 elif col==3: | 1643 elif col== 5: self.rows[row].set('fifth',value) |
1923 self.rows[row].set('third',value) | 1644 elif col== 6: self.rows[row].set('sixth',value) |
1924 elif col==4: | 1645 elif col== 8: self.rows[row].set('misc',value) |
1925 self.rows[row].set('forth',value) | |
1926 elif col==5: | |
1927 self.rows[row].set('fifth',value) | |
1928 elif col==6: | |
1929 self.rows[row].set('sixth',value) | |
1930 elif col==8: | |
1931 self.rows[row].set('misc',value) | |
1932 self.parent.refresh_data() | 1646 self.parent.refresh_data() |
1933 except: | 1647 except: self.SetCellValue(row,col,"0") |
1934 self.SetCellValue(row,col,"0") | |
1935 | 1648 |
1936 def refresh_data(self): | 1649 def refresh_data(self): |
1937 | 1650 |
1938 melee = self.handler.get_attack_data('m') | 1651 melee = self.handler.get_attack_data('m') |
1939 ranged = self.handler.get_attack_data('r') | 1652 ranged = self.handler.get_attack_data('r') |
1949 self.SetReadOnly(0,7) | 1662 self.SetReadOnly(0,7) |
1950 self.SetReadOnly(1,7) | 1663 self.SetReadOnly(1,7) |
1951 self.SetReadOnly(0,9) | 1664 self.SetReadOnly(0,9) |
1952 self.SetReadOnly(1,9) | 1665 self.SetReadOnly(1,9) |
1953 | 1666 |
1954 | |
1955 def on_size(self,evt): | 1667 def on_size(self,evt): |
1956 (w,h) = self.GetClientSizeTuple() | 1668 (w,h) = self.GetClientSizeTuple() |
1957 cols = self.GetNumberCols() | 1669 cols = self.GetNumberCols() |
1958 col_w = w/(cols+1) | 1670 col_w = w/(cols+1) |
1959 self.SetColSize(0,col_w*2) | 1671 self.SetColSize(0,col_w*2) |
1960 for i in range(1,cols): | 1672 for i in range(1,cols): self.SetColSize(i,col_w) |
1961 self.SetColSize(i,col_w) | |
1962 evt.Skip() | 1673 evt.Skip() |
1963 self.Refresh() | 1674 self.Refresh() |
1964 | 1675 |
1965 class weapon_panel(wx.Panel): | 1676 class weapon_panel(wx.Panel): |
1966 def __init__(self, parent, handler): | 1677 def __init__(self, parent, handler): |
1994 | 1705 |
1995 n_list = handler.xml.findall('weapon') | 1706 n_list = handler.xml.findall('weapon') |
1996 self.n_list = n_list | 1707 self.n_list = n_list |
1997 self.xml = handler.xml | 1708 self.xml = handler.xml |
1998 self.handler = handler | 1709 self.handler = handler |
1999 #trash=input("weapon panel init colnames") | |
2000 self.colAttr = ['name','damage','mod','critical','type','weight', | 1710 self.colAttr = ['name','damage','mod','critical','type','weight', |
2001 'range','size','Total','fn', 'comment'] #a 1.5012 | 1711 'range','size','Total','fn', 'comment'] #a 1.5012 |
2002 col_names = ['Name','Damage','To hit\nmod','Critical','Type','Weight', | 1712 col_names = ['Name','Damage','To hit\nmod','Critical','Type','Weight', |
2003 'Range','Size','Total','Foot\nnotes','Comment'] #a 1.5012 | 1713 'Range','Size','Total','Foot\nnotes','Comment'] #a 1.5012 |
2004 gridColCount=len(col_names)#a 1.5012 | 1714 gridColCount=len(col_names)#a 1.5012 |
2005 self.grid.CreateGrid(len(n_list),gridColCount,1) #a 1.5012 | 1715 self.grid.CreateGrid(len(n_list),gridColCount,1) #a 1.5012 |
2006 #self.grid.CreateGrid(len(n_list),9,1) #d 1.5012 | |
2007 self.grid.SetRowLabelSize(0) | 1716 self.grid.SetRowLabelSize(0) |
2008 | 1717 |
2009 for i in range(gridColCount): #a 1.5012 | 1718 for i in range(gridColCount): self.grid.SetColLabelValue(i,col_names[i]) |
2010 self.grid.SetColLabelValue(i,col_names[i]) | |
2011 self.refresh_data() | 1719 self.refresh_data() |
2012 self.temp_dom = None | 1720 self.temp_dom = None |
2013 | 1721 |
2014 | 1722 |
2015 #mark4 | 1723 #mark4 |
2016 #a 1.5012 add entire method. | 1724 #a 1.5012 add entire method. |
2017 def on_gridRclick(self,evt): | 1725 def on_gridRclick(self,evt): |
2018 #print "weapon_panel, on_rclick: self,evt",self,evt | |
2019 row = evt.GetRow() | 1726 row = evt.GetRow() |
2020 col = evt.GetCol() | 1727 col = evt.GetCol() |
2021 value = self.grid.GetCellValue(row,col) | 1728 value = self.grid.GetCellValue(row,col) |
2022 #print "wp, on rclick,grid row,col,value",row,col,value | 1729 |
2023 if col == 9 and value != 'None': | 1730 if col == 9 and value != 'None': |
2024 n = self.n_list[row] | 1731 n = self.n_list[row] |
2025 name = n.get('name') | 1732 name = n.get('name') |
2026 #print "we want a panel!" | |
2027 handler = self.hparent | 1733 handler = self.hparent |
2028 #print "handler:",handler | |
2029 # A handler is a node, and nodes have a reference to | |
2030 # the master frame | |
2031 masterFrame = handler.frame | 1734 masterFrame = handler.frame |
2032 #print "masterFrame:",masterFrame | |
2033 title = name+"'s Special Weapon Characteristics" | 1735 title = name+"'s Special Weapon Characteristics" |
2034 fnFrame = wx.Frame(masterFrame, -1, title) | 1736 fnFrame = wx.Frame(masterFrame, -1, title) |
2035 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) | 1737 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1) |
2036 if not self.temp_dom: | 1738 if not self.temp_dom: |
2037 tree = parse(dir_struct["dnd35"]+ "dnd35weapons.xml") | 1739 tree = parse(dir_struct["dnd35"]+ "dnd35weapons.xml") |
2038 self.temp_dom = tree.getroot() | 1740 self.temp_dom = tree.getroot() |
2039 f_list = self.temp_dom.findall('f') # the footnotes | 1741 f_list = self.temp_dom.findall('f') # the footnotes |
2040 #print "weapon_panel - on_rclick f_list",f_list#a 1.6 | |
2041 n = self.n_list[row] | 1742 n = self.n_list[row] |
2042 name = n.get('name') | 1743 name = n.get('name') |
2043 footnotes = n.get('fn') | 1744 footnotes = n.get('fn') |
2044 html_str = "<html><body>" | 1745 html_str = "<html><body>" |
2045 html_str += """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 > | 1746 html_str += """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 > |
2046 <th width='10%'>Note</th><th>Description</th></tr>\n""" | 1747 <th width='10%'>Note</th><th>Description</th></tr>\n""" |
2047 #print "rclick,name,fn",name,footnotes | |
2048 if footnotes == "": | 1748 if footnotes == "": |
2049 html_str += "<tr ALIGN='center'><td></td>" | 1749 html_str += "<tr ALIGN='center'><td></td>" |
2050 html_str += " <td>This weapon has no footnotes</td></tr>" | 1750 html_str += " <td>This weapon has no footnotes</td></tr>" |
2051 for i in range(len(footnotes)): | 1751 for i in range(len(footnotes)): |
2052 aNote=footnotes[i] | 1752 aNote=footnotes[i] |
2061 html_str += ("<tr ALIGN='center'><td>"+aNote+"</td>"+ | 1761 html_str += ("<tr ALIGN='center'><td>"+aNote+"</td>"+ |
2062 "<td>is not a recognized footnote</td></tr>\n") | 1762 "<td>is not a recognized footnote</td></tr>\n") |
2063 | 1763 |
2064 html_str += "</table>" | 1764 html_str += "</table>" |
2065 html_str += "</body> </html> " | 1765 html_str += "</body> </html> " |
2066 | |
2067 #print html_str | |
2068 fnFrame.panel.SetPage(html_str) | 1766 fnFrame.panel.SetPage(html_str) |
2069 fnFrame.Show() | 1767 fnFrame.Show() |
2070 return | 1768 return |
2071 pass | 1769 pass |
2072 | |
2073 | 1770 |
2074 | 1771 |
2075 def on_cell_change(self,evt): | 1772 def on_cell_change(self,evt): |
2076 row = evt.GetRow() | 1773 row = evt.GetRow() |
2077 col = evt.GetCol() | 1774 col = evt.GetCol() |
2086 | 1783 |
2087 | 1784 |
2088 def refresh_row(self,i): | 1785 def refresh_row(self,i): |
2089 n = self.n_list[i] | 1786 n = self.n_list[i] |
2090 fn = n.get('fn') | 1787 fn = n.get('fn') |
2091 #print "fn=",fn | |
2092 name = n.get('name') | 1788 name = n.get('name') |
2093 mod = n.get('mod') | 1789 mod = n.get('mod') |
2094 ran = n.get('range') | 1790 ran = n.get('range') |
2095 total = str(int(mod) + self.handler.get_mod(ran)) | 1791 total = str(int(mod) + self.handler.get_mod(ran)) |
2096 self.grid.SetCellValue(i,0,name) | 1792 self.grid.SetCellValue(i,0,name) |
2102 self.grid.SetCellValue(i,6,ran) | 1798 self.grid.SetCellValue(i,6,ran) |
2103 self.grid.SetCellValue(i,7,n.get('size') ) | 1799 self.grid.SetCellValue(i,7,n.get('size') ) |
2104 self.grid.SetCellValue(i,8,total) | 1800 self.grid.SetCellValue(i,8,total) |
2105 self.grid.SetCellValue(i,9,safeGetAttr(n,'fn','None')) #a 1.5012 | 1801 self.grid.SetCellValue(i,9,safeGetAttr(n,'fn','None')) #a 1.5012 |
2106 self.grid.SetCellValue(i,10,safeGetAttr(n,'comment','')) #a 1.5012 | 1802 self.grid.SetCellValue(i,10,safeGetAttr(n,'comment','')) #a 1.5012 |
2107 #fn=safeGetAttr(n,'fn','None') #a (debug) 1.5012 | |
2108 #print "fn ",fn,"<" #a (debug) 1.5012 | |
2109 #o 1.5012 original damage vs what someone has changed it to. | |
2110 | |
2111 self.grid.SetReadOnly(i,8) | 1803 self.grid.SetReadOnly(i,8) |
2112 | 1804 |
2113 def on_remove(self,evt): #o 1.6011 correcting wrongful deletion | 1805 def on_remove(self,evt): #o 1.6011 correcting wrongful deletion |
2114 rows = self.grid.GetNumberRows() | 1806 rows = self.grid.GetNumberRows() |
2115 #for i in range(rows): #d 1.6011 do it backwards, | |
2116 for i in range(rows-1,-1,-1): #a 1.6011 or you lose context | 1807 for i in range(rows-1,-1,-1): #a 1.6011 or you lose context |
2117 if self.grid.IsInSelection(i,0): | 1808 if self.grid.IsInSelection(i,0): |
2118 self.grid.DeleteRows(i) | 1809 self.grid.DeleteRows(i) |
2119 self.xml.remove(self.n_list[i]) | 1810 self.xml.remove(self.n_list[i]) |
2120 self.n_list = self.xml.findall('weapon') | 1811 self.n_list = self.xml.findall('weapon') |
2124 if not self.temp_dom: | 1815 if not self.temp_dom: |
2125 tree = parse(dir_struct["dnd35"]+"dnd35weapons.xml") | 1816 tree = parse(dir_struct["dnd35"]+"dnd35weapons.xml") |
2126 self.temp_dom = tree.getroot() | 1817 self.temp_dom = tree.getroot() |
2127 f_list = self.temp_dom.findall('weapon') | 1818 f_list = self.temp_dom.findall('weapon') |
2128 opts = [] | 1819 opts = [] |
2129 #print "weapon_panel - on_add f_list",f_list#a 1.6 | 1820 for f in f_list: opts.append(f.get('name')) |
2130 for f in f_list: | |
2131 opts.append(f.get('name')) | |
2132 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) | 1821 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts) |
2133 if dlg.ShowModal() == wx.ID_OK: | 1822 if dlg.ShowModal() == wx.ID_OK: |
2134 i = dlg.GetSelection() | 1823 i = dlg.GetSelection() |
2135 #print f_list[i] # DOM Element: weapon. | |
2136 new_node = self.xml.append(f_list[i]) | 1824 new_node = self.xml.append(f_list[i]) |
2137 #print self.grid.AppendRows # a bound method of wxGrid | |
2138 self.grid.AppendRows(1) | 1825 self.grid.AppendRows(1) |
2139 self.n_list = self.xml.findall('weapon') | 1826 self.n_list = self.xml.findall('weapon') |
2140 #print "self.n_list",self.n_list # list of DOM weapons | |
2141 self.refresh_row(self.grid.GetNumberRows()-1) | 1827 self.refresh_row(self.grid.GetNumberRows()-1) |
2142 self.handler.refresh_weapons() | 1828 self.handler.refresh_weapons() |
2143 dlg.Destroy() | 1829 dlg.Destroy() |
2144 | 1830 |
2145 def on_size(self,event): | 1831 def on_size(self,event): |
2149 self.sizer2.SetDimension(0,s[1]-15,s[0],15) | 1835 self.sizer2.SetDimension(0,s[1]-15,s[0],15) |
2150 (w,h) = self.grid.GetClientSizeTuple() | 1836 (w,h) = self.grid.GetClientSizeTuple() |
2151 cols = self.grid.GetNumberCols() | 1837 cols = self.grid.GetNumberCols() |
2152 col_w = w/(cols+1) | 1838 col_w = w/(cols+1) |
2153 self.grid.SetColSize(0,col_w*2) | 1839 self.grid.SetColSize(0,col_w*2) |
2154 for i in range(1,cols): | 1840 for i in range(1,cols): self.grid.SetColSize(i,col_w) |
2155 self.grid.SetColSize(i,col_w) | |
2156 | 1841 |
2157 def refresh_data(self): | 1842 def refresh_data(self): |
2158 | 1843 for i in range(len(self.n_list)): self.refresh_row(i) |
2159 for i in range(len(self.n_list)): | |
2160 self.refresh_row(i) | |
2161 | 1844 |
2162 | 1845 |
2163 class attack_panel(wx.Panel): | 1846 class attack_panel(wx.Panel): |
2164 def __init__(self, parent, handler): | 1847 def __init__(self, parent, handler): |
2165 pname = handler.xml.set("name", 'Melee') | 1848 pname = handler.xml.set("name", 'Melee') |
2166 self.parent = parent #a 1.9001 | 1849 self.parent = parent #a 1.9001 |
2167 | |
2168 wx.Panel.__init__(self, parent, -1) | 1850 wx.Panel.__init__(self, parent, -1) |
2169 | |
2170 self.a_grid = attack_grid(self, handler) | 1851 self.a_grid = attack_grid(self, handler) |
2171 self.w_panel = weapon_panel(self, handler) | 1852 self.w_panel = weapon_panel(self, handler) |
2172 self.sizer = wx.BoxSizer(wx.VERTICAL) | 1853 self.sizer = wx.BoxSizer(wx.VERTICAL) |
2173 self.sizer.Add(self.a_grid, 1, wx.EXPAND) | 1854 self.sizer.Add(self.a_grid, 1, wx.EXPAND) |
2174 self.sizer.Add(self.w_panel, 2, wx.EXPAND) | 1855 self.sizer.Add(self.w_panel, 2, wx.EXPAND) |
2175 self.Bind(wx.EVT_SIZE, self.on_size) | 1856 self.Bind(wx.EVT_SIZE, self.on_size) |
2176 | 1857 |
2177 | |
2178 def on_size(self,event): | 1858 def on_size(self,event): |
2179 s = self.GetClientSizeTuple() | 1859 s = self.GetClientSizeTuple() |
2180 self.sizer.SetDimension(0,0,s[0],s[1]) | 1860 self.sizer.SetDimension(0,0,s[0],s[1]) |
2181 | 1861 |
2182 def refresh_data(self): | 1862 def refresh_data(self): |
2183 | |
2184 self.w_panel.refresh_data() | 1863 self.w_panel.refresh_data() |
2185 self.a_grid.refresh_data() | 1864 self.a_grid.refresh_data() |
2186 | 1865 |
2187 | 1866 |
2188 class dnd35armor(combat_char_child): | 1867 class dnd35armor(combat_char_child): |
2209 | 1888 |
2210 ac_total += self.get_total('bonus') | 1889 ac_total += self.get_total('bonus') |
2211 #m 1.5009 change to hardcode dex, was incorrect gv "stat" | 1890 #m 1.5009 change to hardcode dex, was incorrect gv "stat" |
2212 dex_mod = self.root.abilities.get_mod('Dex')#m 1.5009 hardcode dex | 1891 dex_mod = self.root.abilities.get_mod('Dex')#m 1.5009 hardcode dex |
2213 max_dex = self.get_max_dex() | 1892 max_dex = self.get_max_dex() |
2214 if dex_mod < max_dex: | 1893 if dex_mod < max_dex: ac_total += dex_mod |
2215 ac_total += dex_mod | 1894 else: ac_total += max_dex |
2216 else: | |
2217 ac_total += max_dex | |
2218 return ac_total | 1895 return ac_total |
2219 | 1896 |
2220 def get_max_dex(self): | 1897 def get_max_dex(self): |
2221 armor_list = self.xml.findall('armor') | 1898 armor_list = self.xml.findall('armor') |
2222 dex = 10 | 1899 dex = 10 |
2223 for a in armor_list: | 1900 for a in armor_list: |
2224 temp = int(a.get("maxdex")) | 1901 temp = int(a.get("maxdex")) |
2225 if temp < dex: | 1902 if temp < dex: dex = temp |
2226 dex = temp | |
2227 return dex | 1903 return dex |
2228 | 1904 |
2229 def get_total(self,attr): | 1905 def get_total(self,attr): |
2230 armor_list = self.xml.findall('armor') | 1906 armor_list = self.xml.findall('armor') |
2231 total = 0 | 1907 total = 0 |
2232 for a in armor_list: | 1908 for a in armor_list: total += int(a.get(attr)) |
2233 total += int(a.get(attr)) | |
2234 return total | 1909 return total |
2235 | 1910 |
2236 def get_design_panel(self,parent): | 1911 def get_design_panel(self,parent): |
2237 wnd = outline_panel(parent,self,ac_panel,"Armor") | 1912 wnd = outline_panel(parent,self,ac_panel,"Armor") |
2238 wnd.title = "Armor" | 1913 wnd.title = "Armor" |
2276 | 1951 |
2277 | 1952 |
2278 class ac_panel(wx.Panel): | 1953 class ac_panel(wx.Panel): |
2279 def __init__(self, parent, handler): | 1954 def __init__(self, parent, handler): |
2280 pname = handler.xml.set("name", 'Armor') | 1955 pname = handler.xml.set("name", 'Armor') |
2281 self.hparent = handler #a 1.5002 allow ability to run up tree. | 1956 self.hparent = handler |
2282 #a 1.5002 we need the functional parent, not the invoking parent. | |
2283 | |
2284 wx.Panel.__init__(self, parent, -1) | 1957 wx.Panel.__init__(self, parent, -1) |
2285 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) | 1958 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS) |
2286 sizer = wx.BoxSizer(wx.VERTICAL) | 1959 sizer = wx.BoxSizer(wx.VERTICAL) |
2287 sizer.Add(self.grid, 1, wx.EXPAND) | 1960 sizer.Add(self.grid, 1, wx.EXPAND) |
2288 | 1961 |
2296 self.sizer = sizer | 1969 self.sizer = sizer |
2297 self.SetSizer(self.sizer) | 1970 self.SetSizer(self.sizer) |
2298 self.SetAutoLayout(True) | 1971 self.SetAutoLayout(True) |
2299 self.Fit() | 1972 self.Fit() |
2300 | 1973 |
2301 #self.Bind(wx.EVT_SIZE, self.on_size) | |
2302 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) | 1974 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10) |
2303 self.Bind(wx.EVT_BUTTON, self.on_add, id=20) | 1975 self.Bind(wx.EVT_BUTTON, self.on_add, id=20) |
2304 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) | 1976 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change) |
2305 self.xml = handler.xml | 1977 self.xml = handler.xml |
2306 n_list = handler.xml.getchildren() | 1978 n_list = handler.xml.getchildren() |
2307 self.n_list = n_list | 1979 self.n_list = n_list |
2308 col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] | 1980 col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type'] |
2309 self.grid.CreateGrid(len(n_list),len(col_names),1) | 1981 self.grid.CreateGrid(len(n_list),len(col_names),1) |
2310 self.grid.SetRowLabelSize(0) | 1982 self.grid.SetRowLabelSize(0) |
2311 for i in range(len(col_names)): | 1983 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i]) |
2312 self.grid.SetColLabelValue(i,col_names[i]) | |
2313 self.atts =['name','bonus','maxdex','checkpenalty', | 1984 self.atts =['name','bonus','maxdex','checkpenalty', |
2314 'spellfailure','weight','speed','type'] | 1985 'spellfailure','weight','speed','type'] |
2315 for i in range(len(n_list)): | 1986 for i in range(len(n_list)): self.refresh_row(i) |
2316 self.refresh_row(i) | |
2317 self.temp_dom = None | 1987 self.temp_dom = None |
2318 | 1988 |
2319 | 1989 |
2320 def on_cell_change(self,evt): | 1990 def on_cell_change(self,evt): |
2321 row = evt.GetRow() | 1991 row = evt.GetRow() |
2323 value = self.grid.GetCellValue(row,col) | 1993 value = self.grid.GetCellValue(row,col) |
2324 if col >= 1 and col <= 5: | 1994 if col >= 1 and col <= 5: |
2325 try: | 1995 try: |
2326 int(value) | 1996 int(value) |
2327 self.n_list[row].set(self.atts[col],value) | 1997 self.n_list[row].set(self.atts[col],value) |
2328 except: | 1998 except: self.grid.SetCellValue(row,col,"0") |
2329 self.grid.SetCellValue(row,col,"0") | 1999 else: self.n_list[row].set(self.atts[col],value) |
2330 else: | |
2331 self.n_list[row].set(self.atts[col],value) | |
2332 | 2000 |
2333 def refresh_row(self,i): | 2001 def refresh_row(self,i): |
2334 n = self.n_list[i] | 2002 n = self.n_list[i] |
2335 | 2003 for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y])) |
2336 for y in range(len(self.atts)): | |
2337 self.grid.SetCellValue(i,y,n.get(self.atts[y])) | |
2338 | 2004 |
2339 def on_remove(self,evt): | 2005 def on_remove(self,evt): |
2340 rows = self.grid.GetNumberRows() | 2006 rows = self.grid.GetNumberRows() |
2341 for i in range(rows): | 2007 for i in range(rows): |
2342 if self.grid.IsInSelection(i,0): | 2008 if self.grid.IsInSelection(i,0): |
2347 if not self.temp_dom: | 2013 if not self.temp_dom: |
2348 tree = parse(dir_struct["dnd35"]+"dnd35armor.xml") | 2014 tree = parse(dir_struct["dnd35"]+"dnd35armor.xml") |
2349 self.temp_dom = tree.getroot() | 2015 self.temp_dom = tree.getroot() |
2350 f_list = self.temp_dom.findall('armor') | 2016 f_list = self.temp_dom.findall('armor') |
2351 opts = [] | 2017 opts = [] |
2352 for f in f_list: | 2018 for f in f_list: opts.append(f.get('name')) |
2353 opts.append(f.get('name')) | |
2354 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) | 2019 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts) |
2355 if dlg.ShowModal() == wx.ID_OK: | 2020 if dlg.ShowModal() == wx.ID_OK: |
2356 i = dlg.GetSelection() | 2021 i = dlg.GetSelection() |
2357 new_node = self.xml.append(f_list[i]) | 2022 new_node = self.xml.append(f_list[i]) |
2358 self.grid.AppendRows(1) | 2023 self.grid.AppendRows(1) |
2365 self.sizer.SetDimension(0,s[1]-25,s[0],25) | 2030 self.sizer.SetDimension(0,s[1]-25,s[0],25) |
2366 (w,h) = self.grid.GetClientSizeTuple() | 2031 (w,h) = self.grid.GetClientSizeTuple() |
2367 cols = self.grid.GetNumberCols() | 2032 cols = self.grid.GetNumberCols() |
2368 col_w = w/(cols+2) | 2033 col_w = w/(cols+2) |
2369 self.grid.SetColSize(0,col_w*3) | 2034 self.grid.SetColSize(0,col_w*3) |
2370 for i in range(1,cols): | 2035 for i in range(1,cols): self.grid.SetColSize(i,col_w) |
2371 self.grid.SetColSize(i,col_w) |