Mercurial > traipse_dev
diff orpg/dieroller/base.py @ 184:dcae32e219f1 beta
Traipse Beta 'OpenRPG' {100117-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 (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 (Beta!)
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
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
Modified ID's to prevent non updated clients from ruining the fix.
default_manifest.xml renamed to default_upmana.xml
author | sirebral |
---|---|
date | Sun, 17 Jan 2010 21:37:34 -0600 |
parents | 0d9b746b5751 |
children | 13054be69834 |
line wrap: on
line diff
--- a/orpg/dieroller/base.py Fri Jan 15 23:01:42 2010 -0600 +++ b/orpg/dieroller/base.py Sun Jan 17 21:37:34 2010 -0600 @@ -22,18 +22,16 @@ # Author: Andrew Bennett # Maintainer: # Version: -# $Id: die.py,v 1.13 2007/03/13 17:53:42 digitalxero Exp $ +# $Id: die.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ # # Description: This class is used to make working with dice easier # -__version__ = "$Id: die.py,v 1.13 2007/03/13 17:53:42 digitalxero Exp $" - +__version__ = "$Id: die.py,v Traipse 'Ornery-Orc' prof.ebral Exp Exp $" import random import UserList import copy -#import string class die_base(UserList.UserList): name = None @@ -42,11 +40,9 @@ if isinstance(source, (int, float, basestring)): s = [] s.append(di(source)) - else: - s = source + else: s = source UserList.UserList.__init__(self,s) - def sum(self): s = 0 for a in self.data: @@ -58,28 +54,19 @@ o = other elif hasattr(other,"sum"): o = other.sum() - else: - return None - + else: return None result = [] for die in self: - if die < o: - result.append(die) + if die < o: result.append(die) return self.__class__(result) def __rshift__(self,other): - - if type(other) == type(3) or type(other) == type(3.0): - o = other - elif hasattr(other,"sum"): - o = other.sum() - else: - return None - + if type(other) == type(3) or type(other) == type(3.0): o = other + elif hasattr(other,"sum"): o = other.sum() + else: return None result = [] for die in self: - if die > o: - result.append(die) + if die > o: result.append(die) return self.__class__(result) def __rlshift__(self,other): @@ -88,7 +75,6 @@ def __rrshift__(self,other): return self.__lshift__(other) - def __str__(self): if len(self.data) > 0: myStr = "[" + str(self.data[0]) @@ -96,68 +82,49 @@ myStr += "," myStr += str(a) myStr += "] = (" + str(self.sum()) + ")" - else: - myStr = "[] = (0)" + else: myStr = "[] = (0)" return myStr def __lt__(self,other): if type(other) == type(3) or type(other) == type(3.0): return (self.sum() < other) - elif hasattr(other,"sum"): - return (self.sum() < other.sum()) - else: - return UserList.UserList.__lt__(self,other) + elif hasattr(other,"sum"): return (self.sum() < other.sum()) + else: return UserList.UserList.__lt__(self,other) def __le__(self,other): if type(other) == type(3) or type(other) == type(3.0): return (self.sum() <= other) - elif hasattr(other,"sum"): - return (self.sum() <= other.sum()) - else: - return UserList.UserList.__le__(self,other) + elif hasattr(other,"sum"): return (self.sum() <= other.sum()) + else: return UserList.UserList.__le__(self,other) def __eq__(self,other): if type(other) == type(3) or type(other) == type(3.0): return (self.sum() == other) - elif hasattr(other,"sum"): - return (self.sum() == other.sum()) - else: - return UserList.UserList.__eq__(self,other) + elif hasattr(other,"sum"): return (self.sum() == other.sum()) + else: return UserList.UserList.__eq__(self,other) def __ne__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return (self.sum() != other) - elif hasattr(other,"sum"): - return (self.sum() != other.sum()) - else: - return UserList.UserList.__ne__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return (self.sum() != other) + elif hasattr(other,"sum"): return (self.sum() != other.sum()) + else: return UserList.UserList.__ne__(self,other) def __gt__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return (self.sum() > other) - elif hasattr(other,"sum"): - return (self.sum() > other.sum()) - else: - return UserList.UserList.__gt__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return (self.sum() > other) + elif hasattr(other,"sum"): return (self.sum() > other.sum()) + else: return UserList.UserList.__gt__(self,other) def __ge__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return (self.sum() >= other) - elif hasattr(other,"sum"): - return (self.sum() >= other.sum()) - else: - return UserList.UserList.__ge__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return (self.sum() >= other) + elif hasattr(other,"sum"): return (self.sum() >= other.sum()) + else: return UserList.UserList.__ge__(self,other) def __cmp__(self,other): # this function included for backwards compatibility # As of 2.1, lists implement the "rich comparison" # methods overloaded above. - if type(other) == type(3) or type(other) == type(3.0): - return cmp(self.sum(), other) - elif hasattr(other,"sum"): - return cmp(self.sum(), other.sum()) - else: - return UserList.UserList.__cmp__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return cmp(self.sum(), other) + elif hasattr(other,"sum"): return cmp(self.sum(), other.sum()) + else: return UserList.UserList.__cmp__(self,other) def __rcmp__(self,other): @@ -166,16 +133,9 @@ def __add__(self,other): mycopy = copy.deepcopy(self) if type(other) == type(3) or type(other) == type(3.0): - #if other < 0: - # return self.__sub__(-other) - #other = [di(other,other)] other = [static_di(other)] - #return self.sum() + other - - elif type(other) == type("test"): - return self + elif type(other) == type("test"): return self mycopy.extend(other) - #result = UserList.UserList.__add__(mycopy,other) return mycopy def __iadd__(self,other): @@ -197,17 +157,13 @@ mycopy = copy.deepcopy(self) if type(other) == type(3) or type(other) == type(3.0): neg_die = static_di(-other) - #neg_die.set_value(-other) other = [neg_die] - #return self.sum() - other - else: - other = -other + else: other = -other mycopy.extend(other) return mycopy def __rsub__(self,other): mycopy = -copy.deepcopy(self) - #print type(other) if type(other) == type(3) or type(other) == type(3.0): new_die = di(0) new_die.set_value(other) @@ -219,83 +175,56 @@ return self.__sub__(other) def __mul__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.sum() * other - elif hasattr(other,"sum"): - return other.sum() * self.sum() - else: - return UserList.UserList.__mul__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return self.sum() * other + elif hasattr(other,"sum"): return other.sum() * self.sum() + else: return UserList.UserList.__mul__(self,other) def __rmul__(self,other): return self.__mul__(other) def __div__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return float(self.sum()) / other - elif hasattr(other,"sum"): - return float(self.sum()) / other.sum() - else: - return UserList.UserList.__div__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return float(self.sum()) / other + elif hasattr(other,"sum"): return float(self.sum()) / other.sum() + else: return UserList.UserList.__div__(self,other) def __rdiv__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return other / float(self.sum()) - elif hasattr(other,"sum"): - return other.sum() / float(self.sum()) - else: - return UserList.UserList.__rdiv__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return other / float(self.sum()) + elif hasattr(other,"sum"): return other.sum() / float(self.sum()) + else: return UserList.UserList.__rdiv__(self,other) def __mod__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.sum()%other - elif hasattr(other,"sum"): - return self.sum() % other.sum() - else: - return UserList.UserList.__mod__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return self.sum()%other + elif hasattr(other,"sum"): return self.sum() % other.sum() + else: return UserList.UserList.__mod__(self,other) def __rmod__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return other % self.sum() - elif hasattr(other,"sum"): - return other.sum() % self.sum() - else: - return UserList.UserList.__rmod__(self,other) + if type(other) == type(3) or type(other) == type(3.0): return other % self.sum() + elif hasattr(other,"sum"): return other.sum() % self.sum() + else: return UserList.UserList.__rmod__(self,other) def __neg__(self): - for i in range(len(self.data)): - self.data[i] = -self.data[i] + for i in range(len(self.data)): self.data[i] = -self.data[i] return self def __pos__(self): - for i in range(len(self.data)): - self.data[i] = +self.data[i] + for i in range(len(self.data)): self.data[i] = +self.data[i] return self def __abs__(self): - for i in range(len(self.data)): - self.data[i] = abs(self.data[i]) + for i in range(len(self.data)): self.data[i] = abs(self.data[i]) return self - #return abs(self.sum()) def __pow__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.sum() ** other - elif hasattr(other,"sum"): - return self.sum() ** other.sum() - else: - return UserList.UserList.__pow__(self,other) - + if type(other) == type(3) or type(other) == type(3.0): return self.sum() ** other + elif hasattr(other,"sum"): return self.sum() ** other.sum() + else: return UserList.UserList.__pow__(self,other) def __rpow__(self,other): # We're overloading exponentiation of ints to create "other" number of dice - if other >= 1: result = self.__class__(self[0].sides) - for t in range(other-1): - result+=self.__class__(self[0].sides) - else: - result = None - + for t in range(other-1): result+=self.__class__(self[0].sides) + else: result = None return result ### di class to handle actual dice @@ -309,21 +238,17 @@ self.roll(min) def __str__(self): - if len(self.history) > 1: - return str(self.history) - else: - return str(self.value) + if len(self.history) > 1: return str(self.history) + else: return str(self.value) def __neg__(self): self.value = -self.value - for i in range(len(self.history)): - self.history[i] = -self.history[i] + for i in range(len(self.history)): self.history[i] = -self.history[i] return self def __pos__(self): self.value = +self.value - for i in range(len(self.history)): - self.history[i] = +self.history[i] + for i in range(len(self.history)): self.history[i] = +self.history[i] return self def __abs__(self): @@ -333,90 +258,60 @@ return self def __repr__(self): - if len(self.history) > 1: - return str(self.history) - else: - return str(self.value) + if len(self.history) > 1: return str(self.history) + else: return str(self.value) def __int__(self): return self.value def __lt__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.value < other - elif hasattr(other,"value"): - return self.value < other.value - else: - return self < other + if type(other) == type(3) or type(other) == type(3.0): return self.value < other + elif hasattr(other,"value"): return self.value < other.value + else: return self < other def __le__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.value <= other - elif hasattr(other,"value"): - return self.value <= other.value - else: - return self <= other + if type(other) == type(3) or type(other) == type(3.0): return self.value <= other + elif hasattr(other,"value"): return self.value <= other.value + else: return self <= other def __eq__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.value == other - elif hasattr(other,"value"): - return self.value == other.value - else: - return self == other + if type(other) == type(3) or type(other) == type(3.0): return self.value == other + elif hasattr(other,"value"): return self.value == other.value + else: return self == other def __ne__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.value != other - elif hasattr(other,"value"): - return self.value != other.value - else: - return self != other + if type(other) == type(3) or type(other) == type(3.0): return self.value != other + elif hasattr(other,"value"): return self.value != other.value + else: return self != other def __gt__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.value > other - elif hasattr(other,"value"): - return self.value > other.value - else: - return self > other + if type(other) == type(3) or type(other) == type(3.0): return self.value > other + elif hasattr(other,"value"): return self.value > other.value + else: return self > other def __ge__(self,other): - if type(other) == type(3) or type(other) == type(3.0): - return self.value >= other - elif hasattr(other,"value"): - return self.value >= other.value - else: - return self >= other + if type(other) == type(3) or type(other) == type(3.0): return self.value >= other + elif hasattr(other,"value"): return self.value >= other.value + else: return self >= other def __cmp__(self,other): # this function included for backwards compatibility # As of 2.1, lists implement the "rich comparison" # methods overloaded above. - if type(other) == type(3) or type(other) == type(3.0): - return cmp(self.value, other) - elif hasattr(other,"value"): - return cmp(self.value, other.value) - else: - return cmp(self,other) + if type(other) == type(3) or type(other) == type(3.0): return cmp(self.value, other) + elif hasattr(other,"value"): return cmp(self.value, other.value) + else: return cmp(self,other) def roll(self,min=1): - if isinstance(self.sides, basestring) and self.sides.lower() == 'f': - self.value = random.randint(-1, 1) - else: - #self.value = random.randint(min, self.sides) - self.value = int(random.uniform(min, self.sides+1)) + if isinstance(self.sides, basestring) and self.sides.lower() == 'f': self.value = random.randint(-1, 1) + else: self.value = int(random.uniform(min, self.sides+1)) self.history = [] self.history.append(self.value) def extraroll(self): - if isinstance(self.sides, basestring) and self.sides.lower() == 'f': - result = random.randint(-1, 1) - else: - #result = random.randint(1, self.sides) - result = int(random.uniform(1,self.sides+1)) - + if isinstance(self.sides, basestring) and self.sides.lower() == 'f': result = random.randint(-1, 1) + else: result = int(random.uniform(1,self.sides+1)) self.value += result self.history.append(result) @@ -444,8 +339,7 @@ _rollers = {} def __new__(cls): it = cls.__dict__.get("__it__") - if it is not None: - return it + if it is not None: return it cls.__it__ = it = object.__new__(cls) return it