comparison orpg/dieroller/trinity.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children 449a8900f9ac
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 ## a vs die roller as used by WOD games
2 #!/usr/bin/env python
3 # Copyright (C) 2000-2001 The OpenRPG Project
4 #
5 # openrpg-dev@lists.sourceforge.net
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # --
21 #
22 # File: trinity.py
23 # Author: Jacob Matthew, Talisan Creations
24 # Maintainer:
25 # Version:
26 # $Id: trinity.py,v 1.2 2007/05/05 05:30:10 digitalxero Exp $
27 #
28 # Description: Aeon Trinity die roller
29 # Modified from the WoD dieroller "$Id: trinity.py,v 1.2 2007/05/05 05:30:10 digitalxero Exp $"
30 # Targetthr is the Threshhold target
31 # for compatibility with Mage die rolls.
32 # Threshhold addition by robert t childers
33 # Threshhold functionality removed, some tags remain in code.
34 from die import *
35
36 __version__ = "$Id: trinity.py,v 1.2 2007/05/05 05:30:10 digitalxero Exp $"
37
38
39 class trinity(std):
40 def __init__(self,source=[],target=7,targetthr=0):
41 std.__init__(self,source)
42 self.target = target
43 self.targetthr = targetthr
44
45 def vs(self,target):
46 self.target = target
47 return self
48
49 def thr(self,targetthr):
50 self.targetthr = targetthr
51 return self
52
53 def sum(self):
54 rolls = []
55 s = 0
56 b = 0
57 for a in self.data:
58 rolls.extend(a.gethistory())
59 for r in rolls:
60 if r >= self.target:
61 s += 1
62 elif r == 1:
63 b -= 1
64 if s == 0:
65 return b
66 else:
67 return s
68
69 def __str__(self):
70 if len(self.data) > 0:
71 myStr = "[" + str(self.data[0])
72 for a in self.data[1:]:
73 myStr += ","
74 myStr += str(a)
75 if self.sum() < 0:
76 myStr += "] result of a (" + str(self.sum()) + ") botch"
77 elif self.sum() == 0:
78 myStr += "] result of a failure"
79 else:
80 myStr += "] result of (" + str(self.sum()) + ") success"
81
82
83 return myStr