Mercurial > traipse_dev
diff orpg/dieroller/trinity.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/trinity.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/dieroller/trinity.py Thu Aug 20 03:00:39 2009 -0500 @@ -37,47 +37,52 @@ class trinity(std): - def __init__(self,source=[],target=7,targetthr=0): - std.__init__(self,source) - self.target = target - self.targetthr = targetthr + + def __init__(self,source=[],target=7,targetthr=0): + std.__init__(self,source) + self.target = target + self.targetthr = targetthr - def vs(self,target): - self.target = target - return self + + def vs(self,target): + self.target = target + return self - def thr(self,targetthr): - self.targetthr = targetthr - return self + + def thr(self,targetthr): + self.targetthr = targetthr + return self - def sum(self): - rolls = [] - s = 0 - b = 0 - for a in self.data: - rolls.extend(a.gethistory()) - for r in rolls: - if r >= self.target: - s += 1 - elif r == 1: - b -= 1 - if s == 0: - return b - else: - return s + + def sum(self): + rolls = [] + s = 0 + b = 0 + for a in self.data: + rolls.extend(a.gethistory()) + for r in rolls: + if r >= self.target: + s += 1 + elif r == 1: + b -= 1 + if s == 0: + return b + else: + return s - def __str__(self): - if len(self.data) > 0: - myStr = "[" + str(self.data[0]) - for a in self.data[1:]: - myStr += "," - myStr += str(a) - if self.sum() < 0: - myStr += "] result of a (" + str(self.sum()) + ") botch" - elif self.sum() == 0: - myStr += "] result of a failure" - else: - myStr += "] result of (" + str(self.sum()) + ") success" + + def __str__(self): + if len(self.data) > 0: + myStr = "[" + str(self.data[0]) + for a in self.data[1:]: + myStr += "," + myStr += str(a) + if self.sum() < 0: + myStr += "] result of a (" + str(self.sum()) + ") botch" + elif self.sum() == 0: + myStr += "] result of a failure" + else: + myStr += "] result of (" + str(self.sum()) + ") success" - return myStr + return myStr