166
|
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: wod.py
|
|
23 # Author: OpenRPG Dev Team
|
|
24 # Maintainer:
|
|
25 # Version:
|
|
26 # $Id: wod.py,v 1.14 2007/05/09 19:57:00 digitalxero Exp $
|
|
27 #
|
|
28 # Description: WOD die roller
|
|
29 #
|
|
30 # Targetthr is the Threshhold target
|
|
31 # for compatibility with Mage die rolls.
|
|
32 # Threshhold addition by robert t childers
|
|
33 from die import *
|
|
34
|
|
35 __version__ = "$Id: wod.py,v 1.14 2007/05/09 19:57:00 digitalxero Exp $"
|
|
36
|
|
37
|
|
38 class mythos(std):
|
|
39
|
|
40 def __init__(self,source=[],target=0,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 if target == 2: self.targets = [2, 4, 6, 8, 10, 12]
|
|
48 if target == 3: self.targets = [3, 6, 9, 12]
|
|
49 if target == 4: self.targets = [4, 8, 12]
|
|
50 if target == 5: self.targets = [6, 12]
|
|
51 return self
|
|
52
|
|
53
|
|
54 def thr(self,targetthr):
|
|
55 self.targetthr = targetthr
|
|
56 return self
|
|
57
|
|
58
|
|
59 def sum(self):
|
|
60 rolls = []
|
|
61 s = 0
|
|
62 s1 = self.targetthr
|
|
63 botch = 0
|
|
64 for a in self.data: rolls.extend(a.gethistory())
|
|
65 for r in rolls:
|
|
66 if r in self.targets or r == 12:
|
|
67 s += 1
|
|
68 if s1 >0:
|
|
69 s1 -= 1
|
|
70 s -= 1
|
|
71 else: botch = 1
|
|
72 elif r == 1: s -= 1
|
|
73 if botch == 1 and s < 0: s = 0
|
|
74 return s
|
|
75
|
|
76
|
|
77 def __str__(self):
|
|
78 if len(self.data) > 0:
|
|
79 myStr = "[" + str(self.data[0])
|
|
80 for a in self.data[1:]:
|
|
81 myStr += ","
|
|
82 myStr += str(a)
|
|
83 if self.sum() < 0: myStr += "] vs " +str(self.target)+" result of a botch"
|
|
84 elif self.sum() == 0: myStr += "] vs " +str(self.target)+" result of a failure"
|
|
85 else: myStr += "] vs " +str(self.target)+" result of (" + str(self.sum()) + ")"
|
|
86
|
|
87
|
|
88 return myStr
|