comparison orpg/dieroller/rollers/d20.py @ 195:b633f4c64aae alpha

Traipse Alpha 'OpenRPG' {100219-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Patch-2) New Features: New Namespace method with two new syntaxes Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup
author sirebral
date Sat, 24 Apr 2010 08:37:20 -0500
parents 5c9a118476b2
children 24769389a7ba
comparison
equal deleted inserted replaced
182:4b2884f29a72 195:b633f4c64aae
12 # 12 #
13 # File: d20.py 13 # File: d20.py
14 # Author: OpenRPG Dev Team 14 # Author: OpenRPG Dev Team
15 # Maintainer: 15 # Maintainer:
16 # Version: 16 # Version:
17 # $Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $ 17 # $Id: d20.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
18 # 18 #
19 # Description: d20 die roller 19 # Description: d20 die roller
20 __version__ = "$Id: d20.py,v 1.9 2006/11/04 21:24:19 digitalxero Exp $" 20 __version__ = "$Id: d20.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
21 21
22 # d20 stands for "d20 system" not 20 sided die :) 22 # d20 stands for "d20 system" not 20 sided die :)
23 23
24 from std import std 24 from std import std
25 from orpg.dieroller.base import * 25 from orpg.dieroller.base import *
27 class d20(std): 27 class d20(std):
28 name = "d20" 28 name = "d20"
29 29
30 def __init__(self,source=[]): 30 def __init__(self,source=[]):
31 std.__init__(self,source) 31 std.__init__(self,source)
32
33 # these methods return new die objects for specific options
34 32
35 def attack(self,AC,mod,critical): 33 def attack(self,AC,mod,critical):
36 return d20attack(self,AC,mod,critical) 34 return d20attack(self,AC,mod,critical)
37 35
38 def dc(self,DC,mod): 36 def dc(self,DC,mod):
54 myStr = "[" + str(self.data[0]) 52 myStr = "[" + str(self.data[0])
55 for a in self.data[1:]: 53 for a in self.data[1:]:
56 myStr += "," 54 myStr += ","
57 myStr += str(a) 55 myStr += str(a)
58 myStr += "] = (" + str(self.sum()) + ")" 56 myStr += "] = (" + str(self.sum()) + ")"
59
60 myStr += " vs DC " + str(self.DC) 57 myStr += " vs DC " + str(self.DC)
61 58 if self.is_success(): myStr += " Success!"
62 if self.is_success(): 59 else: myStr += " Failure!"
63 myStr += " Success!"
64 else:
65 myStr += " Failure!"
66
67 return myStr 60 return myStr
68 61
69 62
70 class d20attack(std): 63 class d20attack(std):
71 def __init__(self,source=[],AC=10,mod=0,critical=20): 64 def __init__(self,source=[],AC=10,mod=0,critical=20):
84 def critical_check(self): 77 def critical_check(self):
85 self.critical_result = 0 78 self.critical_result = 0
86 self.critical_roll = 0 79 self.critical_roll = 0
87 if self.data[0] >= self.critical and self.is_hit(): 80 if self.data[0] >= self.critical and self.is_hit():
88 self.critical_roll = die_base(20) + self.mod 81 self.critical_roll = die_base(20) + self.mod
89 if self.critical_roll.sum() >= self.AC: 82 if self.critical_roll.sum() >= self.AC: self.critical_result = 1
90 self.critical_result = 1
91 83
92 def is_critical(self): 84 def is_critical(self):
93 return self.critical_result 85 return self.critical_result
94 86
95 def is_hit(self): 87 def is_hit(self):
99 myStr = "[" + str(self.data[0]) 91 myStr = "[" + str(self.data[0])
100 for a in self.data[1:]: 92 for a in self.data[1:]:
101 myStr += "," 93 myStr += ","
102 myStr += str(a) 94 myStr += str(a)
103 myStr += "] = (" + str(self.sum()) + ")" 95 myStr += "] = (" + str(self.sum()) + ")"
96 myStr += " vs AC " + str(self.AC)
97 if self.is_critical(): myStr += " Critical"
98 if self.is_hit(): myStr += " Hit!"
99 else: myStr += " Miss!"
100 return myStr
104 101
105 myStr += " vs AC " + str(self.AC)
106
107 if self.is_critical():
108 myStr += " Critical"
109
110 if self.is_hit():
111 myStr += " Hit!"
112 else:
113 myStr += " Miss!"
114
115 return myStr