comparison orpg/dieroller/rollers/sr4.py @ 28:ff154cf3350c ornery-orc

Traipse 'OpenRPG' {100203-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 (Stable) New Features: New Bookmarks Feature New 'boot' command to remote admin New confirmation window for sent nodes Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG New Zoom Mouse plugin added New Images added to Plugin UI Switching to Element Tree New Map efficiency, from FlexiRPG New Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) New Portable Mercurial New Tip of the Day, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added New Dieroller structure from Core New DieRoller portability for odd Dice New 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added New vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) New Grids act more like Spreadsheets in Use mode, with Auto Calc Fixes: Fix to allow for portability to an OpenSUSE linux OS Fix to mplay_client for Fedora and OpenSUSE 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 Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Fix to whiteboard ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Wed, 03 Feb 2010 22:16:49 -0600
parents
children
comparison
equal deleted inserted replaced
27:51428d30c59e 28:ff154cf3350c
1 ## a vs die roller as used by WOD games
2 #!/usr/bin/env python
3 # Copyright (C) 2000-2001 The OpenRPG Project
4 #
5 # openrpg-dev@lists.sourceforge.net
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # --
21 #
22 # File: sr4.py
23 # Author: Veggiesama, ripped straight from Michael Edwards (AKA akoman)
24 # Maintainer:
25 # Version: 1.1
26 #
27 # 1.1: Now with glitch and critical glitch detection!
28 # 1.1: Cleaned up some of the output to make it simpler.
29 #
30 # Description: Modified from the original Shadowrun dieroller by akoman,
31 # but altered to follow the new Shadowrun 4th Ed dice system.
32 #
33 # SR4 VS
34 # Typing [Xd6.vs(Y)] will roll X dice, checking each die
35 # roll against the MIN_TARGET_NUMBER (default: 5). If it
36 # meets or beats it, it counts as a hit. If the total hits
37 # meet or beat the Y value (threshold), there's a success.
38 #
39 # SR4 EDGE VS
40 # Identical to the above function, except it looks like
41 # [Xd6.edge(Y)] and follows the "Rule of Six". That rule
42 # states any roll of 6 is counted as a hit and rerolled
43 # with a potential to score more hits. The "Edge" bonus
44 # dice must be included into X.
45 #
46 # SR4 INIT
47 # Typing [Xd6.init(Y)] will roll X dice, checking each
48 # die for a hit. All hits are added to Y (the init attrib
49 # of the player), to give an Init Score for the combat.
50 #
51 # SR4 EDGE INIT
52 # Typing [Xd6.initedge(Y)] or [Xd6.edgeinit(Y)] will do
53 # as above, except adding the possibility of Edge dice.
54 #
55 # Note about non-traditional uses:
56 # - D6's are not required. This script will work with any
57 # die possible, and the "Rule of Six" will only trigger
58 # on the highest die roll possible. Not throughly tested.
59 # - If you want to alter the minimum target number (ex.
60 # score a hit on a 4, 5, or 6), scroll down and change
61 # the global value MIN_TARGET_NUMBER to your liking.
62
63 __version__ = "1.1"
64
65 from std import std
66 from orpg.dieroller.base import *
67
68 MIN_TARGET_NUMBER = 5
69 GLITCH_NUMBER = 1
70
71 class sr4(std):
72 name = "sr4"
73
74 def __init__(self,source=[]):
75 std.__init__(self,source)
76 self.threshold = None
77 self.init_attrib = None
78
79 def vs(self,threshold=0):
80 return sr4vs(self, threshold)
81
82 def edge(self,threshold=0):
83 return sr4vs(self, threshold, 1)
84
85 def init(self,init_attrib=0):
86 return sr4init(self, init_attrib)
87
88 def initedge(self,init_attrib=0):
89 return sr4init(self, init_attrib, 1)
90 def edgeinit(self,init_attrib=0):
91 return sr4init(self, init_attrib, 1)
92
93 def countEdge(self,num):
94 if num <= 1:
95 self
96 done = 1
97 for i in range(len(self.data)):
98 if (self.data[i].lastroll() >= num):
99 # counts every rerolled 6 as a hit
100 self.hits += 1
101 self.data[i].extraroll()
102 self.total += 1
103 done = 0
104 elif (self.data[i].lastroll() <= GLITCH_NUMBER):
105 self.ones += 1
106 self.total += 1
107 if done:
108 return self
109 else:
110 return self.countEdge(num)
111
112 def countHits(self,num):
113 for i in range(len(self.data)):
114 if (self.data[i].lastroll() >= MIN_TARGET_NUMBER):
115 # (Rule of Six taken into account in countEdge(), not here)
116 self.hits += 1
117 elif (self.data[i].lastroll() <= GLITCH_NUMBER):
118 self.ones += 1
119 self.total += 1
120
121 def __str__(self):
122 if len(self.data) > 0:
123 self.hits = 0
124 self.ones = 0
125 self.total = 0
126 for i in range(len(self.data)):
127 if (self.data[i].lastroll() >= MIN_TARGET_NUMBER):
128 self.hits += 1
129 elif (self.data[i].lastroll() <= GLITCH_NUMBER):
130 self.ones += 1
131 self.total += 1
132 firstpass = 0
133 myStr = "["
134 for a in self.data[0:]:
135 if firstpass != 0:
136 myStr += ","
137 firstpass = 1
138 if a >= MIN_TARGET_NUMBER:
139 myStr += "<B>" + str(a) + "</B>"
140 elif a <= GLITCH_NUMBER:
141 myStr += "<i>" + str(a) + "</i>"
142 else:
143 myStr += str(a)
144 myStr += "] " + CheckIfGlitch(self.ones, self.hits, self.total)
145 myStr += "Hits: (" + str(self.hits) + ")"
146 else:
147 myStr = "[] = (0)"
148 return myStr
149
150 die_rollers.register(sr4)
151
152 class sr4init(sr4):
153 def __init__(self,source=[],init_attrib=1,edge=0):
154 std.__init__(self,source)
155 if init_attrib < 2:
156 self.init_attrib = 2
157 else:
158 self.init_attrib = init_attrib
159 self.dicesides = self[0].sides
160 self.hits = 0
161 self.ones = 0
162 self.total = 0
163 if edge:
164 self.countEdge(self.dicesides)
165 self.countHits(self.dicesides)
166
167 def __str__(self):
168 if len(self.data) > 0:
169 firstpass = 0
170 myStr = "["
171 for a in self.data[0:]:
172 if firstpass != 0:
173 myStr += ","
174 firstpass = 1
175 if a >= MIN_TARGET_NUMBER:
176 myStr += "<B>" + str(a) + "</B>"
177 elif a <= GLITCH_NUMBER:
178 myStr += "<i>" + str(a) + "</i>"
179 else:
180 myStr += str(a)
181 myStr += "] " + CheckIfGlitch(self.ones, self.hits, self.total)
182 init_score = str(self.init_attrib + self.hits)
183 myStr += "InitScore: " + str(self.init_attrib) + "+"
184 myStr += str(self.hits) + " = (" + init_score + ")"
185 else:
186 myStr = "[] = (0)"
187 return myStr
188
189 class sr4vs(sr4):
190 def __init__(self,source=[], threshold=1, edge=0):
191 std.__init__(self, source)
192 if threshold < 0:
193 self.threshold = 0
194 else:
195 self.threshold = threshold
196 self.dicesides = self[0].sides
197 self.hits = 0
198 self.ones = 0
199 self.total = 0
200 if edge:
201 self.countEdge(self.dicesides)
202 self.countHits(self.dicesides)
203
204 def __str__(self):
205 if len(self.data) > 0:
206 firstpass = 0
207 myStr = "["
208 for a in self.data[0:]:
209 if firstpass != 0:
210 myStr += ","
211 firstpass = 1
212 if a >= MIN_TARGET_NUMBER:
213 myStr += "<B>" + str(a) + "</B>"
214 elif a <= GLITCH_NUMBER:
215 myStr += "<i>" + str(a) + "</i>"
216 else:
217 myStr += str(a)
218 #myStr += "] Threshold=" + str(self.threshold)
219 myStr += "] vs " + str(self.threshold) + " "
220 myStr += CheckIfGlitch(self.ones, self.hits, self.total)
221 if self.hits >= self.threshold:
222 myStr += "*SUCCESS* "
223 else:
224 myStr += "*FAILURE* "
225 myStr += "Hits: (" + str(self.hits) + ")"
226 else:
227 myStr = "[] = (0)"
228 return myStr
229
230 def CheckIfGlitch(ones, hits, total_dice):
231 if (ones * 2) >= total_dice:
232 if hits >= 1:
233 return "*GLITCH* "
234 else:
235 return "*CRITICAL GLITCH* "
236 else:
237 return ""