# HG changeset patch
# User sirebral
# Date 1292820276 21600
# Node ID d02e9197c06636173d0b5ba7a635a62dd5ca798f
# Parent ee890f424e1642fac313557763c9a08dcdba2980
Traipse 'OpenRPG' {101220-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 (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
New ShapeShifter PC Sheet
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
Update to location.py, allows for more portable references when starting Traipse
Update to the Features node
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 Server, removing wxPython dependencies where not needed
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
diff -r ee890f424e16 -r d02e9197c066 images/Copyright Notice.txt
--- a/images/Copyright Notice.txt Wed May 05 08:55:51 2010 -0500
+++ b/images/Copyright Notice.txt Sun Dec 19 22:44:36 2010 -0600
@@ -1,3 +1,5 @@
+Ironclaw logo (tm) 1999, 2010 Sanguine Productions. Used with permission from Sanguine Productions Ltd to Knowledge Arcana Mad Mathematics Laboratories, all rights reserved.
+
The following images are Copyright Sekkyumu and released to the Public Domain
add.png
add_button.png
diff -r ee890f424e16 -r d02e9197c066 images/iron-claw.gif
Binary file images/iron-claw.gif has changed
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/base.py
--- a/orpg/dieroller/base.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/base.py Sun Dec 19 22:44:36 2010 -0600
@@ -126,6 +126,7 @@
elif hasattr(other,"sum"): return cmp(self.sum(), other.sum())
else: return UserList.UserList.__cmp__(self,other)
+
def __rcmp__(self,other):
return self.__cmp__(other)
@@ -229,7 +230,7 @@
### di class to handle actual dice
class di:
- def __init__(self, sides, min=1):
+ def __init__(self,sides,min=1):
self.sides = sides
self.history = None
self.value = None
@@ -263,6 +264,7 @@
def __int__(self):
return self.value
+
def __lt__(self,other):
if type(other) == type(3) or type(other) == type(3.0): return self.value < other
elif hasattr(other,"value"): return self.value < other.value
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/7sea.py
--- a/orpg/dieroller/rollers/7sea.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/rollers/7sea.py Sun Dec 19 22:44:36 2010 -0600
@@ -38,12 +38,13 @@
class seventhsea(std):
name = "7sea"
+ regExpression = "[\(0-9\*\-\+\)]+[a-zA-Z]+[0-9]+"
def __init__(self,source=[]):
std.__init__(self,source)
- def non_stdDie(self, s):
- print '7th Sea'
+ def non_stdDie(self, match):
+ s = match.group(0)
num_sides = s.split('k')
if len(num_sides) > 1:
num_sides; num = num_sides[0]; sides = '10'; target = num_sides[1]
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/__init__.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/alternity.py
--- a/orpg/dieroller/rollers/alternity.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/rollers/alternity.py Sun Dec 19 22:44:36 2010 -0600
@@ -118,7 +118,6 @@
elif ( self.dieRoll <= self.score / 2 ): self.success = 'G'
elif ( self.dieRoll <= self.score ): self.success = 'O'
else: self.success = 'F'
- if ( self.d20 == 20 ): self.success = 'CF'
return myStr
def __str__(self):
@@ -218,31 +217,17 @@
myStr = " ACTION CHECK : "+myStr
successes = {'CS': " CRITICAL SUCCESS",
- 'CF': " CRITICAL FAILURE
-2 Step make up bonus next Action Check",
+ 'CF': " CRITICAL FAILURE",
'A': " AMAZING Success",
'G': " Good Success",
'O': " Ordinary Success",
'F': " Marginal failure"}
- if ( self.d20 == 1 ): myStr += successes['CS'] # SEG Dec 19 2009
- myStr += successes[self.success]
- if ( self.d20 == 1 ) and (self.success == 'F') :
- myStr += " final result ==> "
- myStr += successes['O'] # SEG JAN 23 2010
- if ( self.d20 != 1 ) and (self.success == 'F') :
- myStr += "
-1 Step make up bonus next Action Check"
-
+ if self.d20 == 1:
+ myStr += successes['CS']
+ myStr += ' (' +successes[self.success]+ ' )'
+ elif self.d20 == 20:
+ myStr += successes['CF']
+ myStr += ' (' +successes[self.success]+ ' )'
+ else: myStr += successes[self.success]
return myStr
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/d20.py
--- a/orpg/dieroller/rollers/d20.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/rollers/d20.py Sun Dec 19 22:44:36 2010 -0600
@@ -43,17 +43,17 @@
std.__init__(self,source)
self.DC = DC
self.mod = mod
- self.append(static_di(mod))
+ #self.append(static_di(mod))
def is_success(self):
- return ((self.sum() >= self.DC or self.data[0] == 20) and self.data[0] != 1)
+ return ((self.sum()+self.mod >= self.DC or self.data[0] == 20) and self.data[0] != 1)
def __str__(self):
myStr = "[" + str(self.data[0])
for a in self.data[1:]:
- myStr += ","
+ myStr += ", "
myStr += str(a)
- myStr += "] = (" + str(self.sum()) + ")"
+ myStr += ", "+str(self.mod)+ "] = (" + str(self.sum()+self.mod) + ")"
myStr += " vs DC " + str(self.DC)
if self.is_success(): myStr += " Success!"
else: myStr += " Failure!"
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/earthdawn.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/orpg/dieroller/rollers/earthdawn.py Sun Dec 19 22:44:36 2010 -0600
@@ -0,0 +1,165 @@
+## A die roller as used by Earthdawn RPG
+# Copyright (C) 2000-2010 The OpenRPG Project
+#
+# owner@madmathlabs.com
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# --
+#
+# File: earthdawn.py
+# Author: Prof. Ebral, TaS (Traipse)
+# Maintainer:
+# Version:
+# $Id: earthdawn.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
+#
+# Description: Earthdawn Die Roller
+# Comissioned by Jacob H.
+#
+
+
+from std import std
+import random
+from orpg.dieroller.base import *
+
+class earthdawn(std):
+ name = "earthdawn"
+ regExpression = "[a-zA-Z]+([0-9]+/[0-9]+|[0-9]+)"
+
+ def __init__(self, source=[]):
+ std.__init__(self, source)
+ self.successLevels = self.buildLevels()
+
+ def non_stdDie(self, match):
+ s = match.group(0)
+ if s[:4] == 'step' or s[:1] == 's':
+ dice = s.lower().split('step')
+ rollType = 'Step'
+ if len(dice) == 1: dice = s.lower().split('s')
+ try: step, vs = dice[1].split('/')
+ except: step, vs = dice[1], 0
+ stepRoll = self.stepAlgorithm(step)
+ elif s[:5] == 'karma' or s[:1] == 'k':
+ dice = s.lower().split('karma')
+ rollType = 'Karma'
+ if len(dice) == 1: dice = s.lower().split('k')
+ step, vs = dice[1], 0
+ stepRoll = self.stepAlgorithm(step)
+ elif s[:4] == 'test' or s[:1] == 't':
+ dice = s.lower().split('test')
+ rollType = 'Test'
+ if len(dice) == 1: dice = s.lower().split('t')
+ try: step, vs = dice[1].split('/')
+ except: return
+ return self.successTest(step, vs)
+ return self.finalize(step, stepRoll, vs, rollType)
+
+ def rollDice(self, dice, facets):
+ rolls = []
+ for x in range(0, dice):
+ roll = self.roll(facets)
+ while roll >= facets:
+ rolls.append(roll)
+ roll = self.roll(facets)
+ rolls.append(roll)
+ return rolls
+
+ def roll(self, facets):
+ return int(random.uniform(1, facets+1))
+
+ def stepAlgorithm(self, stepRoll):
+ if stepRoll == 0: return 0
+ oneTothree = {'1': -3, '2': -2, '3': -1}
+ if oneTothree.has_key(stepRoll):
+ dieList = self.rollDice(1, 6)
+ dieList[0] += oneTothree[stepRoll]
+ return dieList
+ stepRoll = int(stepRoll)-3; self.dieList = []
+ for step in xrange(0, stepRoll): self.stepIncrease()
+ d6s = 0; d8s = 0; d10s = 0; d12s = 0
+ dieList = []
+ for die in self.dieList:
+ if die == 6: d6s += 1
+ if die == 8: d8s += 1
+ if die == 10: d10s += 1
+ if die == 12: d12s += 1
+ if d6s!= 0: d6s = self.rollDice(d6s, 6); dieList += d6s
+ if d8s!= 0: d8s = self.rollDice(d8s, 8); dieList += d8s
+ if d10s!= 0: d10s = self.rollDice(d10s, 10); dieList += d10s
+ if d12s!= 0: d12s = self.rollDice(d12s, 12); dieList += d12s
+ return dieList
+
+ def stepIncrease(self):
+ lowDie = 12
+ if len(self.dieList) == 0: self.dieList.append(6); return
+ for splitDie in self.dieList:
+ if splitDie < lowDie: lowDie = splitDie
+ if lowDie == 12: self.dieList[self.dieList.index(lowDie)] = 6; self.dieList.append(6); return
+ else: self.dieList[self.dieList.index(lowDie)] += 2; return
+
+ def successLevel(self, level, vs):
+ index = 0
+ successLevels = self.successLevels[int(vs)]
+ for success in successLevels:
+ if level > success: index = successLevels.index(success)+1
+ elif level == success: index = successLevels.index(success)
+ if index == 0: return 'Pathetic'
+ if index == 1: return 'Poor'
+ if index == 2: return 'Average'
+ if index == 3: return 'Good'
+ if index == 4: return 'Excellent'
+ if index >= 5: return 'Extraordinary'
+
+ def successTest(self, stepTotal, vs):
+ myStr = 'Success Test: ' +stepTotal+ ' vs. ' +vs
+ successLevel = self.successLevel(int(stepTotal), int(vs))
+ myStr += '= ' +successLevel
+ return myStr
+
+ def finalize(self, step, stepRoll, vs, rollType):
+ myStr = '' +rollType+' Roll: ' +step
+ if vs != 0: myStr += ' vs. ' +vs
+ myStr += ' => ' +str(stepRoll)+ ' (Total: '
+ stepTotal = 0
+ for step in stepRoll: stepTotal += step
+ myStr += str(stepTotal)
+ if vs != 0:
+ myStr += ' vs. ' +str(vs)
+ successLevel = self.successLevel(stepTotal, vs)
+ myStr += ') ' +successLevel
+ else: myStr += ')'
+ return myStr
+
+ def buildLevels(self):
+ successLevels = {
+ 2: [0, 1, 4, 6, 8, 9], 3: [0, 2, 5, 7, 9, 10], 4: [0, 3, 6, 9, 11, 12],
+ 5: [1, 4, 7, 10, 13, 14], 6: [1, 5, 8, 12, 16, 17], 7: [2, 6, 10, 14, 18, 19],
+ 8: [3, 7, 12, 15, 19, 20], 9: [4, 8, 14, 17, 21, 22], 10: [5, 9, 15, 19, 22, 23],
+ 11: [5, 10, 16, 20, 24, 25], 12: [6, 11, 17, 22, 26, 27], 13: [6, 12, 19, 24, 28, 29],
+ 14: [7, 13, 20, 25, 30, 31], 15: [8, 14, 22, 26, 30, 31], 16: [9, 15, 23, 27, 32, 33],
+ 17: [10, 16, 24, 29, 33, 34], 18: [11, 17, 25, 30, 35, 36], 19: [11, 18, 27, 32, 36, 37],
+ 20: [12, 19, 28, 33, 38, 39], 21: [13, 20, 29, 35, 40, 41], 22: [14, 21, 30, 36, 41, 42],
+ 23: [15, 22, 32, 37, 42, 43], 24: [15, 23, 33, 38, 43, 44], 25: [16, 24, 34, 40, 45, 46],
+ 26: [17, 25, 35, 41, 46, 47], 27: [18, 26, 36, 42, 48, 49], 28: [18, 27, 38, 44, 49, 50],
+ 29: [20, 28, 39, 45, 50, 51], 30: [20, 29, 40, 46, 52, 53], 31: [21, 30, 41, 47, 53, 54],
+ 32: [22, 31, 42, 48, 54, 55], 33: [23, 32, 44, 50, 56, 57], 34: [23, 33, 45, 51, 57, 58],
+ 35: [24, 34, 46, 52, 59, 60], 36: [25, 35, 47, 53, 59, 60], 37: [26, 36, 48, 55, 61, 62],
+ 38: [27, 37, 50, 56, 62, 63], 39: [28, 38, 51, 57, 63, 64], 40: [29, 39, 52, 58, 65, 66],
+ 41: [28, 40, 52, 60, 70, 71], 42: [29, 41, 53, 61, 71, 72], 43: [30, 42, 54, 63, 72, 73],
+ 44: [31, 43, 55, 64, 74, 75], 45: [31, 44, 57, 66, 76, 77]
+ }
+ return successLevels
+
+die_rollers.register(earthdawn)
+
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/gurps.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/hackmaster.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/hero.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/ironclaw.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/orpg/dieroller/rollers/ironclaw.py Sun Dec 19 22:44:36 2010 -0600
@@ -0,0 +1,869 @@
+## A die roller as used by IronClaw RPG
+# Copyright (C) 2000-2010 The OpenRPG Project
+#
+# owner@madmathlabs.com
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# --
+#
+# File: ironclaw.py
+# Author: Prof. Ebral, TaS (Traipse)
+# Maintainer:
+# Version:
+# $Id: ironclaw.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
+#
+# Description: IronClaw Die Roller
+# Comissioned by Ponderer
+#
+"""
+Notes: The original concept of the Iron Claw roller is too advanced for Ornery Orc so I am taking notes. The idea is a highly desired idea, a PC Sheet that
+can interact with other PC Sheets to expedite die rolls. PC Sheet data will be shared via the map, expected to occur in Pious Paladin, because the map makes
+a safe sand box for the game tree data.
+
+The combat system in Iron Claw is not straight forward enough for compared rolls, so the out put orders the rolls from highest to lowest, coloring the highest
+and the ones. When PC Sheet data can be shared in a safe format, the comparitive possibility already exists. After the makeDecision function the list of dice is returned also, allow for the two dice lists to be rolled and then compared.
+
+By far the most intricate commission I have had so far. I really wish I could have accomplised all that was requested.
+"""
+
+from std import std
+from math import fabs
+import random
+from orpg.dieroller.base import *
+from orpg.tools.InterParse import Parse
+""" For note
+ret = ['(', num.strip(), "**die_rollers['", self.getRoller(), "'](",
+ sides.strip(), '))']
+s = ''.join(ret)
+"""
+class ironclaw(std):
+ name = "ironclaw"
+ regGroup = '[a-zA-Z0-9. (::)(\-\+)]+'
+ regExpression = regGroup+'/'+regGroup+'|'+regGroup
+ pcSheets = {}
+ healingTable = {
+ 1: ['1d4', '2d4', '2d6', '2d8'],
+ 2: ['1d6', '2d6', '2d8', '2d10'],
+ 3: ['1d8', '2d8', '2d10', '2d12'],
+ 4: ['1d10', '2d10', '2d12', '3d12'],
+ 5: ['1d12', '2d12', '3d12', '3d12'],
+ 6: ['2d12', '3d12', '3d12', '4d12'],
+ 7: ['2d12', '3d12', '4d12', '4d12'],
+ 8: ['3d12', '4d12', '4d12', '4d12'],
+ 9: ['3d12', '4d12', '5d12', '6d12']
+ }
+ acceptedDice = ['4', '6', '8', '10', '12']
+ deathTable = {
+ 6: '1d4', 7: '1d6', 8: '1d8', 9: '1d10',
+ 10: '1d12', 11: '2d12', 12: '3d12', 13: 'Dead'
+ }
+ unconTable = {
+ 3: '1d4', 4: '1d6', 5: '1d8', 6: '1d10', 7: '1d12',
+ 8: '2d12', 9: '3d12', 10: '4d12', 11: '4d12', 12: '4d12'
+ }
+ conditions = {'easy': 0, 'medium': 1, 'hard': 2, 'extreme': 3}
+
+ def __init__(self, source=[]):
+ std.__init__(self, source)
+
+ def non_stdDie(self, match):
+ s = match.group(0)
+ vsRoll = s.split('/'); pcSheets = []; PCs = []
+ for roll in vsRoll:
+ PCs.append(roll.split('.'))
+ for pc in PCs:
+ if pc[0].lower() == 'toolbox': return self.ToolBox(pc)
+ else: pcSheets.append(self.findSheets(pc))
+ #
+ actor, aDice, adDice = self.makeDecision(PCs[0], pcSheets[0])
+ myStr = actor; compareTest = None
+ #
+ if len(aDice) > 1:
+ myStr += ' ' +self.cleanDice(aDice)[0]+ ' => '
+ attackRoll = self.rollDice(aDice)
+ myStr += attackRoll[0]
+ compareTest = self.compareTest(attackRoll[1], [1,1])
+ if compareTest == 'botch': myStr += ' Botch!'
+ if (isinstance(adDice, list)) and (compareTest != 'botch'):
+ myStr += ' Damage: ' +self.cleanDice(adDice)[0]+ ' => '
+ myStr += self.rollDamage(adDice)[0]
+ if len(pcSheets) == 2:
+ if pcSheets[1][0] == True: reactor, rDice, rdDice = self.makeDecision(PCs[1], pcSheets[1][1])
+ else:
+ diceList = ['None']
+ for die in PCs[1]:
+ trueDice = self.makeTrueDice(die)
+ for die in trueDice: diceList.append(die)
+ diceList = self.buildActionList(diceList)
+ rDice = self.diceModifiers(diceList)
+ myStr += ' / ' +str(rDice)+ ' => '
+ rDice.sort(); rDice.reverse()
+ rDiceRolled = self.rollDice(rDice)[0]
+ myStr += str(rDice)
+ return myStr
+
+ def ToolBox(self, commands):
+ ## This is expandable. Aimed for GM use ##
+ if commands[1].lower() == 'clearpcs':
+ for key in self.pcSheets.keys(): del self.pcSheets[key]
+ return 'Clearing PC Sheets'
+
+ def makeDecision(self, pcAction, pcSheetData):
+ pcSheet = pcSheetData[1]
+ if self.pcSheets.has_key(pcAction[0]): pcNode = pcSheet['Node']
+ else: pcNode = pcSheetData[2]
+ actionList = self.buildActionList(pcAction); skillList = self.buildSkillList(pcSheet['Skills'])
+ ability = self.buildAbilities(pcSheet['Abilities']); nodeList = self.buildNodeList(pcSheet)
+ myStr = ''+self.NameSpaceXI('name', pcSheet['General']).text+ ' '
+ diceList = []; options = ['parry', 'guard', 'retreat', 'nocover']
+ toolbox = ['setpc', 'delpc', 'clearpcs', 'update']
+ actions = ['denarii', 'aureals', 'fatigue', 'wounds', 'passout',
+ 'resolve', 'soak', 'rest', 'block', 'dodge', 'magic',
+ 'damage', 'meditate', 'initiative', 'strength']
+ #others = ['cast'] ## For future dev
+ #magicCareers = ['cleric', 'elementalist', 'thaumaturge', 'necromancer', 'green and purple mage']
+ damage = None
+ self.updatePC(pcSheet, skillList, ability['speed'], actionList)
+ for action in actionList:
+ action = action.lower(); actionNodes = action.split('::')
+ if action in options: pass ## Pass over these.
+
+ elif action in toolbox:
+ if action == 'setpc': myStr += self.setPCSheet(pcSheetData[2], pcSheet, actionList)
+ elif action == 'delpc': myStr += self.delPCSheet(pcAction[0])
+ elif action == 'update':
+ myStr += self.updatePC(pcSheet, skillList, ability['speed'], actionList)
+ while len(actionList) > 1: actionList.pop()
+
+ elif action in actions:
+ if action in ['denarii', 'aureals']:
+ myStr += self.setCoin(pcSheet['Purse'], action, actionList)
+ elif action in ['fatigue', 'wounds']:
+ myStr += self.setWound(pcSheet['Character'], action, ability['body'], actionList)
+ elif action == 'soak':
+ myStr += 'Soak: '
+ diceList += self.pcSoak(pcSheet['Defense'])
+ elif action == 'strength':
+ myStr += 'Strength: '
+ diceList += self.pcStrength(pcSheet['Abilities'])
+ elif action == 'initiative':
+ myStr += 'Initiative: '
+ diceList += self.pcInit(pcSheet['Defense'])
+ elif action in ['block', 'dodge']:
+ dice = self.dodgeBlock(action, ability, actionList, pcSheet['Defense'], pcSheet['Equipment'], skillList)
+ myStr += action.capitalize()+'s'
+ if dice != 'No Dice Found!': diceList += dice
+ elif action == 'rest':
+ myStr += self.restPC(pcSheet['Character'], pcSheet['Skills'], ability['body'], action, actionList)
+ elif action == 'meditate':
+ myStr += self.restPC(pcSheet['Character'], skillList, ability['body'], action, actionList)
+ elif action == 'magic': myStr += self.pcMagic(pcSheet['Character'], actionList)
+ elif action == 'damage': string, damage = self.pcDamage(actionList); myStr += string
+ elif action == 'passout': myStr += self.passoutTest(pcSheet['Character'], pcSheet['Defense'], skillList, ability['will'])
+ elif action == 'resolve':
+ myStr += 'Resolve: '
+ diceList += self.pcResolve(pcSheet['Character'], pcSheet['Defense'], skillList, ability['will'])
+
+ elif nodeList.has_key(action):
+ if ability.has_key(action):
+ myStr += 'Ability; '+action.capitalize()+' '
+ abilityDice = self.makeTrueDice( str(ability[action].find('text').text) )
+ for die in abilityDice:
+ diceList.append(die)
+ else:
+ string, dice, damage = self.getNodeValue(action, actionList, ability, nodeList, pcSheet, skillList, pcNode)
+ myStr += string+' '
+ if isinstance(dice, list): diceList += dice
+
+ elif skillList.has_key(action):
+ dice = self.getSkillDice(skillList[action])
+ if dice != 'No Dice Found!': diceList += dice
+ myStr += 'Skill; '+action.capitalize()+' '
+
+ elif nodeList.has_key(actionNodes[len(actionNodes)-1]):
+ string, dice, damage = self.getNodeValue(action, actionList, ability, nodeList, pcSheet, skillList, pcNode)
+ myStr += string+' '
+ if isinstance(dice, list): diceList += dice
+
+ else:
+ trueDice = self.makeTrueDice(action)
+ for die in trueDice: diceList.append(die)
+ if len(actionList) > 1: diceList.append(actionList[len(actionList)-1])
+ if len(diceList) > 1: diceList = self.diceModifiers(diceList)
+ if damage != None: damage = self.diceModifiers(damage)
+ return myStr, diceList, damage
+
+ def pcMagic(self, character, actionList):
+ magic = int(actionList[len(actionList)-1])
+ magicPoints = self.NameSpaceVI('magic points', character)
+ cMagic = self.NameSpaceXI('current', magicPoints); cM = int(cMagic.text)
+ mMagic = self.NameSpaceXI('maximum', magicPoints); mM = int(mMagic.text)
+ myStr = 'Regains ' if magic >= 0 else 'Loses '
+ if len(actionList) == 2:
+ if magic < 0:
+ if cM + magic < 0: return 'Insufficient Magic!'
+ cM += magic
+ if cM > mM: cM = mM
+ myStr += str(magic)+ ' Magic.'
+ cMagic.text = str(cM)
+ else:
+ diceList = []
+ for x in xrange(1, len(actionList)):
+ trueDice = self.makeTrueDice(actionList[x])
+ for die in trueDice:diceList.append(die)
+ diceList.append(actionList[len(actionList)-1])
+ diceList = self.diceModifiers(diceList)
+ while len(actionList) > 1: actionList.pop()
+ addMagic = self.rollDice(diceList); x = 0
+ for m in addMagic[1]: x += int(m)
+ cM += x
+ if cM > mM: cM = mM
+ cMagic.text = str(cM)
+ return 'Regains ' +self.cleanDice(diceList)[0]+ ' => ' +addMagic[0]+ ' => [' +str(x)+ '] Magic.'
+ return myStr
+
+ def pcDamage(self, actionList):
+ if len(actionList) == 2: return 'No Damage Dice', None
+ diceList = []
+ if 'd' in actionList[len(actionList)-1]: mod = '0'
+ else: mod = int(actionList[len(actionList)-1])
+ for x in xrange(1, len(actionList)-1):
+ trueDice = self.makeTrueDice(actionList[x])
+ for die in trueDice: diceList.append(die)
+ diceList.append(mod)
+ while len(actionList) > 1: actionList.pop()
+ return '', diceList
+
+ def pcStrength(self, abilities):
+ strength = self.NameSpaceXI('strength dice', abilities)
+ trueDice = self.makeTrueDice(str(strength.text))
+ return trueDice
+
+ def pcSoak(self, defense):
+ soak = self.NameSpaceXI('soak', defense)
+ trueDice = self.makeTrueDice(str(soak.text))
+ return trueDice
+
+ def pcInit(self, defense):
+ init = self.NameSpaceXI('initiative', defense)
+ trueDice = self.makeTrueDice(str(init.text))
+ return trueDice
+
+ def setCoin(self, purse, action, actionList):
+ denarii = self.NameSpaceXI('denarii', purse); d = int(denarii.text)
+ aureals = self.NameSpaceXI('aureals', purse); a = int(aureals.text)
+ coins = int(actionList[len(actionList)-1])
+ myStr = 'Gains ' if coins >= 0 else 'Loses '
+ if action == 'denarii':
+ d += coins
+ while d >= 24:
+ a += 1; d -= 24
+ myStr += str(coins)+ ' Denarii'
+ if d < 0: a -= 1; d += 24
+ if action == 'aureals': a += coins; myStr += str(coins)+ ' Aureals'
+ if a < 0: return 'Not enough coins!'
+ if d < 0: return 'Not enough coins!'
+ aureals.text = str(a); denarii.text = str(d)
+ return myStr
+
+ def setWound(self, character, action, body, actionList):
+ fatigue = self.NameSpaceXI('fatigue', character); f = int(fatigue.text)
+ wounds = self.NameSpaceVI('wounds', character)
+ cWounds = self.NameSpaceXI('current', wounds); cW = int(cWounds.text)
+ mWounds = self.NameSpaceXI('maximum', wounds); mW = int(mWounds.text)
+ total = self.NameSpaceXI('total', character); t = int(total.text)
+ mod = int(actionList[len(actionList)-1])
+ myStr = 'Suffers ' if mod >= 0 else 'Regains '
+ if action == 'fatigue':
+ myStr += str(mod)+ ' Fatigue '; tie = False
+ for x in range(0, mod):
+ f += 1
+ if f > t:
+ f -= 1; cW += 1
+ if (cW >= mW-6) and not tie:
+ deathTest = self.deathTest(cW+(12-mW), body)
+ if deathTest[0] == 'Dead': tie = True; myStr += deathTest[1]
+ if deathTest[2] in ['failure', 'riposte', 'tie', 'botch']: tie = True; myStr += deathTest[1]
+ else: myStr += deathTest[1]
+ if action == 'wounds':
+ myStr += str(int(fabs(mod)))+ ' Wounds '; tie = False
+ if mod > 0:
+ for x in xrange(0, mod):
+ cW += 1
+ if (cW >= mW-6) and not tie:
+ deathTest = self.deathTest(cW+(12-mW), body)
+ if deathTest[0] == 'Dead': tie = True; myStr += deathTest[1]
+ if deathTest[2] in ['failure', 'riposte', 'tie', 'botch']: tie = True; myStr += deathTest[1]
+ else: myStr += deathTest[1]
+ else: cW += mod
+ if cW < 0: cW = 0
+ if f < 0: f = 0
+ t = f + cW; fatigue.text = str(f); cWounds.text = str(cW); total.text = str(t)
+ if t > mW: myStr += 'You have fallen.'
+ return myStr
+
+ def restPC(self, character, skills, body, action, actionList):
+ if 'd' in actionList[len(actionList)-1]: mod = 0
+ else: mod = int(actionList[len(actionList)-1])
+
+ if action == 'meditate':
+ if not skills.has_key('meditate'):
+ if not skills.has_key('meditation'):
+ while len(actionList) > 1: actionList.pop()
+ return 'No skill in Meditation.'
+ magicPoints = self.NameSpaceVI('magic points', character)
+ cMagic = self.NameSpaceXI('current', magicPoints); cM = int(cMagic.text)
+ mMagic = self.NameSpaceXI('maximum', magicPoints); mM = int(mMagic.text)
+ vsDice = self.getSkillDice(skills['meditate'], [3,8]) if skills.has_key('meditate') else self.getSkillDice(skills['meditation'], [3,8])
+ vsDice += vsDice
+ skDice = self.getSkillDice(skills['meditate'], [3,4,5,6,7]) if skills.has_key('meditate') else self.getSkillDice(skills['meditation'], [3,4,5,6,7])
+ if skDice != 'No Dice Found!': vsDice += skDice
+ myStr = 'Meditates, '
+ condition = 'easy'
+ vsCondition = []
+ for x in xrange(1, len(actionList)):
+ trueDice = self.makeTrueDice(actionList[x])
+ for die in trueDice: vsCondition.append(die)
+ if len(vsCondition) == 0: return 'No Difficulty Set.'
+ magicGained = 0; result = 'success' # Begins loop
+ while result in ['success', 'overwhelm']:
+ vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
+ if result == 'success': myStr += 'Meditate Skill: ' +self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
+ if result == 'overwhelm': myStr += ' Rolling Again: ' +self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
+ myStr += ' vs. '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
+ result = self.compareTest(vsRoll[1], conRoll[1])
+ if result == 'riposte': myStr += ' Overwhelming failure'
+ else: myStr += ' '+result.capitalize()
+ if result == 'success':
+ magicGained += 1
+ break
+ if result == 'overwhelm':
+ magicGained += 2
+ if magicGained > 0:
+ myStr += ' Regains '+str(magicGained)+' magic.'
+ cM += magicGained
+ if cM > mM: cM = mM
+ cMagic.text = str(cM)
+ while len(actionList) > 1: actionList.pop()
+
+ if action == 'rest':
+ fatigue = self.NameSpaceXI('fatigue', character); f = int(fatigue.text)
+ wounds = self.NameSpaceVI('wounds', character)
+ cWounds = self.NameSpaceXI('current', wounds); cW = int(cWounds.text)
+ mWounds = self.NameSpaceXI('maximum', wounds); mW = int(mWounds.text)
+ total = self.NameSpaceXI('total', character); t = int(total.text)
+ myStr = 'Rests ' +str(mod)+ ' hours. '
+ f -= mod
+ if f < 0: f = 0
+ if mod >= 8:
+ myStr += 'Roll Magic Dice'
+ if cW > 0:
+ vsDice = body.find('text').text
+ vsDice = self.makeTrueDice(vsDice)
+ c = 9 if cW > 9 else cW
+ condition = 'easy' if not self.conditions.has_key(actionList[1]) else actionList[1]
+ vsCondition = self.healingTable[c][self.conditions[condition]]
+ vsCondition = self.makeTrueDice(vsCondition)
+ vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
+ myStr += ', Roll Wounds; Body: ' +self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
+ myStr += ' vs. Condition ('+condition.capitalize()+'): '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
+ result = self.compareTest(vsRoll[1], conRoll[1])
+ if result == 'riposte': myStr += ' Overwhelming failure'
+ else: myStr += ' '+result.capitalize()
+ if result in ['success', 'overwhelm']: cW -= 1
+ if result == 'botch':
+ cW += 1
+ deathTest = self.deathTest(cW, body)
+ if deathTest[0] == 'Dead': return deathTest[1]
+ else: myStr += deathTest[1]
+ if cW < 0: cW = 0
+ if f < 0: f = 0
+ if t > mW: myStr += 'You have fallen.'
+ t = f + cW; fatigue.text = str(f); cWounds.text = str(cW); total.text = str(t)
+ return myStr
+
+ def dodgeBlock(self, action, ability, actionList, defense, equipment, skillList):
+ optionals = ['guard', 'retreat']
+ blockDice = self.getSkillDice(skillList[action]) if action in skillList.keys() else []
+ speed = self.makeTrueDice( str(ability['speed'].find('text').text) )
+ for s in speed: blockDice.append(s)
+ defendSkill = self.NameSpaceXI(action, defense)
+ defendSkill.text = ', '.join(blockDice)
+ if 'nocover' not in actionList:
+ cover = self.NameSpaceXI('cover', defense)
+ cover = self.makeTrueDice(str(cover.text))
+ for c in cover: blockDice.append(c)
+ if 'retreat' in actionList: blockDice.append('1d8')
+ if action == 'dodge':
+ encumber = self.NameSpaceXI('encumbrance', equipment)
+ try:
+ encumber = float(encumber.text)
+ if encumber < -1:
+ encumber = int(encumber)
+ blockDice = self.encumberDice(blockDice, encumber, speed)
+ except: pass
+ if 'guard' in actionList: blockDice.append('+2')
+ return blockDice
+
+ def pcResolve(self, character, defense, skillList, abilityWill):
+ total = self.NameSpaceXI('total', character); t = int(total.text)
+ resolveDice = self.getSkillDice(skillList['resolve']) if 'resolve' in skillList.keys() else []
+ will = self.makeTrueDice( abilityWill.find('text').text )
+ for w in will: resolveDice.append(w)
+ resolveDice = self.cleanDice(resolveDice)[1]
+ defendSkill = self.NameSpaceXI('resolve', defense)
+ defendSkill.text = ', '.join(resolveDice)
+ return resolveDice
+
+
+ ### Data Functions ###
+ def getSkillDice(self, skill, skip=[0]):
+ dice = []; cells = skill.findall('cell')
+ for x in xrange(3, 9):
+ if (cells[x].text != '') or (cells[x].text != None):
+ if x in skip: pass
+ else:
+ skillDice = self.makeTrueDice(str(cells[x].text))
+ for s in skillDice: dice.append(s)
+ if len(dice) == 0: return 'No Dice Found!'
+ else: return dice
+
+ def buildAbilities(self, pcSheet):
+ nodes = pcSheet.getiterator('nodehandler')
+ ability = {}
+ for node in nodes:
+ if node.get('name') == 'Body': ability['body'] = node
+ if node.get('name') == 'Speed': ability['speed'] = node
+ if node.get('name') == 'Mind': ability['mind'] = node
+ if node.get('name') == 'Will': ability['will'] = node
+ return ability
+
+ def buildActionList(self, actions):
+ actionLength = len(actions); actionList = []
+ for x in xrange(1, actionLength):
+ if x == actionLength-1:
+ getMod = self.getMod(actions[x])
+ for action in getMod[0]: actionList.append(str(action))
+ actionList.append(str(getMod[1]))
+ else:
+ for action in self.getMod(actions[x])[0]: actionList.append(str(action))
+ return actionList
+
+ def buildSkillList(self, skills):
+ grid = skills.find('grid')
+ listRows = []
+ for row in grid.findall('row'):
+ listRows.append(row)
+ skillList = {}
+ for x in xrange(1, len(listRows)):
+ if listRows[x].findall('cell')[0].text != None:
+ skillList[listRows[x].findall('cell')[0].text.lower()] = listRows[x]
+ return skillList
+
+ def buildNodeList(self, pcSheet):
+ nodeList = {}
+ for key in pcSheet.keys():
+ nodes = pcSheet[key].getiterator('nodehandler')
+ for node in nodes:
+ nodeList[node.get('name').lower()] = node
+ return nodeList
+
+
+ ### Test Functions ###
+ def deathTest(self, cW, body):
+ vsDice = body.find('text').text
+ vsDice = self.makeTrueDice(vsDice)
+ vsCondition = self.deathCheck(cW)
+ if vsCondition != []:
+ if vsCondition[0] == 'Dead': myStr = ' You have fallen.'; return [vsCondition[0], myStr, None]
+ vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
+ myStr = '
Death Check: '+self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
+ myStr += ' vs. Death: '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
+ result = self.compareTest(vsRoll[1], conRoll[1])
+ if result == 'riposte': myStr += ' Overwhelming failure'
+ else: myStr += ' '+result.capitalize()
+ if result in ['botch', 'failure', 'riposte']: myStr += ' You have fallen.'
+ else: myStr += ' You have survived.'
+ return [vsCondition[0], myStr, result]
+
+ def passoutTest(self, character, defense, skillList, abilityWill):
+ #mod = int(actionList[len(actionList)-1]) or 0
+ total = self.NameSpaceXI('total', character); t = int(total.text)
+ vsDice = self.getSkillDice(skillList['resolve']) if 'resolve' in skillList.keys() else []
+ will = self.makeTrueDice( abilityWill.find('text').text )
+ for w in will: vsDice.append(w)
+ vsDice = self.cleanDice(vsDice)[1]
+ defendSkill = self.NameSpaceXI('resolve', defense)
+ defendSkill.text = ', '.join(vsDice)
+ vsCondition = self.unconCheck(t)
+ myStr = ''
+ if vsCondition != []:
+ vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
+ myStr += 'Unconciousness Check: '+self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
+ myStr += ' vs. '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
+ result = self.compareTest(vsRoll[1], conRoll[1])
+ if result == 'riposte': myStr += ' Overwhelming failure'
+ else: myStr += ' '+result.capitalize()
+ if result in ['botch', 'failure', 'riposte']: myStr += ' You have passed out.'
+ else: myStr += ' You have survived.'
+ else: myStr += 'No Unconciousness Check Required!'
+ return myStr
+
+ def unconCheck(self, fatigue):
+ dieList = []
+ if fatigue > 12: fatigue = 12
+ if self.unconTable.has_key(fatigue):
+ dieList.append(self.unconTable[fatigue])
+ return dieList
+
+ def deathCheck(self, wounds):
+ dieList = []
+ if wounds > 13: wounds = 13
+ if self.deathTable.has_key(wounds):
+ dieList.append(self.deathTable[wounds])
+ return dieList
+
+ def compareTest(self, dice1, dice2):
+ ## Do Botch, Tie, Overwhelming.
+ botch = 0
+ for x in xrange(0, len(dice1)):
+ if dice1[x] == 1: botch += 1
+ if botch == len(dice1): return 'botch'
+ botch = 0
+ for x in xrange(0, len(dice2)):
+ if dice2[x] == 1: botch += 1
+ if botch == len(dice2):
+ if dice1[0] > dice2[0]:
+ if int(dice1[0]) - int(dice2[0]) >= 5: return 'overwhelm'
+ else: return 'success' #result2 = 'botch'
+ #
+ if dice1[0] == dice2[0]: return 'tie'
+ #
+ if dice1[0] > dice2[0]:
+ if int(dice1[0]) - int(dice2[0]) >= 5: return 'overwhelm'
+ else: return 'success'
+ elif dice2[0] >= dice1[0]:
+ if int(dice2[0]) - int(dice1[0]) >= 5: return 'riposte'
+ else: return 'failure'
+
+ def compareDamage(self, dice1, dice2):
+ # Works like this. [6, 4, 3] vs [5, 5, 2] == 2 Wounds.
+ # [7, 3, 3] vs [6, 3, 3] == 1 Wounds. Ties go to the defender, 1's are not counted.
+ ## Added for future dev.
+ pass
+
+
+ ### Node Functions ###
+ def NameSpaceXI(self, s, node):
+ nodeList = node.getiterator('nodehandler')
+ for node in nodeList:
+ if node.get('name').lower() == s: return node.find('text')
+ return ''
+
+ def NameSpaceVI(self, s, node): ## Sometimes I just need the node. I don't like the name though.
+ nodeList = node.getiterator('nodehandler')
+ for node in nodeList:
+ if node.get('name').lower() == s: return node
+ return ''
+
+ def getNodeValue(self, action, actionList, ability, nodeList, pcSheet, skillList, pcNode):
+ nodePath = actionList[0]
+ weapons = pcSheet['Combat'].getiterator('nodehandler')
+ optionals = ['parry', 'guard', 'retreat']
+ damage = None
+ if nodeList.has_key(action) and nodeList[action] in weapons:
+ toHit = []; damage = []
+ speed = self.makeTrueDice( str(ability['speed'].find('text').text) )
+ for s in speed: toHit.append(s)
+ grid = nodeList[action].find('grid')
+
+ if actionList[1] == 'damage':
+ for row in grid.findall('row'):
+ cells = row.findall('cell')
+ if cells[0].text == 'Damage':
+ trueDice = self.makeTrueDice(cells[1].text)
+ for die in trueDice: damage.append(die)
+ damage.append(actionList[len(actionList)-1])
+ if cells[0].text == 'Name':
+ weaponName = str(cells[1].text)
+ while len(actionList) > 1: actionList.pop()
+ return weaponName, action, damage
+
+ string = 'Attacks!'
+ for row in grid.findall('row'):
+ cells = row.findall('cell')
+ if cells[0].text == 'Skill':
+ weaponSkill = str(cells[1].text).lower()
+ skillDice = self.getSkillDice(skillList[weaponSkill]) if weaponSkill in skillList.keys() else None
+ if isinstance(skillDice, list): toHit += skillDice
+ if cells[0].text == 'Damage':
+ trueDice = self.makeTrueDice(cells[1].text)
+ for die in trueDice: damage.append(die)
+ #damage.append(actionList[len(actionList)-1])
+ if 'parry' in actionList:
+ damage = None
+ string = 'Defends'
+ if 'retreat' in actionList: toHit.append('1d8')
+ if 'guard' in actionList: toHit.append(str(int(actionList[len(actionList)-1])+2))
+ return string, toHit, damage
+ return Parse.NameSpaceE('!&'+pcNode.get('name')+'::'+nodePath+'&!'), action, damage
+
+
+ ### pcSheet Functions ###
+ def findSheets(self, initiate):
+ if self.pcSheets.has_key(initiate[0]): return True, self.pcSheets[initiate[0]]
+ pcSheet = Parse.NameSpaceXE('!&'+initiate[0]+'&!')
+ if pcSheet == None: return [False, [initiate[0]], None]
+ else: return [True, self.buildPCSheet(pcSheet), pcSheet]
+ return [False, [initiate[0]], None]
+
+ def buildPCSheet(self, PC):
+ pcSheet = {}
+ nodes = PC.getiterator('nodehandler')
+ for node in nodes:
+ if node.get('name') == 'Character': pcSheet['Character'] = node
+ if node.get('name') == 'Skills':
+ if node.get('class') == 'rpg_grid_handler': pcSheet['Skills'] = node
+ if node.get('name') == 'General': pcSheet['General'] = node
+ if node.get('name') == 'Abilities': pcSheet['Abilities'] = node
+ if node.get('name') == 'Gifts / Flaws': pcSheet['Gifts / Flaws'] = node
+ if node.get('name') == 'Combat': pcSheet['Combat'] = node
+ if node.get('name') == 'Defense': pcSheet['Defense'] = node
+ if node.get('name') == 'Equipment': pcSheet['Equipment'] = node
+ if node.get('name') == 'Purse': pcSheet['Purse'] = node
+ #print 'pcSheet', len(pcSheet)
+ return pcSheet
+
+ def setPCSheet(self, pcNode, pcSheet, actionList):
+ if len(actionList) < 2: return 'Cannot setPC'
+ while actionList[0].lower() != 'setpc': actionList.pop()
+ self.pcSheets[actionList[1]] = pcSheet
+ self.pcSheets[actionList[1]]['Node'] = pcNode
+ return 'PC Sheet set to '+ actionList[1]
+
+ def delPCSheet(self, pcSheet):
+ del self.pcSheets[pcSheet]
+ return 'PC Sheet '+pcSheet+' deleted.'
+
+ def updatePC(self, pcSheet, skillList, abilitySpeed, actionList):
+ denarii = self.NameSpaceXI('denarii', pcSheet['Purse']); d = int(denarii.text)
+ aureals = self.NameSpaceXI('aureals', pcSheet['Purse']); a = int(aureals.text)
+ while d >= 24: a += 1; d -= 24
+ aureals.text = str(a); denarii.text = str(d)
+ #
+ blockDice = self.getSkillDice(skillList['dodge']) if 'dodge' in skillList.keys() else []
+ speed = self.makeTrueDice( abilitySpeed.find('text').text )
+ for s in speed: blockDice.append(s)
+ blockDice = self.cleanDice(blockDice)[1]
+ defendSkill = self.NameSpaceXI('dodge', pcSheet['Defense'])
+ defendSkill.text = ', '.join(blockDice)
+ #
+ blockDice = self.getSkillDice(skillList['block']) if 'block' in skillList.keys() else []
+ for s in speed: blockDice.append(s)
+ blockDice = self.cleanDice(blockDice)[1]
+ defendSkill = self.NameSpaceXI('block', pcSheet['Defense'])
+ defendSkill.text = ', '.join(blockDice)
+ #
+ fatigue = self.NameSpaceXI('fatigue', pcSheet['Character']); f = int(fatigue.text)
+ wounds = self.NameSpaceVI('wounds', pcSheet['Character'])
+ cWounds = self.NameSpaceXI('current', wounds); cW = int(cWounds.text)
+ mWounds = self.NameSpaceXI('maximum', wounds); mW = int(mWounds.text)
+ total = self.NameSpaceXI('total', pcSheet['Character']); t = int(total.text)
+ t = f + cW; fatigue.text = str(f); cWounds.text = str(cW); total.text = str(t)
+ return 'Updated.'
+
+
+ ### Math Functions ###
+ def getMod(self, action):
+ action = action.split('+')
+ mod = '+'+str(action[1]) if len(action) == 2 else '0'
+ action = action[0]
+ if mod == '0':
+ action = action.split('-')
+ mod = '-'+str(action[1]) if len(action) == 2 else '0'
+ action = action[0]
+ action = [action]
+ return [action, mod]
+
+ def encumberDice(self, diceList, encumber, speed):
+ encumber += 1; speedCap = 12+encumber*2
+ for x in xrange(0, len(diceList)):
+ diceCheck = diceList[x].split('d')
+ try: rolls = int(diceCheck[0])
+ except: continue
+ try: facets = int(diceCheck[1])
+ except: continue
+ if facets > speedCap: facets = speedCap
+ diceList[x] = str(rolls)+'d'+str(facets)
+ return diceList
+
+ def diceModifiers(self, diceList):
+ diceList.sort(); diceList.reverse()
+ dice = [0, 0, 0, 0, 0]
+ getMod = True; mod = 0
+ for dieMod in diceList:
+ try: mod += int(dieMod); del diceList[diceList.index(dieMod)]
+ except: pass
+ if mod <= 0:
+ diceList.append(str(mod))
+ return diceList
+ for die in diceList:
+ d = die.split('d')
+ if die == mod: pass
+ elif d[1] == '4': dice[0] += int(d[0])
+ elif d[1] == '6': dice[1] += int(d[0])
+ elif d[1] == '8': dice[2] += int(d[0])
+ elif d[1] == '10': dice[3] += int(d[0])
+ elif d[1] == '12': dice[4] += int(d[0])
+ diceMod = [0, 0, 0, 0, 0, 0]
+ for i in xrange(0, len(dice)):
+ dMod = (mod-(4-i))*dice[i]
+ if dMod < 0: dMod = 0
+ if i == 4: diceMod[5] += mod*dice[i]; diceMod[4] += dice[i]
+ elif i+mod >= 5: diceMod[5] += dMod; diceMod[4] += dice[i]
+ else: diceMod[i+mod] = dice[i]
+ while diceMod[5] > 0:
+ self.applyMod(diceMod)
+ diceMod.pop(); dice = diceMod
+ diceList = []
+ if dice[0] != 0: diceList.append(str(dice[0])+'d4')
+ if dice[1] != 0: diceList.append(str(dice[1])+'d6')
+ if dice[2] != 0: diceList.append(str(dice[2])+'d8')
+ if dice[3] != 0: diceList.append(str(dice[3])+'d10')
+ if dice[4] != 0: diceList.append(str(dice[4])+'d12')
+ diceList.append(str(mod))
+ return diceList
+
+ def applyMod(self, diceMod):
+ for i in xrange(0, 5):
+ while diceMod[i] > 0:
+ if diceMod[5] == 0: break
+ diceMod[5] -= 1
+ if i == 4: diceMod[0] += 1; break
+ else: diceMod[i+1] += 1; diceMod[i] -= 1
+
+
+ ### Dice Functions ###
+ def makeTrueDice(self, dieSet):
+ dice = dieSet.split(',')
+ dieSet = []
+ for die in dice:
+ if 'd' not in die: die = None
+ else:
+ die = die.replace(' ', '')
+ die = die.split('d')
+ try:
+ int(die[1])
+ if die[0] == '':
+ if die[1] in self.acceptedDice: die = '1d'.join(die)
+ else: die = 'd'.join(die)
+ except: die = None
+ if die != None: dieSet.append(die)
+ return dieSet
+
+ def cleanDice(self, diceList):
+ dice = [0, 0, 0, 0, 0]
+ if 'd' in diceList[len(diceList)-1]: mod = '0'
+ else: mod = diceList[len(diceList)-1]
+ for die in diceList:
+ d = die.split('d')
+ if die == mod: pass
+ elif d[1] == '4': dice[0] += int(d[0])
+ elif d[1] == '6': dice[1] += int(d[0])
+ elif d[1] == '8': dice[2] += int(d[0])
+ elif d[1] == '10': dice[3] += int(d[0])
+ elif d[1] == '12': dice[4] += int(d[0])
+ diceList = []
+ if dice[0] != 0: diceList.append(str(dice[0])+'d4')
+ if dice[1] != 0: diceList.append(str(dice[1])+'d6')
+ if dice[2] != 0: diceList.append(str(dice[2])+'d8')
+ if dice[3] != 0: diceList.append(str(dice[3])+'d10')
+ if dice[4] != 0: diceList.append(str(dice[4])+'d12')
+ cleanList = '['
+ for die in diceList:
+ cleanList += die+', '
+ cleanList += mod+']'
+ return [cleanList, diceList]
+
+ def rollDamage(self, diceList):
+ if 'd' in diceList[len(diceList)-1]: mod = 0; diceList.append('0')
+ else: mod = int(diceList[len(diceList)-1])
+ removeDice = []
+ diceRolls = []
+ for x in xrange(0, len(diceList)-1):
+ dice, facets = diceList[x].split('d')
+ rolls = self.roll(int(dice), int(facets))
+ for roll in rolls: diceRolls.append(roll)
+ diceRolls.sort(); diceRolls.reverse()
+ myStr = '['
+ if mod < 0:
+ for x in xrange(0, int(fabs(mod))): removeDice.append(len(diceRolls)-x-1)
+ if len(diceRolls) > 1:
+ if 0 in removeDice: myStr += ''+str(diceRolls[0])+', '
+ else: myStr += ''+str(diceRolls[0])+', '
+ for x in xrange(1, len(diceRolls)-1):
+ if x in removeDice: myStr += ''+str(diceRolls[x])+', '
+ else: myStr += str(diceRolls[x])+', '
+ myStr += ''+str(diceRolls[len(diceRolls)-1])+', '+str(mod)+'] '
+ else:
+ if 0 in removeDice: myStr += ''+str(diceRolls[0])+', '+str(mod)+'] '
+ else: myStr += ''+str(diceRolls[0])+', '+str(mod)+'] '
+ diceRolls.append(mod)
+ return [myStr, diceRolls]
+
+ def rollDice(self, diceList):
+ if 'd' in diceList[len(diceList)-1]: mod = 0; diceList.append('0')
+ else: mod = int(diceList[len(diceList)-1])
+ if mod < 0: rerolls = mod
+ else: rerolls = 0
+ rollSets = []; myStr = ''; result = [100]
+ while rerolls <= 0:
+ diceRolls = []
+ for x in xrange(0, len(diceList)-1):
+ dice, facets = diceList[x].split('d')
+ rolls = self.roll(int(dice), int(facets))
+ for roll in rolls: diceRolls.append(roll)
+ diceRolls.sort(); diceRolls.reverse()
+ rollSets.append(diceRolls); rerolls += 1
+ for diceRolls in rollSets:
+ if result[0] < diceRolls[0]: pass
+ else: result = diceRolls
+ myStr += '['
+ if len(diceRolls) > 1:
+ myStr += ''+str(diceRolls[0])+', '
+ for x in xrange(1, len(diceRolls)-1): myStr += str(diceRolls[x])+', '
+ myStr += ''+str(diceRolls[len(diceRolls)-1])+'] '
+ else: myStr += ''+str(diceRolls[0])+'] '
+ myStr += 'Result: '+str(result[0])+' '
+ return [myStr, result]
+
+ def roll(self, dice, facets):
+ rolls = []
+ for x in range(0, dice): rolls.append(int(random.uniform(1, facets+1)))
+ return rolls
+
+ def stdDie_Class(self, s): ## Not used
+ num_sides = s.split('d')
+ if len(num_sides) > 1:
+ num = num_sides[0]; sides = num_sides[1]
+ if sides.strip().upper() == 'F': sides = "'f'"
+ try:
+ if int(num) > 100 or int(sides) > 10000: return None
+ except: pass
+ ret = ['(q', num.strip(), "**die_rollers['std'](", sides.strip(), '))']
+ s = ''.join(ret)
+ return s
+
+die_rollers.register(ironclaw)
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/mythos.py
--- a/orpg/dieroller/rollers/mythos.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/rollers/mythos.py Sun Dec 19 22:44:36 2010 -0600
@@ -30,8 +30,8 @@
# Targetthr is the Threshhold target
# for compatibility with Mage die rolls.
# Threshhold addition by robert t childers
-
-from std import std
+
+from std import std
from orpg.dieroller.base import *
__version__ = "$Id: wod.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
@@ -39,6 +39,7 @@
class mythos(std):
name = "mythos"
+ regExpression = "[\(0-9\*\-\+\)]+[a-zA-Z]+[0-9]+"
def __init__(self,source=[],target=0,targetthr=0):
std.__init__(self,source)
@@ -85,7 +86,8 @@
else: myStr += "] vs " +str(self.target)+" result of (" + str(self.sum()) + ")"
return myStr
- def non_stdDie(self, s):
+ def non_stdDie(self, match):
+ s = match.group(0)
num_sides = s.split('v')
if len(num_sides) > 1:
num_sides; num = num_sides[0]; sides = num_sides[1]
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/runequest.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/savage.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/shadowrun.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/sr4.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/srex.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/std.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/trinity.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/wfrpg.py
--- a/orpg/dieroller/rollers/wfrpg.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/rollers/wfrpg.py Sun Dec 19 22:44:36 2010 -0600
@@ -37,11 +37,13 @@
class wfrpg(std):
name = "wfrpg"
+ regExpression = "(?:\d+|\([0-9\*/\-\+]+\))\s*[a-zA-Z]+\s*[a-zA-Z]+"
def __init__(self, source=[]):
std.__init__(self, source)
- def non_stdDie(self, s):
+ def non_stdDie(self, match):
+ s = match.group(0)
self.war_die = {'rec': self.reckless,
'con': self.conservative,
'chr': self.characteristic,
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/wod.py
--- a/orpg/dieroller/rollers/wod.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/rollers/wod.py Sun Dec 19 22:44:36 2010 -0600
@@ -38,6 +38,7 @@
class wod(std):
name = "wod"
+ regExpression = "[\(0-9\*\-\+\)]+[a-zA-Z]+[0-9]+"
def __init__(self,source=[],target=0,targetthr=0):
std.__init__(self,source)
@@ -81,13 +82,14 @@
else: myStr += "] vs " +str(self.target)+" result of (" + str(self.sum()) + ")"
return myStr
- def non_stdDie(self, s):
+ def non_stdDie(self, match):
+ s = match.group(0)
num_sides = s.split('v')
if len(num_sides) > 1:
num_sides; num = num_sides[0]; sides = num_sides[1]
sides = '10'; target = num_sides[1]
ret = ['(', num.strip(), "**die_rollers['wod'](",
sides.strip(), ')).vs(', target, ')']
- s = ''.join(ret); return str(eval(s))
+ s = ''.join(ret); return s
die_rollers.register(wod)
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/rollers/wodex.py
diff -r ee890f424e16 -r d02e9197c066 orpg/dieroller/utils.py
--- a/orpg/dieroller/utils.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dieroller/utils.py Sun Dec 19 22:44:36 2010 -0600
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-# Copyright (C) 2000-2001 The OpenRPG Project
+# Copyright (C) 2000-2010 The OpenRPG Project
#
-# openrpg-dev@lists.sourceforge.net
+# owner@madmathlabs.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,20 +20,32 @@
#
# File: dieroller/utils.py
# Author: OpenRPG Team
-# Maintainer:
+# Maintainer (Traipse): Tyler Starke
# Version:
# $Id: utils.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
#
# Description: Classes to help manage the die roller
#
-__version__ = "$Id: utils.py,v Traipse 'Ornery-Orc' prof.ebral Exp Exp $"
-
import re
import orpg.dieroller.rollers
from orpg.dieroller.base import die_rollers
+"""
+Die Roller Changes:
+I've made some changes for ease of reading. Below you see the new formula and the old depricated formula. The new formula is easier to understand
+and works a little better with math. Try this: [(2+4)+4d(6+8)+(4*4)] with both formulas. Traipse succeeds, Standard (1.7.1) fails.
+
+The new formula deals only with numbers of the Fudge roller. The math has a required process flow, which is unliked currently by me but I am not
+going to spend more time on at currently to correct it. It occurs when using paranthesis on the facet. If paranthesis are used no modifier can be added
+at the end, but you can added it before the roll.
+
+This is the standard roller formula: (Math D Numbers or Math or Fudge). If that fails the new non_stdDie looks for a regExpression formula inside
+the current die roller, set under the name. So all of that bloat to include the english language in the Gilcrease 1.8.0 remains bloat and Traipse's
+dice can be liberated to do what they want, where they want, when they want.
+"""
+
class roller_manager(object):
def __new__(cls):
it = cls.__dict__.get("__it__")
@@ -55,8 +67,14 @@
def listRollers(self):
return die_rollers.keys()
- def stdDieToDClass(self, match):
- s = match.group(0); self.eval = str(match.string)
+ def completeMath(self, matches):
+ s = matches.group(0)
+ try: doMath = str(eval(s))
+ except: doMath = s
+ return doMath
+
+ def stdDie_Class(self, match):
+ s = match.group(0)
num_sides = s.split('d')
if len(num_sides) > 1:
num_sides; num = num_sides[0]; sides = num_sides[1]
@@ -67,38 +85,48 @@
ret = ['(', num.strip(), "**die_rollers['", self.getRoller(), "'](",
sides.strip(), '))']
s = ''.join(ret)
- self.eval = s
return s
- ## Portable Non Standard Die Characters #Prof-Ebral
- else: s = die_rollers._rollers[self.getRoller()]().non_stdDie(s); return s
-
# Use this to convert ndm-style (3d6) dice to d_base format
- def convertTheDieString(self,s):
- self.result = ''
- reg = re.compile("(?:\d+|\([0-9\*/\-\+]+\))\s*[a-zA-Z]+\s*[\dFf]+")
- (result, num_matches) = reg.subn(self.stdDieToDClass, s)
- if num_matches == 0 or result is None:
- reg = re.compile("(?:\d+|\([0-9\*/\-\+]+\))\s*[a-zA-Z]+\s*[a-zA-Z]+") ## Prof Ebral
- (result, num_matches) = reg.subn(self.stdDieToDClass, s) ## Prof Ebral
- """try: ## Kinda pointless when you can create new Regular Expressions
- s2 = self.roller_class + "(0)." + s ## Broken method
- test = eval(s2)
- return s2
- except Exception, e: print e; pass"""
- self.result = result
- try: return self.do_math(s)
- except: pass
- return result
+ def stdDie(self, s):
+ math = '[\(0-9\/\*\-\+\)]+'
+ reg = re.compile('[0-9]+d\s*([0-9]+|'+math+'|[fF])')
+ #reg = re.compile("(?:\d+|\([0-9\*/\-\+]+\))\s*[a-zA-Z]+\s*[\dFf]+") ## Original
+ try:
+ (result, num_matches) = reg.subn(self.stdDie_Class, s)
+ #print 'main', result, num_matches
+ if num_matches == 0 or result is None:
+ reg = re.compile(math)
+ (result, math_matches) = reg.subn(self.completeMath, s)
+ #print 'math1', result, num_matches
+ reg = re.compile('[0-9]+d\s*([0-9]+|'+math+'|[fF])')
+ (result, num_matches) = reg.subn(self.stdDie_Class, result)
+ #print 'math2', result, num_matches
+ except Exception, e:
+ print 'Die string conversion failed,', e
+ return s
+ return str(result)
- def do_math(self, s):
- return str(eval(s))
+ def nonStdDie(self, s):
+ math = '[\(0-9\/\*\-\+\)]+'
+ reg = re.compile(math)
+ (result, math_matches) = reg.subn(self.completeMath, s)
+
+ reg = re.compile(die_rollers._rollers[self.getRoller()].regExpression)
+ (result, num_matches) = reg.subn(self.roller_class().non_stdDie, s) ## Currently skipping math
+
+ if num_matches == 0 or result is None: return s
+ else: return result
def proccessRoll(self, s):
- v = self.convertTheDieString(s)
- try: b = str(eval(v))
- except:
- if v == self.eval: b = s
- else: b = str(v) ##Fail safe for non standard dice.
+ ## Re arranged to allow the non standard dice to use the built in roller methods,
+ ## not re-written roller methods.
+ b = self.stdDie(s)
+ try: b = str(eval(b))
+ except:
+ b = self.nonStdDie(s)
+ try: b = str(eval(b))
+ except: pass
return b
+
diff -r ee890f424e16 -r d02e9197c066 orpg/dirpath/dirpath_tools.py
--- a/orpg/dirpath/dirpath_tools.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/dirpath/dirpath_tools.py Sun Dec 19 22:44:36 2010 -0600
@@ -1,12 +1,4 @@
-import sys
-import os
-import errno
-from orpg.orpg_wx import *
-
-if WXLOADED:
- class tmpApp(wx.App):
- def OnInit(self):
- return True
+import sys, os, errno
#-------------------------------------------------------
# void load_paths( dir_struct_reference )
@@ -92,6 +84,8 @@
"""Notify the user of directory problems
and show directory selection dialog """
+ #from orpg.orpg_wx import *
+
if WXLOADED:
app = tmpApp(0)
app.MainLoop()
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/gametree.py
--- a/orpg/gametree/gametree.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/gametree.py Sun Dec 19 22:44:36 2010 -0600
@@ -47,7 +47,7 @@
import string, urllib, time, os
from shutil import copytree, copystat, copy, copyfile
-from orpg.orpg_xml import xml
+#from orpg.orpg_xml import xml
from orpg.tools.validate import validate
from orpg.tools.orpg_log import logger, debug
from orpg.tools.orpg_settings import settings
@@ -239,7 +239,7 @@
emsg = "Gametree Missing!\n"+filename+" cannot be found.\n\n"\
"Would you like to locate it?\n"\
"(Selecting 'No' will cause a new default gametree to be generated)"
- self.locate_valid_tree("Gametree Error", emsg)
+ self.locate_valid_tree("Gametree Error", emsg, filename)
return
try:
self.xml_root = False
@@ -265,7 +265,7 @@
emsg = filename+" does not appear to be a valid gametree file.\n\n"\
"Would you like to select a different gametree file to use?\n"\
"(Selecting 'No' will cause a new default gametree to be generated)"
- self.locate_valid_tree("Invalid Gametree!", emsg)
+ self.locate_valid_tree("Invalid Gametree!", emsg, filename)
return
try:
# version = self.xml_root.get("version")
@@ -700,8 +700,10 @@
def load_xml(self, xml_element, parent_node, prev_node=None, drag_drop=False):
if parent_node == self.root:
- self.tree_map[xml_element.get('name')] = {}
- self.tree_map[xml_element.get('name')]['node'] = xml_element
+ name = xml_element.get('name').replace(u'\xa0', ' ') #Required for XSLT sheets
+ xml_element.set('name', name)
+ self.tree_map[str(xml_element.get('name'))] = {}
+ self.tree_map[str(xml_element.get('name'))]['node'] = xml_element
xml_element.set('map', '')
if parent_node != self.root:
## Loading XML seems to lag on Grids and Images need a cache for load speed ##
@@ -829,7 +831,8 @@
self.rename_flag = 0
if txt != "":
obj = self.GetPyData(item)
- obj.xml_root.set('name',txt)
+ #obj.xml.set('name', txt)
+ obj.rename(txt)
else: evt.Veto()
def on_label_begin(self, evt):
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/chatmacro.py
--- a/orpg/gametree/nodehandlers/chatmacro.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/chatmacro.py Sun Dec 19 22:44:36 2010 -0600
@@ -42,15 +42,12 @@
def __init__(self,xml,tree_node):
node_handler.__init__(self,xml,tree_node)
self.xml = xml
- self.text_elem = self.xml.find('text')
- self.text = self.text_elem.text
- def set_text(self,txt):
- self.text = txt
+ def set_text(self, txt):
+ self.xml.find('text').text = txt
def on_use(self,evt):
- txt = self.text
- actionlist = txt.split("\n")
+ actionlist = self.xml.find('text').text.split("\n")
for line in actionlist:
if(line != ""):
if line[0] != "/": ## it's not a slash command
@@ -65,8 +62,7 @@
def tohtml(self):
title = self.xml.get("name")
- txt = self.text
- txt = string.replace(txt,'\n',"
")
+ txt = string.replace(self.xml.find('text').text,'\n',"
")
return "
"+title+":
"+txt
P_TITLE = wx.NewId()
@@ -80,7 +76,7 @@
sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Chat Macro"), wx.VERTICAL)
self.text = {}
self.text[P_TITLE] = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
- self.text[P_BODY] = wx.TextCtrl(self, P_BODY, handler.text, style=wx.TE_MULTILINE)
+ self.text[P_BODY] = wx.TextCtrl(self, P_BODY, handler.xml.find('text').text, style=wx.TE_MULTILINE)
sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND)
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/containers.py
--- a/orpg/gametree/nodehandlers/containers.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/containers.py Sun Dec 19 22:44:36 2010 -0600
@@ -186,7 +186,7 @@
if id == P_TITLE:
txt = self.text[id].GetValue()
if txt != "":
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
@@ -248,7 +248,7 @@
def on_text(self,evt):
txt = self.title.GetValue()
if txt != "":
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
@@ -343,6 +343,6 @@
def on_text(self,evt):
txt = self.title.GetValue()
if txt != "":
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/core.py
--- a/orpg/gametree/nodehandlers/core.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/core.py Sun Dec 19 22:44:36 2010 -0600
@@ -214,7 +214,7 @@
pass
def on_send_to_chat(self,evt):
- self.chat.ParsePost(self.tohtml(),True,True)
+ Parse.Post(self.tohtml(),False)
def on_drop(self, evt):
drag_obj = self.tree.drag_obj
@@ -257,10 +257,28 @@
self.tree.Delete(self.mytree_node)
return self.xml
- def rename(self,name):
+ def rename(self, name):
if len(name):
- self.tree.SetItemText(self.mytree_node,name)
+ self.tree.SetItemText(self.mytree_node, name)
+ old_name = self.xml.get('name')
self.xml.set('name', name)
+ family_tree = self.tree.get_tree_map(self.mytree_node)
+ family_tree.reverse()
+ self.remap_node(self.mytree_node)
+ if self.tree.tree_map.has_key(old_name):
+ del self.tree.tree_map[old_name]
+ self.tree.tree_map[self.xml.get('name')] = {}
+ self.tree.tree_map[self.xml.get('name')]['node'] = self.xml
+
+ def remap_node(self, xml_root):
+ child, cookie = self.tree.GetFirstChild(xml_root)
+ while child.IsOk():
+ family_tree = self.tree.get_tree_map(child)
+ family_tree.reverse(); family_tree.pop()
+ map_str = '::'.join(family_tree)
+ self.tree.GetPyData(child).xml.set('map', map_str)
+ self.remap_node(child)
+ child, cookie = self.tree.GetNextChild(xml_root, cookie)
def change_icon(self,icon):
self.xml.set("icon",icon)
@@ -345,6 +363,7 @@
if bad_txt_found:
wx.MessageBox("Some non 7-bit ASCII characters found and stripped","Warning!")
txt = u_txt
+ #print txt, self.handler, self.handler.xml
self.handler.text._set_nodeValue(txt)
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/d20.py
--- a/orpg/gametree/nodehandlers/d20.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/d20.py Sun Dec 19 22:44:36 2010 -0600
@@ -358,7 +358,7 @@
else: mod1 = ""
txt = '%s Skill Check: [1d20%s%s]' % (name, mod1, mod)
chat = self.chat
- chat.ParsePost(txt,True,True)
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,skill_grid,"Skills")
@@ -409,7 +409,7 @@
else: mod1 = ""
chat = self.chat
txt = '%s check: [1d20%s%s]' % ( name, mod1, mod )
- chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_mod(self,abbr):
score = int(self.abilities[abbr].get('base'))
@@ -477,7 +477,7 @@
else: mod1 = ""
chat = self.chat
txt = '%s save: [1d20%s%s]' % (name, mod1, mod)
- chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,save_grid,"Saves")
@@ -607,14 +607,14 @@
left = eval( '%s - ( %s )' % ( memrz, use ) )
if left < 0:
txt = '%s Tried to cast %s but has used all of them for today, "Please rest so I can cast more."' % ( cname, name )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s can cast %s %d more time%s' % ( cname, name, left, s )
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.spells[ name ].set( 'used', `eval( use )` )
def refresh_spells(self):
@@ -672,14 +672,14 @@
left = eval( '%s - ( %s )' % ( memrz, use ) )
if left < 0:
txt = '%s Tried to cast %s but has used all of them for today, "Please rest so I can cast more."' % ( cname, name )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s casts %s ( level %s, "%s" )' % ( cname, name, level, descr )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s can cast %s %d more time%s' % ( cname, name, left, s )
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.spells[ name ].set( 'used', `eval( use )` )
def refresh_spells(self):
@@ -741,29 +741,29 @@
numcast = eval('%s / %s' % (left, points))
if left < 0:
txt = '%s doesnt have enough PowerPoints to use %s' % ( cname, name )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s uses %s as a Free Talent ( level %s, "%s" )' % ( cname, name, level, descr )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s )
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.char_hander.set_char_pp('free', left)
else:
left = eval('%s - ( %s )' % ( cpp, points ))
numcast = eval('%s / %s' % (left, points))
if left < 0:
txt = '%s doesnt have enough PowerPoints to use %s' % ( cname, name )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s uses %s ( level %s, "%s" )' % ( cname, name, level, descr )
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s can use %s %d more time%s' % ( cname, name, numcast, s )
txt += ' - And has %d more Powerpoints left' % (left)
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.char_hander.set_char_pp('current1', left)
def refresh_powers(self):
@@ -1007,7 +1007,7 @@
txt = 'Critical hit? [1d20%+d] ===> Damage: [%dd%d%+d%s]' \
% (bab[i] + attack_mod, crit_mult*num_damage_dice, \
damage_die, crit_mult*damage_mod, extra_damage)
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,attack_panel,"Attacks")
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/dnd35.py
--- a/orpg/gametree/nodehandlers/dnd35.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/dnd35.py Sun Dec 19 22:44:36 2010 -0600
@@ -4,6 +4,7 @@
from inspect import * #a 1.9001
from orpg.dirpath import dir_struct
from xml.etree.ElementTree import parse
+from orpg.tools.InterParse import Parse
dnd35_EXPORT = wx.NewId()
############Global Stuff##############
@@ -275,7 +276,7 @@
nodeName = 'Languages'
value = self.lang.GetValue()
for node in self.n_list:
- if node._get_tagName() == nodeName: node.text = value
+ if node.tag == nodeName: node.text = value
def saveMoney(self, row, col):
value = self.grid.GetCellValue(row, col)
@@ -396,7 +397,7 @@
else: mod1 = ""
chat = self.chat
txt = '%s check: [1d20%s%s]' % ( name, mod1, mod )
- chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_mod(self,abbr):
score = int(self.abilities[abbr].get('base'))
@@ -669,7 +670,7 @@
else: mod1 = ""
chat = self.chat
txt = '%s save: [1d20%s%s]' % (name, mod1, mod)
- chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,save_grid,"Saves")
@@ -924,7 +925,7 @@
chat = self.chat
txt = '%s Skill Check: [1d20%s%s%s] %s' % (
name, mod1, mod, acCp, armor)
- chat.ParsePost(txt,True,True)
+ Parse.Post(txt, self.chat, True, True)
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,skill_grid,"Skills")
@@ -1240,7 +1241,7 @@
chp = self.xml.get('current')
mhp = self.xml.get('max')
txt = '((HP: %s / %s))' % ( chp, mhp )
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def tohtml(self):
html_str = "
"
@@ -1442,7 +1443,7 @@
if monkLvl == None: #a 1.5009
txt = 'Attempting to use monk attack, but has no monk '
txt += 'levels, please choose a different attack.'
- chat.ParsePost( txt, True, True ) #a 1.5009
+ Parse.Post( txt, self.chat, True, True ) #a 1.5009
return #a 1.5009
else: #a 1.5009
lvl=int(monkLvl)
@@ -1456,7 +1457,7 @@
if monkLvl == None: #a 1.5009
txt = 'Attempting to use monk attack, but has no monk '
txt += 'levels, please choose a different attack.'
- chat.ParsePost( txt, True, True ) #a 1.5009
+ Parse.Post( txt, self.chat, True, True ) #a 1.5009
return #a 1.5009
else: #a 1.5009
lvl=int(monkLvl)
@@ -1470,7 +1471,7 @@
if monkLvl == None: #a 1.5009
txt = 'Attempting to use monk attack, but has no monk '
txt += 'levels, please choose a different attack.'
- chat.ParsePost( txt, True, True ) #a 1.5009
+ Parse.Post( txt, self.chat, True, True ) #a 1.5009
return #a 1.5009
else: #a 1.5009
lvl=int(monkLvl)
@@ -1515,7 +1516,7 @@
if monkLvl == None:
txt = 'Attempting to use monk attack, but has no monk '
txt += 'levels, please choose a different attack.'
- chat.ParsePost( txt, True, True ) #a 1.5009
+ Parse.Post( txt, self.chat, True, True ) #a 1.5009
return
else:
lvl = int(monkLvl)
@@ -1548,7 +1549,7 @@
else: mod1 = ""
txt = ' %s Attack Roll: [1d20%s%s%s]' % (name, mod1, base, flu)
txt += ' ===> Damage: [%s%s]' % (dmg, aStrengthMod)
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,attack_panel,"Attacks")
@@ -1918,7 +1919,7 @@
fac = (int(ac)-(self.root.abilities.get_mod('Dex')))
txt = '((AC: %s Normal, %s Flatfoot))' % ( ac, fac ) #a 1.5002
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True ) #a 1.5009
def tohtml(self):
html_str = """
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/dnd3e.py
--- a/orpg/gametree/nodehandlers/dnd3e.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/dnd3e.py Sun Dec 19 22:44:36 2010 -0600
@@ -33,6 +33,7 @@
from orpg.dirpath import dir_struct
from orpg.tools.orpg_log import debug
from xml.etree.ElementTree import parse
+from orpg.tools.InterParse import Parse
dnd3e_EXPORT = wx.NewId()
############Global Stuff##############
@@ -763,7 +764,7 @@
else: mod1 = ""
chat = self.chat
txt = '%s save: [1d20%s%s]' % (name, mod1, mod)
- chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,save_grid,"Saves")
@@ -1016,7 +1017,7 @@
chat = self.chat
txt = '%s Skill Check: [1d20%s%s%s] %s' % (
name, mod1, mod, acCp, armor)
- chat.ParsePost(txt,True,True)
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,skill_grid,"Skills")
@@ -1318,7 +1319,7 @@
chp = self.xml.get('current')
mhp = self.xml.get('max')
txt = '((HP: %s / %s))' % ( chp, mhp )
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def tohtml(self):
html_str = ""
@@ -1524,7 +1525,7 @@
if monkLvl == None: #a 1.5009
txt = 'Attempting to use monk attack, but has no monk '
txt += 'levels, please choose a different attack.'
- chat.ParsePost( txt, True, True ) #a 1.5009
+ Parse.Post( txt, self.chat, True, True )
return #a 1.5009
else: #a 1.5009
lvl=int(monkLvl)
@@ -1538,7 +1539,7 @@
if monkLvl == None:
txt = 'Attempting to use monk attack, but has no monk '
txt += 'levels, please choose a different attack.'
- chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
return
else:
lvl=int(monkLvl)
@@ -1583,7 +1584,7 @@
txt = '%s ' % (spacer)
txt += '%s Attack Roll: [1d20%s%s%s]' % (name, mod1, base, flu)
txt += ' ===> Damage: [%s%s]' % (dmg, aStrengthMod)
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def get_design_panel(self,parent):
wnd = outline_panel(parent,self,attack_panel,"Attacks")
@@ -1948,7 +1949,7 @@
ac = self.get_armor_class()
fac = (int(ac)-(self.root.abilities.get_mod('Dex')))
txt = '((AC: %s Normal, %s Flatfoot))' % ( ac, fac ) #a 1.5002
- self.chat.ParsePost( txt, True, True )
+ Parse.Post( txt, self.chat, True, True )
def tohtml(self):
html_str = """
@@ -2168,14 +2169,14 @@
if left < 0:
txt = '%s Tried to cast %s but has used all of them for today,'
txt +='"Please rest so I can cast more."' % ( charNameL, name ) #a 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s casts %s ( level %s, "%s" )' % ( charNameL, name, level, descr )#a f 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s can cast %s %d more time%s' % ( charNameL, name, left, s ) #a 1.5002
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.spells[ name ].set( 'used', `eval( use )` )
def refresh_spells(self):
@@ -2257,7 +2258,8 @@
self.grid.SetCellValue(i,2,name)
self.grid.SetReadOnly(i,2)
self.grid.SetCellValue(i,3,type)
- self.grid.SetReadOnly(i,3)
self.grid.SetCellValue(i,1,level)
+ self.grid.SetReadOnly(i,3)
+ self.grid.SetCellValue(i,1,level)
self.grid.SetReadOnly(i,1)
def on_remove(self,evt):
@@ -2344,14 +2346,14 @@
if left < 0:
txt = '%s Tried to cast %s but has used all of them for today,' #m 1.5002 break in 2.
txt += "Please rest so I can cast more."' % ( charNameL, name )' #a 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s casts %s ( level %s, "%s" )' % ( charNameL, name, level, descr ) #a 5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s can cast %s %d more time%s' % ( charNameL, name, left, s ) #a 1.5002
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.spells[ name ].set( 'used', `eval( use )` )
def refresh_spells(self):
@@ -2401,7 +2403,8 @@
self.SetSizer(self.sizer)
self.SetAutoLayout(True)
self.Fit()
-
self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
+
+ self.Bind(wx.EVT_BUTTON, self.on_remove, id=10)
self.Bind(wx.EVT_BUTTON, self.on_add, id=20)
self.Bind(wx.EVT_BUTTON, self.on_refresh_spells, id=30)
self.grid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
@@ -2531,25 +2534,25 @@
#In theory you should never see this -mgt
txt = ('%s doesnt have enough PowerPoints to use %s'
% ( charNameL, name )) #a 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = ('%s uses %s as a Free Talent ( level %s, "%s" )'
% ( charNameL, name, level, descr )) #a 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1: s = 's'
txt = '%s has %d Free Talent%s left' % ( charNameL, numcast, s ) #a 1.5002
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.root.pp.set_char_pp('free',left) #a 1.5002
else:
left = eval('%s - ( %s )' % ( cpp, points ))
#numcast = eval('%s / %s' % (left, points))
if left < 0:
txt = '%s doesnt have enough PowerPoints to use %s' % ( charNameL, name ) #m 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
else:
txt = '%s uses %s ( level %s, "%s" )' % ( charNameL, name, level, descr ) #m 1.5002
- self.chat.ParsePost( txt, True, False )
+ Parse.Post( txt, self.chat, True, False )
s = ''
if left != 1:
s = 's'
@@ -2557,7 +2560,7 @@
#txt = '%s can use %s %d more time%s' % ( charNameL, name, numcast, s ) #m 1.5002
#txt += ' - And has %d more PowerpointsP left' % (left)
txt = '%s has %d more Powerpoint%s' % ( charNameL, left, s ) #m 1.5002
- self.chat.ParsePost( txt, False, False )
+ Parse.Post( txt, self.chat, False, False )
self.root.pp.set_char_pp('current1',left) #a 1.5002
def refresh_powers(self):
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/forms.py
--- a/orpg/gametree/nodehandlers/forms.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/forms.py Sun Dec 19 22:44:36 2010 -0600
@@ -30,7 +30,7 @@
from containers import *
import orpg.minidom as minidom
-from orpg.orpg_xml import xml
+#from orpg.orpg_xml import xml
from wx.lib.scrolledpanel import ScrolledPanel
from orpg.tools.settings import settings
from orpg.tools.InterParse import Parse
@@ -149,7 +149,7 @@
txt = self.text[id].GetValue()
if not len(txt): return
if id == P_TITLE:
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
elif id == F_HEIGHT or id == F_WIDTH:
try: int(txt)
@@ -222,8 +222,9 @@
def tohtml(self):
txt = self.get_value()
- txt = string.replace(txt,'\n',"
")
- if not self.is_hide_title(): txt = ""+self.xml.get("name")+": "+txt
+ if txt == None: txt = ''
+ txt = txt.replace('\n','
')
+ if not self.is_hide_title(): txt = ''+self.xml.get('name')+': '+txt
return txt
def get_value(self):
@@ -421,7 +422,7 @@
if id == P_TITLE:
txt = self.title.GetValue()
if not len(txt): return
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
if id == F_TEXT:
txt = self.text.GetValue()
@@ -926,7 +927,7 @@
txt = self.text.GetValue()
if not len(txt): return
if id == P_TITLE:
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
def on_send_button(self,evt):
@@ -1003,7 +1004,7 @@
txt = self.text[id].GetValue()
if not len(txt): return
if id == P_TITLE:
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
elif id == P_URL: self.handler.link.set('href',txt)
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/map_miniature_nodehandler.py
--- a/orpg/gametree/nodehandlers/map_miniature_nodehandler.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/map_miniature_nodehandler.py Sun Dec 19 22:44:36 2010 -0600
@@ -124,7 +124,7 @@
def tohtml(self):
html_str = ""
- html_str += ""
+ html_str += ""
html_str += " |
\n"
html_str += "" + self.xml.get("name") + " |
"
return html_str
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/minilib.py
--- a/orpg/gametree/nodehandlers/minilib.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/minilib.py Sun Dec 19 22:44:36 2010 -0600
@@ -37,6 +37,7 @@
import map_miniature_nodehandler
import orpg.mapper.map_msg
import orpg.minidom as minidom
+from orpg.tools.InterParse import Parse
# import scriptkit
# Constants
@@ -44,17 +45,6 @@
FROM_MINILIB_MAP = {'url':'path', 'name':'label', 'unique':None}
CORE_ATTRIBUTES = ['name', 'url', 'unique', 'posy', 'posx', 'hide', 'face', 'heading', 'align', 'locked', 'width', 'height']
-ATTRIBUTE_NAME = 'name'
-ATTRIBUTE_URL = 'url'
-ATTRIBUTE_UNIQUE = 'unique'
-ATTRIBUTE_ID = 'id'
-ATTRIBUTE_POSX = 'posx'
-ATTRIBUTE_POSY = 'posy'
-
-TAG_MINIATURE = 'miniature'
-
-COMPONENT_MAP = 'map'
-COMPONENT_SESSION = 'session'
#
#
#
@@ -100,11 +90,11 @@
"""
str = ''
str += "Label | Image | URL | Unique |
"
- for mini in self.xml.findall(TAG_MINIATURE):
- url = mini.get(ATTRIBUTE_URL)
- label = mini.get(ATTRIBUTE_NAME)
+ for mini in self.xml.findall('miniature'):
+ url = mini.get('url')
+ label = mini.get('name')
flag = 0
- try: flag = eval( mini.get(ATTRIBUTE_UNIQUE) )
+ try: flag = eval( mini.get('unique') )
except: pass
show = 'yes'
if flag: show = 'no'
@@ -133,13 +123,13 @@
for attrib in obj.keys():
key = TO_MINILIB_MAP.get( attrib, attrib )
if key != None: dict[ key ] = obj.get( attrib )
- dict[ ATTRIBUTE_UNIQUE ] = unique
+ dict[ 'unique' ] = unique
self.new_mini( dict )
else: node_handler.on_drop(self, evt)
def new_mini( self, data={}, add=1 ):
- mini = Element( TAG_MINIATURE )
+ mini = Element( 'miniature' )
for key in data.keys(): mini.set( key, data[ key ] )
for key in CORE_ATTRIBUTES:
if mini.get( key ) == ('' or None): mini.set( key, '0' )
@@ -154,37 +144,39 @@
def add_leaf( self, mini, icon='gear' ):
tree = self.tree
icons = tree.icons
- key = mini.get( ATTRIBUTE_NAME )
+ key = mini.get( 'name' )
self.mydata.append( mini )
def update_leaves( self ):
self.mydata = []
- for n in self.xml.findall(TAG_MINIATURE): self.add_leaf( n )
+ for n in self.xml.findall('miniature'): self.add_leaf( n )
def on_drag( self, evt ):
print 'drag event caught'
def send_mini_to_map( self, mini, count=1, addName=True ):
if mini == None: return
- if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://':
- self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.get( ATTRIBUTE_URL ), mini.get( ATTRIBUTE_NAME ) )) )
+ if mini.get( 'url' ) == '' or mini.get( 'url' ) == 'http://':
+ Parse.Post( self.chat.colorize(self.chat.syscolor,
+ '"%s" is not a valid URL, the mini "%s" will not be added to the map' % (
+ mini.get( 'url' ), mini.get( 'name' ) )) )
return
- session = component.get( COMPONENT_SESSION )
+ session = component.get( 'session' )
if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER):
component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer")
return
- map = component.get(COMPONENT_MAP)
+ canvas = component.get('map')
for loop in range( count ):
msg = self.get_miniature_XML( mini, addName)
msg = str("")
- map.new_data( msg )
+ canvas.new_data( msg )
session.send( msg )
def get_miniature_XML( self, mini_xml, addName = True ):
msg = orpg.mapper.map_msg.mini_msg()
- map = component.get( COMPONENT_MAP )
- session = component.get( COMPONENT_SESSION )
- msg.init_prop( ATTRIBUTE_ID, session.get_next_id() )
+ canvas = component.get( 'map' )
+ session = component.get( 'session' )
+ msg.init_prop( 'id', session.get_next_id() )
msg.init_prop('selected', '1')# this will make the mini initially selected
for k in mini_xml.keys():
# translate our attributes to map attributes
@@ -193,24 +185,24 @@
if not addName and k == 'name': pass
else: msg.init_prop( key, mini_xml.get( k ) )
unique = self.is_unique( mini_xml )
- if addName: label = mini_xml.get( ATTRIBUTE_NAME )
+ if addName: label = mini_xml.get( 'name' )
else: label = ''
return msg.get_all_xml()
def is_unique( self, mini ):
- unique = mini.get( ATTRIBUTE_UNIQUE )
+ unique = mini.get( 'unique' )
val = 0
try: val = eval( unique )
except: val = len( unique )
return val
def sanity_check_nodes( self ):
- for node in self.xml.findall(TAG_MINIATURE):
- if node.get( ATTRIBUTE_POSX ) == '': node.set( ATTRIBUTE_POSX, '0' )
- if node.get( ATTRIBUTE_POSY ) == '': node.set( ATTRIBUTE_POSY, '0' )
+ for node in self.xml.findall('miniature'):
+ if node.get( 'posx' ) == '': node.set( 'posx', '0' )
+ if node.get( 'posy' ) == '': node.set( 'posy', '0' )
def get_mini( self, index ):
- try: return self.xml.findall(TAG_MINIATURE)[index]
+ try: return self.xml.findall('miniature')[index]
except: return None
class mini_handler( node_handler ):
@@ -279,7 +271,7 @@
"""Returns a dictionary of label => game tree miniature DOM node mappings.
"""
self.list = []
- for mini in self.handler.xml.findall(TAG_MINIATURE): self.list.append( mini.get( ATTRIBUTE_NAME ) )
+ for mini in self.handler.xml.findall('miniature'): self.list.append( mini.get( 'name' ) )
return self.list
def on_close(self, evt):
@@ -383,7 +375,7 @@
def on_text(self, evt):
txt = self.text.GetValue()
if txt != "":
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
class minilib_grid(wx.grid.Grid):
@@ -407,7 +399,7 @@
self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.select_cell)
def update_cols( self ):
- for n in self.handler.xml.findall(TAG_MINIATURE):
+ for n in self.handler.xml.findall('miniature'):
for k in n.keys():
if k not in self.keys: self.keys.append( k )
@@ -426,7 +418,7 @@
"""Returns the list of 'miniature' DOM elements associated with this
miniature library.
"""
- return self.handler.xml.findall( TAG_MINIATURE )
+ return self.handler.xml.findall( 'miniature' )
def add_row( self, count = 1 ):
"""creates a new miniature node, and then adds it to the current
@@ -434,8 +426,8 @@
"""
self.AppendRows( count )
node = self.handler.new_mini( {
- ATTRIBUTE_NAME :' ',
- ATTRIBUTE_URL :'http://'} )# minidom.Element( TAG_MINIATURE )
+ 'name' :' ',
+ 'url' :'http://'} )# minidom.Element( 'miniature' )
self.update_all()
#self.handler.xml.append( node )
@@ -446,7 +438,7 @@
"""
if self.selectedRow > -1:
pos = self.selectedRow
- list = self.handler.xml.findall(TAG_MINIATURE)
+ list = self.handler.xml.findall('miniature')
self.handler.xml.remove( list[pos] )
self.DeleteRows( pos, 1 )
@@ -492,7 +484,7 @@
return self.GetTable().GetValue( self.selectedRow, 1 )
def getSelectedSerial( self ):
- """Returns the ATTRIBUTE_UNIQUE value for the selected row
+ """Returns the 'unique' value for the selected row
"""
return self.GetTable().GetValue( self.selectedRow, 2 )
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/rpg_grid.py
--- a/orpg/gametree/nodehandlers/rpg_grid.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/rpg_grid.py Sun Dec 19 22:44:36 2010 -0600
@@ -543,7 +543,7 @@
def on_text(self,evt):
txt = self.title.GetValue()
if txt != "":
- self.handler.xml.set('name',txt)
+ #self.handler.xml.set('name',txt)
self.handler.rename(txt)
def refresh_row(self,rowi):
diff -r ee890f424e16 -r d02e9197c066 orpg/gametree/nodehandlers/voxchat.py
--- a/orpg/gametree/nodehandlers/voxchat.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/gametree/nodehandlers/voxchat.py Sun Dec 19 22:44:36 2010 -0600
@@ -31,7 +31,6 @@
import re, os, string, core
from orpg.orpg_windows import *
-import core
import orpg.tools.scriptkit
import orpg.tools.predTextCtrl
import orpg.tools.rgbhex
diff -r ee890f424e16 -r d02e9197c066 orpg/main.py
--- a/orpg/main.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/main.py Sun Dec 19 22:44:36 2010 -0600
@@ -63,7 +63,7 @@
from xml.etree.ElementTree import ElementTree, Element, parse
from xml.etree.ElementTree import fromstring, tostring
-from orpg.orpg_xml import xml #to be replaced by etree
+#from orpg.orpg_xml import xml #to be replaced by etree
####################################
@@ -207,7 +207,7 @@
[' -'],
[' Tab Styles'],
[' Slanted'],
- [' Colorful', "check"],
+ #[' Colorful', "check"],
[' Black and White', "check"],
[' Aqua', "check"],
[' Custom', "check"],
@@ -257,7 +257,8 @@
self.mainmenu.SetMenuState('ToolsPasswordManager', True if settings.get('PWMannager') == 'On' else False)
tabtheme = settings.get('TabTheme') #This change is stable. TaS.
- self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
+ if tabtheme == 'slanted&colorful': tabtheme = 'customflat'; settings.change('TabTheme', 'customflat')
+ #self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
@@ -323,9 +324,8 @@
#Tab Styles Menus
def SetTabStyles(self, *args, **kwargs):
-
tabtheme = settings.get('TabTheme') #This change is stable. TaS.
- self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
+ #self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedColorful", tabtheme == 'slanted&colorful')
self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedBlackandWhite", tabtheme == 'slanted&bw')
self.mainmenu.SetMenuState("OpenRPGTabStylesSlantedAqua", tabtheme == 'slanted&aqua')
self.mainmenu.SetMenuState("OpenRPGTabStylesFlatBlackandWhite", tabtheme == 'flat&bw')
@@ -341,7 +341,6 @@
else:
try: menu = args[0]
except: logger.general('Invalid Syntax for orpgFrame->SetTabStyles(self, *args, **kwargs)'); return
-
if kwargs.has_key('graidentTo'): graidentTo = kwargs['graidentTo']
else: graidentTo = None
if kwargs.has_key('graidentFrom'): graidentFrom = kwargs['graidentFrom']
@@ -365,7 +364,7 @@
for wnd in tabbedwindows:
style = wnd.GetWindowStyleFlag()
# remove old tabs style
- mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS | FNB.FNB_COLORFUL_TABS)
+ mirror = ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS )
style &= mirror
style |= newstyle
wnd.SetWindowStyleFlag(style)
@@ -752,11 +751,11 @@
def do_tab_window(self, xml_dom, parent_wnd):
# if container window loop through childern and do a recursive call
- temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_ALLOW_FOREIGN_DND)
+ temp_wnd = orpgTabberWnd(parent_wnd)
children = xml_dom.getchildren()
for c in children:
- wnd = self.build_window(c,temp_wnd)
+ wnd = self.build_window(c, temp_wnd)
name = c.get("name")
temp_wnd.AddPage(wnd, name, False)
return temp_wnd
@@ -936,12 +935,15 @@
except: etreeEl.text = data
display_name = self.chat.chat_display_name(player)
- if etreeEl.text:self.chat.Post(display_name+etreeEl.text)
+ if etreeEl.text:
+ if "is creating room" in etreeEl.text: self.chat.Post(etreeEl.text)
+ else: self.chat.Post(display_name+etreeEl.text)
for child in etreeEl.getchildren():
if child.tag == 'tree':
- dlg = wx.MessageDialog(None, component.strip_html(display_name) + ' is trying to send you a tree node. Accept?', 'Question',
- wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
+ dlg = wx.MessageDialog(None,
+ component.strip_html(display_name) + ' is trying to send you a tree node. Accept?',
+ 'Question', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
dlg.Destroy()
self.tree.on_receive_data(tostring(child))
@@ -1129,7 +1131,7 @@
def OnInit(self):
component.add('log', logger)
- component.add('xml', xml)
+ #component.add('xml', xml)
component.add('settings', settings)
component.add('validate', validate)
component.add("tabbedWindows", [])
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/background.py
--- a/orpg/mapper/background.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/background.py Sun Dec 19 22:44:36 2010 -0600
@@ -211,28 +211,31 @@
else: return ''
def layerTakeDOM(self, xml_dom):
- type = BG_COLOR
- color = xml_dom.getAttribute("color")
- logger.debug("color=" + color)
- path = urllib.unquote(xml_dom.getAttribute("path"))
- logger.debug("path=" + path)
- # Begin ted's map changes
- if xml_dom.hasAttribute("color"):
- r,g,b = self.r_h.rgb_tuple(xml_dom.getAttribute("color"))
+ bg_type = xml_dom.get("type")
+ urlpath = xml_dom.get('path')
+ color = xml_dom.get("color")
+
+ if urlpath != None:
+ path = urllib.unquote(xml_dom.get("path"))
+ logger.debug("path=" + path)
+
+ if color != None:
+ logger.debug("color=" + color)
+ r,g,b = self.r_h.rgb_tuple(color)
self.set_color(cmpColour(r,g,b))
- # End ted's map changes
- if xml_dom.hasAttribute("type"):
- type = int(xml_dom.getAttribute("type"))
- logger.debug("type=" + str(type))
- if type == BG_TEXTURE:
+
+ if bg_type != None:
+ logger.debug("type=" + bg_type)
+ bg_type = int(xml_dom.get("type"))
+ if bg_type == BG_TEXTURE:
if path != "": self.set_texture(path)
- elif type == BG_IMAGE:
+ elif bg_type == BG_IMAGE:
if path != "": self.set_image(path, 1)
- elif type == BG_NONE: self.clear()
- if xml_dom.hasAttribute('local') and xml_dom.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(xml_dom.getAttribute('localPath'))):
- self.localPath = urllib.unquote(xml_dom.getAttribute('localPath'))
+ elif bg_type == BG_NONE: self.clear()
+ if xml_dom.get('local') == 'True' and os.path.exists(urllib.unquote(xml_dom.get('localPath'))):
+ self.localPath = urllib.unquote(xml_dom.get('localPath'))
self.local = True
- self.localTime = int(xml_dom.getAttribute('localTime'))
+ self.localTime = int(xml_dom.get('localTime'))
if self.localTime-time.time() <= 144000:
file = open(self.localPath, "rb")
imgdata = file.read()
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/background_handler.py
--- a/orpg/mapper/background_handler.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/background_handler.py Sun Dec 19 22:44:36 2010 -0600
@@ -83,7 +83,7 @@
postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype})
if self.settings.get_setting('LocalorRemote') == 'Remote':
- thread.start_new_thread(self.canvas.layers['bg'].upload,
+ thread.start_new_thread(self.upload,
(postdata, dlg.GetPath(), self.bg_type.GetStringSelection()))
else:
try: min_url = component.get("cherrypy") + filename
@@ -97,6 +97,13 @@
self.canvas.send_map_data()
self.canvas.Refresh(False)
+ def upload(self, postdata, filename, imgtype):
+ self.canvas.layers['bg'].upload(postdata, filename, imgtype)
+ self.update_info()
+ self.canvas.send_map_data()
+ self.canvas.Refresh(False)
+ return
+
def update_info(self):
bg_type = self.canvas.layers['bg'].get_type()
session=self.canvas.frame.session
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/base_msg.py
--- a/orpg/mapper/base_msg.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/base_msg.py Sun Dec 19 22:44:36 2010 -0600
@@ -29,7 +29,7 @@
from threading import RLock
from orpg.networking.mplay_client import *
-from xml.etree.ElementTree import ElementTree, Element
+from xml.etree.ElementTree import ElementTree, Element, fromstring
class map_element_msg_base:
# This is a base class
@@ -216,20 +216,24 @@
self._from_dom(xml_dom,self.set_prop)
def init_from_xml(self,xml):
- xml_dom = parseXml(xml)
- node_list = xml_dom.getElementsByTagName(self.tagname)
+ #xml_dom = parseXml(xml)
+ xml_dom = fromstring(xml)
+ #node_list = xml_dom.getElementsByTagName(self.tagname)
+ node_list = xml_dom.findall(self.tagname)
if len(node_list) < 1: print "Warning: no <" + self.tagname + "/> elements found in DOM."
else:
while len(node_list): self.init_from_dom(node_list.pop())
- if xml_dom: xml_dom.unlink()
+ #if xml_dom: xml_dom.unlink()
def set_from_xml(self,xml):
- xml_dom = parseXml(xml)
- node_list = xml_dom.getElementsByTagName(self.tagname)
+ #xml_dom = parseXml(xml)
+ xml_dom = fromstring(xml)
+ #node_list = xml_dom.getElementsByTagName(self.tagname)
+ node_list = xml_dom.findall(self.tagname)
if len(node_list) < 1: print "Warning: no <" + self.tagname + "/> elements found in DOM."
else:
while len(node_list): self.set_from_dom(node_list.pop())
- if xml_dom: xml_dom.unlink()
+ #if xml_dom: xml_dom.unlink()
# XML importers end
#########################################
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/fog.py
--- a/orpg/mapper/fog.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/fog.py Sun Dec 19 22:44:36 2010 -0600
@@ -27,7 +27,7 @@
from base import *
from random import Random
from region import *
-from orpg.minidom import Element
+from xml.etree.ElementTree import Element, tostring
import traceback
COURSE = 10
@@ -47,8 +47,8 @@
for pairs in string.split( points, ';' ):
pair = string.split( pairs, ',' )
p = Element( "point" )
- p.setAttribute( "x", pair[0] )
- p.setAttribute( "y", pair[1] )
+ p.set( "x", pair[0] )
+ p.set( "y", pair[1] )
result.append( p )
return result
@@ -59,23 +59,20 @@
localOutline = "points"
elem = Element( "poly" )
if action == "del":
- elem.setAttribute( "action", action )
- elem.setAttribute( "outline", localOutline )
+ elem.set( "action", action )
+ elem.set( "outline", localOutline )
if localOutline == 'points':
- list = self.points_to_elements( self.outline )
- for p in list: elem.appendChild( p )
- str = elem.toxml()
- elem.unlink()
- return str
- elem.setAttribute( "action", action )
+ foglist = self.points_to_elements( self.outline )
+ for p in foglist: elem.append( p )
+ return tostring(elem)
+ elem.set( "action", action )
if localOutline != None:
- elem.setAttribute( "outline", localOutline )
+ elem.set( "outline", localOutline )
if localOutline == 'points':
- list = self.points_to_elements( self.outline )
- for p in list: elem.appendChild( p )
- xml_str = elem.toxml()
- elem.unlink()
- return xml_str
+ foglist = self.points_to_elements( self.outline )
+ for p in foglist: elem.append( p )
+ #xml_str = elem.toxml()
+ return tostring(elem)
class fog_layer(layer_base):
def __init__(self, canvas):
@@ -223,11 +220,12 @@
if not self.use_fog:
self.use_fog = True
self.recompute_fog()
- if xml_dom.hasAttribute('serial'): self.serial_number = int(xml_dom.getAttribute('serial'))
- children = xml_dom._get_childNodes()
+ serial = xml_dom.get('serial')
+ if serial != None: self.serial_number = int(serial)
+ children = xml_dom.getchildren()
for l in children:
- action = l.getAttribute("action")
- outline = l.getAttribute("outline")
+ action = l.get("action")
+ outline = l.get("outline")
if (outline == "all"):
polyline = [IPoint().make(0,0), IPoint().make(self.width-1, 0),
IPoint().make(self.width-1, self.height-1),
@@ -240,10 +238,10 @@
polyline = []
lastx = None
lasty = None
- list = l._get_childNodes()
+ list = l.getchildren()
for point in list:
- x = point.getAttribute( "x" )
- y = point.getAttribute( "y" )
+ x = point.get( "x" )
+ y = point.get( "y" )
if (x != lastx or y != lasty):
polyline.append(IPoint().make(int(x), int(y)))
lastx = x
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/fog_msg.py
--- a/orpg/mapper/fog_msg.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/fog_msg.py Sun Dec 19 22:44:36 2010 -0600
@@ -27,7 +27,7 @@
from base_msg import *
from region import *
-from orpg.minidom import Element
+from xml.etree.ElementTree import Element, tostring
import string
class fog_msg(map_element_msg_base):
@@ -41,19 +41,17 @@
def get_line(self,outline,action,output_act):
elem = Element( "poly" )
- if ( output_act ): elem.setAttribute( "action", action )
- if ( outline == 'all' ) or ( outline == 'none' ): elem.setAttribute( "outline", outline )
+ if ( output_act ): elem.set( "action", action )
+ if ( outline == 'all' ) or ( outline == 'none' ): elem.set( "outline", outline )
else:
- elem.setAttribute( "outline", "points" )
+ elem.set( "outline", "points" )
for pair in string.split( outline, ";" ):
p = string.split( pair, "," )
point = Element( "point" )
- point.setAttribute( "x", p[ 0 ] )
- point.setAttribute( "y", p[ 1 ] )
- elem.appendChild( point )
- str = elem.toxml()
- elem.unlink()
- return str
+ point.set( "x", p[ 0 ] )
+ point.set( "y", p[ 1 ] )
+ elem.append( point )
+ return tostring(elem)
# convenience method to use if only this line is modified
# outputs a element containing only the changes to this line
@@ -83,23 +81,18 @@
str(x2)+","+str(y1)+";"+
str(x2)+","+str(y2)+";"+
str(x1)+","+str(y2),action,output_action)
- s = ""
s += fog_string
- s += ""
- else: s+="/>"
+ s += ""
return s
def interpret_dom(self,xml_dom):
self.use_fog=1
- #print 'fog_msg.interpret_dom called'
- children = xml_dom._get_childNodes()
- #print "children",children
+ children = xml_dom.getchildren()
for l in children:
- action = l.getAttribute("action")
- outline = l.getAttribute("outline")
- #print "action/outline",action, outline
+ action = l.get("action")
+ outline = l.get("outline")
if (outline=="all"):
polyline=[]
self.fogregion.Clear()
@@ -109,14 +102,13 @@
self.fogregion.Clear()
else:
polyline=[]
- list = l._get_childNodes()
+ list = l.getchildren()
for node in list:
- polyline.append( IPoint().make( int(node.getAttribute("x")), int(node.getAttribute("y")) ) )
+ polyline.append( IPoint().make( int(node.get("x")), int(node.get("y")) ) )
# pointarray = outline.split(";")
# for m in range(len(pointarray)):
# pt=pointarray[m].split(",")
# polyline.append(IPoint().make(int(pt[0]),int(pt[1])))
- #print "length of polyline", len(polyline)
if (len(polyline)>2):
if action=="del": self.fogregion.FromPolygon(polyline,0)
else: self.fogregion.FromPolygon(polyline,1)
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/grid.py
--- a/orpg/mapper/grid.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/grid.py Sun Dec 19 22:44:36 2010 -0600
@@ -406,19 +406,20 @@
else: return ''
def layerTakeDOM(self, xml_dom):
- if xml_dom.hasAttribute("color"):
- r,g,b = self.r_h.rgb_tuple(xml_dom.getAttribute("color"))
+ color = xml_dom.get('color')
+ if color != None:
+ r,g,b = self.r_h.rgb_tuple(color)
self.set_color(cmpColour(r,g,b))
#backwards compatible with non-isometric map formated clients
- ratio = RATIO_DEFAULT
- if xml_dom.hasAttribute("ratio"): ratio = xml_dom.getAttribute("ratio")
- if xml_dom.hasAttribute("mode"):
- self.SetMode(int(xml_dom.getAttribute("mode")))
- if xml_dom.hasAttribute("size"):
- self.unit_size = int(xml_dom.getAttribute("size"))
+ ratio = RATIO_DEFAULT if xml_dom.get("ratio") == None else xml_dom.get('ratio')
+ mode = xml_dom.get('mode')
+ if mode != None: self.SetMode(int(mode))
+ size = xml_dom.get('size')
+ if size != None:
+ self.unit_size = int(size)
self.unit_size_y = self.unit_size
- if xml_dom.hasAttribute("snap"):
- if (xml_dom.getAttribute("snap") == 'True') or (xml_dom.getAttribute("snap") == "1"): self.snap = True
- else: self.snap = False
- if xml_dom.hasAttribute("line"):
- self.SetLine(int(xml_dom.getAttribute("line")))
+ if (xml_dom.get("snap") == 'True') or (xml_dom.get("snap") == "1"): self.snap = True
+ else: self.snap = False
+ line = xml_dom.get('line')
+ if line != None: self.SetLine(int(line))
+
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/map.py
--- a/orpg/mapper/map.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/map.py Sun Dec 19 22:44:36 2010 -0600
@@ -45,6 +45,8 @@
from images import ImageHandler
from orpg.orpgCore import component
from orpg.tools.orpg_settings import settings
+from xml.etree.ElementTree import ElementTree, Element, parse
+from xml.etree.ElementTree import fromstring, tostring
# Various marker modes for player tools on the map
MARKER_MODE_NONE = 0
@@ -259,21 +261,26 @@
dc.DrawRectangle(0,0,clientsize[0]+1,clientsize[1]+1)
dc.SetDeviceOrigin(-topleft[0], -topleft[1])
dc.SetUserScale(scale, scale)
+
+ layer_order = []
+ for i in xrange (0, len(self.parent.layer_handlers)-1):
+ if self.parent.layer_tabs.GetPageText(i) in ('Background', 'Fog', 'General'): pass
+ else: layer_order.append(self.parent.layer_tabs.GetPageText(i))
self.layers['bg'].layerDraw(dc, scale, topleft, clientsize)
- self.layers['grid'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
- [clientsize[0]/scale, clientsize[1]/scale])
- self.layers['miniatures'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
- [clientsize[0]/scale, clientsize[1]/scale])
- self.layers['whiteboard'].layerDraw(dc)
+
+ for layer in layer_order:
+ if layer == 'Grid': self.layers['grid'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
+ [clientsize[0]/scale, clientsize[1]/scale])
+ if layer == 'Miniatures': self.layers['miniatures'].layerDraw(dc, [topleft[0]/scale, topleft[1]/scale],
+ [clientsize[0]/scale, clientsize[1]/scale])
+ if layer == 'Whiteboard': self.layers['whiteboard'].layerDraw(dc)
+
self.layers['fog'].layerDraw(dc, topleft, clientsize)
dc.SetPen(wx.NullPen)
dc.SetBrush(wx.NullBrush)
-
- dc.SelectObject(wx.NullBitmap)
- del dc
+ dc.SelectObject(wx.NullBitmap); del dc
wdc = self.preppaint()
wdc.DrawBitmap(bmp, topleft[0], topleft[1])
-
if settings.get_setting("AlwaysShowMapScale") == "1":
self.showmapscale(wdc)
try: evt.Skip()
@@ -622,15 +629,16 @@
--Snowdog 5/27/03
"""
try:
- #parse the map DOM
- xml_dom = parseXml(xml)
+ xml_dom = fromstring(xml)
if xml_dom == None: return
- node_list = xml_dom.getElementsByTagName("map")
+ node_list = xml_dom.findall("map")
+ if len(node_list) < 1:
+ if xml_dom.tag == 'map': node_list = [xml_dom]
if len(node_list) < 1: pass
else:
# set map version to incoming data so layers can convert
- self.map_version = node_list[0].getAttribute("version")
- action = node_list[0].getAttribute("action")
+ self.map_version = node_list[0].get("version")
+ action = node_list[0].get("action")
if action == "new":
self.layers = {}
try: self.layers['bg'] = layer_back_ground(self)
@@ -643,37 +651,38 @@
except: pass
try: self.layers['fog'] = fog_layer(self)
except: pass
- sizex = node_list[0].getAttribute("sizex")
+ sizex = node_list[0].get("sizex") or ''
if sizex != "":
sizex = int(float(sizex))
sizey = self.size[1]
self.set_size((sizex,sizey))
self.size_changed = 0
- sizey = node_list[0].getAttribute("sizey")
+ sizey = node_list[0].get("sizey") or ''
if sizey != "":
sizey = int(float(sizey))
sizex = self.size[0]
self.set_size((sizex,sizey))
self.size_changed = 0
- children = node_list[0]._get_childNodes()
+ children = node_list[0].getchildren()
#fog layer must be computed first, so that no data is inadvertently revealed
for c in children:
- name = c._get_nodeName()
+ name = c.tag
if name == "fog": self.layers[name].layerTakeDOM(c)
for c in children:
- name = c._get_nodeName()
+ name = c.tag
if name != "fog": self.layers[name].layerTakeDOM(c)
# all map data should be converted, set map version to current version
self.map_version = MAP_VERSION
- self.Refresh(False)
- xml_dom.unlink() # eliminate circular refs
+ self.Refresh(True)
except: pass
def re_ids_in_xml(self, xml):
+ exception = "\nDeprecated call to: Function re_ids_in_xml, line 679, map.py\nThis can mangle XML, please report!"
+ logger.exception(exception)
new_xml = ""
tmp_map = map_msg()
- xml_dom = parseXml(str(xml))
- node_list = xml_dom.getElementsByTagName("map")
+ xml_dom = fromstring(xml)
+ node_list = xml_dom.findall("map")
if len(node_list) < 1: pass
else:
tmp_map.init_from_dom(node_list[0])
@@ -701,8 +710,7 @@
elif l.tagname == 'circle': id = 'circle-' + self.frame.session.get_next_id()
l.init_prop("id", id)
new_xml = tmp_map.get_all_xml()
- if xml_dom: xml_dom.unlink()
- return str(new_xml)
+ return new_xml
class map_wnd(wx.Panel):
def __init__(self, parent, id):
@@ -714,20 +722,23 @@
self.root_dir = os.getcwd()
self.current_layer = 2
self.layer_tabs = orpgTabberWnd(self, style=FNB.FNB_NO_X_BUTTON|FNB.FNB_BOTTOM|FNB.FNB_NO_NAV_BUTTONS)
+
self.layer_handlers = []
- self.layer_handlers.append(background_handler(self.layer_tabs,-1,self.canvas))
- self.layer_tabs.AddPage(self.layer_handlers[0],"Background")
- self.layer_handlers.append(grid_handler(self.layer_tabs,-1,self.canvas))
- self.layer_tabs.AddPage(self.layer_handlers[1],"Grid")
- self.layer_handlers.append(miniatures_handler(self.layer_tabs,-1,self.canvas))
- self.layer_tabs.AddPage(self.layer_handlers[2],"Miniatures", True)
- self.layer_handlers.append(whiteboard_handler(self.layer_tabs,-1,self.canvas))
- self.layer_tabs.AddPage(self.layer_handlers[3],"Whiteboard")
- self.layer_handlers.append(fog_handler(self.layer_tabs,-1,self.canvas))
- self.layer_tabs.AddPage(self.layer_handlers[4],"Fog")
- self.layer_handlers.append(map_handler(self.layer_tabs,-1,self.canvas))
- self.layer_tabs.AddPage(self.layer_handlers[5],"General")
+ self.layer_handlers.append(background_handler(self.layer_tabs, -1, self.canvas))
+ self.layer_tabs.AddPage(self.layer_handlers[0], "Background")
+ self.layer_handlers.append(grid_handler(self.layer_tabs, -1, self.canvas))
+ self.layer_tabs.AddPage(self.layer_handlers[1], "Grid")
+ self.layer_handlers.append(miniatures_handler(self.layer_tabs, -1, self.canvas))
+ self.layer_tabs.AddPage(self.layer_handlers[2], "Miniatures", True)
+ self.layer_handlers.append(whiteboard_handler(self.layer_tabs, -1, self.canvas))
+ self.layer_tabs.AddPage(self.layer_handlers[3], "Whiteboard")
+ self.layer_handlers.append(fog_handler(self.layer_tabs, -1, self.canvas))
+ self.layer_tabs.AddPage(self.layer_handlers[4], "Fog")
+ self.layer_handlers.append(map_handler(self.layer_tabs, -1, self.canvas))
+ self.layer_tabs.AddPage(self.layer_handlers[5], "General")
self.layer_tabs.SetSelection(2)
+
+ self.layer_order = {1: 'grid', 2: 'miniatures', 3: 'whiteboard'}
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.EXPAND)
self.sizer.Add(self.layer_tabs, 0, wx.EXPAND)
@@ -778,9 +789,9 @@
d = wx.FileDialog(self.GetParent(), "Select a file", dir_struct["user"], "", "*.xml", wx.OPEN)
if d.ShowModal() == wx.ID_OK:
f = open(d.GetPath())
- map_string = f.read()
- new_xml = self.canvas.re_ids_in_xml(map_string)
- if new_xml:
+ new_xml = f.read()
+ f.close()
+ if new_xml != None:
self.canvas.takexml(new_xml)
self.canvas.send_map_data("new")
self.update_tools()
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/map_msg.py
--- a/orpg/mapper/map_msg.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/map_msg.py Sun Dec 19 22:44:36 2010 -0600
@@ -53,17 +53,17 @@
def init_from_dom(self,xml_dom):
self.p_lock.acquire()
- if xml_dom.tagName == self.tagname:
+ if xml_dom.tag == self.tagname:
# If this is a map message, look for the "action=new"
# Notice we only do this when the root is a map tag
- if self.tagname == "map" and xml_dom.hasAttribute("action") and xml_dom.getAttribute("action") == "new":
+ if self.tagname == "map" and xml_dom.get("action") == "new":
self.clear()
# Process all of the properties in each tag
- if xml_dom.getAttributeKeys():
- for k in xml_dom.getAttributeKeys():
- self.init_prop(k,xml_dom.getAttribute(k))
- for c in xml_dom._get_childNodes():
- name = c._get_nodeName()
+ if xml_dom.keys():
+ for k in xml_dom.keys():
+ self.init_prop(k,xml_dom.get(k))
+ for c in xml_dom.getchildren():
+ name = c.tag
if not self.children.has_key(name):
if name == "miniatures": self.children[name] = minis_msg(self.p_lock)
elif name == "grid": self.children[name] = grid_msg(self.p_lock)
@@ -84,16 +84,16 @@
def set_from_dom(self,xml_dom):
self.p_lock.acquire()
- if xml_dom.tagName == self.tagname:
+ if xml_dom.tag == self.tagname:
# If this is a map message, look for the "action=new"
# Notice we only do this when the root is a map tag
- if self.tagname == "map" and xml_dom.hasAttribute("action") and xml_dom.getAttribute("action") == "new":
+ if self.tagname == "map" and xml_dom.get("action") == "new":
self.clear()
# Process all of the properties in each tag
- if xml_dom.getAttributeKeys():
- for k in xml_dom.getAttributeKeys(): self.set_prop(k,xml_dom.getAttribute(k))
- for c in xml_dom._get_childNodes():
- name = c._get_nodeName()
+ if xml_dom.keys():
+ for k in xml_dom.keys(): self.set_prop(k,xml_dom.get(k))
+ for c in xml_dom.getchildren():
+ name = c.tag
if not self.children.has_key(name):
if name == "miniatures": self.children[name] = minis_msg(self.p_lock)
elif name == "grid": self.children[name] = grid_msg(self.p_lock)
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/miniatures.py
--- a/orpg/mapper/miniatures.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/miniatures.py Sun Dec 19 22:44:36 2010 -0600
@@ -344,27 +344,27 @@
else: return ''
def takedom(self, xml_dom):
- self.id = xml_dom.getAttribute("id")
- if xml_dom.hasAttribute("posx"): self.pos.x = int(xml_dom.getAttribute("posx"))
- if xml_dom.hasAttribute("posy"): self.pos.y = int(xml_dom.getAttribute("posy"))
- if xml_dom.hasAttribute("heading"): self.heading = int(xml_dom.getAttribute("heading"))
- if xml_dom.hasAttribute("face"): self.face = int(xml_dom.getAttribute("face"))
- if xml_dom.hasAttribute("path"):
- self.path = urllib.unquote(xml_dom.getAttribute("path"))
+ self.id = xml_dom.get("id")
+ if xml_dom.get("posx") != None: self.pos.x = int(xml_dom.get("posx"))
+ if xml_dom.get("posy") != None: self.pos.y = int(xml_dom.get("posy"))
+ if xml_dom.get("heading") != None: self.heading = int(xml_dom.get("heading"))
+ if xml_dom.get("face") != None: self.face = int(xml_dom.get("face"))
+ if xml_dom.get("path") != None:
+ self.path = urllib.unquote(xml_dom.get("path"))
self.set_bmp(ImageHandler.load(self.path, 'miniature', self.id))
- if xml_dom.hasAttribute("locked"):
- if xml_dom.getAttribute("locked") == '1' or xml_dom.getAttribute("locked") == 'True': self.locked = True
+ if xml_dom.get("locked") != None:
+ if xml_dom.get("locked") == '1' or xml_dom.get("locked") == 'True': self.locked = True
else: self.locked = False
- if xml_dom.hasAttribute("hide"):
- if xml_dom.getAttribute("hide") == '1' or xml_dom.getAttribute("hide") == 'True': self.hide = True
+ if xml_dom.get("hide") != None:
+ if xml_dom.get("hide") == '1' or xml_dom.get("hide") == 'True': self.hide = True
else: self.hide = False
- if xml_dom.hasAttribute("label"): self.label = xml_dom.getAttribute("label")
- if xml_dom.hasAttribute("zorder"): self.zorder = int(xml_dom.getAttribute("zorder"))
- if xml_dom.hasAttribute("align"):
- if xml_dom.getAttribute("align") == '1' or xml_dom.getAttribute("align") == 'True': self.snap_to_align = 1
+ if xml_dom.get("label") != None: self.label = xml_dom.get("label")
+ if xml_dom.get("zorder") != None: self.zorder = int(xml_dom.get("zorder"))
+ if xml_dom.get("align") != None:
+ if xml_dom.get("align") == '1' or xml_dom.get("align") == 'True': self.snap_to_align = 1
else: self.snap_to_align = 0
- if xml_dom.hasAttribute("width"): self.width = int(xml_dom.getAttribute("width"))
- if xml_dom.hasAttribute("height"): self.height = int(xml_dom.getAttribute("height"))
+ if xml_dom.get("width") != None: self.width = int(xml_dom.get("width"))
+ if xml_dom.get("height") != None: self.height = int(xml_dom.get("height"))
##-----------------------------
## miniature layer
@@ -489,36 +489,36 @@
else: return ""
def layerTakeDOM(self, xml_dom):
- if xml_dom.hasAttribute('serial'):
- self.serial_number = int(xml_dom.getAttribute('serial'))
- children = xml_dom._get_childNodes()
+ if xml_dom.get('serial') != None:
+ self.serial_number = int(xml_dom.get('serial'))
+ children = xml_dom.getchildren()
for c in children:
- action = c.getAttribute("action")
- id = c.getAttribute('id')
+ action = c.get("action")
+ id = c.get('id')
if action == "del":
mini = self.get_miniature_by_id(id)
if mini: self.miniatures.remove(mini); del mini
elif action == "new":
- pos = cmpPoint(int(c.getAttribute('posx')),int(c.getAttribute('posy')))
- path = urllib.unquote(c.getAttribute('path'))
- label = c.getAttribute('label')
+ pos = cmpPoint(int(c.get('posx')),int(c.get('posy')))
+ path = urllib.unquote(c.get('path'))
+ label = c.get('label')
height = width = heading = face = snap_to_align = zorder = 0
locked = hide = False
- if c.hasAttribute('height'): height = int(c.getAttribute('height'))
- if c.hasAttribute('width'): width = int(c.getAttribute('width'))
- if c.getAttribute('locked') == 'True' or c.getAttribute('locked') == '1': locked = True
- if c.getAttribute('hide') == 'True' or c.getAttribute('hide') == '1': hide = True
- if c.getAttribute('heading'): heading = int(c.getAttribute('heading'))
- if c.hasAttribute('face'): face = int(c.getAttribute('face'))
- if c.hasAttribute('align'): snap_to_align = int(c.getAttribute('align'))
- if c.getAttribute('zorder'): zorder = int(c.getAttribute('zorder'))
+ if c.get('height') != None: height = int(c.get('height'))
+ if c.get('width') != None: width = int(c.get('width'))
+ if c.get('locked') == 'True' or c.get('locked') == '1': locked = True
+ if c.get('hide') == 'True' or c.get('hide') == '1': hide = True
+ if c.get('heading') != None: heading = int(c.get('heading'))
+ if c.get('face') != None: face = int(c.get('face'))
+ if c.get('align') != None: snap_to_align = int(c.get('align'))
+ if c.get('zorder') != None: zorder = int(c.get('zorder'))
min = BmpMiniature(id, path, ImageHandler.load(path, 'miniature', id), pos, heading,
face, label, locked, hide, snap_to_align, zorder, width, height)
self.miniatures.append(min)
- if c.hasAttribute('local') and c.getAttribute('local') == 'True' and os.path.exists(urllib.unquote(c.getAttribute('localPath'))):
- localPath = urllib.unquote(c.getAttribute('localPath'))
+ if c.get('local') == 'True' and os.path.exists(urllib.unquote(c.get('localPath'))):
+ localPath = urllib.unquote(c.get('localPath'))
local = True
- localTime = float(c.getAttribute('localTime'))
+ localTime = float(c.get('localTime'))
if localTime-time.time() <= 144000:
file = open(localPath, "rb")
imgdata = file.read()
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/miniatures_msg.py
--- a/orpg/mapper/miniatures_msg.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/miniatures_msg.py Sun Dec 19 22:44:36 2010 -0600
@@ -79,11 +79,11 @@
def init_from_dom(self,xml_dom):
self.p_lock.acquire()
- if xml_dom.tagName == self.tagname:
- if xml_dom.getAttributeKeys():
- for k in xml_dom.getAttributeKeys(): self.init_prop(k,xml_dom.getAttribute(k))
+ if xml_dom.tag == self.tagname:
+ if xml_dom.keys():
+ for k in xml_dom.keys(): self.init_prop(k,xml_dom.get(k))
- for c in xml_dom._get_childNodes():
+ for c in xml_dom.getchildren():
mini = mini_msg(self.p_lock)
try: mini.init_from_dom(c)
except Exception, e: print e; continue
@@ -103,10 +103,10 @@
def set_from_dom(self,xml_dom):
self.p_lock.acquire()
- if xml_dom.tagName == self.tagname:
- if xml_dom.getAttributeKeys():
- for k in xml_dom.getAttributeKeys(): self.set_prop(k,xml_dom.getAttribute(k))
- for c in xml_dom._get_childNodes():
+ if xml_dom.tag == self.tagname:
+ if xml_dom.keys():
+ for k in xml_dom.keys(): self.set_prop(k,xml_dom.get(k))
+ for c in xml_dom.getchildren():
mini = mini_msg(self.p_lock)
try: mini.set_from_dom(c)
except Exception, e: print e; continue
diff -r ee890f424e16 -r d02e9197c066 orpg/mapper/whiteboard.py
--- a/orpg/mapper/whiteboard.py Wed May 05 08:55:51 2010 -0500
+++ b/orpg/mapper/whiteboard.py Sun Dec 19 22:44:36 2010 -0600
@@ -46,7 +46,7 @@
self.scale = 1
self.r_h = RGBHex()
self.selected = False
- self.text_string = text_string
+ self.text_string = text_string.replace('"', '"').replace("'", ''')
self.id = id
self.weight = int(weight)
self.pointsize = int(pointsize)
@@ -95,7 +95,8 @@
# Draw text
(w,x,y,z) = self.get_rect(dc)
dc.SetFont(self.font)
- dc.DrawText(self.text_string, self.posx, self.posy)
+ text_string = self.text_string.replace('"', '"').replace(''', "'")
+ dc.DrawText(text_string, self.posx, self.posy)
dc.SetTextForeground(wx.Colour(0,0,0))
def toxml(self, action="update"):
@@ -119,21 +120,21 @@
else: return ''
def takedom(self, xml_dom):
- self.text_string = xml_dom.getAttribute("text_string")
- self.id = xml_dom.getAttribute("id")
- if xml_dom.hasAttribute("posy"): self.posy = int(xml_dom.getAttribute("posy"))
- if xml_dom.hasAttribute("posx"): self.posx = int(xml_dom.getAttribute("posx"))
- if xml_dom.hasAttribute("weight"):
- self.weight = int(xml_dom.getAttribute("weight"))
+ self.text_string = xml_dom.get("text_string")
+ self.id = xml_dom.get("id")
+ if xml_dom.get("posy") != None: self.posy = int(xml_dom.get("posy"))
+ if xml_dom.get("posx") != None: self.posx = int(xml_dom.get("posx"))
+ if xml_dom.get("weight"):
+ self.weight = int(xml_dom.get("weight"))
self.font.SetWeight(self.weight)
- if xml_dom.hasAttribute("style"):
- self.style = int(xml_dom.getAttribute("style"))
+ if xml_dom.get("style") != None:
+ self.style = int(xml_dom.get("style"))
self.font.SetStyle(self.style)
- if xml_dom.hasAttribute("pointsize"):
- self.pointsize = int(xml_dom.getAttribute("pointsize"))
+ if xml_dom.get("pointsize") != None:
+ self.pointsize = int(xml_dom.get("pointsize"))
self.font.SetPointSize(self.pointsize)
- if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '':
- self.textcolor = xml_dom.getAttribute("color")
+ if xml_dom.get("color") != None and xml_dom.get("color") != '':
+ self.textcolor = xml_dom.get("color")
if self.textcolor == '#0000000': self.textcolor = '#000000'
class WhiteboardLine:
@@ -231,16 +232,16 @@
return ''
def takedom(self, xml_dom):
- self.line_string = xml_dom.getAttribute("line_string")
- self.id = xml_dom.getAttribute("id")
- if xml_dom.hasAttribute("upperleftx"): self.upperleft.x = int(xml_dom.getAttribute("upperleftx"))
- if xml_dom.hasAttribute("upperlefty"): self.upperleft.y = int(xml_dom.getAttribute("upperlefty"))
- if xml_dom.hasAttribute("lowerrightx"): self.lowerright.x = int(xml_dom.getAttribute("lowerrightx"))
- if xml_dom.hasAttribute("lowerrighty"): self.lowerright.y = int(xml_dom.getAttribute("lowerrighty"))
- if xml_dom.hasAttribute("color") and xml_dom.getAttribute("color") != '':
- self.linecolor = xml_dom.getAttribute("color")
+ self.line_string = xml_dom.get("line_string")
+ self.id = xml_dom.get("id")
+ if xml_dom.get("upperleftx") != None: self.upperleft.x = int(xml_dom.get("upperleftx"))
+ if xml_dom.get("upperlefty") != None: self.upperleft.y = int(xml_dom.get("upperlefty"))
+ if xml_dom.get("lowerrightx") != None: self.lowerright.x = int(xml_dom.get("lowerrightx"))
+ if xml_dom.get("lowerrighty") != None: self.lowerright.y = int(xml_dom.get("lowerrighty"))
+ if xml_dom.get("color") != None and xml_dom.get("color") != '':
+ self.linecolor = xml_dom.get("color")
if self.linecolor == '#0000000': self.linecolor = '#000000'
- if xml_dom.hasAttribute("width"): self.linewidth = int(xml_dom.getAttribute("width"))
+ if xml_dom.get("width") != None: self.linewidth = int(xml_dom.get("width"))
##-----------------------------
## whiteboard layer
@@ -369,7 +370,7 @@
def add_text(self, text_string, pos, style, pointsize, weight, color="#000000"):
id = 'text-' + self.canvas.session.get_next_id()
- text = WhiteboardText(id,text_string, pos, style, pointsize, weight, color)
+ text = WhiteboardText(id, text_string, pos, style, pointsize, weight, color)
self.texts.append(text)
xml_str = "