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