annotate orpg/dieroller/rollers/ironclaw.py @ 243:3bbfd84619c0 beta

Traipse Beta 'OpenRPG' {101018-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Closing/Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log New Earthdawn Dieroller New IronClaw roller, sheet, and image Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner Update to Dieroller. Cleaner, more effecient expression system Update to Hidden Die plugin, allows for non standard dice rolls Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug Fix to Gametree for XSLT Sheets Fix to Gametree for locating gametree files Fix to Send to Chat from Gametree Fix to Gametree, renaming and remapping operates correctly
author sirebral
date Mon, 18 Oct 2010 23:48:49 -0500
parents
children 682032381be8
rev   line source
243
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
1 ## A die roller as used by IronClaw RPG
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
2 # Copyright (C) 2000-2010 The OpenRPG Project
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
3 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
4 # owner@madmathlabs.com
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
5 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
6 # This program is free software; you can redistribute it and/or modify
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
7 # it under the terms of the GNU General Public License as published by
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
8 # the Free Software Foundation; either version 2 of the License, or
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
9 # (at your option) any later version.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
10 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
14 # GNU General Public License for more details.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
15 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
17 # along with this program; if not, write to the Free Software
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
19 # --
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
20 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
21 # File: ironclaw.py
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
22 # Author: Prof. Ebral, TaS (Traipse)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
23 # Maintainer:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
24 # Version:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
25 # $Id: ironclaw.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
26 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
27 # Description: IronClaw Die Roller
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
28 # Comissioned by Ponderer
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
29 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
30 """
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
31 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
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
32 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
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
33 a safe sand box for the game tree data.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
34
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
35 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
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
36 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.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
37
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
38 By far the most intricate commission I have had so far. I really wish I could have accomplised all that was requested.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
39 """
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
40
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
41 from std import std
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
42 from math import fabs
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
43 import random
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
44 from orpg.dieroller.base import *
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
45 from orpg.tools.InterParse import Parse
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
46 """ For note
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
47 ret = ['(', num.strip(), "**die_rollers['", self.getRoller(), "'](",
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
48 sides.strip(), '))']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
49 s = ''.join(ret)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
50 """
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
51 class ironclaw(std):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
52 name = "ironclaw"
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
53 regGroup = '[a-zA-Z0-9. (::)(\-\+)]+'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
54 regExpression = regGroup+'/'+regGroup+'|'+regGroup
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
55 pcSheets = {}
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
56 healingTable = {
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
57 1: ['1d4', '2d4', '2d6', '2d8'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
58 2: ['1d6', '2d6', '2d8', '2d10'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
59 3: ['1d8', '2d8', '2d10', '2d12'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
60 4: ['1d10', '2d10', '2d12', '3d12'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
61 5: ['1d12', '2d12', '3d12', '3d12'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
62 6: ['2d12', '3d12', '3d12', '4d12'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
63 7: ['2d12', '3d12', '4d12', '4d12'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
64 8: ['3d12', '4d12', '4d12', '4d12'],
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
65 9: ['3d12', '4d12', '5d12', '6d12']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
66 }
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
67 acceptedDice = ['4', '6', '8', '10', '12']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
68 deathTable = {
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
69 6: '1d4', 7: '1d6', 8: '1d8', 9: '1d10',
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
70 10: '1d12', 11: '2d12', 12: '3d12', 13: 'Dead'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
71 }
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
72 unconTable = {
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
73 3: '1d4', 4: '1d6', 5: '1d8', 6: '1d10', 7: '1d12',
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
74 8: '2d12', 9: '3d12', 10: '4d12', 11: '4d12', 12: '4d12'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
75 }
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
76 conditions = {'easy': 0, 'medium': 1, 'hard': 2, 'extreme': 3}
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
77
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
78 def __init__(self, source=[]):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
79 std.__init__(self, source)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
80
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
81 def non_stdDie(self, match):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
82 s = match.group(0)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
83 vsRoll = s.split('/'); pcSheets = []; PCs = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
84 for roll in vsRoll:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
85 PCs.append(roll.split('.'))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
86 for pc in PCs:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
87 if pc[0].lower() == 'toolbox': return self.ToolBox(pc)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
88 else: pcSheets.append(self.findSheets(pc))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
89 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
90 actor, aDice, adDice = self.makeDecision(PCs[0], pcSheets[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
91 myStr = actor; compareTest = None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
92 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
93 if len(aDice) > 1:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
94 myStr += ' ' +self.cleanDice(aDice)[0]+ ' => '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
95 attackRoll = self.rollDice(aDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
96 myStr += attackRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
97 compareTest = self.compareTest(attackRoll[1], [1,1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
98 if compareTest == 'botch': myStr += ' Botch!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
99 if (isinstance(adDice, list)) and (compareTest != 'botch'):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
100 myStr += ' Damage: ' +self.cleanDice(adDice)[0]+ ' => '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
101 myStr += self.rollDamage(adDice)[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
102 if len(pcSheets) == 2:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
103 if pcSheets[1][0] == True: reactor, rDice, rdDice = self.makeDecision(PCs[1], pcSheets[1][1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
104 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
105 diceList = ['None']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
106 for die in PCs[1]:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
107 trueDice = self.makeTrueDice(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
108 for die in trueDice: diceList.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
109 diceList = self.buildActionList(diceList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
110 rDice = self.diceModifiers(diceList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
111 myStr += ' / ' +str(rDice)+ ' => '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
112 rDice.sort(); rDice.reverse()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
113 rDiceRolled = self.rollDice(rDice)[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
114 myStr += str(rDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
115 return myStr
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
116
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
117 def ToolBox(self, commands):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
118 ## This is expandable. Aimed for GM use ##
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
119 if commands[1].lower() == 'clearpcs':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
120 for key in self.pcSheets.keys(): del self.pcSheets[key]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
121 return 'Clearing PC Sheets'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
122
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
123 def makeDecision(self, pcAction, pcSheetData):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
124 pcSheet = pcSheetData[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
125 if self.pcSheets.has_key(pcAction[0]): pcNode = pcSheet['Node']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
126 else: pcNode = pcSheetData[2]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
127 actionList = self.buildActionList(pcAction); skillList = self.buildSkillList(pcSheet['Skills'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
128 ability = self.buildAbilities(pcSheet['Abilities']); nodeList = self.buildNodeList(pcSheet)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
129 myStr = '<b>'+self.NameSpaceXI('name', pcSheet['General']).text+ '</b> '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
130 diceList = []; options = ['parry', 'guard', 'retreat', 'nocover']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
131 toolbox = ['setpc', 'delpc', 'clearpcs', 'update']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
132 actions = ['denarii', 'aureals', 'fatigue', 'wounds', 'passout',
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
133 'resolve', 'soak', 'rest', 'block', 'dodge', 'magic',
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
134 'damage', 'meditate', 'initiative', 'strength']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
135 #others = ['cast'] ## For future dev
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
136 #magicCareers = ['cleric', 'elementalist', 'thaumaturge', 'necromancer', 'green and purple mage']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
137 damage = None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
138 self.updatePC(pcSheet, skillList, ability['speed'], actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
139 for action in actionList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
140 action = action.lower(); actionNodes = action.split('::')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
141 if action in options: pass ## Pass over these.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
142
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
143 elif action in toolbox:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
144 if action == 'setpc': myStr += self.setPCSheet(pcSheetData[2], pcSheet, actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
145 elif action == 'delpc': myStr += self.delPCSheet(pcAction[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
146 elif action == 'update':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
147 myStr += self.updatePC(pcSheet, skillList, ability['speed'], actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
148 while len(actionList) > 1: actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
149
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
150 elif action in actions:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
151 if action in ['denarii', 'aureals']:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
152 myStr += self.setCoin(pcSheet['Purse'], action, actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
153 elif action in ['fatigue', 'wounds']:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
154 myStr += self.setWound(pcSheet['Character'], action, ability['body'], actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
155 elif action == 'soak':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
156 myStr += 'Soak: '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
157 diceList += self.pcSoak(pcSheet['Defense'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
158 elif action == 'strength':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
159 myStr += 'Strength: '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
160 diceList += self.pcStrength(pcSheet['Abilities'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
161 elif action == 'initiative':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
162 myStr += 'Initiative: '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
163 diceList += self.pcInit(pcSheet['Defense'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
164 elif action in ['block', 'dodge']:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
165 dice = self.dodgeBlock(action, ability, actionList, pcSheet['Defense'], pcSheet['Equipment'], skillList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
166 myStr += action.capitalize()+'s'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
167 if dice != 'No Dice Found!': diceList += dice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
168 elif action == 'rest':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
169 myStr += self.restPC(pcSheet['Character'], pcSheet['Skills'], ability['body'], action, actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
170 elif action == 'meditate':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
171 myStr += self.restPC(pcSheet['Character'], skillList, ability['body'], action, actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
172 elif action == 'magic': myStr += self.pcMagic(pcSheet['Character'], actionList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
173 elif action == 'damage': string, damage = self.pcDamage(actionList); myStr += string
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
174 elif action == 'passout': myStr += self.passoutTest(pcSheet['Character'], pcSheet['Defense'], skillList, ability['will'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
175 elif action == 'resolve':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
176 myStr += 'Resolve: '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
177 diceList += self.pcResolve(pcSheet['Character'], pcSheet['Defense'], skillList, ability['will'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
178
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
179 elif nodeList.has_key(action):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
180 if ability.has_key(action):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
181 myStr += '<u>Ability; '+action.capitalize()+'</u> '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
182 abilityDice = self.makeTrueDice( str(ability[action].find('text').text) )
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
183 for die in abilityDice:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
184 diceList.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
185 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
186 string, dice, damage = self.getNodeValue(action, actionList, ability, nodeList, pcSheet, skillList, pcNode)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
187 myStr += string+' '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
188 if isinstance(dice, list): diceList += dice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
189
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
190 elif skillList.has_key(action):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
191 dice = self.getSkillDice(skillList[action])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
192 if dice != 'No Dice Found!': diceList += dice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
193 myStr += '<u>Skill; '+action.capitalize()+'</u> '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
194
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
195 elif nodeList.has_key(actionNodes[len(actionNodes)-1]):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
196 string, dice, damage = self.getNodeValue(action, actionList, ability, nodeList, pcSheet, skillList, pcNode)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
197 myStr += string+' '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
198 if isinstance(dice, list): diceList += dice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
199
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
200 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
201 trueDice = self.makeTrueDice(action)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
202 for die in trueDice: diceList.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
203 if len(actionList) > 1: diceList.append(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
204 if len(diceList) > 1: diceList = self.diceModifiers(diceList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
205 if damage != None: damage = self.diceModifiers(damage)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
206 return myStr, diceList, damage
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
207
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
208 def pcMagic(self, character, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
209 magic = int(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
210 magicPoints = self.NameSpaceVI('magic points', character)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
211 cMagic = self.NameSpaceXI('current', magicPoints); cM = int(cMagic.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
212 mMagic = self.NameSpaceXI('maximum', magicPoints); mM = int(mMagic.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
213 myStr = 'Regains ' if magic >= 0 else 'Loses '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
214 if len(actionList) == 2:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
215 if magic < 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
216 if cM + magic < 0: return 'Insufficient Magic!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
217 cM += magic
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
218 if cM > mM: cM = mM
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
219 myStr += str(magic)+ ' Magic.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
220 cMagic.text = str(cM)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
221 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
222 diceList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
223 for x in xrange(1, len(actionList)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
224 trueDice = self.makeTrueDice(actionList[x])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
225 for die in trueDice:diceList.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
226 diceList.append(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
227 diceList = self.diceModifiers(diceList)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
228 while len(actionList) > 1: actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
229 addMagic = self.rollDice(diceList); x = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
230 for m in addMagic[1]: x += int(m)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
231 cM += x
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
232 if cM > mM: cM = mM
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
233 cMagic.text = str(cM)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
234 return 'Regains ' +self.cleanDice(diceList)[0]+ ' => ' +addMagic[0]+ ' => [' +str(x)+ '] Magic.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
235 return myStr
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
236
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
237 def pcDamage(self, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
238 if len(actionList) == 2: return 'No Damage Dice', None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
239 diceList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
240 if 'd' in actionList[len(actionList)-1]: mod = '0'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
241 else: mod = int(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
242 for x in xrange(1, len(actionList)-1):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
243 trueDice = self.makeTrueDice(actionList[x])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
244 for die in trueDice: diceList.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
245 diceList.append(mod)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
246 while len(actionList) > 1: actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
247 return '', diceList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
248
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
249 def pcStrength(self, abilities):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
250 strength = self.NameSpaceXI('strength dice', abilities)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
251 trueDice = self.makeTrueDice(str(strength.text))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
252 return trueDice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
253
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
254 def pcSoak(self, defense):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
255 soak = self.NameSpaceXI('soak', defense)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
256 trueDice = self.makeTrueDice(str(soak.text))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
257 return trueDice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
258
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
259 def pcInit(self, defense):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
260 init = self.NameSpaceXI('initiative', defense)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
261 trueDice = self.makeTrueDice(str(init.text))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
262 return trueDice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
263
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
264 def setCoin(self, purse, action, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
265 denarii = self.NameSpaceXI('denarii', purse); d = int(denarii.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
266 aureals = self.NameSpaceXI('aureals', purse); a = int(aureals.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
267 coins = int(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
268 myStr = 'Gains ' if coins >= 0 else 'Loses '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
269 if action == 'denarii':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
270 d += coins
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
271 while d >= 24:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
272 a += 1; d -= 24
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
273 myStr += str(coins)+ ' Denarii'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
274 if d < 0: a -= 1; d += 24
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
275 if action == 'aureals': a += coins; myStr += str(coins)+ ' Aureals'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
276 if a < 0: return 'Not enough coins!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
277 if d < 0: return 'Not enough coins!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
278 aureals.text = str(a); denarii.text = str(d)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
279 return myStr
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
280
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
281 def setWound(self, character, action, body, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
282 fatigue = self.NameSpaceXI('fatigue', character); f = int(fatigue.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
283 wounds = self.NameSpaceVI('wounds', character)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
284 cWounds = self.NameSpaceXI('current', wounds); cW = int(cWounds.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
285 mWounds = self.NameSpaceXI('maximum', wounds); mW = int(mWounds.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
286 total = self.NameSpaceXI('total', character); t = int(total.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
287 mod = int(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
288 myStr = 'Suffers ' if mod >= 0 else 'Regains '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
289 if action == 'fatigue':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
290 myStr += str(mod)+ ' Fatigue '; tie = False
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
291 for x in range(0, mod):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
292 f += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
293 if f > t:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
294 f -= 1; cW += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
295 if (cW >= 6) and not tie:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
296 deathTest = self.deathTest(cW, body)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
297 if deathTest[0] == 'Dead': tie = True; myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
298 if deathTest[2] in ['failure', 'riposte', 'tie', 'botch']: tie = True; myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
299 else: myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
300 if action == 'wounds':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
301 myStr += str(int(fabs(mod)))+ ' Wounds '; tie = False
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
302 if mod > 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
303 for x in xrange(0, mod):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
304 cW += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
305 if (cW >= 6) and not tie:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
306 deathTest = self.deathTest(cW, body)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
307 if deathTest[0] == 'Dead': tie = True; myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
308 if deathTest[2] in ['failure', 'riposte', 'tie', 'botch']: tie = True; myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
309 else: myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
310 else: cW += mod
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
311 if cW < 0: cW = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
312 if f < 0: f = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
313 t = f + cW; fatigue.text = str(f); cWounds.text = str(cW); total.text = str(t)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
314 if t > mW: myStr += 'You have fallen.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
315 return myStr
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
316
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
317 def restPC(self, character, skills, body, action, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
318 if 'd' in actionList[len(actionList)-1]: mod = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
319 else: mod = int(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
320
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
321 if action == 'meditate':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
322 if not skills.has_key('meditate'):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
323 if not skills.has_key('meditation'):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
324 while len(actionList) > 1: actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
325 return 'No skill in Meditation.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
326 magicPoints = self.NameSpaceVI('magic points', character)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
327 cMagic = self.NameSpaceXI('current', magicPoints); cM = int(cMagic.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
328 mMagic = self.NameSpaceXI('maximum', magicPoints); mM = int(mMagic.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
329 vsDice = self.getSkillDice(skills['meditate']) if skills.has_key('meditate') else self.getSkillDice(skills['meditation'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
330 vsDice += vsDice; vsDice.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
331 myStr = 'Meditates, '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
332 condition = 'easy'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
333 vsCondition = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
334 for x in xrange(1, len(actionList)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
335 trueDice = self.makeTrueDice(actionList[x])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
336 for die in trueDice: vsCondition.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
337 if len(vsCondition) == 0: return 'No Difficulty Set.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
338 magicGained = 0; result = 'success' # Begins loop
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
339 while result in ['success', 'overwhelm']:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
340 vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
341 if result == 'success': myStr += 'Meditate Skill: ' +self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
342 if result == 'overwhelm': myStr += ' Rolling Again: ' +self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
343 myStr += ' vs. '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
344 result = self.compareTest(vsRoll[1], conRoll[1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
345 if result == 'riposte': myStr += ' Overwhelming failure'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
346 else: myStr += ' '+result.capitalize()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
347 if result == 'success':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
348 magicGained += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
349 break
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
350 if result == 'overwhelm':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
351 magicGained += 2
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
352 if magicGained > 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
353 myStr += ' Regains '+str(magicGained)+' magic.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
354 cM += magicGained
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
355 if cM > mM: cM = mM
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
356 cMagic.text = str(cM)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
357 while len(actionList) > 1: actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
358
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
359 if action == 'rest':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
360 fatigue = self.NameSpaceXI('fatigue', character); f = int(fatigue.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
361 wounds = self.NameSpaceVI('wounds', character)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
362 cWounds = self.NameSpaceXI('current', wounds); cW = int(cWounds.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
363 mWounds = self.NameSpaceXI('maximum', wounds); mW = int(mWounds.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
364 total = self.NameSpaceXI('total', character); t = int(total.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
365 myStr = 'Rests ' +str(mod)+ ' hours. '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
366 f -= mod
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
367 if f < 0: f = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
368 if mod >= 8:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
369 myStr += '<b>Roll Magic Dice</b>'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
370 if cW > 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
371 vsDice = body.find('text').text
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
372 vsDice = self.makeTrueDice(vsDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
373 c = 9 if cW > 9 else cW
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
374 condition = 'easy' if not self.conditions.has_key(actionList[1]) else actionList[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
375 vsCondition = self.healingTable[c][self.conditions[condition]]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
376 vsCondition = self.makeTrueDice(vsCondition)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
377 vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
378 myStr += ', Roll Wounds; Body: ' +self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
379 myStr += ' vs. Condition ('+condition.capitalize()+'): '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
380 result = self.compareTest(vsRoll[1], conRoll[1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
381 if result == 'riposte': myStr += ' Overwhelming failure'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
382 else: myStr += ' '+result.capitalize()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
383 if result in ['success', 'overwhelm']: cW -= 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
384 if result == 'botch':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
385 cW += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
386 deathTest = self.deathTest(cW, body)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
387 if deathTest[0] == 'Dead': return deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
388 else: myStr += deathTest[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
389 if cW < 0: cW = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
390 if f < 0: f = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
391 if t > mW: myStr += 'You have fallen.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
392 t = f + cW; fatigue.text = str(f); cWounds.text = str(cW); total.text = str(t)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
393 return myStr
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
394
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
395 def dodgeBlock(self, action, ability, actionList, defense, equipment, skillList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
396 optionals = ['guard', 'retreat']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
397 blockDice = self.getSkillDice(skillList[action]) if action in skillList.keys() else []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
398 speed = self.makeTrueDice( str(ability['speed'].find('text').text) )
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
399 for s in speed: blockDice.append(s)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
400 defendSkill = self.NameSpaceXI(action, defense)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
401 defendSkill.text = ', '.join(blockDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
402 if 'nocover' not in actionList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
403 cover = self.NameSpaceXI('cover', defense)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
404 cover = self.makeTrueDice(str(cover.text))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
405 for c in cover: blockDice.append(c)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
406 if 'retreat' in actionList: blockDice.append('1d8')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
407 if action == 'dodge':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
408 encumber = self.NameSpaceXI('encumbrance', equipment)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
409 try:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
410 encumber = float(encumber.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
411 if encumber < -1:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
412 encumber = int(encumber)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
413 blockDice = self.encumberDice(blockDice, encumber, speed)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
414 except: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
415 if 'guard' in actionList: blockDice.append('+2')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
416 return blockDice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
417
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
418 def pcResolve(self, character, defense, skillList, abilityWill):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
419 total = self.NameSpaceXI('total', character); t = int(total.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
420 resolveDice = self.getSkillDice(skillList['resolve']) if 'resolve' in skillList.keys() else []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
421 will = self.makeTrueDice( abilityWill.find('text').text )
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
422 for w in will: resolveDice.append(w)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
423 resolveDice = self.cleanDice(resolveDice)[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
424 defendSkill = self.NameSpaceXI('resolve', defense)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
425 defendSkill.text = ', '.join(resolveDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
426 return resolveDice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
427
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
428
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
429 ### Data Functions ###
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
430 def getSkillDice(self, skill, skip=[0]):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
431 dice = []; cells = skill.findall('cell')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
432 for x in xrange(3, 9):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
433 if (cells[x].text != '') or (cells[x].text != None):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
434 if x in skip: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
435 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
436 skillDice = self.makeTrueDice(str(cells[x].text))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
437 for s in skillDice: dice.append(s)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
438 if len(dice) == 0: return 'No Dice Found!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
439 else: return dice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
440
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
441 def buildAbilities(self, pcSheet):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
442 nodes = pcSheet.getiterator('nodehandler')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
443 ability = {}
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
444 for node in nodes:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
445 if node.get('name') == 'Body': ability['body'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
446 if node.get('name') == 'Speed': ability['speed'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
447 if node.get('name') == 'Mind': ability['mind'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
448 if node.get('name') == 'Will': ability['will'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
449 return ability
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
450
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
451 def buildActionList(self, actions):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
452 actionLength = len(actions); actionList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
453 for x in xrange(1, actionLength):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
454 if x == actionLength-1:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
455 getMod = self.getMod(actions[x])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
456 for action in getMod[0]: actionList.append(str(action))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
457 actionList.append(str(getMod[1]))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
458 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
459 for action in self.getMod(actions[x])[0]: actionList.append(str(action))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
460 return actionList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
461
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
462 def buildSkillList(self, skills):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
463 grid = skills.find('grid')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
464 listRows = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
465 for row in grid.findall('row'):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
466 listRows.append(row)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
467 skillList = {}
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
468 for x in xrange(1, len(listRows)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
469 if listRows[x].findall('cell')[0].text != None:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
470 skillList[listRows[x].findall('cell')[0].text.lower()] = listRows[x]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
471 return skillList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
472
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
473 def buildNodeList(self, pcSheet):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
474 nodeList = {}
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
475 for key in pcSheet.keys():
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
476 nodes = pcSheet[key].getiterator('nodehandler')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
477 for node in nodes:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
478 nodeList[node.get('name').lower()] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
479 return nodeList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
480
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
481
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
482 ### Test Functions ###
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
483 def deathTest(self, cW, body):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
484 vsDice = body.find('text').text
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
485 vsDice = self.makeTrueDice(vsDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
486 vsCondition = self.deathCheck(cW)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
487 if vsCondition != []:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
488 if vsCondition[0] == 'Dead': myStr = ' You have fallen.'; return [vsCondition[0], myStr, None]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
489 vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
490 myStr = '<br />Death Check: '+self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
491 myStr += ' vs. Death: '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
492 result = self.compareTest(vsRoll[1], conRoll[1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
493 if result == 'riposte': myStr += ' Overwhelming failure'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
494 else: myStr += ' '+result.capitalize()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
495 if result in ['botch', 'failure', 'riposte']: myStr += ' You have fallen.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
496 else: myStr += ' You have survived.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
497 return [vsCondition[0], myStr, result]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
498
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
499 def passoutTest(self, character, defense, skillList, abilityWill):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
500 #mod = int(actionList[len(actionList)-1]) or 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
501 total = self.NameSpaceXI('total', character); t = int(total.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
502 vsDice = self.getSkillDice(skillList['resolve']) if 'resolve' in skillList.keys() else []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
503 will = self.makeTrueDice( abilityWill.find('text').text )
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
504 for w in will: vsDice.append(w)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
505 vsDice = self.cleanDice(vsDice)[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
506 defendSkill = self.NameSpaceXI('resolve', defense)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
507 defendSkill.text = ', '.join(vsDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
508 vsCondition = self.unconCheck(t)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
509 myStr = ''
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
510 if vsCondition != []:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
511 vsRoll = self.rollDice(vsDice); conRoll = self.rollDice(vsCondition)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
512 myStr += 'Unconciousness Check: '+self.cleanDice(vsDice)[0]+ ' => ' +vsRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
513 myStr += ' vs. '+self.cleanDice(vsCondition)[0]+ ' => ' +conRoll[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
514 result = self.compareTest(vsRoll[1], conRoll[1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
515 if result == 'riposte': myStr += ' Overwhelming failure'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
516 else: myStr += ' '+result.capitalize()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
517 if result in ['botch', 'failure', 'riposte']: myStr += ' You have passed out.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
518 else: myStr += ' You have survived.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
519 else: myStr += 'No Unconciousness Check Required!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
520 return myStr
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
521
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
522 def unconCheck(self, fatigue):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
523 dieList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
524 if fatigue > 12: fatigue = 12
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
525 if self.unconTable.has_key(fatigue):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
526 dieList.append(self.unconTable[fatigue])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
527 return dieList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
528
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
529 def deathCheck(self, wounds):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
530 dieList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
531 if wounds > 13: wounds = 13
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
532 if self.deathTable.has_key(wounds):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
533 dieList.append(self.deathTable[wounds])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
534 return dieList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
535
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
536 def compareTest(self, dice1, dice2):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
537 ## Do Botch, Tie, Overwhelming.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
538 botch = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
539 for x in xrange(0, len(dice1)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
540 if dice1[x] == 1: botch += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
541 if botch == len(dice1): return 'botch'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
542 botch = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
543 for x in xrange(0, len(dice2)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
544 if dice2[x] == 1: botch += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
545 if botch == len(dice2):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
546 if dice1[0] > dice2[0]:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
547 if int(dice1[0]) - int(dice2[0]) >= 5: return 'overwhelm'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
548 else: return 'success' #result2 = 'botch'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
549 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
550 if dice1[0] == dice2[0]: return 'tie'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
551 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
552 if dice1[0] > dice2[0]:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
553 if int(dice1[0]) - int(dice2[0]) >= 5: return 'overwhelm'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
554 else: return 'success'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
555 elif dice2[0] >= dice1[0]:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
556 if int(dice2[0]) - int(dice1[0]) >= 5: return 'riposte'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
557 else: return 'failure'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
558
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
559 def compareDamage(self, dice1, dice2):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
560 # Works like this. [6, 4, 3] vs [5, 5, 2] == 2 Wounds.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
561 # [7, 3, 3] vs [6, 3, 3] == 1 Wounds. Ties go to the defender, 1's are not counted.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
562 ## Added for future dev.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
563 pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
564
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
565
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
566 ### Node Functions ###
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
567 def NameSpaceXI(self, s, node):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
568 nodeList = node.getiterator('nodehandler')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
569 for node in nodeList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
570 if node.get('name').lower() == s: return node.find('text')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
571 return ''
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
572
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
573 def NameSpaceVI(self, s, node): ## Sometimes I just need the node. I don't like the name though.
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
574 nodeList = node.getiterator('nodehandler')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
575 for node in nodeList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
576 if node.get('name').lower() == s: return node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
577 return ''
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
578
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
579 def getNodeValue(self, action, actionList, ability, nodeList, pcSheet, skillList, pcNode):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
580 nodePath = actionList[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
581 weapons = pcSheet['Combat'].getiterator('nodehandler')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
582 optionals = ['parry', 'guard', 'retreat']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
583 damage = None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
584 if nodeList.has_key(action) and nodeList[action] in weapons:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
585 toHit = []; damage = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
586 speed = self.makeTrueDice( str(ability['speed'].find('text').text) )
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
587 for s in speed: toHit.append(s)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
588 grid = nodeList[action].find('grid')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
589
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
590 if actionList[1] == 'damage':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
591 for row in grid.findall('row'):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
592 cells = row.findall('cell')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
593 if cells[0].text == 'Damage':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
594 trueDice = self.makeTrueDice(cells[1].text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
595 for die in trueDice: damage.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
596 damage.append(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
597 if cells[0].text == 'Name':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
598 weaponName = str(cells[1].text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
599 while len(actionList) > 1: actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
600 return weaponName, action, damage
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
601
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
602 string = 'Attacks!'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
603 for row in grid.findall('row'):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
604 cells = row.findall('cell')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
605 if cells[0].text == 'Skill':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
606 weaponSkill = str(cells[1].text).lower()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
607 skillDice = self.getSkillDice(skillList[weaponSkill]) if weaponSkill in skillList.keys() else None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
608 if isinstance(skillDice, list): toHit += skillDice
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
609 if cells[0].text == 'Damage':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
610 trueDice = self.makeTrueDice(cells[1].text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
611 for die in trueDice: damage.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
612 #damage.append(actionList[len(actionList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
613 if 'parry' in actionList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
614 damage = None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
615 string = 'Defends'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
616 if 'retreat' in actionList: toHit.append('1d8')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
617 if 'guard' in actionList: toHit.append(str(int(actionList[len(actionList)-1])+2))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
618 return string, toHit, damage
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
619 return Parse.NameSpaceE('!&'+pcNode.get('name')+'::'+nodePath+'&!'), action, damage
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
620
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
621
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
622 ### pcSheet Functions ###
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
623 def findSheets(self, initiate):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
624 if self.pcSheets.has_key(initiate[0]): return True, self.pcSheets[initiate[0]]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
625 pcSheet = Parse.NameSpaceXE('!&'+initiate[0]+'&!')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
626 if pcSheet == None: return [False, [initiate[0]], None]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
627 else: return [True, self.buildPCSheet(pcSheet), pcSheet]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
628 return [False, [initiate[0]], None]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
629
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
630 def buildPCSheet(self, PC):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
631 pcSheet = {}
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
632 nodes = PC.getiterator('nodehandler')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
633 for node in nodes:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
634 if node.get('name') == 'Character': pcSheet['Character'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
635 if node.get('name') == 'Skills':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
636 if node.get('class') == 'rpg_grid_handler': pcSheet['Skills'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
637 if node.get('name') == 'General': pcSheet['General'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
638 if node.get('name') == 'Abilities': pcSheet['Abilities'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
639 if node.get('name') == 'Gifts / Flaws': pcSheet['Gifts / Flaws'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
640 if node.get('name') == 'Combat': pcSheet['Combat'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
641 if node.get('name') == 'Defense': pcSheet['Defense'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
642 if node.get('name') == 'Equipment': pcSheet['Equipment'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
643 if node.get('name') == 'Purse': pcSheet['Purse'] = node
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
644 #print 'pcSheet', len(pcSheet)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
645 return pcSheet
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
646
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
647 def setPCSheet(self, pcNode, pcSheet, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
648 if len(actionList) < 2: return 'Cannot setPC'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
649 while actionList[0].lower() != 'setpc': actionList.pop()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
650 self.pcSheets[actionList[1]] = pcSheet
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
651 self.pcSheets[actionList[1]]['Node'] = pcNode
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
652 return 'PC Sheet set to '+ actionList[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
653
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
654 def delPCSheet(self, pcSheet):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
655 del self.pcSheets[pcSheet]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
656 return 'PC Sheet '+pcSheet+' deleted.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
657
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
658 def updatePC(self, pcSheet, skillList, abilitySpeed, actionList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
659 denarii = self.NameSpaceXI('denarii', pcSheet['Purse']); d = int(denarii.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
660 aureals = self.NameSpaceXI('aureals', pcSheet['Purse']); a = int(aureals.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
661 while d >= 24: a += 1; d -= 24
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
662 aureals.text = str(a); denarii.text = str(d)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
663 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
664 blockDice = self.getSkillDice(skillList['dodge']) if 'dodge' in skillList.keys() else []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
665 speed = self.makeTrueDice( abilitySpeed.find('text').text )
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
666 for s in speed: blockDice.append(s)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
667 blockDice = self.cleanDice(blockDice)[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
668 defendSkill = self.NameSpaceXI('dodge', pcSheet['Defense'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
669 defendSkill.text = ', '.join(blockDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
670 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
671 blockDice = self.getSkillDice(skillList['block']) if 'block' in skillList.keys() else []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
672 for s in speed: blockDice.append(s)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
673 blockDice = self.cleanDice(blockDice)[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
674 defendSkill = self.NameSpaceXI('block', pcSheet['Defense'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
675 defendSkill.text = ', '.join(blockDice)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
676 #
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
677 fatigue = self.NameSpaceXI('fatigue', pcSheet['Character']); f = int(fatigue.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
678 wounds = self.NameSpaceVI('wounds', pcSheet['Character'])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
679 cWounds = self.NameSpaceXI('current', wounds); cW = int(cWounds.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
680 mWounds = self.NameSpaceXI('maximum', wounds); mW = int(mWounds.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
681 total = self.NameSpaceXI('total', pcSheet['Character']); t = int(total.text)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
682 t = f + cW; fatigue.text = str(f); cWounds.text = str(cW); total.text = str(t)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
683 return 'Updated.'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
684
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
685
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
686 ### Math Functions ###
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
687 def getMod(self, action):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
688 action = action.split('+')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
689 mod = '+'+str(action[1]) if len(action) == 2 else '0'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
690 action = action[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
691 if mod == '0':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
692 action = action.split('-')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
693 mod = '-'+str(action[1]) if len(action) == 2 else '0'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
694 action = action[0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
695 action = [action]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
696 return [action, mod]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
697
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
698 def encumberDice(self, diceList, encumber, speed):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
699 encumber += 1; speedCap = 12+encumber*2
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
700 for x in xrange(0, len(diceList)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
701 diceCheck = diceList[x].split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
702 try: rolls = int(diceCheck[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
703 except: continue
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
704 try: facets = int(diceCheck[1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
705 except: continue
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
706 if facets > speedCap: facets = speedCap
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
707 diceList[x] = str(rolls)+'d'+str(facets)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
708 return diceList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
709
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
710 def diceModifiers(self, diceList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
711 diceList.sort(); diceList.reverse()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
712 dice = [0, 0, 0, 0, 0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
713 getMod = True; mod = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
714 for dieMod in diceList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
715 try: mod += int(dieMod); del diceList[diceList.index(dieMod)]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
716 except: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
717 if mod <= 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
718 diceList.append(str(mod))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
719 return diceList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
720 for die in diceList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
721 d = die.split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
722 if die == mod: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
723 elif d[1] == '4': dice[0] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
724 elif d[1] == '6': dice[1] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
725 elif d[1] == '8': dice[2] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
726 elif d[1] == '10': dice[3] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
727 elif d[1] == '12': dice[4] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
728 diceMod = [0, 0, 0, 0, 0, 0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
729 for i in xrange(0, len(dice)):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
730 dMod = (mod-(4-i))*dice[i]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
731 if dMod < 0: dMod = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
732 if i == 4: diceMod[5] += mod*dice[i]; diceMod[4] += dice[i]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
733 elif i+mod >= 5: diceMod[5] += dMod; diceMod[4] += dice[i]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
734 else: diceMod[i+mod] = dice[i]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
735 while diceMod[5] > 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
736 self.applyMod(diceMod)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
737 diceMod.pop(); dice = diceMod
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
738 diceList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
739 if dice[0] != 0: diceList.append(str(dice[0])+'d4')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
740 if dice[1] != 0: diceList.append(str(dice[1])+'d6')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
741 if dice[2] != 0: diceList.append(str(dice[2])+'d8')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
742 if dice[3] != 0: diceList.append(str(dice[3])+'d10')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
743 if dice[4] != 0: diceList.append(str(dice[4])+'d12')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
744 diceList.append(str(mod))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
745 return diceList
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
746
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
747 def applyMod(self, diceMod):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
748 for i in xrange(0, 5):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
749 while diceMod[i] > 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
750 if diceMod[5] == 0: break
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
751 diceMod[5] -= 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
752 if i == 4: diceMod[0] += 1; break
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
753 else: diceMod[i+1] += 1; diceMod[i] -= 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
754
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
755
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
756 ### Dice Functions ###
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
757 def makeTrueDice(self, dieSet):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
758 dice = dieSet.split(',')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
759 dieSet = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
760 for die in dice:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
761 if 'd' not in die: die = None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
762 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
763 die = die.replace(' ', '')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
764 die = die.split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
765 try:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
766 int(die[1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
767 if die[0] == '':
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
768 if die[1] in self.acceptedDice: die = '1d'.join(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
769 else: die = 'd'.join(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
770 except: die = None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
771 if die != None: dieSet.append(die)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
772 return dieSet
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
773
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
774 def cleanDice(self, diceList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
775 dice = [0, 0, 0, 0, 0]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
776 if 'd' in diceList[len(diceList)-1]: mod = '0'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
777 else: mod = diceList[len(diceList)-1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
778 for die in diceList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
779 d = die.split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
780 if die == mod: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
781 elif d[1] == '4': dice[0] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
782 elif d[1] == '6': dice[1] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
783 elif d[1] == '8': dice[2] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
784 elif d[1] == '10': dice[3] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
785 elif d[1] == '12': dice[4] += int(d[0])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
786 diceList = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
787 if dice[0] != 0: diceList.append(str(dice[0])+'d4')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
788 if dice[1] != 0: diceList.append(str(dice[1])+'d6')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
789 if dice[2] != 0: diceList.append(str(dice[2])+'d8')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
790 if dice[3] != 0: diceList.append(str(dice[3])+'d10')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
791 if dice[4] != 0: diceList.append(str(dice[4])+'d12')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
792 cleanList = '['
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
793 for die in diceList:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
794 cleanList += die+', '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
795 cleanList += mod+']'
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
796 return [cleanList, diceList]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
797
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
798 def rollDamage(self, diceList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
799 if 'd' in diceList[len(diceList)-1]: mod = 0; diceList.append('0')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
800 else: mod = int(diceList[len(diceList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
801 removeDice = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
802 diceRolls = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
803 for x in xrange(0, len(diceList)-1):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
804 dice, facets = diceList[x].split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
805 rolls = self.roll(int(dice), int(facets))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
806 for roll in rolls: diceRolls.append(roll)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
807 diceRolls.sort(); diceRolls.reverse()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
808 myStr = '['
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
809 if mod < 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
810 for x in xrange(0, int(fabs(mod))): removeDice.append(len(diceRolls)-x-1)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
811 if len(diceRolls) > 1:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
812 if 0 in removeDice: myStr += '<font color=blue>'+str(diceRolls[0])+'</font>, '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
813 else: myStr += '<font color=red>'+str(diceRolls[0])+'</font>, '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
814 for x in xrange(1, len(diceRolls)-1):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
815 if x in removeDice: myStr += '<font color=blue>'+str(diceRolls[x])+'</font>, '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
816 else: myStr += str(diceRolls[x])+', '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
817 myStr += '<font color=blue>'+str(diceRolls[len(diceRolls)-1])+'</font>, '+str(mod)+'] '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
818 else:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
819 if 0 in removeDice: myStr += '<font color=blue>'+str(diceRolls[0])+'</font>, '+str(mod)+'] '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
820 else: myStr += '<font color=red>'+str(diceRolls[0])+'</font>, '+str(mod)+'] '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
821 diceRolls.append(mod)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
822 return [myStr, diceRolls]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
823
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
824 def rollDice(self, diceList):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
825 if 'd' in diceList[len(diceList)-1]: mod = 0; diceList.append('0')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
826 else: mod = int(diceList[len(diceList)-1])
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
827 if mod < 0: rerolls = mod
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
828 else: rerolls = 0
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
829 rollSets = []; myStr = ''; result = [100]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
830 while rerolls <= 0:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
831 diceRolls = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
832 for x in xrange(0, len(diceList)-1):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
833 dice, facets = diceList[x].split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
834 rolls = self.roll(int(dice), int(facets))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
835 for roll in rolls: diceRolls.append(roll)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
836 diceRolls.sort(); diceRolls.reverse()
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
837 rollSets.append(diceRolls); rerolls += 1
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
838 for diceRolls in rollSets:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
839 if result[0] < diceRolls[0]: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
840 else: result = diceRolls
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
841 myStr += '['
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
842 if len(diceRolls) > 1:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
843 myStr += '<font color=red>'+str(diceRolls[0])+'</font>, '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
844 for x in xrange(1, len(diceRolls)-1): myStr += str(diceRolls[x])+', '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
845 myStr += '<font color=blue>'+str(diceRolls[len(diceRolls)-1])+'</font>] '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
846 else: myStr += '<font color=red>'+str(diceRolls[0])+'</font>] '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
847 myStr += 'Result: <font color=red>'+str(result[0])+'</font> '
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
848 return [myStr, result]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
849
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
850 def roll(self, dice, facets):
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
851 rolls = []
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
852 for x in range(0, dice): rolls.append(int(random.uniform(1, facets+1)))
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
853 return rolls
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
854
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
855 def stdDie_Class(self, s): ## Not used
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
856 num_sides = s.split('d')
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
857 if len(num_sides) > 1:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
858 num = num_sides[0]; sides = num_sides[1]
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
859 if sides.strip().upper() == 'F': sides = "'f'"
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
860 try:
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
861 if int(num) > 100 or int(sides) > 10000: return None
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
862 except: pass
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
863 ret = ['(q', num.strip(), "**die_rollers['std'](", sides.strip(), '))']
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
864 s = ''.join(ret)
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
865 return s
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
866
3bbfd84619c0 Traipse Beta 'OpenRPG' {101018-00}
sirebral
parents:
diff changeset
867 die_rollers.register(ironclaw)