155
|
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
|
|
41 def __init__(self,source=[],target=7,targetthr=0):
|
|
42 std.__init__(self,source)
|
|
43 self.target = target
|
|
44 self.targetthr = targetthr
|
|
45
|
|
46
|
|
47 def vs(self,target):
|
|
48 self.target = target
|
|
49 return self
|
|
50
|
|
51
|
|
52 def thr(self,targetthr):
|
|
53 self.targetthr = targetthr
|
|
54 return self
|
|
55
|
|
56
|
|
57 def sum(self):
|
|
58 rolls = []
|
|
59 s = 0
|
|
60 b = 0
|
|
61 for a in self.data:
|
|
62 rolls.extend(a.gethistory())
|
|
63 for r in rolls:
|
|
64 if r >= self.target:
|
|
65 s += 1
|
|
66 elif r == 1:
|
|
67 b -= 1
|
|
68 if s == 0:
|
|
69 return b
|
|
70 else:
|
|
71 return s
|
|
72
|
|
73
|
|
74 def __str__(self):
|
|
75 if len(self.data) > 0:
|
|
76 myStr = "[" + str(self.data[0])
|
|
77 for a in self.data[1:]:
|
|
78 myStr += ","
|
|
79 myStr += str(a)
|
|
80 if self.sum() < 0:
|
|
81 myStr += "] result of a (" + str(self.sum()) + ") botch"
|
|
82 elif self.sum() == 0:
|
|
83 myStr += "] result of a failure"
|
|
84 else:
|
|
85 myStr += "] result of (" + str(self.sum()) + ") success"
|
|
86
|
|
87
|
|
88 return myStr
|