[wpdev-commits] xmlscripts/scripts/system trading.py,1.7,1.8
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-09-04 18:39:18
|
Update of /cvsroot/wpdev/xmlscripts/scripts/system In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27656/system Modified Files: trading.py Log Message: Updates for trading Fix for bug #0000128 Index: trading.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/system/trading.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** trading.py 4 Sep 2004 16:44:50 -0000 1.7 --- trading.py 4 Sep 2004 18:39:08 -0000 1.8 *************** *** 23,26 **** --- 23,68 ---- return True + # + # Disallow using items in trade containers + # + def onUse(char, item): + if item.container and item.container.container == char and item.container.layer == LAYER_TRADING: + return True + else: + return False + + def onPickup(player1, item): + box1 = player1.itemonlayer(LAYER_TRADING) + if not box1: + return False + + if item.container != box1: + return False + + if not player1.hastag('trade_partner'): + return False + + player2 = wolfpack.findchar(int(player1.gettag('trade_partner'))) + if not player2: + return False + box2 = player2.itemonlayer(LAYER_TRADING) + + if not box2: + return False + + player1.settag( 'trade_button', 0 ) + player2.settag( 'trade_button', 0 ) + + # Reset the trading status and resend it + # To me + sendtradepacket( player1.socket, 2, box1.serial, 0, 0, "" ) + + # To partner + sendtradepacket( player2.socket, 2, box2.serial, 0, 0, "" ) + + item.removefromview(True) + + return False + def onTradeAdd( player, item ): #not implemented yet in code *************** *** 40,43 **** --- 82,109 ---- return True + + def onDropOnItem( item, box1 ): + player1 = box1.container + if not player1.hastag('trade_partner'): + return False + player2 = wolfpack.findchar(int(player1.gettag('trade_partner'))) + if not player2: + return False + box2 = player2.itemonlayer(LAYER_TRADING) + + if not box2: + return False + + player1.settag( 'trade_button', 0 ) + player2.settag( 'trade_button', 0 ) + + # Reset the trading status and resend it + # To me + sendtradepacket( player1.socket, 2, box1.serial, 0, 0, "" ) + + # To partner + sendtradepacket( player2.socket, 2, box2.serial, 0, 0, "" ) + + return False # *************** *** 74,77 **** --- 140,146 ---- player1.additem( LAYER_TRADING, box1 ) box1.update() + box1new = 1 + else: + box1new = 0 # Same operation for partner *************** *** 82,85 **** --- 151,157 ---- player2.additem( LAYER_TRADING, box2 ) box2.update() + box2new = 1 + else: + box2new = 0 # Unable to create trade containers *************** *** 89,101 **** return False ! #onLogout event should be executed for tradewindow disposing player1.addscript( 'system.trading' ) player2.addscript( 'system.trading' ) ! #We want to know serial of partner in future player1.settag( 'trade_partner', player2.serial ) player2.settag( 'trade_partner', player1.serial ) ! #We need to store button state of each player player1.settag( 'trade_button', 0 ) player2.settag( 'trade_button', 0 ) --- 161,173 ---- return False ! # onLogout event should be executed for tradewindow disposing player1.addscript( 'system.trading' ) player2.addscript( 'system.trading' ) ! # We want to know serial of partner in future player1.settag( 'trade_partner', player2.serial ) player2.settag( 'trade_partner', player1.serial ) ! # We need to store button state of each player player1.settag( 'trade_button', 0 ) player2.settag( 'trade_button', 0 ) *************** *** 103,118 **** #Send trade window to both players #To me ! sendtradepacket( player1.socket, 0, player2.serial, box1.serial, box2.serial, player2.name ) #To partner ! sendtradepacket( player2.socket, 0, player1.serial, box2.serial, box1.serial, player1.name ) #Send buttons state #To me ! sendtradepacket( player1.socket, 2, box1.serial, 0, 0, "" ) #To partner ! sendtradepacket( player2.socket, 2, box2.serial, 0, 0, "" ) box1.additem( firstitem ) firstitem.update() return True --- 175,196 ---- #Send trade window to both players #To me ! if box1new: ! sendtradepacket( player1.socket, 0, player2.serial, box1.serial, box2.serial, player2.name ) ! #To partner ! if box2new: ! sendtradepacket( player2.socket, 0, player1.serial, box2.serial, box1.serial, player1.name ) #Send buttons state #To me ! sendtradepacket( player1.socket, 2, box1.serial, 0, 0, "" ) #To partner ! sendtradepacket( player2.socket, 2, box2.serial, 0, 0, "" ) box1.additem( firstitem ) firstitem.update() + + box1.addscript('system.trading') + box2.addscript('system.trading') return True *************** *** 169,172 **** --- 247,251 ---- sendclosetrade( player.socket, box1.serial ) box1.delete() + if box2: back2 = partner.getbackpack() |