annotate orpg/gametree/nodehandlers/dnd35.py @ 245:682032381be8 beta

Traipse Beta 'OpenRPG' {101130-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 (Closing/Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log New Earthdawn Dieroller New IronClaw roller, sheet, and image Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner Update to Dieroller. Cleaner, more effecient expression system Update to Hidden Die plugin, allows for non standard dice rolls Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug Fix to Gametree for XSLT Sheets Fix to Gametree for locating gametree files Fix to Send to Chat from Gametree Fix to Gametree, renaming and remapping operates correctly Fix to aliaslib, prevents error caused when SafeHTML is sent None
author sirebral
date Tue, 30 Nov 2010 02:34:58 -0600
parents 3bbfd84619c0
children
rev   line source
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1 from core import *
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2 from containers import *
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
3 from string import * #a 1.6003
82
2fa8bd6785a5 TerminalWriter's colors are nice, but if no debug console is open it causes the software to look for one until a recursion error is created. Crash reports are sent to the debug console and a pop-up tells the user one has happened. Fix to chat window from SnowDog.
sirebral
parents: 71
diff changeset
4 from inspect import * #a 1.9001
2fa8bd6785a5 TerminalWriter's colors are nice, but if no debug console is open it causes the software to look for one until a recursion error is created. Crash reports are sent to the debug console and a pop-up tells the user one has happened. Fix to chat window from SnowDog.
sirebral
parents: 71
diff changeset
5 from orpg.dirpath import dir_struct
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 82
diff changeset
6 from xml.etree.ElementTree import parse
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
7 from orpg.tools.InterParse import Parse
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
8 dnd35_EXPORT = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
9
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
10 ############Global Stuff##############
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
11
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
12 HP_CUR = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
13 HP_MAX = wx.NewId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
14
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
15 def getRoot (node): # a 1.5002 this whole function is new.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
16 root = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
17 target = node
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
18 while target != None:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
19 root = target
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
20 target = target.hparent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
21 return root
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
22
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
23 #a 1.6 convinience function added safeGetAttr
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
24 def safeGetAttr(node, label, defRetV=None):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
25 cna=node.attrib
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 82
diff changeset
26 for key in cna:
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
27 if key == label: return cna[key]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
28 return defRetV
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
29 #a 1.6... safeGetAttr end.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
30
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
31 ########End of My global Stuff########
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
32 ########Start of Main Node Handlers#######
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
33 class dnd35char_handler(container_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
34 """ Node handler for a dnd35 charactor
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
35 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
36 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
37 def __init__(self,xml_dom,tree_node):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
38 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
39 self.Version = "v1.000" #a 1.6000 general documentation, usage.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
40 print "dnd35char_handler - version:",self.Version #m 1.6000
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
41 self.hparent = None #a 1.5002 allow ability to run up tree, this is the
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
42 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
43 self.child_handlers = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
44 self.new_child_handler('general','GeneralInformation',dnd35general,'gear')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
45 self.new_child_handler('inventory','MoneyAndInventory',dnd35inventory,'money')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
46 self.new_child_handler('character','ClassesAndStats',dnd35classnstats,'knight')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
47 self.new_child_handler('snf','SkillsAndFeats',dnd35skillsnfeats,'book')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
48 self.new_child_handler('combat','Combat',dnd35combat,'spears')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
49 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
50
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
51 def new_child_handler(self,tag,text,handler_class,icon='gear'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
52 node_list = self.xml.findall(tag)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
53 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
54 i = self.tree.icons[icon]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
55 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
56 handler = handler_class(node_list[0],new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
57 tree.SetPyData(new_tree_node,handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
58 self.child_handlers[tag] = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
59
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
60 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
61 return tabbed_panel(parent,self,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
62
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
63 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
64 return tabbed_panel(parent,self,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
65
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
66 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
67 html_str = "<table><tr><td colspan=2 >"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
68 html_str += self.general.tohtml()+"</td></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
69 html_str += "<tr><td width='50%' valign=top >"+self.abilities.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
70 html_str += "<P>" + self.saves.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
71 html_str += "<P>" + self.attacks.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
72 html_str += "<P>" + self.ac.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
73 html_str += "<P>" + self.feats.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
74 html_str += "<P>" + self.inventory.tohtml() +"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
75 html_str += "<td width='50%' valign=top >"+self.classes.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
76 html_str += "<P>" + self.hp.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
77 html_str += "<P>" + self.skills.tohtml() +"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
78 html_str += "</tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
79 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
80
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
81 def about(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
82 """html_str = "<img src='" + dir_struct["icon"]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
83 html_str += "dnd3e_logo.gif' ><br /><b>dnd35 Character Tool "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
84 html_str += self.Version+"</b>" #m 1.6000 was hard coded.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
85 html_str += "<br />by Dj Gilcrease<br />digitalxero@gmail.com"
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 135
diff changeset
86 return html_str"""
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 135
diff changeset
87 text = 'dnd35 Character Tool' + self.Version +'\n'
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 135
diff changeset
88 text += 'by Dj Gilcrease digitalxero@gmail.com'
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
89 return text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
90
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
91 ########Core Handlers are done now############
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
92 ########Onto the Sub Nodes########
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
93 ##Primary Sub Node##
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
94
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
95 class outline_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
96 def __init__(self, parent, handler, wnd, txt,):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
97 self.parent = parent #a 1.9001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
98 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
99 self.panel = wnd(self,handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
100 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self,-1,txt), wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
101
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
102 self.sizer.Add(self.panel, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
103 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
104 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
105 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
106
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
107 class dnd35_char_child(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
108 """ Node Handler for skill. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
109 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
110 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
111 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
112 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
113 self.char_hander = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
114 self.drag = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
115 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
116 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
117
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
118 def on_drop(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
119 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
120
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
121 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
122 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
123
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
124 def on_ldclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
125 return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
126
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
127 def on_html(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
128 html_str = self.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
129 wnd = http_html_window(self.frame.note,-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
130 wnd.title = self.xml.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
131 self.frame.add_panel(wnd)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
132 wnd.SetPage(html_str)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
133
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
134 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
135 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
136
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
137 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
138 return self.get_design_panel(parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
139
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
140 def delete(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
141 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
142
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
143 class dnd35general(dnd35_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
144 """ Node Handler for general information. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
145 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
146 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
147 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
148 dnd35_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
149 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
150 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
151 self.root.general = self #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
152 self.charName = self.get_char_name() # a 1.5002 make getting name easier.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
153
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
154 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
155 wnd = outline_panel(parent,self,gen_grid,"General Information")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
156 wnd.title = "General Info"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
157 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
158
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
159 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
160 n_list = self.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
161 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>General Information</th></tr><tr><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
162 for n in n_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
163 html_str += "<B>"+n.tag.capitalize() +":</B> "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
164 html_str += n.text + ", "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
165 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
166 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
167
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
168 def on_name_change(self,name):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
169 self.char_hander.rename(name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
170 #o 1.5002 self.char_hander = parent in this case.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
171 self.charName = name #a 1.5002 make getting name easier.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
172
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
173 def get_char_name( self ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
174 node = self.xml.findall( 'name' )[0]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
175 return node.text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
176
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
177 class gen_grid(wx.grid.Grid):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
178 """grid for gen info"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
179 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
180 pname = handler.xml.set("name", 'General')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
181 self.hparent = handler #a 1.5002 allow ability to run up tree, needed
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
182 # a 1.5002 parent is functional parent, not invoking parent.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
183 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
184 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
185 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
186 n_list = handler.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
187 self.CreateGrid(len(n_list),2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
188 self.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
189 self.SetColLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
190 self.n_list = n_list
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
191 i = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
192 for i in range(len(n_list)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
193
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
194 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
195 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
196 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
197 value = self.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
198 t_node = self.n_list[row]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
199 t_node.text = value
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
200 if row==0: self.handler.on_name_change(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
201
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
202 def refresh_row(self, rowi):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
203 self.SetCellValue(rowi, 0, self.n_list[rowi].tag)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
204 self.SetReadOnly(rowi, 0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
205 self.SetCellValue(rowi, 1, self.n_list[rowi].text)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
206 self.AutoSizeColumn(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
207
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
208 class dnd35inventory(dnd35_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
209 """ Node Handler for general information. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
210 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
211 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
212 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
213 dnd35_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
214 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
215 self.root = getRoot(self) #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
216 self.root.inventory = self #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
217
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
218 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
219 wnd = inventory_pane(parent, self) #outline_panel(parent,self,inventory_grid,"Inventory")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
220 wnd.title = "Inventory"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
221 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
222
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
223 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
224 n_list = self.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
225 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Inventory</th></tr><tr><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
226 for n in n_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
227 html_str += "<B>"+n.tag.capitalize() +":</B> "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
228 html_str += n.text + "<br />"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
229 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
230 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
231
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
232 class inventory_pane(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
233 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
234 wx.Panel.__init__(self, parent, wx.ID_ANY)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
235 self.n_list = handler.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
236 self.autosize = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
237 self.sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Inventory"), wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
238 self.lang = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Languages")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
239 self.gear = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Gear")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
240 self.magic = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_BESTWRAP, name="Magic")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
241 self.grid = wx.grid.Grid(self, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
242 self.grid.CreateGrid(len(self.n_list)-3,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
243 self.grid.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
244 self.grid.SetColLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
245 for i in xrange(len(self.n_list)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
246 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
247 sizer1.Add(self.grid, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
248 sizer1.Add(self.lang, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
249 self.sizer.Add(sizer1, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
250 sizer2 = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
251 sizer2.Add(self.gear, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
252 sizer2.Add(self.magic, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
253 self.sizer.Add(sizer2, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
254 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
255 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
256 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
257 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.lang)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
258 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.gear)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
259 self.Bind(wx.EVT_TEXT, self.onTextNodeChange, self.magic)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
260 self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.on_cell_change, self.grid)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
261
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
262 def fillTextNode(self, name, value):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
263 if name == 'Languages': self.lang.SetValue(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
264 elif name == 'Gear': self.gear.SetValue(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
265 elif name == 'Magic': self.magic.SetValue(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
266
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
267 def onTextNodeChange(self, event):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
268 id = event.GetId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
269 if id == self.gear.GetId():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
270 nodeName = 'Gear'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
271 value = self.gear.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
272 elif id == self.magic.GetId():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
273 nodeName = 'Magic'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
274 value = self.magic.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
275 elif id == self.lang.GetId():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
276 nodeName = 'Languages'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
277 value = self.lang.GetValue()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
278 for node in self.n_list:
245
682032381be8 Traipse Beta 'OpenRPG' {101130-00}
sirebral
parents: 243
diff changeset
279 if node.tag == nodeName: node.text = value
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
280
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
281 def saveMoney(self, row, col):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
282 value = self.grid.GetCellValue(row, col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
283 self.n_list[row].text = value
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
284
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
285 def on_cell_change(self, evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
286 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
287 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
288 self.grid.AutoSizeColumn(col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
289 wx.CallAfter(self.saveMoney, row, col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
290
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
291 def refresh_row(self, row):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
292 tagname = self.n_list[row].tag
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
293 value = self.n_list[row].text
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
294 if tagname == 'Gear': self.fillTextNode(tagname, value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
295 elif tagname == 'Magic': self.fillTextNode(tagname, value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
296 elif tagname == 'Languages': self.fillTextNode(tagname, value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
297 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
298 self.grid.SetCellValue(row, 0, tagname)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
299 self.grid.SetReadOnly(row, 0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
300 self.grid.SetCellValue(row, 1, value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
301 self.grid.AutoSize()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
302
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
303
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
304 class dnd35classnstats(dnd35_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
305 """ Node handler for a dnd35 charactor
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
306 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
307 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
308 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
309 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
310 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
311 dnd35_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
312 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
313 self.child_handlers = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
314 self.new_child_handler('abilities','Abilities Scores',dnd35ability,'gear')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
315 self.new_child_handler('classes','Classes',dnd35classes,'knight')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
316 self.new_child_handler('saves','Saves',dnd35saves,'skull')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
317 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
318
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
319 def new_child_handler(self,tag,text,handler_class,icon='gear'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
320 node_list = self.xml.findall(tag)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
321 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
322 i = self.tree.icons[icon]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
323 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
324 handler = handler_class(node_list[0],new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
325 tree.SetPyData(new_tree_node,handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
326 self.child_handlers[tag] = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
327
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
328 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
329 return tabbed_panel(parent,self,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
330
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
331 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
332 return tabbed_panel(parent,self,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
333
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
334 class class_char_child(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
335 """ Node Handler for skill. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
336 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
337 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
338 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
339 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
340 self.char_hander = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
341 self.drag = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
342 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
343 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
344
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
345 def on_drop(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
346 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
347
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
348 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
349 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
350
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
351 def on_ldclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
352 return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
353
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
354 def on_html(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
355 html_str = self.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
356 wnd = http_html_window(self.frame.note,-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
357 wnd.title = self.xml.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
358 self.frame.add_panel(wnd)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
359 wnd.SetPage(html_str)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
360
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
361 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
362 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
363
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
364 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
365 return self.get_design_panel(parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
366
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
367 def delete(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
368 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
369
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
370 class dnd35ability(class_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
371 """ Node Handler for ability. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
372 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
373 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
374 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
375 class_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
376 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
377 self.root = getRoot(self) #a 1.5002 get top of our local function tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
378 self.root.abilities = self #a 1.5002 let other classes find me.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
379
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
380 self.abilities = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
381 node_list = self.xml.findall('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
382 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
383 icons = tree.icons
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
384
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
385 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
386 name = n.get('abbr')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
387 self.abilities[name] = n
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
388 new_tree_node = tree.AppendItem( self.mytree_node, name, icons['gear'], icons['gear'] )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
389 tree.SetPyData( new_tree_node, self )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
390
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
391 def on_rclick( self, evt ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
392 item = self.tree.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
393 name = self.tree.GetItemText( item )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
394 if not item == self.mytree_node: #a 1.6016
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
395 mod = self.get_mod( name )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
396 if mod >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
397 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
398 chat = self.chat
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
399 txt = '%s check: [1d20%s%s]' % ( name, mod1, mod )
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
400 Parse.Post( txt, self.chat, True, True )
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
401
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
402 def get_mod(self,abbr):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
403 score = int(self.abilities[abbr].get('base'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
404 mod = (score - 10) / 2
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
405 mod = int(mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
406 return mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
407
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
408 def set_score(self,abbr,score):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
409 if score >= 0: self.abilities[abbr].set("base",str(score))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
410
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
411 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
412 wnd = outline_panel(parent,self,abil_grid,"Abilities")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
413 wnd.title = "Abilities (edit)"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
414 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
415
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
416 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
417 html_str = """<table border='1' width=100%><tr BGCOLOR=#E9E9E9 ><th width='50%'>Ability</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
418 <th>Base</th><th>Modifier</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
419 node_list = self.xml.findall('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
420 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
421 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
422 abbr = n.get('abbr')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
423 base = n.get('base')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
424 mod = str(self.get_mod(abbr))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
425 if int(mod) >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
426 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
427 html_str = (html_str + "<tr ALIGN='center'><td>"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
428 name+"</td><td>"+base+'</td><td>%s%s</td></tr>' % (mod1, mod))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
429 html_str = html_str + "</table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
430 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
431
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
432 class abil_grid(wx.grid.Grid):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
433 """grid for abilities"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
434 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
435 pname = handler.xml.set("name", 'Stats')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
436 self.hparent = handler #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
437 self.root = getRoot(self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
438 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
439 self.Bind(wx.EVT_SIZE, self.on_size)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
440 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
441 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
442 stats = handler.xml.findall('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
443 self.CreateGrid(len(stats),3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
444 self.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
445 col_names = ['Ability','Score','Modifier']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
446 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
447 self.stats = stats
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
448 i = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
449 for i in range(len(stats)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
450 self.char_wnd = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
451
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
452 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
453 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
454 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
455 value = self.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
456 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
457 int(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
458 self.stats[row].set('base',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
459 self.refresh_row(row)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
460 except:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
461 self.SetCellValue(row,col,"0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
462 if self.char_wnd: self.char_wnd.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
463
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
464 def refresh_row(self,rowi):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
465 s = self.stats[rowi]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
466 name = s.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
467 abbr = s.get('abbr')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
468 self.SetCellValue(rowi,0,name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
469 self.SetReadOnly(rowi,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
470 self.SetCellValue(rowi,1,s.get('base'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
471 self.SetCellValue(rowi,2,str(self.handler.get_mod(abbr)))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
472 self.SetReadOnly(rowi,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
473 self.root.saves.refresh_data() #a 1.9002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
474 self.root.attacks.refreshMRdata() #a 1.9001 `
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
475
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
476 def on_size(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
477 (w,h) = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
478 cols = self.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
479 col_w = w/(cols+2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
480 self.SetColSize(0,col_w*3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
481 for i in range(1,cols): self.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
482 evt.Skip()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
483 self.Refresh()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
484
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
485 def refresh_data(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
486 for r in range(self.GetNumberRows()-1): self.refresh_row(r)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
487
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
488 class dnd35classes(class_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
489 """ Node Handler for classes. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
490 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
491 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
492 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
493 class_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
494 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
495 self.root = getRoot(self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
496 self.root.classes = self
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
497
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
498 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
499 wnd = outline_panel(parent,self,class_panel,"Classes")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
500 wnd.title = "Classes"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
501 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
502
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
503 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
504 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Classes</th></tr><tr><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
505 n_list = self.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
506 for n in n_list: html_str += n.get('name') + " ("+n.get('level')+"), "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
507 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
508 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
509
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
510 def get_char_lvl( self, attr ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
511 node_list = self.xml.findall('class')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
512 tot = 0 #a 1.5009 actually, slipping in a quick enhancement ;-)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
513 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
514 lvl = n.get('level')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
515 tot += int(lvl)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
516 type = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
517 if attr == "level": return lvl
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
518 elif attr == "class": return type
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
519 if attr == "lvl": return tot
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
520
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
521 def get_class_lvl( self, classN ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
522 node_list = self.xml.findall('class')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
523 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
524 lvl = n.get('level')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
525 type = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
526 if classN == type: return lvl
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
527
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
528 class class_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
529 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
530 pname = handler.xml.set("name", 'Class')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
531 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
532 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
533 sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
534 sizer.Add(self.grid, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
535
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
536 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
537 sizer1.Add(wx.Button(self, 10, "Remove Class"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
538 sizer1.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
539 sizer1.Add(wx.Button(self, 20, "Add Class"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
540
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
541 sizer.Add(sizer1, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
542 self.sizer = sizer
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
543 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
544 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
545 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
546
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
547 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
548 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
549 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
550
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
551 n_list = handler.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
552 self.n_list = n_list
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
553 self.xml = handler.xml
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
554 self.grid.CreateGrid(len(n_list),3,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
555 self.grid.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
556 self.grid.SetColLabelValue(0,"Class")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
557 self.grid.SetColLabelValue(1,"Level")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
558 self.grid.SetColLabelValue(2,"Refrence")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
559 for i in range(len(n_list)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
560 self.temp_dom = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
561
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
562 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
563 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
564 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
565 value = self.grid.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
566 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
567 int(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
568 self.n_list[row].set('level',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
569 except: self.grid.SetCellValue(row,col,"1")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
570
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
571
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
572 def refresh_row(self,i):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
573 n = self.n_list[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
574 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
575 level = n.get('level')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
576 book = n.get('book')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
577 self.grid.SetCellValue(i,0,name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
578 self.grid.SetReadOnly(i,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
579 self.grid.SetCellValue(i,1,level)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
580 self.grid.SetCellValue(i,2,book)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
581 self.grid.SetReadOnly(i,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
582 self.grid.AutoSizeColumn(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
583 self.grid.AutoSizeColumn(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
584 self.grid.AutoSizeColumn(2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
585
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
586 def on_remove(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
587 rows = self.grid.GetNumberRows()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
588 for i in range(rows):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
589 if self.grid.IsInSelection(i,0):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
590 self.grid.DeleteRows(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
591 self.xml.remove(self.n_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
592
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
593 def on_add(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
594 if not self.temp_dom:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
595 tree = parse(dir_struct["dnd35"]+"dnd35classes.xml")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
596 xml_dom = tree.getroot()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
597 self.temp_dom = xml_dom
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
598 f_list = self.temp_dom.findall('class')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
599 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
600 for f in f_list: opts.append(f.get('name'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
601 dlg = wx.SingleChoiceDialog(self,'Choose Class','Classes',opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
602 if dlg.ShowModal() == wx.ID_OK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
603 i = dlg.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
604 new_node = self.xml.append(f_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
605 self.grid.AppendRows(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
606 self.refresh_row(self.grid.GetNumberRows()-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
607 dlg.Destroy()
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 135
diff changeset
608
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
609 def on_size(self,event):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
610 s = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
611 self.grid.SetDimensions(0,0,s[0],s[1]-25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
612 self.sizer.SetDimension(0,s[1]-25,s[0],25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
613 (w,h) = self.grid.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
614 cols = self.grid.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
615 col_w = w/(cols)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
616 for i in range(0,cols): self.grid.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
617
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
618
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
619 class dnd35saves(class_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
620 """ Node Handler for saves. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
621 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
622 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
623 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
624 class_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
625 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
626 self.saveGridFrame = [] #a 1.9002 handle list, check frame for close.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
627
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
628 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
629 icons = self.tree.icons
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
630
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
631 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
632 self.root.saves = self #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
633 node_list = self.xml.findall('save')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
634 self.saves={}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
635 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
636 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
637 self.saves[name] = n
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
638 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear'])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
639 tree.SetPyData(new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
640
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
641 #a 1.9002 this whole method
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
642 def refresh_data(self): # refresh the data in the melee/ranged section
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
643 # of the attack chart.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
644 # count backwards, maintains context despite "removes"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
645 for i in range(len(self.saveGridFrame)-1,-1,-1):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
646 x = self.saveGridFrame[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
647 if x == None: x.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
648 else: self.saveGridFrame.remove(x)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
649
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
650 def get_mod(self,name):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
651 save = self.saves[name]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
652 stat = save.get('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
653 stat_mod = self.root.abilities.get_mod(stat)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
654 base = int(save.get('base'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
655 miscmod = int(save.get('miscmod'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
656 magmod = int(save.get('magmod'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
657 total = stat_mod + base + miscmod + magmod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
658 return total
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
659
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
660 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
661
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
662 item = self.tree.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
663 name = self.tree.GetItemText(item)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
664 if item == self.mytree_node:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
665 pass #a 1.5003 syntatic place holder
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
666 return #a 1.5003
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
667 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
668 mod = self.get_mod(name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
669 if mod >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
670 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
671 chat = self.chat
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
672 txt = '%s save: [1d20%s%s]' % (name, mod1, mod)
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
673 Parse.Post( txt, self.chat, True, True )
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
674
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
675 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
676 wnd = outline_panel(parent,self,save_grid,"Saves")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
677 wnd.title = "Saves"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
678 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
679
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
680 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
681 html_str = """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
682 <th width='30%'>Save</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
683 <th>Key</th><th>Base</th><th>Abil</th><th>Magic</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
684 <th>Misc</th><th>Total</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
685 node_list = self.xml.findall('save')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
686 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
687 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
688 stat = n.get('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
689 base = n.get('base')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
690 html_str = html_str + "<tr ALIGN='center'><td>"+name+"</td><td>"+stat+"</td><td>"+base+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
691 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
692 mag = n.get('magmod')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
693 misc = n.get('miscmod')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
694 mod = str(self.get_mod(name))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
695 if mod >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
696 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
697 html_str = html_str + "<td>"+str(stat_mod)+"</td><td>"+mag+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
698 html_str = html_str + '<td>'+misc+'</td><td>%s%s</td></tr>' % (mod1, mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
699 html_str = html_str + "</table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
700 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
701
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
702 #mark6
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
703 class save_grid(wx.grid.Grid):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
704 """grid for saves"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
705 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
706 pname = handler.xml.set("name", 'Saves')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
707 self.hparent = handler #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
708 #a 1.5002 in this case, we need the functional parent, not the invoking parent.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
709 self.root = getRoot(self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
710 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
711 self.Bind(wx.EVT_SIZE, self.on_size)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
712 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
713 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
714 saves = handler.xml.findall('save')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
715 self.CreateGrid(len(saves),7)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
716 self.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
717 col_names = ['Save','Key','base','Abil','Magic','Misc','Total']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
718 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
719 self.saves = saves
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
720 i = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
721 for i in range(len(saves)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
722 climber = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
723 nameNode = climber.GetClassName()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
724 while nameNode != 'wxFrame':
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
725 climber = climber.parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
726 nameNode = climber.GetClassName()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
727 masterFrame=climber
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
728 masterFrame.refresh_data=self.refresh_data
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
729 handler.saveGridFrame.append(masterFrame)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
730
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
731 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
732 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
733 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
734 value = self.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
735 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
736 int(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
737 if col == 2: self.saves[row].set('base',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
738 elif col == 4: self.saves[row].set('magmod',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
739 elif col == 5: self.saves[row].set('miscmod',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
740 self.refresh_row(row)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
741 except: self.SetCellValue(row,col,"0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
742
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
743 def refresh_row(self,rowi):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
744 s = self.saves[rowi]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
745 name = s.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
746 self.SetCellValue(rowi,0,name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
747 self.SetReadOnly(rowi,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
748 stat = s.get('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
749 self.SetCellValue(rowi,1,stat)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
750 self.SetReadOnly(rowi,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
751 self.SetCellValue(rowi,2,s.get('base'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
752 self.SetCellValue(rowi,3,str(self.root.abilities.get_mod(stat)))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
753 self.SetReadOnly(rowi,3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
754 self.SetCellValue(rowi,4,s.get('magmod'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
755 self.SetCellValue(rowi,5,s.get('miscmod'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
756 mod = str(self.handler.get_mod(name))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
757 self.SetCellValue(rowi,6,mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
758 self.SetReadOnly(rowi,6)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
759
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
760 def on_size(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
761 (w,h) = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
762 cols = self.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
763 col_w = w/(cols+2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
764 self.SetColSize(0,col_w*3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
765 for i in range(1,cols): self.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
766 evt.Skip()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
767 self.Refresh()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
768
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
769 def refresh_data(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
770 for r in range(self.GetNumberRows()): self.refresh_row(r)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
771
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
772 class dnd35skillsnfeats(dnd35_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
773 """ Node handler for a dnd35 charactor
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
774 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
775 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
776 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
777 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
778 self.root = getRoot(self) #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
779 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
780 dnd35_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
781 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
782 self.child_handlers = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
783 self.new_child_handler('skills','Skills',dnd35skill,'book')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
784 self.new_child_handler('feats','Feats',dnd35feats,'book')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
785 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
786
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
787 def new_child_handler(self,tag,text,handler_class,icon='gear'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
788 node_list = self.xml.findall(tag)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
789 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
790 i = self.tree.icons[icon]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
791 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
792 handler = handler_class(node_list[0],new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
793 tree.SetPyData(new_tree_node,handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
794 self.child_handlers[tag] = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
795
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
796 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
797 return tabbed_panel(parent,self,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
798
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
799 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
800 return tabbed_panel(parent,self,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
801
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
802 class skills_char_child(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
803 """ Node Handler for skill. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
804 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
805 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
806 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
807 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
808 self.char_hander = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
809 self.drag = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
810 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
811 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
812
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
813 def on_drop(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
814 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
815
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
816 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
817 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
818
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
819 def on_ldclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
820 return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
821
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
822 def on_html(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
823 html_str = self.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
824 wnd = http_html_window(self.frame.note,-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
825 wnd.title = self.xml.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
826 self.frame.add_panel(wnd)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
827 wnd.SetPage(html_str)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
828
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
829 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
830 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
831
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
832 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
833 return self.get_design_panel(parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
834
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
835 def delete(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
836 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
837
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
838 class dnd35skill(skills_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
839 """ Node Handler for skill. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
840 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
841 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
842 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
843 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
844 #a 1.5002 Need the functional parent, not the invoking parent.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
845 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
846 self.root.skills = self #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
847
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
848 skills_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
849 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
850 icons = self.tree.icons
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
851 node_list = self.xml.findall('skill')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
852
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
853 self.skills={}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
854 #Adding code to not display skills you can not use -mgt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
855 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
856 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
857 self.skills[name] = n
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
858 skill_check = self.skills[name]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
859 ranks = int(skill_check.get('rank'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
860 trained = int(skill_check.get('untrained'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
861 if ranks > 0 or trained == 1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
862 new_tree_node = tree.AppendItem(self.mytree_node,name,
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
863 icons['gear'],icons['gear'])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
864 else: continue
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
865 tree.SetPyData(new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
866
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
867 def refresh_skills(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
868 #Adding this so when you update the grid the tree will reflect
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
869 #The change. -mgt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
870 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
871 icons = self.tree.icons
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
872 tree.CollapseAndReset(self.mytree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
873 node_list = self.xml.findall('skill')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
874
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
875 self.skills={}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
876 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
877 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
878 self.skills[name] = n
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
879 skill_check = self.skills[name]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
880 ranks = int(skill_check.get('rank'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
881 trained = int(skill_check.get('untrained'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
882 if ranks > 0 or trained == 1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
883 new_tree_node = tree.AppendItem(self.mytree_node,name,
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
884 icons['gear'],icons['gear'])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
885 else: continue
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
886 tree.SetPyData(new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
887
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
888 def get_mod(self,name):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
889 skill = self.skills[name]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
890 stat = skill.get('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
891 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
892 rank = int(skill.get('rank'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
893 misc = int(skill.get('misc'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
894 total = stat_mod + rank + misc
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
895 return total
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
896
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
897 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
898 item = self.tree.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
899 name = self.tree.GetItemText(item)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
900 if item == self.mytree_node: return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
901 ac = self.root.ac.get_check_pen() #a 1.5002 for 1.5004 verify fix.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
902 skill = self.skills[name]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
903 untr = skill.get('untrained') #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
904 rank = skill.get('rank') #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
905 if eval('%s == 0' % (untr)): #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
906 if eval('%s == 0' % (rank)): #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
907 res = 'You fumble around, accomplishing nothing' #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
908 txt = '%s Skill Check: %s' % (name, res) #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
909 chat = self.chat #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
910 chat.Post(txt,True,True) #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
911 return #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
912 armor = ''
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
913 acCp = ''
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
914 if ac < 0: #acCp >= 1 #m 1.5004 this is stored as negatives.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
915 armorCheck = int(skill.get('armorcheck'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
916 if armorCheck == 1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
917 acCp=ac
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
918 armor = '(includes Armor Penalty of %s)' % (acCp)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
919 if item == self.mytree_node:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
920 dnd35_char_child.on_ldclick(self,evt)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
921 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
922 mod = self.get_mod(name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
923 if mod >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
924 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
925 chat = self.chat
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
926 txt = '%s Skill Check: [1d20%s%s%s] %s' % (
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
927 name, mod1, mod, acCp, armor)
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
928 Parse.Post(txt, self.chat, True, True)
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
929
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
930 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
931 wnd = outline_panel(parent,self,skill_grid,"Skills")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
932 wnd.title = "Skills (edit)"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
933 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
934
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
935 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
936 html_str = """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
937 <th width='30%'>Skill</th><th>Key</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
938 <th>Rank</th><th>Abil</th><th>Misc</th><th>Total</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
939 node_list = self.xml.findall('skill')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
940
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
941 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
942 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
943 stat = n.get('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
944 rank = n.get('rank')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
945 untr = n.get('untrained') #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
946 #Filter unsuable skills out of pretty print -mgt
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
947 if eval('%s > 0' % (rank)) or eval('%s == 1' % (untr)):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
948 if eval('%s >=1' % (rank)):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
949 html_str += "<tr ALIGN='center' bgcolor='#CCCCFF'><td>" #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
950 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
951 elif eval('%s == 1' % (untr)): #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
952 html_str += "<tr ALIGN='center' bgcolor='#C0FF40'><td>" #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
953 html_str += name+"</td><td>"+stat+"</td><td>"+rank+"</td>" #a 1.6004
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
954 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
955 html_str += "<tr ALIGN='center'><td>"+name+"</td><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
956 html_str += stat+"</td><td>"+rank+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
957 else: continue
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
958 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
959 misc = n.get('misc')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
960 mod = str(self.get_mod(name))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
961 if mod >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
962 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
963 html_str += "<td>"+str(stat_mod)+"</td><td>"+misc #m 1.6009 str()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
964 html_str += '</td><td>%s%s</td></tr>' % (mod1, mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
965 html_str = html_str + "</table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
966 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
967
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
968
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
969 class skill_grid(wx.grid.Grid):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
970 """ panel for skills """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
971 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
972 self.hparent = handler #a 1.5002 need function parent, not invoker
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
973 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
974 pname = handler.xml.set("name", 'Skills')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
975
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
976 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
977 self.Bind(wx.EVT_SIZE, self.on_size)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
978 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
979 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
980 skills = handler.xml.findall('skill')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
981 self.CreateGrid(len(skills),6)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
982 self.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
983 col_names = ['Skill','Key','Rank','Abil','Misc','Total']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
984 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
985 rowi = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
986 self.skills = skills
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
987 for i in range(len(skills)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
988
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
989 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
990 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
991 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
992 value = self.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
993 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
994 int(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
995 if col == 2: self.skills[row].set('rank',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
996 elif col == 4: self.skills[row].set('misc',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
997 self.refresh_row(row)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
998 except: self.SetCellValue(row,col,"0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
999 self.handler.refresh_skills()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1000
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1001 def refresh_row(self,rowi):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1002 s = self.skills[rowi]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1003 name = s.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1004 self.SetCellValue(rowi,0,name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1005 self.SetReadOnly(rowi,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1006 stat = s.get('stat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1007 self.SetCellValue(rowi,1,stat)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1008 self.SetReadOnly(rowi,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1009 self.SetCellValue(rowi,2,s.get('rank'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1010 #self.SetCellValue(rowi,3,str(dnd_globals["stats"][stat])) #d 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1011 if self.root.abilities: stat_mod=self.root.abilities.get_mod(stat) #a 1.5002
152
6081bdc2b8d5 Traipse Beta 'OpenRPG' {091125-00}
sirebral
parents: 135
diff changeset
1012 else:
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1013 stat_mod = -6 #a 1.5002 this can happen if code is changed so
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1014 print "Please advise dnd35 maintainer alert 1.5002 raised"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1015
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1016 self.SetCellValue(rowi,3,str(stat_mod)) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1017 self.SetReadOnly(rowi,3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1018 self.SetCellValue(rowi,4,s.get('misc'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1019 mod = str(self.handler.get_mod(name))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1020 self.SetCellValue(rowi,5,mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1021 self.SetReadOnly(rowi,5)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1022
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1023 def on_size(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1024 (w,h) = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1025 cols = self.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1026 col_w = w/(cols+2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1027 self.SetColSize(0,col_w*3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1028 for i in range(1,cols): self.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1029 evt.Skip()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1030 self.Refresh()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1031
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1032 def refresh_data(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1033 for r in range(self.GetNumberRows()): self.refresh_row(r)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1034
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1035
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1036 class dnd35feats(skills_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1037 """ Node Handler for classes. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1038 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1039 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1040 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1041 skills_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1042 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1043 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1044 self.root.feats = self #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1045
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1046
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1047 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1048 setTitle="Feats - " + self.root.general.charName #a 1.5010
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1049 wnd = outline_panel(parent,self,feat_panel,setTitle) #a 1.5010
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1050 wnd.title = "Feats" #d 1.5010
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1051 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1052
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1053 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1054 html_str = "<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 ><th>Feats</th></tr><tr><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1055 n_list = self.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1056 for n in n_list: html_str += n.get('name')+ ", "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1057 html_str = html_str[:len(html_str)-2] + "</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1058 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1059
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1060 class feat_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1061 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1062
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1063 self.hparent = handler #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1064
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1065 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1066 pname = handler.xml.set("name", 'Feats') #d 1.5010
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1067 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1068 self.grid = wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1069 sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1070 sizer.Add(self.grid, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1071
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1072 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1073 sizer1.Add(wx.Button(self, 10, "Remove Feat"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1074 sizer1.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1075 sizer1.Add(wx.Button(self, 20, "Add Feat"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1076
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1077 sizer.Add(sizer1, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1078 self.sizer = sizer
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1079
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1080 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1081 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1082 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1083
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1084 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1085 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1086
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1087 n_list = handler.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1088 self.n_list = n_list
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1089 self.xml = handler.xml
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1090 self.grid.CreateGrid(len(n_list),3,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1091 self.grid.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1092 self.grid.SetColLabelValue(0,"Feat")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1093 self.grid.SetColLabelValue(1,"Reference")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1094 self.grid.SetColLabelValue(2,"Description") #m 1.6 typo correction.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1095 wrap = wx.grid.GridCellAutoWrapStringRenderer()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1096 attr = wx.grid.GridCellAttr()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1097 attr.SetRenderer(wrap)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1098 self.grid.SetColAttr(2, attr)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1099 for i in range(len(n_list)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1100 self.temp_dom = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1101
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1102 def refresh_row(self,i):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1103 feat = self.n_list[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1104 name = feat.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1105 type = feat.get('type')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1106 desc = feat.get('desc') #m 1.6 correct typo
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1107 self.grid.SetCellValue(i,0,name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1108 self.grid.SetReadOnly(i,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1109 self.grid.SetCellValue(i,1,type)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1110 self.grid.SetReadOnly(i,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1111 self.grid.SetCellValue(i,2,desc) #m 1.6 correct typo
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1112 self.grid.SetReadOnly(i,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1113 self.grid.AutoSizeColumn(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1114 self.grid.AutoSizeColumn(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1115 self.grid.AutoSizeColumn(2, False)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1116 self.grid.AutoSizeRow(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1117
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1118 def on_remove(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1119 rows = self.grid.GetNumberRows()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1120 for i in range(rows):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1121 if self.grid.IsInSelection(i,0):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1122 self.grid.DeleteRows(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1123 self.xml.remove(self.n_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1124
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1125 def on_add(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1126
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1127 if not self.temp_dom:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1128 tree = parse(dir_struct["dnd35"]+"dnd35feats.xml")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1129 xml_dom = tree.getroot()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1130 self.temp_dom = xml_dom
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1131 f_list = self.temp_dom.findall('feat')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1132 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1133 for f in f_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1134 opts.append(f.get('name') + " - [" +
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1135 f.get('type') + "] - " + f.get('desc'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1136 dlg = wx.SingleChoiceDialog(self,'Choose Feat','Feats',opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1137 if dlg.ShowModal() == wx.ID_OK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1138 i = dlg.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1139 new_node = self.xml.append(f_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1140 self.grid.AppendRows(1)
82
2fa8bd6785a5 TerminalWriter's colors are nice, but if no debug console is open it causes the software to look for one until a recursion error is created. Crash reports are sent to the debug console and a pop-up tells the user one has happened. Fix to chat window from SnowDog.
sirebral
parents: 71
diff changeset
1141 self.refresh_row(self.grid.GetNumberRows()-1)
2fa8bd6785a5 TerminalWriter's colors are nice, but if no debug console is open it causes the software to look for one until a recursion error is created. Crash reports are sent to the debug console and a pop-up tells the user one has happened. Fix to chat window from SnowDog.
sirebral
parents: 71
diff changeset
1142 f_list=0; opts=0
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1143 dlg.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1144
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1145
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1146 def on_size(self,event):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1147 s = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1148 self.grid.SetDimensions(0,0,s[0],s[1]-25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1149 self.sizer.SetDimension(0,s[1]-25,s[0],25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1150 (w,h) = self.grid.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1151 cols = self.grid.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1152 col_w = w/(cols)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1153 for i in range(0,cols): self.grid.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1154
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1155 class dnd35combat(dnd35_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1156 """ Node handler for a dnd35 charactor
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1157 <nodehandler name='?' module='dnd35' class='dnd35char_handler2' />
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1158 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1159 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1160
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1161 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1162 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1163 self.root = getRoot(self) #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1164 #mark3
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1165 dnd35_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1166 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1167 self.child_handlers = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1168 self.new_child_handler('hp','Hit Points',dnd35hp,'gear')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1169 self.new_child_handler('attacks','Attacks',dnd35attacks,'spears')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1170 self.new_child_handler('ac','Armor',dnd35armor,'spears')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1171 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1172
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1173 def new_child_handler(self,tag,text,handler_class,icon='gear'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1174 node_list = self.xml.findall(tag)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1175 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1176 i = self.tree.icons[icon]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1177 new_tree_node = tree.AppendItem(self.mytree_node,text,i,i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1178 handler = handler_class(node_list[0],new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1179 tree.SetPyData(new_tree_node,handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1180 self.child_handlers[tag] = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1181
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1182 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1183 return tabbed_panel(parent,self,1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1184
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1185 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1186 return tabbed_panel(parent,self,2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1187
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1188
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1189 class combat_char_child(node_handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1190 """ Node Handler for combat. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1191 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1192 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1193 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1194 node_handler.__init__(self,xml_dom,tree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1195 self.char_hander = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1196 self.drag = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1197 self.frame = component.get('frame')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1198 self.myeditor = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1199
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1200 def on_drop(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1201 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1202
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1203 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1204 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1205
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1206 def on_ldclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1207 return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1208
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1209 def on_html(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1210 html_str = self.tohtml()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1211 wnd = http_html_window(self.frame.note,-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1212 wnd.title = self.xml.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1213 self.frame.add_panel(wnd)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1214 wnd.SetPage(html_str)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1215
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1216 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1217 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1218
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1219 def get_use_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1220 return self.get_design_panel(parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1221
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1222 def delete(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1223 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1224
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1225 class dnd35hp(combat_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1226 """ Node Handler for hit points. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1227 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1228 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1229 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1230 combat_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1231 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1232 self.root = getRoot(self) #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1233 self.root.hp = self #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1234
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1235 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1236 wnd = outline_panel(parent,self,hp_panel,"Hit Points")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1237 wnd.title = "Hit Points"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1238 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1239
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1240 def on_rclick( self, evt ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1241 chp = self.xml.get('current')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1242 mhp = self.xml.get('max')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1243 txt = '((HP: %s / %s))' % ( chp, mhp )
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1244 Parse.Post( txt, self.chat, True, True )
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1245
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1246 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1247 html_str = "<table width=100% border=1 >"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1248 html_str += "<tr BGCOLOR=#E9E9E9 ><th colspan=4>Hit Points</th></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1249 html_str += "<tr><th>Max:</th>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1250 html_str += "<td>"+self.xml.get('max')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1251 html_str += "<th>Current:</th>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1252 html_str += "<td>"+self.xml.get('current')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1253 html_str += "</tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1254 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1255
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1256 class hp_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1257 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1258 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1259 self.hparent = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1260 pname = handler.xml.set("name", 'HitPoints')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1261 self.sizer = wx.FlexGridSizer(2, 4, 2, 2) # rows, cols, hgap, vgap
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1262 self.xml = handler.xml
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1263 self.sizer.AddMany([ (wx.StaticText(self, -1, "HP Current:"), 0,
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1264 wx.ALIGN_CENTER_VERTICAL),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1265 (wx.TextCtrl(self, HP_CUR,
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1266 self.xml.get('current')), 0, wx.EXPAND),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1267 (wx.StaticText(self, -1, "HP Max:"), 0, wx.ALIGN_CENTER_VERTICAL),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1268 (wx.TextCtrl(self, HP_MAX, self.xml.get('max')),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1269 0, wx.EXPAND),
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1270 ])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1271 self.sizer.AddGrowableCol(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1272 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1273 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1274 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1275
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1276 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_MAX)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1277 self.Bind(wx.EVT_TEXT, self.on_text, id=HP_CUR)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1278
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1279 def on_text(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1280 id = evt.GetId()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1281 if id == HP_CUR: self.xml.set('current',evt.GetString())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1282 elif id == HP_MAX: self.xml.set('max',evt.GetString())
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1283
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1284 def on_size(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1285 s = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1286 self.sizer.SetDimension(0,0,s[0],s[1])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1287
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1288 class dnd35attacks(combat_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1289 """ Node Handler for attacks. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1290 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1291 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1292 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1293 combat_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1294 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1295 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1296 self.root.attacks = self #a 1.6009 so others can find me.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1297 self.mrFrame = [] #a 1.9001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1298 self.updateFootNotes = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1299 self.updateFootNotes = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1300 self.html_str = "<html><body>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1301 self.html_str += ("<br /> This character has weapons with no "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1302 "footnotes. This program will "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1303 "add footnotes to the weapons which have names that still match "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1304 "the orginal names. If you have changed the weapon name, you "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1305 "will see some weapons with a footnote of 'X', you will have "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1306 "to either delete and re-add the weapon, or research "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1307 "and add the correct footnotes for the weapon.\n"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1308 "<br /> Please be aware, that only the bow/sling footnote is "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1309 "being used to affect changes to rolls; implemenation of other "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1310 "footnotes to automaticly adjust rolls will be completed as "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1311 "soon as time allows." +
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1312 "<br /><br />Update to character:"+self.root.general.charName+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1313 "<br /><br />"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1314 """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1315 <th width='80%'>Weapon Name</th><th>Added Footnote</th></tr>\n""")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1316 self.temp_dom={}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1317 node_list = self.xml.findall('melee')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1318 self.melee = node_list[0]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1319 node_list = self.xml.findall('ranged')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1320 self.ranged = node_list[0]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1321 self.refresh_weapons()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1322 if self.updateFootNotes == True:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1323 self.updateFootNotes = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1324 name = self.root.general.charName
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1325 self.html_str += "</table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1326 self.html_str += "</body> </html> "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1327 masterFrame = self.root.frame
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1328 title = name+"'s weapons' update to have footnotes"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1329 fnFrame = wx.Frame(masterFrame, -1, title)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1330 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1331 fnFrame.panel.SetPage(self.html_str)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1332 fnFrame.Show()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1333
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1334 #a 1.9001 this whole method
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1335 def refreshMRdata(self): # refresh the data in the melee/ranged section
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1336 # of the attack chart.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1337 # count backwards, maintains context despite "removes"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1338 for i in range(len(self.mrFrame)-1,-1,-1): #a 1.9001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1339 x = self.mrFrame[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1340 if x == None: x.refreshMRdata() #a 1.9001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1341 else: self.mrFrame.remove(x)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1342
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1343 def refresh_weapons(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1344 self.weapons = {}
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1345
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1346 tree = self.tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1347 icons = self.tree.icons
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1348 tree.CollapseAndReset(self.mytree_node)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1349 node_list = self.xml.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1350 for n in node_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1351 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1352 fn = safeGetAttr(n,'fn') #a 1.5012 can be removed when
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1353 if fn == None:#a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1354 self.updateFootNotes=True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1355 self.updateFootN(n) #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1356 new_tree_node = tree.AppendItem(
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1357 self.mytree_node,name,icons['sword'],icons['sword'])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1358 tree.SetPyData(new_tree_node,self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1359 self.weapons[name]=n
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1360
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1361 def updateFootN(self,n):#a 1.5012 this whole function
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1362 if not self.temp_dom:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1363 tree = parse(dir_struct["dnd35"]+"dnd35weapons.xml")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1364 self.temp_dom = tree.getroot()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1365 nameF = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1366 w_list = self.temp_dom.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1367 found = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1368 for w in w_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1369 if nameF == w.get('name'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1370 found = True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1371 fnN = safeGetAttr(n,'fn')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1372 if fnN == None or fnN == 'None':
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1373 fnW = w.get('fn')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1374 self.html_str += ("<tr ALIGN='center'><td>"+nameF+"</td>"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1375 "<td>"+fnW+"</td></tr>\n")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1376 n.set('fn',fnW)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1377 break
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1378 if not found:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1379 self.html_str += ("<tr ALIGN='center'><td>"+nameF+" - Custom "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1380 "Weapon, research "+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1381 "and update manually; setting footnote to indicate custom</td>"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1382 "<td>"+'X'+"</td></tr>\n")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1383 n.set('fn','X')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1384
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1385
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1386 def get_mod(self,type='m'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1387 (base, base2, base3, base4, base5, base6, stat_mod, misc) \
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1388 = self.get_attack_data(type)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1389 return int(base + misc + int(stat_mod))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1390
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1391 def get_attack_data(self,type='m'):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1392 if type=='m' or type=='0':
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1393 stat = 'Str' #m was dnd_globals["stats"]['Str'] 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1394 temp = self.melee
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1395 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1396 stat = 'Dex' #m was dnd_globals["stats"]['Dex'] 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1397 temp = self.ranged
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1398 stat_mod = -7
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1399 stat_mod = self.root.abilities.get_mod(stat) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1400 base = int(temp.get('base'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1401 base2 = int(temp.get('second'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1402 base3 = int(temp.get('third'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1403 base4 = int(temp.get('forth'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1404 base5 = int(temp.get('fifth'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1405 base6 = int(temp.get('sixth'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1406 misc = int(temp.get('misc'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1407 return (base, base2, base3, base4, base5, base6, stat_mod ,misc)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1408
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1409 def on_rclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1410 item = self.tree.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1411 name = self.tree.GetItemText(item)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1412 if item == self.mytree_node: return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1413 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1414 mod = int(self.weapons[name].get('mod'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1415 wepMod = mod #a 1.5008
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1416 footNotes = safeGetAttr(self.weapons[name],'fn','')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1417 cat = self.weapons[name].get('category') #a1.6001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1418 result = split(cat,"-",2) #a 1.6001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1419 if len(result) < 2: #a 1.6021 this if & else
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1420 print "warning: 1.6002 unable to interpret weapon category"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1421 print "format 'type weapon-[Range|Melee]', probably missing"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1422 print "the hyphen. Assuming Melee"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1423 print "weapon name: ",name
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1424 tres="Melee"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1425 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1426 tres=result[1]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1427 if tres == 'Melee': rangeOrMelee = 'm'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1428 elif tres == 'Ranged': rangeOrMelee = 'r'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1429 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1430 print "warning: 1.6001 unable to interpret weapon category"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1431 print "treating weapon as Melee, please correct xml"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1432 print "weapon name:",name
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1433 rangeOrMelee ='m'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1434 mod = mod + self.get_mod(rangeOrMelee) #a 1.5008
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1435 chat = self.chat
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1436 dmg = self.weapons[name].get('damage')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1437
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1438 #a 1.6003 start code fix instance a
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1439 result = split(dmg,"/",2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1440 dmg = result[0]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1441 monkLvl = self.root.classes.get_class_lvl('Monk') # a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1442 if find(dmg, "Monk Med") > -1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1443 if monkLvl == None: #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1444 txt = 'Attempting to use monk attack, but has no monk '
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1445 txt += 'levels, please choose a different attack.'
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1446 Parse.Post( txt, self.chat, True, True ) #a 1.5009
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1447 return #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1448 else: #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1449 lvl=int(monkLvl)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1450 if lvl <= 3: dmg = dmg.replace("Monk Med", "1d6")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1451 elif lvl <= 7: dmg = dmg.replace("Monk Med", "1d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1452 elif lvl <= 11: dmg = dmg.replace("Monk Med", "1d10")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1453 elif lvl <= 15: dmg = dmg.replace("Monk Med", "2d6")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1454 elif lvl <= 19: dmg = dmg.replace("Monk Med", "2d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1455 elif lvl <= 20: dmg = dmg.replace("Monk Med", "2d10")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1456 if find(dmg, "Monk Small") > -1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1457 if monkLvl == None: #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1458 txt = 'Attempting to use monk attack, but has no monk '
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1459 txt += 'levels, please choose a different attack.'
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1460 Parse.Post( txt, self.chat, True, True ) #a 1.5009
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1461 return #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1462 else: #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1463 lvl=int(monkLvl)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1464 if lvl <= 3: dmg = dmg.replace("Monk Small", "1d4")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1465 elif lvl <= 7: dmg = dmg.replace("Monk Small", "1d6")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1466 elif lvl <= 11: dmg = dmg.replace("Monk Small", "1d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1467 elif lvl <= 15: dmg = dmg.replace("Monk Small", "1d10")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1468 elif lvl <= 19: dmg = dmg.replace("Monk Small", "2d6")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1469 elif lvl <= 20: dmg = dmg.replace("Monk Small", "2d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1470 if find(dmg, "Monk Large") > -1:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1471 if monkLvl == None: #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1472 txt = 'Attempting to use monk attack, but has no monk '
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1473 txt += 'levels, please choose a different attack.'
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1474 Parse.Post( txt, self.chat, True, True ) #a 1.5009
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1475 return #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1476 else: #a 1.5009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1477 lvl=int(monkLvl)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1478 if lvl <= 3: dmg = dmg.replace("Monk Large", "1d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1479 elif lvl <= 7: dmg = dmg.replace("Monk Large", "2d6")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1480 elif lvl <= 11: dmg = dmg.replace("Monk Large", "2d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1481 elif lvl <= 15: dmg = dmg.replace("Monk Large", "3d6")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1482 elif lvl <= 19: dmg = dmg.replace("Monk Large", "3d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1483 elif lvl <= 20: dmg = dmg.replace("Monk Large", "4d8")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1484 flurry = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1485 str_mod = self.root.abilities.get_mod('Str') #a 1.5007,11,12,13
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1486 if rangeOrMelee == 'r': #a 1.5008
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1487 #if off_hand == True then stat_mod = stat_mod/2 #o 1.5013
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1488 #c 1.5007 ranged weapons normally get no str mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1489 if find(footNotes,'b') > -1:#a 1.5012 if it's a bow
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1490 if str_mod >= 0: str_mod = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1491 else: str_mod = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1492 mod2 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1493 if str_mod >= 0: mod2 = "+" #1.6 tidy up code.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1494 aStrengthMod = mod2 + str(str_mod) #a 1.5008 applicable strength mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1495 if find(name ,"Flurry of Blows") > -1: flurry = True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1496 (base, base2, base3, base4, base5, base6, stat_mod, misc) = self.get_attack_data(rangeOrMelee) #a 1.5008
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1497 name = name.replace('(Monk Med)', '')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1498 name = name.replace('(Monk Small)', '')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1499 if not flurry:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1500 if name == 'Shuriken':
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1501 for n in xrange(3):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1502 self.sendRoll(base, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod, rollAnyWay=True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1503 self.sendRoll(base2, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1504 self.sendRoll(base3, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1505 self.sendRoll(base4, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1506 self.sendRoll(base5, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1507 self.sendRoll(base6, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1508 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1509 self.sendRoll(base, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod, rollAnyWay=True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1510 self.sendRoll(base2, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1511 self.sendRoll(base3, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1512 self.sendRoll(base4, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1513 self.sendRoll(base5, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1514 self.sendRoll(base6, stat_mod, misc, wepMod, name, '', dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1515 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1516 if monkLvl == None:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1517 txt = 'Attempting to use monk attack, but has no monk '
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1518 txt += 'levels, please choose a different attack.'
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1519 Parse.Post( txt, self.chat, True, True ) #a 1.5009
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1520 return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1521 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1522 lvl = int(monkLvl)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1523 if lvl <= 4:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1524 flu = '-2'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1525 atks = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1526 elif lvl <= 8:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1527 flu = '-1'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1528 atks = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1529 elif lvl <= 10:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1530 flu = ''
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1531 atks = False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1532 elif lvl <= 20:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1533 flu = ''
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1534 atks = True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1535
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1536 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1537 self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1538 if atks: self.sendRoll(base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1539 self.sendRoll(base2, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1540 self.sendRoll(base3, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1541 self.sendRoll(base4, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1542 self.sendRoll(base5, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1543 self.sendRoll(base6, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1544
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1545 def sendRoll(self, base, stat_mod, misc, wepMod, name, flu, dmg, aStrengthMod, rollAnyWay=False):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1546 if base != 0 or rollAnyWay:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1547 base = base + int(stat_mod) + misc + wepMod #m 1.5008
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1548 if base >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1549 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1550 txt = ' %s Attack Roll: <b>[1d20%s%s%s]</b>' % (name, mod1, base, flu)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1551 txt += ' ===> Damage: <b>[%s%s]</b>' % (dmg, aStrengthMod)
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1552 Parse.Post( txt, self.chat, True, True )
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1553
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1554 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1555 wnd = outline_panel(parent,self,attack_panel,"Attacks")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1556 wnd.title = "Attacks"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1557 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1558
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1559 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1560 melee = self.get_attack_data('m')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1561 ranged = self.get_attack_data('r')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1562 html_str = ("""<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >"""+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1563 "<th>Attack</th><th>Total</th><th >Base</th>"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1564 "<th>Abil</th><th>Misc</th></tr>")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1565 html_str += "<tr ALIGN='center' ><th >Melee:</th>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1566 html_str += "<td>"+str(melee[0]+melee[1]+melee[2])+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1567 html_str += "<td>"+str(melee[0])+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1568 html_str += "<td>"+str(melee[1])+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1569 html_str += "<td>"+str(melee[2])+"</td></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1570
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1571 html_str += "<tr ALIGN='center' ><th >Ranged:</th>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1572 html_str += "<td>"+str(ranged[0]+ranged[1]+ranged[2])+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1573 html_str += "<td>"+str(ranged[0])+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1574 html_str += "<td>"+str(ranged[1])+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1575 html_str += "<td>"+str(ranged[2])+"</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1576
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1577 n_list = self.xml.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1578 for n in n_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1579 mod = n.get('mod')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1580 if mod >= 0: mod1 = "+"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1581 else: mod1 = ""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1582 ran = n.get('range')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1583 total = str(int(mod) + self.get_mod(ran))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1584 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1585 <th colspan=2>Weapon</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1586 <th>Attack</th><th >Damage</th><th>Critical</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1587 html_str += "<tr ALIGN='center' ><td colspan=2>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1588 html_str += n.get('name')+"</td><td>"+total+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1589 html_str += "<td>"+n.get('damage')+"</td><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1590 html_str += n.get('critical')+"</td></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1591 html_str += """<tr BGCOLOR=#E9E9E9 ><th>Range</th><th>Weight</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1592 <th>Type</th><th>Size</th><th>Misc Mod</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1593 html_str += "<tr ALIGN='center'><td>"+ran+"</td><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1594 html_str += n.get('weight')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1595 html_str += "<td>"+n.get('type')+"</td><td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1596 html_str += n.get('size')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1597 html_str += '<td>%s%s</td></tr>' % (mod1, mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1598 html_str += """<tr><th BGCOLOR=#E9E9E9 colspan=2>Footnotes:</th>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1599 html_str += "<th colspan=3>"+safeGetAttr(n,'fn','')+"</th></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1600 html_str += '</table>'
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1601 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1602
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1603 class attack_grid(wx.grid.Grid):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1604 """grid for attacks"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1605 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1606 pname = handler.xml.set("name", 'Melee')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1607 self.hparent = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1608 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1609 self.root = getRoot(self) #a 1.9001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1610 self.parent = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1611 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1612 self.rows = (self.handler.melee,self.handler.ranged)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1613 self.CreateGrid(2,10)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1614 self.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1615 col_names = ['Type','base','base 2','base 3','base 4','base 5',
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1616 'base 6','abil','misc','Total']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1617 for i in range(len(col_names)): self.SetColLabelValue(i,col_names[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1618 self.SetCellValue(0,0,"Melee")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1619 self.SetCellValue(1,0,"Ranged")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1620 self.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1621 self.Bind(wx.EVT_SIZE, self.on_size)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1622 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1623 climber = parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1624 nameNode = climber.GetClassName()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1625 while nameNode != 'wxFrame':
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1626 climber = climber.parent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1627 nameNode = climber.GetClassName()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1628 masterFrame=climber
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1629 masterFrame.refreshMRdata=self.refresh_data
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1630
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1631 handler.mrFrame.append(masterFrame)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1632
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1633
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1634 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1635 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1636 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1637 value = self.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1638 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1639 int(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1640 if col==1: self.rows[row].set('base',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1641 elif col== 2: self.rows[row].set('second',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1642 elif col== 3: self.rows[row].set('third',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1643 elif col== 4: self.rows[row].set('forth',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1644 elif col== 5: self.rows[row].set('fifth',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1645 elif col== 6: self.rows[row].set('sixth',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1646 elif col== 8: self.rows[row].set('misc',value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1647 self.parent.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1648 except: self.SetCellValue(row,col,"0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1649
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1650 def refresh_data(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1651
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1652 melee = self.handler.get_attack_data('m')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1653 ranged = self.handler.get_attack_data('r')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1654 tmelee = int(melee[0]) + int(melee[6]) + int(melee[7])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1655 tranged = int(ranged[0]) + int(ranged[6]) + int(ranged[7])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1656 for i in range(0,8): #a 1.5005
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1657 self.SetCellValue(0,i+1,str(melee[i]))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1658 self.SetCellValue(1,i+1,str(ranged[i]))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1659 self.SetCellValue(0,9,str(tmelee))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1660 self.SetCellValue(1,9,str(tranged))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1661 self.SetReadOnly(0,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1662 self.SetReadOnly(1,0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1663 self.SetReadOnly(0,7)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1664 self.SetReadOnly(1,7)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1665 self.SetReadOnly(0,9)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1666 self.SetReadOnly(1,9)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1667
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1668 def on_size(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1669 (w,h) = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1670 cols = self.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1671 col_w = w/(cols+1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1672 self.SetColSize(0,col_w*2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1673 for i in range(1,cols): self.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1674 evt.Skip()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1675 self.Refresh()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1676
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1677 class weapon_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1678 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1679 self.hparent = handler #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1680 self.root = getRoot(self)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1681
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1682 pname = handler.xml.set("name", 'Weapons')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1683
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1684 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1685 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1686 sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1687 sizer.Add(self.grid, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1688
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1689 sizer2 = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1690 sizer2.Add(wx.Button(self, 10, "Remove Weapon"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1691 sizer2.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1692 sizer2.Add(wx.Button(self, 20, "Add Weapon"), 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1693
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1694 sizer.Add(sizer2, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1695 sizer.Add(wx.StaticText(self, -1, "Right click a weapon's footnote to see what the footnotes mean."),0, wx.EXPAND)#a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1696 self.sizer = sizer
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1697 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1698 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1699 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1700
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1701 self.sizer2 = sizer2
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1702 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1703 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1704 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1705 self.grid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.on_gridRclick)#a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1706
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1707 n_list = handler.xml.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1708 self.n_list = n_list
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1709 self.xml = handler.xml
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1710 self.handler = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1711 self.colAttr = ['name','damage','mod','critical','type','weight',
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1712 'range','size','Total','fn', 'comment'] #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1713 col_names = ['Name','Damage','To hit\nmod','Critical','Type','Weight',
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1714 'Range','Size','Total','Foot\nnotes','Comment'] #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1715 gridColCount=len(col_names)#a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1716 self.grid.CreateGrid(len(n_list),gridColCount,1) #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1717 self.grid.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1718
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1719 for i in range(gridColCount): self.grid.SetColLabelValue(i,col_names[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1720 self.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1721 self.temp_dom = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1722
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1723
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1724 #mark4
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1725 #a 1.5012 add entire method.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1726 def on_gridRclick(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1727 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1728 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1729 value = self.grid.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1730
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1731 if col == 9 and value != 'None':
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1732 n = self.n_list[row]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1733 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1734 handler = self.hparent
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1735 masterFrame = handler.frame
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1736 title = name+"'s Special Weapon Characteristics"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1737 fnFrame = wx.Frame(masterFrame, -1, title)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1738 fnFrame.panel = wx.html.HtmlWindow(fnFrame,-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1739 if not self.temp_dom:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1740 tree = parse(dir_struct["dnd35"]+ "dnd35weapons.xml")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1741 self.temp_dom = tree.getroot()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1742 f_list = self.temp_dom.findall('f') # the footnotes
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1743 n = self.n_list[row]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1744 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1745 footnotes = n.get('fn')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1746 html_str = "<html><body>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1747 html_str += """<table border='1' width=100% ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1748 <th width='10%'>Note</th><th>Description</th></tr>\n"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1749 if footnotes == "":
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1750 html_str += "<tr ALIGN='center'><td></td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1751 html_str += " <td>This weapon has no footnotes</td></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1752 for i in range(len(footnotes)):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1753 aNote=footnotes[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1754 found=False
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1755 for f in f_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1756 if f.get('mark') == aNote:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1757 found=True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1758 text=f.get('txt')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1759 html_str += ("<tr ALIGN='center'><td>"+aNote+"</td>"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1760 "<td>"+text+"</td></tr>\n")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1761 if not found:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1762 html_str += ("<tr ALIGN='center'><td>"+aNote+"</td>"+
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1763 "<td>is not a recognized footnote</td></tr>\n")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1764
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1765 html_str += "</table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1766 html_str += "</body> </html> "
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1767 fnFrame.panel.SetPage(html_str)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1768 fnFrame.Show()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1769 return
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1770 pass
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1771
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1772
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1773 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1774 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1775 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1776 value = self.grid.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1777 if col == 2 and not int(value): # special case for mod, demoted
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1778 value = "0" #a 5.012 demoted
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1779 self.n_list[row].set('mod',value) # a 5.012 demoted
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1780 if not (col == 9 and value == "None" and
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1781 self.n_list[row].get('fn') == "None"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1782 ): #a 5.012 special case for footnotes
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1783 self.n_list[row].set(self.colAttr[col],value)#a 5.012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1784
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1785
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1786 def refresh_row(self,i):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1787 n = self.n_list[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1788 fn = n.get('fn')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1789 name = n.get('name')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1790 mod = n.get('mod')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1791 ran = n.get('range')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1792 total = str(int(mod) + self.handler.get_mod(ran))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1793 self.grid.SetCellValue(i,0,name)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1794 self.grid.SetCellValue(i,1,n.get('damage'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1795 self.grid.SetCellValue(i,2,mod)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1796 self.grid.SetCellValue(i,3,n.get('critical'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1797 self.grid.SetCellValue(i,4,n.get('type'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1798 self.grid.SetCellValue(i,5,n.get('weight'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1799 self.grid.SetCellValue(i,6,ran)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1800 self.grid.SetCellValue(i,7,n.get('size') )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1801 self.grid.SetCellValue(i,8,total)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1802 self.grid.SetCellValue(i,9,safeGetAttr(n,'fn','None')) #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1803 self.grid.SetCellValue(i,10,safeGetAttr(n,'comment','')) #a 1.5012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1804 self.grid.SetReadOnly(i,8)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1805
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1806 def on_remove(self,evt): #o 1.6011 correcting wrongful deletion
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1807 rows = self.grid.GetNumberRows()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1808 for i in range(rows-1,-1,-1): #a 1.6011 or you lose context
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1809 if self.grid.IsInSelection(i,0):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1810 self.grid.DeleteRows(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1811 self.xml.remove(self.n_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1812 self.n_list = self.xml.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1813 self.handler.refresh_weapons()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1814
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1815 def on_add(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1816 if not self.temp_dom:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1817 tree = parse(dir_struct["dnd35"]+"dnd35weapons.xml")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1818 self.temp_dom = tree.getroot()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1819 f_list = self.temp_dom.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1820 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1821 for f in f_list: opts.append(f.get('name'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1822 dlg = wx.SingleChoiceDialog(self,'Choose Weapon','Weapon List',opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1823 if dlg.ShowModal() == wx.ID_OK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1824 i = dlg.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1825 new_node = self.xml.append(f_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1826 self.grid.AppendRows(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1827 self.n_list = self.xml.findall('weapon')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1828 self.refresh_row(self.grid.GetNumberRows()-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1829 self.handler.refresh_weapons()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1830 dlg.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1831
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1832 def on_size(self,event):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1833 s = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1834 self.grid.SetDimensions(0,0,s[0],s[1]-40)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1835 self.sizer.SetDimension(0,s[1]-40,s[0],25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1836 self.sizer2.SetDimension(0,s[1]-15,s[0],15)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1837 (w,h) = self.grid.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1838 cols = self.grid.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1839 col_w = w/(cols+1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1840 self.grid.SetColSize(0,col_w*2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1841 for i in range(1,cols): self.grid.SetColSize(i,col_w)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1842
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1843 def refresh_data(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1844 for i in range(len(self.n_list)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1845
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1846
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1847 class attack_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1848 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1849 pname = handler.xml.set("name", 'Melee')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1850 self.parent = parent #a 1.9001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1851 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1852 self.a_grid = attack_grid(self, handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1853 self.w_panel = weapon_panel(self, handler)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1854 self.sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1855 self.sizer.Add(self.a_grid, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1856 self.sizer.Add(self.w_panel, 2, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1857 self.Bind(wx.EVT_SIZE, self.on_size)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1858
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1859 def on_size(self,event):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1860 s = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1861 self.sizer.SetDimension(0,0,s[0],s[1])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1862
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1863 def refresh_data(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1864 self.w_panel.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1865 self.a_grid.refresh_data()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1866
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1867
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1868 class dnd35armor(combat_char_child):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1869 """ Node Handler for ac. This handler will be
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1870 created by dnd35char_handler.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1871 """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1872 def __init__(self,xml_dom,tree_node,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1873 combat_char_child.__init__(self,xml_dom,tree_node,parent)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1874 self.hparent = parent #a 1.5002 allow ability to run up tree.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1875 self.root = getRoot(self) #a 1.5002
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1876 self.root.ac = self #a 1.6009
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1877
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1878 def get_spell_failure(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1879 return self.get_total('spellfailure')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1880
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1881 def get_total_weight(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1882 return self.get_total('weight')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1883
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1884 def get_check_pen(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1885 return self.get_total('checkpenalty')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1886
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1887 def get_armor_class(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1888 ac_total = 10
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1889
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1890 ac_total += self.get_total('bonus')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1891 #m 1.5009 change to hardcode dex, was incorrect gv "stat"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1892 dex_mod = self.root.abilities.get_mod('Dex')#m 1.5009 hardcode dex
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1893 max_dex = self.get_max_dex()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1894 if dex_mod < max_dex: ac_total += dex_mod
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1895 else: ac_total += max_dex
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1896 return ac_total
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1897
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1898 def get_max_dex(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1899 armor_list = self.xml.findall('armor')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1900 dex = 10
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1901 for a in armor_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1902 temp = int(a.get("maxdex"))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1903 if temp < dex: dex = temp
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1904 return dex
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1905
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1906 def get_total(self,attr):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1907 armor_list = self.xml.findall('armor')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1908 total = 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1909 for a in armor_list: total += int(a.get(attr))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1910 return total
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1911
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1912 def get_design_panel(self,parent):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1913 wnd = outline_panel(parent,self,ac_panel,"Armor")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1914 wnd.title = "Armor"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1915 return wnd
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1916
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1917 def on_rclick( self, evt ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1918 ac = self.get_armor_class()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1919 fac = (int(ac)-(self.root.abilities.get_mod('Dex')))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1920
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1921 txt = '((AC: %s Normal, %s Flatfoot))' % ( ac, fac ) #a 1.5002
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents: 156
diff changeset
1922 Parse.Post( txt, self.chat, True, True ) #a 1.5009
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1923
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1924 def tohtml(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1925 html_str = """<table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1926 <th>AC</th><th>Check Penalty</th><th >Spell Failure</th>
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1927 <th>Max Dex</th><th>Total Weight</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1928 html_str += "<tr ALIGN='center' >"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1929 html_str += "<td>"+str(self.get_armor_class())+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1930 html_str += "<td>"+str(self.get_check_pen())+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1931 html_str += "<td>"+str(self.get_spell_failure())+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1932 html_str += "<td>"+str(self.get_max_dex())+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1933 html_str += "<td>"+str(self.get_total_weight())+"</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1934 n_list = self.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1935 for n in n_list:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1936 html_str += """<P><table width=100% border=1 ><tr BGCOLOR=#E9E9E9 >
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1937 <th colspan=3>Armor</th><th>Type</th><th >Bonus</th></tr>"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1938 html_str += "<tr ALIGN='center' >"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1939 html_str += "<td colspan=3>"+n.get('name')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1940 html_str += "<td>"+n.get('type')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1941 html_str += "<td>"+n.get('bonus')+"</td></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1942 html_str += """<tr BGCOLOR=#E9E9E9 >"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1943 html_str += "<th>Check Penalty</th><th>Spell Failure</th>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1944 html_str += "<th>Max Dex</th><th>Speed</th><th>Weight</th></tr>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1945 html_str += "<tr ALIGN='center'>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1946 html_str += "<td>"+n.get('checkpenalty')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1947 html_str += "<td>"+n.get('spellfailure')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1948 html_str += "<td>"+n.get('maxdex')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1949 html_str += "<td>"+n.get('speed')+"</td>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1950 html_str += "<td>"+n.get('weight')+"</td></tr></table>"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1951 return html_str
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1952
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1953
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1954 class ac_panel(wx.Panel):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1955 def __init__(self, parent, handler):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1956 pname = handler.xml.set("name", 'Armor')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1957 self.hparent = handler
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1958 wx.Panel.__init__(self, parent, -1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1959 self.grid =wx.grid.Grid(self, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1960 sizer = wx.BoxSizer(wx.VERTICAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1961 sizer.Add(self.grid, 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1962
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1963 sizer1 = wx.BoxSizer(wx.HORIZONTAL)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1964 sizer1.Add(wx.Button(self, 10, "Remove Armor"), 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1965 sizer1.Add(wx.Size(10,10))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1966 sizer1.Add(wx.Button(self, 20, "Add Armor"), 1, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1967
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1968 sizer.Add(sizer1, 0, wx.EXPAND)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1969
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1970 self.sizer = sizer
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1971 self.SetSizer(self.sizer)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1972 self.SetAutoLayout(True)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1973 self.Fit()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1974
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1975 self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1976 self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1977 self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1978 self.xml = handler.xml
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1979 n_list = handler.xml.getchildren()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1980 self.n_list = n_list
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1981 col_names = ['Armor','bonus','maxdex','cp','sf','weight','speed','type']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1982 self.grid.CreateGrid(len(n_list),len(col_names),1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1983 self.grid.SetRowLabelSize(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1984 for i in range(len(col_names)): self.grid.SetColLabelValue(i,col_names[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1985 self.atts =['name','bonus','maxdex','checkpenalty',
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1986 'spellfailure','weight','speed','type']
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1987 for i in range(len(n_list)): self.refresh_row(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1988 self.temp_dom = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1989
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1990
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1991 def on_cell_change(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1992 row = evt.GetRow()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1993 col = evt.GetCol()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1994 value = self.grid.GetCellValue(row,col)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1995 if col >= 1 and col <= 5:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1996 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1997 int(value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1998 self.n_list[row].set(self.atts[col],value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
1999 except: self.grid.SetCellValue(row,col,"0")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2000 else: self.n_list[row].set(self.atts[col],value)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2001
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2002 def refresh_row(self,i):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2003 n = self.n_list[i]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2004 for y in range(len(self.atts)): self.grid.SetCellValue(i,y,n.get(self.atts[y]))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2005
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2006 def on_remove(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2007 rows = self.grid.GetNumberRows()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2008 for i in range(rows):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2009 if self.grid.IsInSelection(i,0):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2010 self.grid.DeleteRows(i)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2011 self.xml.remove(self.n_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2012
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2013 def on_add(self,evt):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2014 if not self.temp_dom:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2015 tree = parse(dir_struct["dnd35"]+"dnd35armor.xml")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2016 self.temp_dom = tree.getroot()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2017 f_list = self.temp_dom.findall('armor')
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2018 opts = []
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2019 for f in f_list: opts.append(f.get('name'))
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2020 dlg = wx.SingleChoiceDialog(self,'Choose Armor:','Armor List',opts)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2021 if dlg.ShowModal() == wx.ID_OK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2022 i = dlg.GetSelection()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2023 new_node = self.xml.append(f_list[i])
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2024 self.grid.AppendRows(1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2025 self.refresh_row(self.grid.GetNumberRows()-1)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2026 dlg.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2027
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2028 def on_size(self,event):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2029 s = self.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2030 self.grid.SetDimensions(0,0,s[0],s[1]-25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2031 self.sizer.SetDimension(0,s[1]-25,s[0],25)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2032 (w,h) = self.grid.GetClientSizeTuple()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2033 cols = self.grid.GetNumberCols()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2034 col_w = w/(cols+2)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2035 self.grid.SetColSize(0,col_w*3)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 152
diff changeset
2036 for i in range(1,cols): self.grid.SetColSize(i,col_w)