Mercurial > traipse_dev
diff orpg/dieroller/sr4.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/sr4.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/dieroller/sr4.py Thu Aug 20 03:00:39 2009 -0500 @@ -68,25 +68,32 @@ GLITCH_NUMBER = 1 class sr4(std): + def __init__(self,source=[]): std.__init__(self,source) self.threshold = None self.init_attrib = None + def vs(self,threshold=0): return sr4vs(self, threshold) + def edge(self,threshold=0): return sr4vs(self, threshold, 1) + def init(self,init_attrib=0): return sr4init(self, init_attrib) + def initedge(self,init_attrib=0): return sr4init(self, init_attrib, 1) + def edgeinit(self,init_attrib=0): return sr4init(self, init_attrib, 1) + def countEdge(self,num): if num <= 1: self @@ -106,6 +113,7 @@ else: return self.countEdge(num) + def countHits(self,num): for i in range(len(self.data)): if (self.data[i].lastroll() >= MIN_TARGET_NUMBER): @@ -115,6 +123,7 @@ self.ones += 1 self.total += 1 + def __str__(self): if len(self.data) > 0: self.hits = 0 @@ -145,6 +154,7 @@ return myStr class sr4init(sr4): + def __init__(self,source=[],init_attrib=1,edge=0): std.__init__(self,source) if init_attrib < 2: @@ -159,6 +169,7 @@ self.countEdge(self.dicesides) self.countHits(self.dicesides) + def __str__(self): if len(self.data) > 0: firstpass = 0 @@ -182,6 +193,7 @@ return myStr class sr4vs(sr4): + def __init__(self,source=[], threshold=1, edge=0): std.__init__(self, source) if threshold < 0: @@ -196,6 +208,7 @@ self.countEdge(self.dicesides) self.countHits(self.dicesides) + def __str__(self): if len(self.data) > 0: firstpass = 0 @@ -222,6 +235,7 @@ myStr = "[] = (0)" return myStr + def CheckIfGlitch(ones, hits, total_dice): if (ones * 2) >= total_dice: if hits >= 1: