Ticket #71: patch.txt

File patch.txt, 6.2 KB (added by anonymous, 10 years ago)

Patch taken from clients/parpg for ticket fix code.

Line 
1Index: scripts/objects/base.py
2===================================================================
3--- scripts/objects/base.py     (revision 211)
4+++ scripts/objects/base.py     (working copy)
5@@ -88,7 +88,6 @@
6         self.name = name
7         self.text = text
8         self.desc = desc
9-        super(GameObject,self).__init__ (**kwargs)
10         
11     def trueAttr(self, attr):
12         """Shortcut function to check if the current object has a member named
13@@ -119,7 +118,6 @@
14         @param is_open: Keyword boolean argument sets the initial state."""
15         self.is_openable = True
16         self.is_open = is_open
17-        super(Openable,self).__init__ (**kwargs)
18     
19     def open(self):
20         """Opens the object, and runs an 'onOpen' script, if present"""
21@@ -142,7 +140,7 @@
22         """
23         self.is_lockable = True
24         self.locked = locked
25-        super(Lockable,self).__init__ (**kwargs)
26+        Openable.__init__( self, **kwargs )
27         
28     def unlock (self):
29         """Handles unlocking functionality"""
30@@ -166,14 +164,12 @@
31         self.is_carryable = True
32         self.in_container = None
33         self.weight = 1.0
34-        super(Carryable,self).__init__ (**kwargs)
35     
36 class Container (object):
37     """Gives objects the capability to hold other objects"""
38     def __init__ (self, **kwargs):
39         self.is_container = True
40         self.items = []
41-        super(Container,self).__init__ (**kwargs)
42         
43     def placeItem (self, item):
44         """Adds the provided carriable item to the inventory.
45@@ -201,12 +197,10 @@
46     def __init__ (self, **kwargs):
47         self.is_inventory = True
48         self.containers = []
49-        super(Inventory,self).__init__ (**kwargs)
50     
51 class Living (object):
52     def __init__ (self, **kwargs):
53         self.is_living = True
54-        super(Living,self).__init__ (**kwargs)
55     def die(self):
56         self.is_living = False
57         
58@@ -219,12 +213,11 @@
59            values are 3-item tuples (function, positional_args, keyword_args)"""
60         self.is_scriptable = True
61         self.scripts = scripts
62-        super(Scriptable,self).__init__ (**kwargs)
63         
64     def runScript (self, event):
65         """Runs the script for the given event"""
66-        if event in self.scripts and self.scrpits[event]:
67-            func, args, kwargs = self.scrpits[event]
68+        if event in self.scripts and self.scripts[event]:
69+            func, args, kwargs = self.scripts[event]
70             func (*args, **kwargs)
71             
72     def setScript (self, event, func, args = [] , kwargs={}):
73@@ -235,38 +228,32 @@
74     """Provides the object with character statistics"""
75     def __init__ (self, **kwargs):
76         self.is_charstats = True
77-        super(CharStats,self).__init__ (**kwargs)
78         
79 class Wearable (object):
80     def __init__ (self, **kwargs):
81         """Allows the object to be weared somewhere on the body (e.g. pants)"""
82         self.is_wearable = True
83-        super(Wearable,self).__init__ (**kwargs)
84     
85 class Usable (object):
86     """Allows the object to be used in some way (e.g. a Zippo lighter
87        to make a fire)"""
88     def __init__ (self, **kwargs):
89         self.is_usable = True
90-        super(Usable,self).__init__ (**kwargs)
91         
92 class Weapon (object):
93     """Allows the object to be used as a weapon"""
94     def __init__ (self, **kwargs):
95         self.is_weapon = True
96-        super(Weapon,self).__init__ (**kwargs)
97         
98 class Destructable (object):
99     """Allows the object to be destroyed"""
100     def __init__ (self, **kwargs):
101         self.is_destructable = True
102-        super(Destructable,self).__init__ (**kwargs)
103         
104 class Trappable (object):
105     """Provides trap slots to the object"""
106     def __init__ (self, **kwargs):
107         self.is_trappable = True
108-        super(Trappable,self).__init__ (**kwargs)
109         
110 if __name__=="__main__":
111     """This will be turned into a test suite"""
112@@ -274,9 +261,20 @@
113                     CharStats, Wearable, Usable, Weapon, Destructable,
114                     Trappable, Carryable, ):
115         def __init__ (self, ID, *args, **kwargs):
116-            super(Wildcard,self).__init__ (ID, *args, **kwargs)
117             self.name = 'All-purpose carry-all'
118             self.text = 'What is this? I dont know'   
119+            GameObject.  __init__( self, ID, **kwargs )
120+            Lockable.    __init__( self, **kwargs )
121+            Container.   __init__( self, **kwargs )
122+            Living.      __init__( self, **kwargs )
123+            Scriptable.  __init__( self, **kwargs )
124+            CharStats.   __init__( self, **kwargs )
125+            Wearable.    __init__( self, **kwargs )
126+            Usable.      __init__( self, **kwargs )
127+            Weapon.      __init__( self, **kwargs )
128+            Destructable.__init__( self, **kwargs )
129+            Trappable.   __init__( self, **kwargs )
130+            Carryable.   __init__( self, **kwargs )
131     
132     test = GameObject (1, {'map':'img/test.png'}, (1,1), None, 'Test object','Description')
133     print test
134Index: scripts/objects/actors.py
135===================================================================
136--- scripts/objects/actors.py   (revision 211)
137+++ scripts/objects/actors.py   (working copy)
138@@ -111,7 +111,10 @@
139     PC class
140     """
141     def __init__ (self, ID, agent_layer = None, engine = None, **kwargs):
142-        super(PlayerCharacter, self).__init__(ID, **kwargs)
143+        GameObject.__init__( self, ID, **kwargs )
144+        Living.__init__( self, **kwargs )
145+        CharStats.__init__( self, **kwargs )
146+
147         self.is_PC = True
148         
149         # PC _has_ an inventory, he _is not_ one
150@@ -272,7 +275,11 @@
151     def __init__(self, ID, agent_layer = None, name = 'NPC', \
152                  text = 'A nonplayer character', **kwargs):
153         # init game object
154-        super(NonPlayerCharacter, self).__init__(ID, **kwargs)
155+        GameObject.__init__( self, ID, **kwargs )
156+        Living.__init__( self, **kwargs )
157+        Scriptable.__init__( self, **kwargs )
158+        CharStats.__init__( self, **kwargs )
159+
160         self.is_NPC = True
161         self.inventory = None
162