Mercurial > traipse_dev
comparison orpg/dieroller/rollers/alternity.py @ 195:b633f4c64aae alpha
Traipse Alpha 'OpenRPG' {100219-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 (Patch-2)
New Features:
New Namespace method with two new syntaxes
Fixes:
Fix to Server GUI startup errors
Fix to Server GUI Rooms tab updating
Fix to Chat and Settings if non existant die roller is picked
Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated
Fix to Alias Lib's Export to Tree, Open, Save features
Fix to alias node, now works properly
Fix to Splitter node, minor GUI cleanup
author | sirebral |
---|---|
date | Sat, 24 Apr 2010 08:37:20 -0500 |
parents | 5c9a118476b2 |
children |
comparison
equal
deleted
inserted
replaced
182:4b2884f29a72 | 195:b633f4c64aae |
---|---|
22 # | 22 # |
23 # Traipse Release: | 23 # Traipse Release: |
24 # The changes made in the Traipe release are intended to create a more direct connection | 24 # The changes made in the Traipe release are intended to create a more direct connection |
25 # between the source and the intrepretor. IF, ELIF statements have been replaced with dictionaries, | 25 # between the source and the intrepretor. IF, ELIF statements have been replaced with dictionaries, |
26 # unused objects have been replace with re-usable objects, and the code has been condensed. | 26 # unused objects have been replace with re-usable objects, and the code has been condensed. |
27 | 27 # |
28 # SEG: JAN 24 2010 - v.1.4 O'Flux Release: | |
29 # Edits & Additions: fixed a few minor bugs; Damage roll & Display Issues. | |
30 # Added Secondary Damage Calculation and Display. Fix all errors. | |
31 # Added proper results for Critcal Successes with failure ==> final Result Ordinary Success | |
32 # Removed reduntent Method to make parent class true with all others working as child. | |
33 # Made all special output same colour codes font size. Cleaned out old commented lines. | |
34 # Tested for Traipse on Win 7 | |
35 # | |
36 # Skill Check Example: | |
37 # [1d20.sk(12,-2)] | |
38 # OUTPUT Example: | |
39 # => [6,-3] = (3) AMAZING Success | |
40 # | |
41 # Pistol, Laser; 0 step -- Attack Example: | |
42 # [1d20.at(12,0,(1d4+1,"w"),(1d6+1,"w"),(1d4,"m"))] | |
43 # OUTPUT Example: | |
44 # => [1,0] = (1) CRITICAL SUCCESS AMAZING HIT | |
45 # ===> Damage [4] = (4) mortal ======> Secondary Damage (2) stun / (2) wound | |
46 # | |
47 # Action Check Example: | |
48 # [1d20.ac(14,-1)] | |
49 # OUTPUT Example: | |
50 # => ACTION CHECK : [18,-3] = (15) Marginal failure | |
51 # -1 Step make up bonus next Action Check | |
52 # | |
53 # | |
28 | 54 |
29 import re | 55 import re |
30 | 56 |
31 from std import std | 57 from std import std |
32 from time import time, clock | 58 from time import time, clock |
33 from orpg.dieroller.base import di, die_base, die_rollers | 59 from orpg.dieroller.base import di, die_base, die_rollers |
60 | |
61 ##from orpg.tools.orpg_log import debug | |
62 | |
34 | 63 |
35 __version__ = "$Id: alternity.py,v 0.1 2003/01/02 12:00:00 cchriss Exp $" | 64 __version__ = "$Id: alternity.py,v 0.1 2003/01/02 12:00:00 cchriss Exp $" |
36 | 65 |
37 # Alternity stands for "Alternity system" 20 sided die plus mods | 66 # Alternity stands for "Alternity system" 20 sided die plus mods |
38 | 67 |
46 def sk(self,score,mod): | 75 def sk(self,score,mod): |
47 return sk(self,score,mod) | 76 return sk(self,score,mod) |
48 | 77 |
49 def at(self,score,mod,dmgo,dmgg,dmga): | 78 def at(self,score,mod,dmgo,dmgg,dmga): |
50 return at(self,score,mod,dmgo,dmgg,dmga) | 79 return at(self,score,mod,dmgo,dmgg,dmga) |
80 | |
81 def ac(self,score,mod): | |
82 return ac(self,score,mod) | |
51 | 83 |
52 die_rollers.register(alternity) | 84 die_rollers.register(alternity) |
53 | 85 |
54 class sk(std): | 86 class sk(std): |
55 def __init__(self,source=[],sc="10/5/2",mod=0): | 87 def __init__(self,source=[],sc="10/5/2",mod=0): |
58 self.score = int( m.group(0) ) | 90 self.score = int( m.group(0) ) |
59 self.mod = mod | 91 self.mod = mod |
60 | 92 |
61 def getMod(self,mod=0): | 93 def getMod(self,mod=0): |
62 m=0 | 94 m=0 |
63 mods = { -4: -di(12), -3: -di(8), -2: -di(6), -1: -di(4), 1: -di(4), | 95 mods = { -4: -di(12), -3: -di(8), -2: -di(6), -1: -di(4), 1: di(4), |
64 2: di(6), 3: di(8), 4: di(12), 5: di(20)} | 96 2: di(6), 3: di(8), 4: di(12), 5: di(20)} # SEG fix 1: di(4) # |
65 if mod in mods.keys(): m = mods[mod].value | 97 if mod in mods.keys(): m = mods[mod].value |
66 elif mod <= -5: m=-di(20).value | 98 elif mod <= -5: m=-di(20).value |
67 elif mod == 6: m=di(20).value + di(20).value | 99 elif mod == 6: m=di(20).value + di(20).value |
68 elif mod >= 7: m=di(20).value + di(20).value + di(20).value | 100 elif mod >= 7: m=di(20).value + di(20).value + di(20).value |
69 return m | 101 return m |
70 | 102 |
71 def getRolLStr(self): | 103 def getRolLStr(self): |
72 myStr = "[" + str(self.data[0]) | 104 myStr = "[" + str(self.data[0]) |
73 self.d20 = self.sum() | 105 self.d20 = self.sum() |
74 amod = self.getMod(self.mod) | 106 self.amod = self.getMod(self.mod) |
75 self.dieRoll = self.d20 + amod | 107 |
108 ## varN = "self.amod" | |
109 ## debug(varN) | |
110 ## debug(self.amod) ## seg added debug output | |
111 | |
112 self.dieRoll = self.d20 + self.amod | |
76 for a in self.data[1:]: | 113 for a in self.data[1:]: |
77 myStr += "," | 114 myStr += "," |
78 myStr += str(a) | 115 myStr += str(a) |
79 myStr += "," + str(amod) + "] = (" + str(self.dieRoll) + ")" | 116 myStr += "," + str(self.amod) + "] = (" + str(self.dieRoll) + ")" |
80 if ( self.d20 == 1 ): self.success = 'CS' | |
81 if ( self.dieRoll <= self.score / 4 ): self.success = 'A' | 117 if ( self.dieRoll <= self.score / 4 ): self.success = 'A' |
82 elif ( self.dieRoll <= self.score / 2 ): self.success = 'G' | 118 elif ( self.dieRoll <= self.score / 2 ): self.success = 'G' |
83 elif ( self.dieRoll <= self.score ): self.success = 'O' | 119 elif ( self.dieRoll <= self.score ): self.success = 'O' |
84 else: self.success = 'F' | 120 else: self.success = 'F' |
85 if ( self.d20 == 20 ): self.success = 'CF' | 121 if ( self.d20 == 20 ): self.success = 'CF' |
86 return myStr | 122 return myStr |
87 | 123 |
88 def __str__(self): | 124 def __str__(self): |
89 myStr = self.getRolLStr() | 125 myStr = self.getRolLStr() |
90 successes = {'CS': " <b><font color='#00aa00'>CRITICAL SUCCESS</font></b>", | 126 |
91 'CF': " <b><font color='#ff0000'>CRITICAL FAILURE</font></b>", | 127 ## varN = "myStr" |
92 'A': " <b>AMAZING Success</b>", | 128 ## debug(varN) |
93 'G': " <b>Good Success</b>", | 129 ## debug(myStr) ## seg added debug output |
94 'O': " <b>Ordinary Success</b>", | 130 |
95 'F': " <b>failure</b>"} | 131 successes = {'CS': " <b><font size=2 color='#8D38C9'>CRITICAL SUCCESS</font></b>", |
132 'CF': " <b><font size=2 color='#151B54'>CRITICAL FAILURE</font></b>", | |
133 'A': " <b><font size=2 color='#E42217'>AMAZING Success</font></b>", | |
134 'G': " <b><font size=2 color='#306EFF'>Good Success</font></b>", | |
135 'O': " <b><font size=2 color='#52D017'>Ordinary Success</font></b>", | |
136 'F': " <b><font size=2 color='#41627E'>failure</font></b>"} | |
137 | |
138 if ( self.d20 == 1 ): myStr += successes['CS'] # SEG Dec 19 2009 | |
96 myStr += successes[self.success] | 139 myStr += successes[self.success] |
140 if ( self.d20 == 1 ) and (self.success == 'F') : | |
141 myStr += " final result ==> " | |
142 myStr += successes['O'] # SEG JAN 23 2010 | |
97 return myStr | 143 return myStr |
98 | 144 |
99 class at(sk): | 145 class at(sk): |
100 ## Traipse Usage: The source I received had the damage rolls like this 1d6s, with the damage type a | 146 ## Traipse Usage: The source I received had the damage rolls like this 1d6s, with the damage type a |
101 ## letter that could be sliced from the roll. However, the roll is parsed before the letter can be | 147 ## letter that could be sliced from the roll. However, the roll is parsed before the letter can be |
102 ## sliced from it, and with the letter attached it created an error. | 148 ## sliced from it, and with the letter attached it created an error. |
103 ## | 149 ## |
104 ## The Traipse method puts the damage type and the damage roll into a Tuple, ie (1d6, 's'). | 150 ## The Traipse method puts the damage type and the damage roll into a Tuple, ie (1d6, 's'). |
105 ## When uing this method you must include single or double quoutes around the damage type or the | 151 ## When using this method you must include single or double quoutes around the damage type or the |
106 ## software will treat it as an object. | 152 ## software will treat it as an object. |
153 | |
107 def __init__(self,source=[],sc=10, mod=0, dmgo="(1d6, 's')",dmgg="(1d6, 'w')",dmga="(1d6, 'm')"): | 154 def __init__(self,source=[],sc=10, mod=0, dmgo="(1d6, 's')",dmgg="(1d6, 'w')",dmga="(1d6, 'm')"): |
108 sk.__init__(self,source,sc,mod) | 155 sk.__init__(self,source,sc,mod) |
109 self.dmgo = dmgo | 156 self.dmgo = dmgo |
110 self.dmgg = dmgg | 157 self.dmgg = dmgg |
111 self.dmga = dmga | 158 self.dmga = dmga |
112 | 159 |
113 def getdmg(self,dmgroll): | 160 def getdmg(self,dmgroll): |
114 astr = "===> Damage " | 161 astr = "<b>===></b> Damage " |
115 droll = str(dmgroll[0]) | 162 droll = str(dmgroll[0]) |
163 xyz = droll.split('(') | |
164 secD = (int(xyz[1][:-1])/2) ## SEG* Calculate Secondary Damage | |
165 | |
166 ## varN = "secD" | |
167 ## debug(varN) | |
168 ## debug(secD) ## seg added debug output | |
169 | |
116 dtype = dmgroll[1] | 170 dtype = dmgroll[1] |
117 astr += droll | 171 astr += droll |
118 if dtype=="s": astr += " stun" | 172 if dtype=="s": astr += " <b><font size=2 color='#52D017'>stun</font></b><BR>" |
119 elif dtype=="w": astr += " wound" | 173 elif dtype=="w": |
120 elif dtype=="m":astr += " mortal" | 174 astr += " <b><font size=2 color='#C11B17'>wound</font></b>"+" <b>======></b> Secondary Damage ("+str(secD) \ |
175 +") <b><font size=2 color='#52D017'>stun</font></b><BR>" # SEG* Display Secondary Damage | |
176 elif dtype=="m": | |
177 astr += " <b><font size=2 color='#FF0000'>mortal</font></b>"+" <b>======></b> Secondary Damage ("+str(secD) \ | |
178 +") <b><font size=2 color='#52D017'>stun</font></b>"+" <b>/</b> ("+str(secD)+") <b><font size=2 color='#C11B17'>wound</font></b><BR>" # SEG* Display Secondary Damage | |
121 return astr | 179 return astr |
122 | 180 |
123 def __str__(self): | 181 def __str__(self): |
124 myStr = self.getRolLStr() | 182 myStr = self.getRolLStr() |
125 successes = {'CS': " <b><font color='#00aa00'>CRITICAL SUCCESS</font></b>", | 183 |
126 'CF': " <b><font color='#ff0000'>CRITICAL FAILURE</font></b>", | 184 ## varN = "myStr" |
127 'A': " <b><font color='#00aa00'>AMAZING HIT</font></b> ", | 185 ## debug(varN) |
128 'G': " <b>Good HIT</b> ", | 186 ## debug(myStr) ## seg added debug output |
129 'O': " <b>Ordinary HIT</b> ", | 187 |
130 'F': " <b>miss</b>"} | 188 successes = {'CS': " <b><font size=2 color='#8D38C9'>CRITICAL SUCCESS</font></b>", |
189 'CF': " <b><font size=2 color='#151B54'>CRITICAL FAILURE</font></b>", | |
190 'A': " <b><font size=2 color='#E42217'>AMAZING HIT</font></b><BR> ", | |
191 'G': " <b><font size=2 color='#306EFF'>Good HIT</font></b><BR> ", | |
192 'O': " <b><font size=2 color='#52D017'>Ordinary HIT</font></b><BR> ", | |
193 'F': " <b><font size=2 color='#41627E'>miss</font></b>"} | |
194 if ( self.d20 == 1 ): | |
195 myStr += successes['CS'] # SEG Dec 19 2009 | |
196 | |
197 if ( self.d20 == 1 ) and (self.success == 'F') : | |
198 myStr += successes['F'] # SEG JAN 23 2010 | |
199 myStr += " final result ==> " | |
200 self.success = 'O' | |
201 | |
131 myStr += successes[self.success] | 202 myStr += successes[self.success] |
132 if self.success == 'A': myStr += self.getdmg(self.dmga) | 203 if self.success == 'A': myStr += self.getdmg(self.dmga) |
133 elif self.success == 'G': myStr += self.getdmg(self.dmgg) | 204 elif self.success == 'G': myStr += self.getdmg(self.dmgg) |
134 elif self.success == 'O': myStr += self.getdmg(self.dmgo) | 205 elif self.success == 'O': myStr += self.getdmg(self.dmgo) |
135 return myStr | 206 return myStr |
136 | 207 |
208 class ac(sk): | |
209 def __init__(self,source=[],sc=10,mod=0): | |
210 sk.__init__(self,source,sc,mod) | |
211 | |
212 def __str__(self): | |
213 myStr = self.getRolLStr() | |
214 | |
215 ## varN = "myStr" | |
216 ## debug(varN) | |
217 ## debug(myStr) ## seg added debug output | |
218 | |
219 myStr = " <b><font color='#E42217'>ACTION CHECK : </font></b>"+myStr | |
220 successes = {'CS': " <b><font size=2 color='#8D38C9'>CRITICAL SUCCESS</font></b>", | |
221 'CF': " <b><font size=2 color='#151B54'>CRITICAL FAILURE</font></b><BR> -2 Step make up bonus next Action Check", | |
222 'A': " <b><font size=2 color='#E42217'>AMAZING Success</font></b>", | |
223 'G': " <b><font size=2 color='#306EFF'>Good Success</font></b>", | |
224 'O': " <b><font size=2 color='#52D017'>Ordinary Success</font></b>", | |
225 'F': " <b><font size=2 color='#41627E'>Marginal failure</font></b>"} | |
226 if ( self.d20 == 1 ): myStr += successes['CS'] # SEG Dec 19 2009 | |
227 myStr += successes[self.success] | |
228 if ( self.d20 == 1 ) and (self.success == 'F') : | |
229 myStr += " final result ==> " | |
230 myStr += successes['O'] # SEG JAN 23 2010 | |
231 if ( self.d20 != 1 ) and (self.success == 'F') : | |
232 myStr += "<BR> -1 Step make up bonus next Action Check" | |
233 | |
234 return myStr | |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | |
248 |