annotate orpg/dieroller/rollers/sr4.py @ 177:60dde67c4ed6 alpha

Traipse Alpha 'OpenRPG' {100114-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 (Keeping up with 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 Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; 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)]. 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 (Alpha!!) 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 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
author sirebral
date Thu, 14 Jan 2010 03:32:20 -0600
parents 5c9a118476b2
children
rev   line source
167
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
1 ## a vs die roller as used by WOD games
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
2 #!/usr/bin/env python
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
3 # Copyright (C) 2000-2001 The OpenRPG Project
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
4 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
5 # openrpg-dev@lists.sourceforge.net
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
6 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
7 # This program is free software; you can redistribute it and/or modify
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
8 # it under the terms of the GNU General Public License as published by
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
9 # the Free Software Foundation; either version 2 of the License, or
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
10 # (at your option) any later version.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
11 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
15 # GNU General Public License for more details.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
16 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
17 # You should have received a copy of the GNU General Public License
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
18 # along with this program; if not, write to the Free Software
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
20 # --
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
21 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
22 # File: sr4.py
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
23 # Author: Veggiesama, ripped straight from Michael Edwards (AKA akoman)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
24 # Maintainer:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
25 # Version: 1.1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
26 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
27 # 1.1: Now with glitch and critical glitch detection!
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
28 # 1.1: Cleaned up some of the output to make it simpler.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
29 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
30 # Description: Modified from the original Shadowrun dieroller by akoman,
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
31 # but altered to follow the new Shadowrun 4th Ed dice system.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
32 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
33 # SR4 VS
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
34 # Typing [Xd6.vs(Y)] will roll X dice, checking each die
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
35 # roll against the MIN_TARGET_NUMBER (default: 5). If it
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
36 # meets or beats it, it counts as a hit. If the total hits
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
37 # meet or beat the Y value (threshold), there's a success.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
38 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
39 # SR4 EDGE VS
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
40 # Identical to the above function, except it looks like
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
41 # [Xd6.edge(Y)] and follows the "Rule of Six". That rule
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
42 # states any roll of 6 is counted as a hit and rerolled
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
43 # with a potential to score more hits. The "Edge" bonus
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
44 # dice must be included into X.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
45 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
46 # SR4 INIT
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
47 # Typing [Xd6.init(Y)] will roll X dice, checking each
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
48 # die for a hit. All hits are added to Y (the init attrib
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
49 # of the player), to give an Init Score for the combat.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
50 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
51 # SR4 EDGE INIT
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
52 # Typing [Xd6.initedge(Y)] or [Xd6.edgeinit(Y)] will do
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
53 # as above, except adding the possibility of Edge dice.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
54 #
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
55 # Note about non-traditional uses:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
56 # - D6's are not required. This script will work with any
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
57 # die possible, and the "Rule of Six" will only trigger
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
58 # on the highest die roll possible. Not throughly tested.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
59 # - If you want to alter the minimum target number (ex.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
60 # score a hit on a 4, 5, or 6), scroll down and change
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
61 # the global value MIN_TARGET_NUMBER to your liking.
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
62
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
63 __version__ = "1.1"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
64
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
65 from std import std
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
66 from orpg.dieroller.base import *
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
67
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
68 MIN_TARGET_NUMBER = 5
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
69 GLITCH_NUMBER = 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
70
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
71 class sr4(std):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
72 name = "sr4"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
73
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
74 def __init__(self,source=[]):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
75 std.__init__(self,source)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
76 self.threshold = None
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
77 self.init_attrib = None
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
78
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
79 def vs(self,threshold=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
80 return sr4vs(self, threshold)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
81
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
82 def edge(self,threshold=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
83 return sr4vs(self, threshold, 1)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
84
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
85 def init(self,init_attrib=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
86 return sr4init(self, init_attrib)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
87
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
88 def initedge(self,init_attrib=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
89 return sr4init(self, init_attrib, 1)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
90 def edgeinit(self,init_attrib=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
91 return sr4init(self, init_attrib, 1)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
92
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
93 def countEdge(self,num):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
94 if num <= 1:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
95 self
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
96 done = 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
97 for i in range(len(self.data)):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
98 if (self.data[i].lastroll() >= num):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
99 # counts every rerolled 6 as a hit
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
100 self.hits += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
101 self.data[i].extraroll()
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
102 self.total += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
103 done = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
104 elif (self.data[i].lastroll() <= GLITCH_NUMBER):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
105 self.ones += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
106 self.total += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
107 if done:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
108 return self
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
109 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
110 return self.countEdge(num)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
111
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
112 def countHits(self,num):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
113 for i in range(len(self.data)):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
114 if (self.data[i].lastroll() >= MIN_TARGET_NUMBER):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
115 # (Rule of Six taken into account in countEdge(), not here)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
116 self.hits += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
117 elif (self.data[i].lastroll() <= GLITCH_NUMBER):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
118 self.ones += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
119 self.total += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
120
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
121 def __str__(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
122 if len(self.data) > 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
123 self.hits = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
124 self.ones = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
125 self.total = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
126 for i in range(len(self.data)):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
127 if (self.data[i].lastroll() >= MIN_TARGET_NUMBER):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
128 self.hits += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
129 elif (self.data[i].lastroll() <= GLITCH_NUMBER):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
130 self.ones += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
131 self.total += 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
132 firstpass = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
133 myStr = "["
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
134 for a in self.data[0:]:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
135 if firstpass != 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
136 myStr += ","
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
137 firstpass = 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
138 if a >= MIN_TARGET_NUMBER:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
139 myStr += "<B>" + str(a) + "</B>"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
140 elif a <= GLITCH_NUMBER:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
141 myStr += "<i>" + str(a) + "</i>"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
142 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
143 myStr += str(a)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
144 myStr += "] " + CheckIfGlitch(self.ones, self.hits, self.total)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
145 myStr += "Hits: (" + str(self.hits) + ")"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
146 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
147 myStr = "[] = (0)"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
148 return myStr
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
149
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
150 die_rollers.register(sr4)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
151
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
152 class sr4init(sr4):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
153 def __init__(self,source=[],init_attrib=1,edge=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
154 std.__init__(self,source)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
155 if init_attrib < 2:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
156 self.init_attrib = 2
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
157 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
158 self.init_attrib = init_attrib
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
159 self.dicesides = self[0].sides
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
160 self.hits = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
161 self.ones = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
162 self.total = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
163 if edge:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
164 self.countEdge(self.dicesides)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
165 self.countHits(self.dicesides)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
166
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
167 def __str__(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
168 if len(self.data) > 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
169 firstpass = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
170 myStr = "["
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
171 for a in self.data[0:]:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
172 if firstpass != 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
173 myStr += ","
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
174 firstpass = 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
175 if a >= MIN_TARGET_NUMBER:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
176 myStr += "<B>" + str(a) + "</B>"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
177 elif a <= GLITCH_NUMBER:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
178 myStr += "<i>" + str(a) + "</i>"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
179 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
180 myStr += str(a)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
181 myStr += "] " + CheckIfGlitch(self.ones, self.hits, self.total)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
182 init_score = str(self.init_attrib + self.hits)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
183 myStr += "InitScore: " + str(self.init_attrib) + "+"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
184 myStr += str(self.hits) + " = (" + init_score + ")"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
185 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
186 myStr = "[] = (0)"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
187 return myStr
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
188
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
189 class sr4vs(sr4):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
190 def __init__(self,source=[], threshold=1, edge=0):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
191 std.__init__(self, source)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
192 if threshold < 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
193 self.threshold = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
194 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
195 self.threshold = threshold
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
196 self.dicesides = self[0].sides
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
197 self.hits = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
198 self.ones = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
199 self.total = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
200 if edge:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
201 self.countEdge(self.dicesides)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
202 self.countHits(self.dicesides)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
203
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
204 def __str__(self):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
205 if len(self.data) > 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
206 firstpass = 0
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
207 myStr = "["
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
208 for a in self.data[0:]:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
209 if firstpass != 0:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
210 myStr += ","
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
211 firstpass = 1
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
212 if a >= MIN_TARGET_NUMBER:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
213 myStr += "<B>" + str(a) + "</B>"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
214 elif a <= GLITCH_NUMBER:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
215 myStr += "<i>" + str(a) + "</i>"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
216 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
217 myStr += str(a)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
218 #myStr += "] Threshold=" + str(self.threshold)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
219 myStr += "] vs " + str(self.threshold) + " "
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
220 myStr += CheckIfGlitch(self.ones, self.hits, self.total)
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
221 if self.hits >= self.threshold:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
222 myStr += "*SUCCESS* "
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
223 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
224 myStr += "*FAILURE* "
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
225 myStr += "Hits: (" + str(self.hits) + ")"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
226 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
227 myStr = "[] = (0)"
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
228 return myStr
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
229
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
230 def CheckIfGlitch(ones, hits, total_dice):
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
231 if (ones * 2) >= total_dice:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
232 if hits >= 1:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
233 return "*GLITCH* "
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
234 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
235 return "*CRITICAL GLITCH* "
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
236 else:
5c9a118476b2 Traipse Alpha 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
237 return ""