Mercurial > traipse_dev
comparison orpg/dieroller/die.py @ 163:565ab3d84430 alpha
Traipse Alpha 'OpenRPG' {091202-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 Gametree Recursion method, mapping, context sensitivity, and
effeciency..
New Features node with bonus nodes and Node Referencing help added
Added 7th Sea die roller method; 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)].
Includes support for Mythos roller.
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 no reactive settings when Ok is
pressed.
author | sirebral |
---|---|
date | Wed, 02 Dec 2009 21:20:44 -0600 |
parents | bf799efe7a8a |
children |
comparison
equal
deleted
inserted
replaced
161:a766e1cbcb7c | 163:565ab3d84430 |
---|---|
35 import copy | 35 import copy |
36 #import string | 36 #import string |
37 | 37 |
38 class die_base(UserList.UserList): | 38 class die_base(UserList.UserList): |
39 | 39 |
40 | |
41 def __init__(self,source = []): | 40 def __init__(self,source = []): |
42 if isinstance(source, (int, float, basestring)): | 41 if isinstance(source, (int, float, basestring)): |
43 s = [] | 42 s = [] |
44 s.append(di(source)) | 43 s.append(di(source)) |
45 else: | 44 else: s = source |
46 s = source | |
47 UserList.UserList.__init__(self,s) | 45 UserList.UserList.__init__(self,s) |
48 | 46 |
49 | |
50 | |
51 def sum(self): | 47 def sum(self): |
52 s = 0 | 48 s = 0 |
53 for a in self.data: | 49 for a in self.data: |
54 s += int(a) | 50 s += int(a) |
55 return s | 51 return s |
56 | 52 |
57 | |
58 def __lshift__(self,other): | 53 def __lshift__(self,other): |
59 if type(other) == type(3) or type(other) == type(3.0): | 54 if type(other) == type(3) or type(other) == type(3.0): o = other |
60 o = other | 55 elif hasattr(other,"sum"): o = other.sum() |
61 elif hasattr(other,"sum"): | 56 else: return None |
62 o = other.sum() | |
63 else: | |
64 return None | |
65 | |
66 result = [] | 57 result = [] |
67 for die in self: | 58 for die in self: |
68 if die < o: | 59 if die < o: result.append(die) |
69 result.append(die) | |
70 return self.__class__(result) | 60 return self.__class__(result) |
71 | 61 |
72 | |
73 def __rshift__(self,other): | 62 def __rshift__(self,other): |
74 | 63 if type(other) == type(3) or type(other) == type(3.0): o = other |
75 if type(other) == type(3) or type(other) == type(3.0): | 64 elif hasattr(other,"sum"): o = other.sum() |
76 o = other | 65 else: return None |
77 elif hasattr(other,"sum"): | |
78 o = other.sum() | |
79 else: | |
80 return None | |
81 | |
82 result = [] | 66 result = [] |
83 for die in self: | 67 for die in self: |
84 if die > o: | 68 if die > o: result.append(die) |
85 result.append(die) | |
86 return self.__class__(result) | 69 return self.__class__(result) |
87 | 70 |
88 | |
89 def __rlshift__(self,other): | 71 def __rlshift__(self,other): |
90 return self.__rshift__(other) | 72 return self.__rshift__(other) |
91 | 73 |
92 | |
93 def __rrshift__(self,other): | 74 def __rrshift__(self,other): |
94 return self.__lshift__(other) | 75 return self.__lshift__(other) |
95 | 76 |
96 | |
97 | |
98 def __str__(self): | 77 def __str__(self): |
99 if len(self.data) > 0: | 78 if len(self.data) > 0: |
100 myStr = "[" + str(self.data[0]) | 79 myStr = "[" + str(self.data[0]) |
101 for a in self.data[1:]: | 80 for a in self.data[1:]: |
102 myStr += "," | 81 myStr += "," |
103 myStr += str(a) | 82 myStr += str(a) |
104 myStr += "] = (" + str(self.sum()) + ")" | 83 myStr += "] = (" + str(self.sum()) + ")" |
105 else: | 84 else: myStr = "[] = (0)" |
106 myStr = "[] = (0)" | |
107 return myStr | 85 return myStr |
108 | 86 |
109 | |
110 def __lt__(self,other): | 87 def __lt__(self,other): |
111 if type(other) == type(3) or type(other) == type(3.0): | 88 if type(other) == type(3) or type(other) == type(3.0): return (self.sum() < other) |
112 return (self.sum() < other) | 89 elif hasattr(other,"sum"): return (self.sum() < other.sum()) |
113 elif hasattr(other,"sum"): | 90 else: return UserList.UserList.__lt__(self,other) |
114 return (self.sum() < other.sum()) | 91 |
115 else: | |
116 return UserList.UserList.__lt__(self,other) | |
117 | |
118 | |
119 def __le__(self,other): | 92 def __le__(self,other): |
120 if type(other) == type(3) or type(other) == type(3.0): | 93 if type(other) == type(3) or type(other) == type(3.0): return (self.sum() <= other) |
121 return (self.sum() <= other) | 94 elif hasattr(other,"sum"): return (self.sum() <= other.sum()) |
122 elif hasattr(other,"sum"): | 95 else: return UserList.UserList.__le__(self,other) |
123 return (self.sum() <= other.sum()) | 96 |
124 else: | |
125 return UserList.UserList.__le__(self,other) | |
126 | |
127 | |
128 def __eq__(self,other): | 97 def __eq__(self,other): |
129 if type(other) == type(3) or type(other) == type(3.0): | 98 if type(other) == type(3) or type(other) == type(3.0): return (self.sum() == other) |
130 return (self.sum() == other) | 99 elif hasattr(other,"sum"): return (self.sum() == other.sum()) |
131 elif hasattr(other,"sum"): | 100 else: return UserList.UserList.__eq__(self,other) |
132 return (self.sum() == other.sum()) | 101 |
133 else: | |
134 return UserList.UserList.__eq__(self,other) | |
135 | |
136 | |
137 def __ne__(self,other): | 102 def __ne__(self,other): |
138 if type(other) == type(3) or type(other) == type(3.0): | 103 if type(other) == type(3) or type(other) == type(3.0): return (self.sum() != other) |
139 return (self.sum() != other) | 104 elif hasattr(other,"sum"):return (self.sum() != other.sum()) |
140 elif hasattr(other,"sum"): | 105 else: return UserList.UserList.__ne__(self,other) |
141 return (self.sum() != other.sum()) | 106 |
142 else: | |
143 return UserList.UserList.__ne__(self,other) | |
144 | |
145 | |
146 def __gt__(self,other): | 107 def __gt__(self,other): |
147 if type(other) == type(3) or type(other) == type(3.0): | 108 if type(other) == type(3) or type(other) == type(3.0): return (self.sum() > other) |
148 return (self.sum() > other) | 109 elif hasattr(other,"sum"): return (self.sum() > other.sum()) |
149 elif hasattr(other,"sum"): | 110 else: return UserList.UserList.__gt__(self,other) |
150 return (self.sum() > other.sum()) | 111 |
151 else: | |
152 return UserList.UserList.__gt__(self,other) | |
153 | |
154 | |
155 def __ge__(self,other): | 112 def __ge__(self,other): |
156 if type(other) == type(3) or type(other) == type(3.0): | 113 if type(other) == type(3) or type(other) == type(3.0): return (self.sum() >= other) |
157 return (self.sum() >= other) | 114 elif hasattr(other,"sum"): return (self.sum() >= other.sum()) |
158 elif hasattr(other,"sum"): | 115 else: return UserList.UserList.__ge__(self,other) |
159 return (self.sum() >= other.sum()) | 116 |
160 else: | |
161 return UserList.UserList.__ge__(self,other) | |
162 | |
163 | |
164 def __cmp__(self,other): | 117 def __cmp__(self,other): |
165 # this function included for backwards compatibility | 118 # this function included for backwards compatibility |
166 # As of 2.1, lists implement the "rich comparison" | 119 # As of 2.1, lists implement the "rich comparison" |
167 # methods overloaded above. | 120 # methods overloaded above. |
168 if type(other) == type(3) or type(other) == type(3.0): | 121 if type(other) == type(3) or type(other) == type(3.0): return cmp(self.sum(), other) |
169 return cmp(self.sum(), other) | 122 elif hasattr(other,"sum"): return cmp(self.sum(), other.sum()) |
170 elif hasattr(other,"sum"): | 123 else: return UserList.UserList.__cmp__(self,other) |
171 return cmp(self.sum(), other.sum()) | 124 |
172 else: | |
173 return UserList.UserList.__cmp__(self,other) | |
174 | |
175 | |
176 | |
177 def __rcmp__(self,other): | 125 def __rcmp__(self,other): |
178 return self.__cmp__(other) | 126 return self.__cmp__(other) |
179 | 127 |
180 | |
181 def __add__(self,other): | 128 def __add__(self,other): |
182 mycopy = copy.deepcopy(self) | 129 mycopy = copy.deepcopy(self) |
183 if type(other) == type(3) or type(other) == type(3.0): | 130 if type(other) == type(3) or type(other) == type(3.0): other = [static_di(other)] |
184 #if other < 0: | 131 elif type(other) == type("test"): return self |
185 # return self.__sub__(-other) | |
186 #other = [di(other,other)] | |
187 other = [static_di(other)] | |
188 #return self.sum() + other | |
189 | |
190 elif type(other) == type("test"): | |
191 return self | |
192 mycopy.extend(other) | 132 mycopy.extend(other) |
193 #result = UserList.UserList.__add__(mycopy,other) | |
194 return mycopy | 133 return mycopy |
195 | 134 |
196 | |
197 def __iadd__(self,other): | 135 def __iadd__(self,other): |
198 return self.__add__(other) | 136 return self.__add__(other) |
199 | 137 |
200 | |
201 def __radd__(self,other): | 138 def __radd__(self,other): |
202 mycopy = copy.deepcopy(self) | 139 mycopy = copy.deepcopy(self) |
203 if type(other) == type(3) or type(other) == type(3.0): | 140 if type(other) == type(3) or type(other) == type(3.0): |
204 new_die = di(0) | 141 new_die = di(0) |
205 new_die.set_value(other) | 142 new_die.set_value(other) |
206 other = new_die | 143 other = new_die |
207 mycopy.insert(0,other) | 144 mycopy.insert(0,other) |
208 return mycopy | 145 return mycopy |
209 | 146 |
210 | |
211 def __int__(self): | 147 def __int__(self): |
212 return self.sum() | 148 return self.sum() |
213 | 149 |
214 | |
215 def __sub__(self,other): | 150 def __sub__(self,other): |
216 mycopy = copy.deepcopy(self) | 151 mycopy = copy.deepcopy(self) |
217 if type(other) == type(3) or type(other) == type(3.0): | 152 if type(other) == type(3) or type(other) == type(3.0): |
218 neg_die = static_di(-other) | 153 neg_die = static_di(-other) |
219 #neg_die.set_value(-other) | |
220 other = [neg_die] | 154 other = [neg_die] |
221 #return self.sum() - other | 155 else: other = -other |
222 else: | |
223 other = -other | |
224 mycopy.extend(other) | 156 mycopy.extend(other) |
225 return mycopy | 157 return mycopy |
226 | 158 |
227 | |
228 def __rsub__(self,other): | 159 def __rsub__(self,other): |
229 mycopy = -copy.deepcopy(self) | 160 mycopy = -copy.deepcopy(self) |
230 #print type(other) | |
231 if type(other) == type(3) or type(other) == type(3.0): | 161 if type(other) == type(3) or type(other) == type(3.0): |
232 new_die = di(0) | 162 new_die = di(0) |
233 new_die.set_value(other) | 163 new_die.set_value(other) |
234 other = new_die | 164 other = new_die |
235 mycopy.insert(0,other) | 165 mycopy.insert(0,other) |
236 return mycopy | 166 return mycopy |
237 | 167 |
238 | |
239 def __isub__(self,other): | 168 def __isub__(self,other): |
240 return self.__sub__(other) | 169 return self.__sub__(other) |
241 | 170 |
242 | |
243 def __mul__(self,other): | 171 def __mul__(self,other): |
244 if type(other) == type(3) or type(other) == type(3.0): | 172 if type(other) == type(3) or type(other) == type(3.0): return self.sum() * other |
245 return self.sum() * other | 173 elif hasattr(other,"sum"): return other.sum() * self.sum() |
246 elif hasattr(other,"sum"): | 174 else: return UserList.UserList.__mul__(self,other) |
247 return other.sum() * self.sum() | |
248 else: | |
249 return UserList.UserList.__mul__(self,other) | |
250 | 175 |
251 | 176 |
252 def __rmul__(self,other): | 177 def __rmul__(self,other): |
253 return self.__mul__(other) | 178 return self.__mul__(other) |
254 | 179 |
255 | 180 |
256 def __div__(self,other): | 181 def __div__(self,other): |
257 if type(other) == type(3) or type(other) == type(3.0): | 182 if type(other) == type(3) or type(other) == type(3.0): return float(self.sum()) / other |
258 return float(self.sum()) / other | 183 elif hasattr(other,"sum"): return float(self.sum()) / other.sum() |
259 elif hasattr(other,"sum"): | 184 else: return UserList.UserList.__div__(self,other) |
260 return float(self.sum()) / other.sum() | |
261 else: | |
262 return UserList.UserList.__div__(self,other) | |
263 | 185 |
264 | 186 |
265 def __rdiv__(self,other): | 187 def __rdiv__(self,other): |
266 if type(other) == type(3) or type(other) == type(3.0): | 188 if type(other) == type(3) or type(other) == type(3.0): return other / float(self.sum()) |
267 return other / float(self.sum()) | 189 elif hasattr(other,"sum"): return other.sum() / float(self.sum()) |
268 elif hasattr(other,"sum"): | 190 else: return UserList.UserList.__rdiv__(self,other) |
269 return other.sum() / float(self.sum()) | |
270 else: | |
271 return UserList.UserList.__rdiv__(self,other) | |
272 | 191 |
273 | 192 |
274 def __mod__(self,other): | 193 def __mod__(self,other): |
275 if type(other) == type(3) or type(other) == type(3.0): | 194 if type(other) == type(3) or type(other) == type(3.0): |
276 return self.sum()%other | 195 return self.sum()%other |