comparison orpg/dieroller/rollers/std.py @ 227:81d0bfd5e800 alpha

Traipse Alpha 'OpenRPG' {100612-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 (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 03:50:37 -0500
parents 5c9a118476b2
children
comparison
equal deleted inserted replaced
182:4b2884f29a72 227:81d0bfd5e800
1 from orpg.dieroller.base import die_base, die_rollers 1 from orpg.dieroller.base import die_base, die_rollers
2 2
3 class std(die_base): 3 class std(die_base):
4 name = "std" 4 name = "std"
5 5
6 def __init__(self,source=[]): 6 def __init__(self, source=[]):
7 die_base.__init__(self,source) 7 die_base.__init__(self, source)
8 8
9 # Examples of adding member functions through inheritance. 9 # Examples of adding member functions through inheritance.
10 10
11 def ascending(self): 11 def ascending(self):
12 result = self[:] 12 result = self[:]
17 result = self[:] 17 result = self[:]
18 result.sort() 18 result.sort()
19 result.reverse() 19 result.reverse()
20 return result 20 return result
21 21
22 def takeHighest(self,num_dice): 22 def takeHighest(self, num_dice):
23 return self.descending()[:num_dice] 23 return self.descending()[:num_dice]
24 24
25 def takeLowest(self,num_dice): 25 def takeLowest(self,num_dice):
26 return self.ascending()[:num_dice] 26 return self.ascending()[:num_dice]
27 27
28 def extra(self,num): 28 def extra(self, num):
29 for i in range(len(self.data)): 29 for i in range(len(self.data)):
30 if self.data[i].lastroll() >= num: 30 if self.data[i].lastroll() >= num:
31 self.data[i].extraroll() 31 self.data[i].extraroll()
32 return self 32 return self
33 33
34 def open(self,num): 34 def open(self, num):
35 if num <= 1: 35 if num <= 1: self
36 self
37 done = 1 36 done = 1
38 for i in range(len(self.data)): 37 for i in range(len(self.data)):
39 if self.data[i].lastroll() >= num: 38 if self.data[i].lastroll() >= num:
40 self.data[i].extraroll() 39 self.data[i].extraroll()
41 done = 0 40 done = 0
42 if done: 41 if done: print self; return self
43 return self 42 else: return self.open(num)
44 else:
45 return self.open(num)
46 43
47 def minroll(self,min): 44 def minroll(self,min):
48 for i in range(len(self.data)): 45 for i in range(len(self.data)):
49 if self.data[i].lastroll() < min: 46 if self.data[i].lastroll() < min:
50 self.data[i].roll(min) 47 self.data[i].roll(min)
51 return self 48 return self
52 49
53 def each(self,mod): 50 def each(self, mod):
54 mod = int(mod) 51 mod = int(mod)
55 for i in range(len(self.data)): 52 for i in range(len(self.data)):
56 self.data[i].modify(mod) 53 self.data[i].modify(mod)
57 return self 54 return self
58
59 55
60 def vs(self, target): 56 def vs(self, target):
61 for dn in self.data: 57 for dn in self.data:
62 dn.target = target 58 dn.target = target
63 return self 59 return self
70 def sum(self): 66 def sum(self):
71 retValue = 0 67 retValue = 0
72 for dn in self.data: 68 for dn in self.data:
73 setValue = reduce( lambda x, y : int(x)+int(y), dn.history ) 69 setValue = reduce( lambda x, y : int(x)+int(y), dn.history )
74 if dn.target: 70 if dn.target:
75 if setValue >= dn.target: 71 for dv in dn.history:
76 retValue += 1 72 if int(dv) >= dn.target: retValue += 1
77
78 else: 73 else:
79 retValue += setValue 74 retValue += setValue
80
81 return retValue 75 return retValue
82 76
83 die_rollers.register(std) 77 die_rollers.register(std)