comparison orpg/dieroller/rollers/hackmaster.py @ 171:ff48c2741fe7 beta

Traipse Beta 'OpenRPG' {091210-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Added 7th Sea die roller method; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Includes support for Mythos roller. Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and no reactive settings when Ok is pressed.
author sirebral
date Thu, 10 Dec 2009 22:30:40 -0600
parents
children dcae32e219f1
comparison
equal deleted inserted replaced
165:e4a803df4c88 171:ff48c2741fe7
1 #!/usr/bin/env python
2 # Copyright Not Yet, see how much I trust you
3 #
4 # openrpg-dev@lists.sourceforge.net
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: hackmaster.py
22 # Author: Ric Soard
23 # Maintainer:
24 # Version:
25 # $Id: hackmaster.py,v 0.4 2003/08/12
26 #
27 # Description: special die roller for HackMaster(C)(TM) RPG
28 # has penetration damage - .damage(bonus,honor)
29 # has attack - .attack(bonus, honor)
30 # has severity .severity(honor)
31 # has help - .help()
32 #
33 #
34
35 __version__ = "$Id: hackmaster.py,v 1.8 2006/11/15 12:11:22 digitalxero Exp $"
36
37 import random
38 from std import std
39 from orpg.dieroller.base import *
40
41 #hackmaster Class basically passes into functional classes
42 class hackmaster(std):
43 name = "hackmaster"
44
45 def __init__(self,source=[]):
46 std.__init__(self,source)
47
48 def damage(self, mod, hon):
49 return HMdamage(self, mod, hon)
50
51 def attack(self, mod, hon):
52 return HMattack(self, mod, hon)
53
54 def help(self):
55 return HMhelp(self)
56
57 def severity(self, honor):
58 return HMSeverity(self, honor)
59
60 die_rollers.register(hackmaster)
61
62 # HM Damage roller - rolles penetration as per the PHB - re-rolles on max die - 1, adds honor to the penetration rolls
63 # and this appears to be invisible to the user ( if a 4 on a d4 is rolled a 3 will appear and be followed by another
64 # die. if High honor then a 4 will appear followed by a another die.
65 class HMdamage(std):
66 def __init__(self,source=[], mod = 0, hon = 0):
67 std.__init__(self,source)
68 self.mod = mod
69 self.hon = hon
70 self.check_pen()
71 #here we roll the mod die
72 self.append(static_di(self.mod))
73 #here we roll the honor die
74 self.append(static_di(self.hon))
75
76 def damage(mod = 0, hon = 0):
77 self.mod = mod
78 self.hon = hon
79
80 # This function is called by default to display the die string to the chat window.
81 # Our die string attempts to explain the results
82 def __str__(self):
83 myStr = "Damage "
84 myStr += "[Damage Roll, Modifiers, Honor]: " + " [" + str(self.data[0])
85 for a in self.data[1:]:
86 myStr += ","
87 myStr += str(a)
88 myStr += "] = (" + str(self.sum()) + ")"
89
90 return myStr
91
92 # This function checks to see if we need to reroll for penetration
93 def check_pen(self):
94 for i in range(len(self.data)):
95 if self.data[i].lastroll() >= self.data[i].sides:
96 self.pen_roll(i)
97
98 #this function rolls the penetration die, and checks to see if it needs to be re-rolled again.
99 def pen_roll(self,num):
100 result = int(random.uniform(1,self.data[num].sides+1))
101 self.data[num].value += (result - 1 + self.hon)
102 self.data[num].history.append(result - 1 + self.hon)
103 if result >= self.data[num].sides:
104 self.pen_roll(num)
105
106 # this function rolls for the HM Attack. the function checks for a 20 and displays critical, and a 1
107 # and displays fumble
108 class HMattack(std):
109 def __init__(self, source=[], mod = 0, base_severity = 0, hon = 0, size = 0):
110 std.__init__(self,source)
111 self.size = size
112 self.mod = mod
113 self.base_severity = base_severity
114 self.hon = hon
115 self.fumble = 0
116 self.crit = 0
117 self.check_crit()
118 #this is a static die that adds the modifier
119 self.append(static_di(self.mod))
120 #this is a static die that adds honor, we want high rolls so it's +1
121 self.append(static_di(self.hon))
122
123
124 def check_crit(self):
125 if self.data[0] == self.data[0].sides:
126 self.crit = 1
127 if self.data[0] == 1:
128 self.fumble = 1
129
130
131 #this function is the out put to the chat window, it basicaly just displays the roll unless
132 #it's a natural 20, or a natural 1
133 def __str__(self):
134 if self.crit > 0:
135 myStr = "Critical Hit!!: "
136 elif self.fumble > 0:
137 myStr = "FUMBLE!!"
138 else:
139 myStr = "To Hit:"
140 myStr += "[To Hit Roll, Modifiers, Honor]" + " [" + str(self.data[0])
141 for a in self.data[1:]:
142 myStr += ","
143 myStr += str(a)
144 myStr += "] = (" + str(self.sum()) + ")"
145 return myStr
146
147 class HMhelp(std):
148 def __init__(self,source=[]):
149 std.__init__(self,source)
150 self.source = source
151
152 def __str__(self):
153 myStr = " <br /> .attack(Bonus, Honor): <br />"
154 myStr += " The attack roll rolles the dice and adds your bonus <br />"
155 myStr += " and honor modifier and returns you final roll. <br />"
156 myStr += " On a natural 20 the dieroller displays Critical Hit!! <br />"
157 myStr += " On a natural 1 the dieroller displays FUMBLE!! <br />"
158 myStr += " Example A 1st level fighter with +1 to hit and a +2 sword and High Honor <br />"
159 myStr += " would roll [1d20.attack(3,1)] <br />"
160 myStr += " .damage(Bonus, Honor): <br />"
161 myStr += " The damage roll rolls the dice and rerolls on a max roll for <br />"
162 myStr += " penetration damage, the penetration die is -1 and is rerolled on a max roll <br />"
163 myStr += " The roller returns the damage dice, monidifiers, and honor <br />"
164 myStr += " Example A magic-user uses a quaterstaff +1 with high honor, he would roll <br />"
165 myStr += " [1d6.damage(1,1)] <br />"
166 myStr += " .severity(honor): <br />"
167 myStr += " the severity is for critical hit resolution - the character rolls <br />"
168 myStr += " a d8 and adds honor bonus. the die is rerolled on natural 8 and natural 1 with a -1 modifier <br />"
169 myStr += " on an 8 the reroll is added on a 1 the reroll is subtracted <br />"
170 myStr += " Example [1d8.severity(1)] <br />"
171 myStr += " .help() : <br />"
172 myStr += " displays this message <br />"
173
174 return myStr
175
176 # the severity roll is for critical resolution. The die is rerolled and added
177 #on a natural 8 and rerolled and subtracted on a 1
178 class HMSeverity(std):
179 def __init__(self, source =[], honor=0):
180 std.__init__(self,source)
181 self.source = source
182 self.hon = honor
183 self.data = []
184 self.append(di(8))
185 self.CheckReroll()
186 self.append(static_di(self.hon))
187
188
189 def __str__(self):
190 myStr = "[Severity Dice, Honor]" + " [" + str(self.data[0])
191 for a in self.data[1:]:
192 myStr += ","
193 myStr += str(a)
194 myStr += "] = (" + str(self.sum()) + ")"
195 return myStr
196
197 def CheckReroll(self):
198 if self.data[0] == self.data[0].sides:
199 self.crit_chain(0,1)
200 if self.data[0] == 1:
201 self.crit_chain(0,-1)
202
203 #this function needes moved for severity
204 def crit_chain(self,num,neg):
205 result = int(random.uniform(1,self.data[num].sides+1))
206 self.data[num].value += (((result - 1) * neg) + self.hon)
207 self.data[num].history.append(((result - 1) * neg) + self.hon)
208 if result >= self.data[num].sides:
209 self.crit_chain(num,1)
210 if result == 1:
211 self.crit_chain(num,-1)