Mercurial > traipse_dev
diff orpg/dieroller/shadowrun.py @ 71:449a8900f9ac ornery-dev
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
author | sirebral |
---|---|
date | Thu, 20 Aug 2009 03:00:39 -0500 |
parents | 4385a7d0efd1 |
children | bf799efe7a8a |
line wrap: on
line diff
--- a/orpg/dieroller/shadowrun.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/dieroller/shadowrun.py Thu Aug 20 03:00:39 2009 -0500 @@ -43,20 +43,24 @@ # the objective is to find the highest die total out of rolled dice. This is then generally # used as the target in a 'Success Test' (for which .vs functions) from die import * - + __version__ = "1.0" class shadowrun(std): + def __init__(self,source=[],target=2): std.__init__(self,source) + def vs(self,target): return srVs(self, target) + def open(self): return srOpen(self) class srVs(std): + def __init__(self,source=[], target=2): std.__init__(self, source) # In Shadowrun, not target number may be below 2. All defaults are set to two and any @@ -69,6 +73,7 @@ # made the dieroller generic enough to use any die type self.openended(self[0].sides) + def openended(self,num): if num <= 1: self @@ -82,6 +87,7 @@ else: return self.openended(num) + def __sum__(self): s = 0 for r in self.data: @@ -89,6 +95,7 @@ s += 1 return s + def __str__(self): if len(self.data) > 0: myStr = "[" + str(self.data[0]) @@ -102,10 +109,12 @@ return myStr class srOpen(std): + def __init__(self,source=[]): std.__init__(self,source) self.openended(self[0].sides) + def openended(self,num): if num <= 1: self @@ -119,6 +128,7 @@ else: return self.openended(num) + def __sum__(self): s = 0 for r in self.data: @@ -126,6 +136,7 @@ s = r return s + def __str__(self): if len(self.data) > 0: myStr = "[" + str(self.data[0])