Update of /cvsroot/wpdev/xmlscripts/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28093
Modified Files:
door.py food.py key.py keyring.py lock.py lockpick.py
potionkeg.py potions.py spiderweb.py
Log Message:
- Replaced access to .events with the calls hasevent/addevent/removeevent in all relevant places.
Notice that addevent() is expected to add the event to the head of the list.
I recognized no situation (of those changed) where it would make a difference adding the event to the end of the list, so in those cases used addevent aswell.
- Fixed a copy&paste error in trap.py on removing the tags (pointed out by Incannus).
note: .events can now be made read only, bearing in mind that in doing so there is no way to make a distinction between adding an event at the top or at the end of the event list.
Index: door.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/door.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** door.py 14 Jul 2004 07:41:03 -0000 1.14
--- door.py 24 Aug 2004 18:10:22 -0000 1.15
***************
*** 207,211 ****
for item in container.content:
# Check if it's a key
! if 'key' in item.events and item.hastag( 'lock' ) and int( item.gettag( 'lock' ) ) == lock:
return 1
--- 207,211 ----
for item in container.content:
# Check if it's a key
! if item.hasevent( 'key' ) and item.hastag( 'lock' ) and int( item.gettag( 'lock' ) ) == lock:
return 1
Index: keyring.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/keyring.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** keyring.py 26 May 2004 13:07:20 -0000 1.4
--- keyring.py 24 Aug 2004 18:10:23 -0000 1.5
***************
*** 3,7 ****
def onDropOnItem(keyring, key):
! if 'keyring' not in keyring.events or 'key' not in key.events:
return 0
--- 3,7 ----
def onDropOnItem(keyring, key):
! if not keyring.hasevent( 'keyring' ) or not key.hasevent( 'key' ):
return 0
***************
*** 69,73 ****
return
! if not 'lock' in target.item.events or not target.item.hastag('lock'):
char.socket.clilocmessage(501666)
return
--- 69,73 ----
return
! if not target.item.hasevent( 'lock' ) or not target.item.hastag( 'lock' ):
char.socket.clilocmessage(501666)
return
***************
*** 79,83 ****
for key in keys:
! if key.hastag('lock') and 'key' in key.events:
key_lock = str(key.gettag('lock'))
--- 79,83 ----
for key in keys:
! if key.hastag('lock') and key.hasevent( 'key' ):
key_lock = str(key.gettag('lock'))
Index: spiderweb.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/spiderweb.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** spiderweb.py 11 Jul 2004 02:47:25 -0000 1.3
--- spiderweb.py 24 Aug 2004 18:10:23 -0000 1.4
***************
*** 9,16 ****
def onCollide(char, item):
# Ignore if the character already has the event
! if 'spiderweb' in char.events:
return
! char.events = ['spiderweb'] + char.events
if char.socket:
char.socket.sysmessage('You are entangled in the spiderweb. You have to break free!')
--- 9,16 ----
def onCollide(char, item):
# Ignore if the character already has the event
! if char.hasevent( 'spiderweb' ):
return
! char.addevent( 'spiderweb' )
if char.socket:
char.socket.sysmessage('You are entangled in the spiderweb. You have to break free!')
***************
*** 28,32 ****
for item in items:
! if 'spiderweb' in item.events:
spiderweb = item
break
--- 28,32 ----
for item in items:
! if item.hasevent( 'spiderweb' ):
spiderweb = item
break
***************
*** 51,59 ****
return True
! events = char.events
! while 'spiderweb' in events:
! events.remove('spiderweb')
! char.events = events
!
char.socket.sysmessage('You manage to break free of the spiderweb.')
return False
--- 51,55 ----
return True
! char.removeevent( 'spiderweb' )
char.socket.sysmessage('You manage to break free of the spiderweb.')
return False
***************
*** 70,74 ****
for item in items:
! if 'spiderweb' in item.events:
spiderweb = item
break
--- 66,70 ----
for item in items:
! if item.hasevent( 'spiderweb' ):
spiderweb = item
break
***************
*** 86,93 ****
for target in targets:
! events = target.events
! while 'spiderweb' in events:
! events.remove('spiderweb')
! target.events = events
return amount
--- 82,86 ----
for target in targets:
! target.removeevent( 'spiderweb' )
return amount
Index: lockpick.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/lockpick.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** lockpick.py 9 Jul 2004 21:47:45 -0000 1.4
--- lockpick.py 24 Aug 2004 18:10:23 -0000 1.5
***************
*** 12,16 ****
char.socket.clilocmessage(500312)
else:
! if not target.item or 'lock' not in target.item.events:
char.socket.clilocmessage(502069)
elif not char.canreach(target.item, 3):
--- 12,16 ----
char.socket.clilocmessage(500312)
else:
! if not target.item or not target.item.hasevent( 'lock' ):
char.socket.clilocmessage(502069)
elif not char.canreach(target.item, 3):
***************
*** 31,39 ****
if char.checkskill(LOCKPICKING, 0, 1200):
# SUCCESS: Remove lockpick and the lock
! events = target.item.events
! while 'lock' in events:
! events.remove('lock')
! target.item.events = events
!
target.item.deltag('lock')
target.item.deltag('locked')
--- 31,35 ----
if char.checkskill(LOCKPICKING, 0, 1200):
# SUCCESS: Remove lockpick and the lock
! target.item.removeevent( 'lock' )
target.item.deltag('lock')
target.item.deltag('locked')
Index: key.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/key.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** key.py 9 Jul 2004 21:47:45 -0000 1.11
--- key.py 24 Aug 2004 18:10:23 -0000 1.12
***************
*** 88,92 ****
rename_key(char,key)
! elif 'lock' in target.item.events:
if target.item.hastag('locked') and int(target.item.gettag('locked')) == 1:
target.item.deltag('locked')
--- 88,92 ----
rename_key(char,key)
! elif target.item.hasevent( 'lock' ):
if target.item.hastag('locked') and int(target.item.gettag('locked')) == 1:
target.item.deltag('locked')
***************
*** 110,114 ****
# Check if the targetted item is a key
! if not target.item or not 'key' in target.item.events:
char.socket.clilocmessage(501679)
return
--- 110,114 ----
# Check if the targetted item is a key
! if not target.item or not target.item.hasevent( 'key' ):
char.socket.clilocmessage(501679)
return
Index: potions.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/potions.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** potions.py 16 Jul 2004 07:09:26 -0000 1.42
--- potions.py 24 Aug 2004 18:10:23 -0000 1.43
***************
*** 380,386 ****
bonus = min(18, math.floor(18 * (char.skill[MAGERY] / 1000.0)))
! char.events = ['magic.nightsight'] + char.events
! char.settag("nightsight", bonus)
! char.settag("nightsight_start", time.minutes())
char.lightbonus += bonus
--- 380,386 ----
bonus = min(18, math.floor(18 * (char.skill[MAGERY] / 1000.0)))
! char.addevent( 'magic.nightsight' )
! char.settag( 'nightsight', bonus)
! char.settag( 'nightsight_start', time.minutes())
char.lightbonus += bonus
Index: potionkeg.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/potionkeg.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** potionkeg.py 19 Jul 2004 23:22:15 -0000 1.11
--- potionkeg.py 24 Aug 2004 18:10:23 -0000 1.12
***************
*** 14,18 ****
return False
! if ( not 'potionkeg' in potionkeg.events ) or ( not 'potions' in potion.events ):
return False
--- 14,18 ----
return False
! if not potionkeg.hasevent( 'potionkeg' ) or not potion.hasevent( 'potions' ):
return False
***************
*** 72,76 ****
return False
! if not 'potionkeg' in potionkeg.events:
return False
--- 72,76 ----
return False
! if not potionkeg.hasevent( 'potionkeg' ):
return False
Index: food.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/food.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** food.py 8 Aug 2004 20:17:45 -0000 1.12
--- food.py 24 Aug 2004 18:10:23 -0000 1.13
***************
*** 91,104 ****
def onCollide( char, item ):
if char.npc and item.baseid in farm_food and char.baseid in farm_eaters:
! if 'food' in char.events:
! return True
! if char.baseid in farm_eaters:
! char.events = ['food'] + char.events
! char.say( "*nibbles*" )
! item.movable = 3
! item.update()
return True
! else:
! return False
else:
return False
--- 91,101 ----
def onCollide( char, item ):
if char.npc and item.baseid in farm_food and char.baseid in farm_eaters:
! if char.hasevent( 'food' ):
return True
! char.addevent( 'food' )
! char.say( "*nibbles*" )
! item.movable = 3
! item.update()
! return True
else:
return False
***************
*** 107,115 ****
if char.baseid in farm_eaters:
items = wolfpack.items(char.pos.x, char.pos.y, char.pos.map, 0)
food = None
for item in items:
! if 'food' in item.events and item.baseid in farm_food:
food = item
break
if food:
food.delete()
--- 104,114 ----
if char.baseid in farm_eaters:
items = wolfpack.items(char.pos.x, char.pos.y, char.pos.map, 0)
+
food = None
for item in items:
! if item.hasevent( 'food' ) and item.baseid in farm_food:
food = item
break
+
if food:
food.delete()
***************
*** 119,131 ****
char.hitpoints += 1
char.update()
! events = char.events
! while 'food' in events:
! events.remove('food')
! char.events = events
! return True
! else:
! events = char.events
! while 'food' in events:
! events.remove('food')
! char.events = events
! return True
--- 118,122 ----
char.hitpoints += 1
char.update()
!
! char.removeevent('food')
! return True
Index: lock.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/lock.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** lock.py 26 May 2004 13:07:20 -0000 1.11
--- lock.py 24 Aug 2004 18:10:23 -0000 1.12
***************
*** 30,37 ****
if response.button == 1:
# Prepend 'lock' to the event chain
! if not 'lock' in item.events:
! events = item.events
! events[:0] = ['lock']
! item.events = events
# Set the lock id
--- 30,35 ----
if response.button == 1:
# Prepend 'lock' to the event chain
! if not item.hasevent( 'lock' ):
! item.addevent( 'lock' )
# Set the lock id
***************
*** 66,73 ****
# Remove the event from the eventlist
! events = item.events
! while 'lock' in events:
! events.remove('lock')
! item.events = events
item.resendtooltip()
--- 64,68 ----
# Remove the event from the eventlist
! item.removeevent( 'lock' )
item.resendtooltip()
***************
*** 93,97 ****
# Check if the item already has a lock
! if 'lock' in target.item.events and target.item.hastag('lock'):
gump.addBackground(id=0x2436, width=425, height=285)
--- 88,92 ----
# Check if the item already has a lock
! if target.item.hasevent('lock') and target.item.hastag('lock'):
gump.addBackground(id=0x2436, width=425, height=285)
***************
*** 169,173 ****
def searchkey(item, lock):
# It's a key.
! if 'key' in item.events and item.hastag('lock'):
if lock == str(item.gettag('lock')):
return 1
--- 164,168 ----
def searchkey(item, lock):
# It's a key.
! if item.hasevent( 'key' ) and item.hastag( 'lock' ):
if lock == str(item.gettag('lock')):
return 1
***************
*** 202,206 ****
# Only doors can be opened without unlocking them
# if the user has the key in his posession.
! if 'door' in item.events:
if searchkey(char.getbackpack(), lock):
char.socket.clilocmessage(501282)
--- 197,201 ----
# Only doors can be opened without unlocking them
# if the user has the key in his posession.
! if item.hasevent( 'door' ):
if searchkey(char.getbackpack(), lock):
char.socket.clilocmessage(501282)
|