annotate orpg/dieroller/rollers/sr4.py @ 239:56c1f2729413 beta

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