comparison orpg/dieroller/hero.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children 449a8900f9ac
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 # (at your option) any later version.
2 #
3 # This program is distributed in the hope that it will be useful,
4 # but WITHOUT ANY WARRANTY; without even the implied warranty of
5 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 # GNU General Public License for more details.
7 #
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11 # --
12 #
13 # File: Hero.py
14 # Version:
15 # $Id: Hero.py,v .3 DJM & Heroman
16 #
17 # Description: Hero System die roller originally based on Posterboy's D20 Dieroller
18 #
19 # Changelog:
20 # v.3 by Heroman
21 # Added hl() to show hit location (+side), and hk() for Hit Location killing damage
22 # (No random stun multiplier)
23 # v.2 DJM
24 # Removed useless modifiers from the Normal damage roller
25 # Changed Combat Value roller and SKill roller so that positive numbers are bonuses,
26 # negative numbers are penalties
27 # Changed Killing damage roller to correct stun multiplier bug
28 # Handled new rounding issues
29 #
30 # v.1 original release DJM
31
32 from die import *
33 from time import time, clock
34 import random
35
36
37 __version__ = "$Id: hero.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $"
38
39 # Hero stands for "Hero system" not 20 sided die :)
40
41 class hero(std):
42 def __init__(self,source=[]):
43 std.__init__(self,source)
44
45 # these methods return new die objects for specific options
46
47 def k(self,mod):
48 return herok(self,mod)
49
50 def hl(self):
51 return herohl(self)
52
53 def hk(self):
54 return herohk(self)
55
56 def n(self):
57 return heron(self)
58
59 def cv(self,cv,mod):
60 return herocv(self,cv,mod)
61
62 def sk(self,sk,mod):
63 return herosk(self,sk,mod)
64
65 class herocv(std):
66 def __init__(self,source=[],cv=10,mod=0):
67 std.__init__(self,source)
68 self.cv = cv
69 self.mod = mod
70
71
72 def __str__(self):
73 myStr = "[" + str(self.data[0])
74 for a in self.data[1:]:
75 myStr += ","
76 myStr += str(a)
77 myStr += "] = (" + str(self.sum()) + ")"
78
79 myStr += " with a CV of " + str(self.cv)
80 myStr += " and a modifier of " + str(self.mod)
81 cvhit = 11 + self.cv - self.sum() + self.mod
82 myStr += " hits up to <b>DCV <font color='#ff0000'>" + str(cvhit) + "</font></b>"
83 return myStr
84
85 class herosk(std):
86 def __init__(self,source=[],sk=11,mod=0):
87 std.__init__(self,source)
88 self.sk = sk
89 self.mod = mod
90
91 def is_success(self):
92 return (((self.sum()-self.mod) <= self.sk))
93
94 def __str__(self):
95 myStr = "[" + str(self.data[0])
96 for a in self.data[1:]:
97 myStr += ","
98 myStr += str(a)
99 strAdd="] - "
100 swapmod=self.mod
101 if self.mod < 0:
102 strAdd= "] + "
103 swapmod= -self.mod
104 myStr += strAdd + str(swapmod)
105 modSum = self.sum()-self.mod
106 myStr += " = (" + str(modSum) + ")"
107 myStr += " vs " + str(self.sk)
108
109 if self.is_success():
110 myStr += " or less <font color='#ff0000'>Success!"
111 else:
112 myStr += " or less <font color='#ff0000'>Failure!"
113
114 Diff = self.sk - modSum
115 myStr += " by " + str(Diff) +" </font>"
116
117 return myStr
118
119 class herok(std):
120 def __init__(self,source=[],mod=0):
121 std.__init__(self,source)
122 self.mod = mod
123
124 def __str__(self):
125 myStr = "[" + str(self.data[0])
126 for a in self.data[1:]:
127 myStr += ","
128 myStr += str(a)
129 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>)"
130 stunx = random.randint(1,6)-1
131 if stunx <= 1:
132 stunx = 1
133 myStr += " <b>Body</b> and a stunx of (" + str(stunx)
134 stunx = stunx + self.mod
135 myStr += " + " + str(self.mod)
136 stunsum = round(self.sum()) * stunx
137 myStr += ") for a total of (<font color='#ff0000'><b>" + str(int(stunsum)) + "</b></font>) <b>Stun</b>"
138 return myStr
139
140 class herohl(std):
141 def __init__(self,source=[],mod=0):
142 std.__init__(self,source)
143 self.mod = mod
144
145 def __str__(self):
146 myStr = "[" + str(self.data[0])
147 side = random.randint(1,6)
148 sidestr = "Left "
149 if side >=4:
150 sidestr = "Right "
151 for a in self.data[1:]:
152 myStr += ","
153 myStr += str(a)
154 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>) "
155 location = int(round(self.sum()))
156 if location <= 5:
157 myStr += "Location: <B>Head</B>, StunX:<B>x5</B>, NStun:<B>x2</B>, Bodyx:<B>x2</B>"
158 elif location == 6:
159 myStr += "Location: <B>" + sidestr + "Hand</B>, StunX:<B>x1</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
160 elif location == 7:
161 myStr += "Location: <B>" + sidestr + "Arm</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
162 elif location == 8:
163 myStr += "Location: <B>" + sidestr + "Arm</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
164 elif location == 9:
165 myStr += "Location: <B>" + sidestr + "Shoulder</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
166 elif location == 10:
167 myStr += "Location: <B>Chest</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
168 elif location == 11:
169 myStr += "Location: <B>Chest</B>, StunX:<B>x3</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
170 elif location == 12:
171 myStr += "Location: <B>Stomach</B>, StunX:<B>x4</B>, NStun:<B>x1 1/2</B>, Bodyx:<B>x1</B>"
172 elif location == 13:
173 myStr += "Location: <B>Vitals</B>, StunX:<B>x4</B>, NStun:<B>x1 1/2</B>, Bodyx:<B>x2</B>"
174 elif location == 14:
175 myStr += "Location: <B>" + sidestr + "Thigh</B>, StunX:<B>x2</B>, NStun:<B>x1</B>, Bodyx:<B>x1</B>"
176 elif location == 15:
177 myStr += "Location: <B>" + sidestr + "Leg</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
178 elif location == 16:
179 myStr += "Location: <B>" + sidestr + "Leg</B>, StunX:<B>x2</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
180 elif location >= 17:
181 myStr += "Location: <B>" + sidestr + "Foot</B>, StunX:<B>x1</B>, NStun:<B>x1/2</B>, Bodyx:<B>x1/2</B>"
182 return myStr
183
184 class herohk(std):
185 def __init__(self,source=[],mod=0):
186 std.__init__(self,source)
187 self.mod = mod
188
189 def __str__(self):
190 myStr = "[" + str(self.data[0])
191 for a in self.data[1:]:
192 myStr += ","
193 myStr += str(a)
194 myStr += "] = (<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>)"
195 stunx = 1
196 myStr += " <b>Body</b> "
197 stunx = stunx + self.mod
198 stunsum = round(self.sum()) * stunx
199 myStr += " for a total of (<font color='#ff0000'><b>" + str(int(stunsum)) + "</b></font>) <b>Stun</b>"
200 return myStr
201
202 class heron(std):
203 def __init__(self,source=[],mod=0):
204 std.__init__(self,source)
205 self.bodtot=0
206
207 def __str__(self):
208 myStr = "[" + str(self.data[0])
209 if self.data[0] == 6:
210 self.bodtot=self.bodtot+2
211 else:
212 self.bodtot=self.bodtot+1
213 if self.data[0] <= 1:
214 self.bodtot=self.bodtot-1
215 for a in self.data[1:]:
216 myStr += ","
217 myStr += str(a)
218 if a == 6:
219 self.bodtot=self.bodtot+2
220 else:
221 self.bodtot=self.bodtot+1
222 if a <= 1:
223 self.bodtot=self.bodtot-1
224 myStr += "] = (<font color='#ff0000'><b>" + str(self.bodtot) + "</b></font>)"
225 myStr += " <b>Body</b> and "
226 myStr += "(<font color='#ff0000'><b>" + str(int(round(self.sum()))) + "</b></font>) <b>Stun</b>"
227 return myStr