annotate orpg/dieroller/rollers/std.py @ 217:c719a07cd28d beta

Traipse Beta 'OpenRPG' {100430-01} 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 New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lin node, change title in design mode 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 Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Daily-01: Again forgot the version number Files affect in last update: Currently selected branch: beta Author: sirebral Files Modified (in update): orpg/chat/commands.py orpg/gametree/gametree.py orpg/gametree/nodehandlers/containers.py orpg/gametree/nodehandlers/minilib.py orpg/pluginhandler.py plugins/xxhiddendice.py plugins/xxsimpleinit.py
author sirebral
date Fri, 30 Apr 2010 05:44:05 -0500
parents 13054be69834
children 9230a33defd9
rev   line source
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
1 from orpg.dieroller.base import die_base, die_rollers
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
2
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
3 class std(die_base):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
4 name = "std"
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
5
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
6 def __init__(self, source=[]):
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
7 die_base.__init__(self, source)
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
8
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
9 # Examples of adding member functions through inheritance.
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
10
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
11 def ascending(self):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
12 result = self[:]
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
13 result.sort()
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
14 return result
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
15
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
16 def descending(self):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
17 result = self[:]
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
18 result.sort()
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
19 result.reverse()
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
20 return result
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
21
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
22 def takeHighest(self, num_dice):
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
23 return self.descending()[:num_dice]
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
24
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
25 def takeLowest(self,num_dice):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
26 return self.ascending()[:num_dice]
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
27
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
28 def extra(self, num):
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
29 for i in range(len(self.data)):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
30 if self.data[i].lastroll() >= num:
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
31 self.data[i].extraroll()
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
32 return self
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
33
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
34 def open(self, num):
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
35 if num <= 1: self
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
36 done = 1
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
37 for i in range(len(self.data)):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
38 if self.data[i].lastroll() >= num:
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
39 self.data[i].extraroll()
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
40 done = 0
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
41 if done: return self
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
42 else: return self.open(num)
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
43
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
44 def minroll(self,min):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
45 for i in range(len(self.data)):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
46 if self.data[i].lastroll() < min:
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
47 self.data[i].roll(min)
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
48 return self
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
49
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
50 def each(self, mod):
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
51 mod = int(mod)
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
52 for i in range(len(self.data)):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
53 self.data[i].modify(mod)
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
54 return self
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
55
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
56 def vs(self, target):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
57 for dn in self.data:
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
58 dn.target = target
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
59 return self
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
60
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
61
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
62 ## If we are testing against a saving throw, we check for
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
63 ## greater than or equal to against the target value and
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
64 ## we only return the number of successful saves. A negative
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
65 ## value will never be generated.
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
66 def sum(self):
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
67 retValue = 0
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
68 for dn in self.data:
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
69 setValue = reduce( lambda x, y : int(x)+int(y), dn.history )
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
70 if dn.target:
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
71 for dv in dn.history:
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 184
diff changeset
72 if int(dv) >= dn.target: retValue += 1
171
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
73 else:
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
74 retValue += setValue
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
75 return retValue
ff48c2741fe7 Traipse Beta 'OpenRPG' {091210-00}
sirebral
parents:
diff changeset
76
184
dcae32e219f1 Traipse Beta 'OpenRPG' {100117-00}
sirebral
parents: 171
diff changeset
77 die_rollers.register(std)