Mercurial > traipse_dev
diff orpg/dieroller/srex.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/srex.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/dieroller/srex.py Thu Aug 20 03:00:39 2009 -0500 @@ -59,19 +59,24 @@ __version__ = "1.1" class srex(std): + def __init__(self,source=[]): std.__init__(self,source) + def vs(self,actualtarget=4,tnrange=3): #reports all tns around specified, max distance of range return srVs(self,actualtarget,(actualtarget-tnrange),(actualtarget+tnrange)) + def vswide(self,actualtarget=4,maxtarget=12): #wide simply means it reports TNs from 2 to a specified max. return srVs(self,actualtarget,2,maxtarget) + def open(self): #unchanged from standard shadowrun open. return srOpen(self) class srVs(std): + def __init__(self,source=[],actualtarget=4,mintn=2,maxtn=12): std.__init__(self, source) if actualtarget > 30: @@ -100,6 +105,7 @@ # made the dieroller generic enough to use any die type self.openended(self[0].sides) + def openended(self,num): if num <= 1: self @@ -116,6 +122,7 @@ return self.openended(num) #count successes, by looping through each die, and checking it against the currently set TN + def __sum__(self): s = 0 for r in self.data: @@ -126,6 +133,7 @@ #a modified sum, but this one takes a target argument, and is there because otherwise it is difficult to loop through #tns counting successes against each one without changing target, which is rather dangerous as the original TN could #easily be lost. + def xsum(self,curtarget): s = 0 for r in self.data: @@ -134,6 +142,7 @@ return s + def __str__(self): if len(self.data) > 0: myStr = "[" + str(self.data[0]) @@ -154,10 +163,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 @@ -171,6 +182,7 @@ else: return self.openended(num) + def __sum__(self): s = 0 for r in self.data: @@ -178,6 +190,7 @@ s = r return s + def __str__(self): if len(self.data) > 0: myStr = "[" + str(self.data[0])