Split deposit box code into separate functions.

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@18855 282e977c-c81d-0410-88c4-b93c2d0d6712
master
partmedia 2013-08-03 00:25:23 +00:00
parent a11526d65f
commit f87de491cd
1 changed files with 153 additions and 141 deletions

View File

@ -65,40 +65,9 @@ thanks_message = [
'Thank you. Hows about a big slobbery kiss?', 'Thank you. Hows about a big slobbery kiss?',
] ]
if whoami.Name.find('Deposit Box') > -1: # ----------------------------------------------------------------------------
# Called when the deposit box (ATM) is opened.
ScriptParm = Crossfire.ScriptParameters() def depositBoxOpen():
if ScriptParm == 'Close':
t = activator.CheckInventory('SkudCtrl')
Total = float(t.Title)
Total = long(Total)
t.Quantity = 0
MyInv = whoami.Inventory
Value = 0
while MyInv != None:
if MyInv.Name != 'Apply' and MyInv.Name != 'Close':
Value += MyInv.Value * MyInv.Quantity
MyInv1 = MyInv.Below
MyInv.Teleport(activator.Map, 15, 3)
MyInv = MyInv1
else:
MyInv = MyInv.Below
bank.deposit(activatorname, Value)
Difference = abs(Value - Total)
Fee = Difference - Difference / fees
bank.withdraw(activatorname, int(Fee))
whoami.Say('A Service charge of ' + str(int(Fee))
+ ' silver coins has been charged on this transaction.'
)
else:
balance = bank.getbalance(activatorname) balance = bank.getbalance(activatorname)
Total = balance Total = balance
@ -209,7 +178,50 @@ if whoami.Name.find('Deposit Box') > -1:
# tnew=t.InserInto(whoami) # tnew=t.InserInto(whoami)
if whoami.Name != 'Deposit Box': # ----------------------------------------------------------------------------
# Called when the deposit box (ATM) is closed.
def depositBoxClose():
t = activator.CheckInventory('SkudCtrl')
Total = float(t.Title)
Total = long(Total)
t.Quantity = 0
MyInv = whoami.Inventory
Value = 0
while MyInv != None:
if MyInv.Name != 'Apply' and MyInv.Name != 'Close':
Value += MyInv.Value * MyInv.Quantity
MyInv1 = MyInv.Below
MyInv.Teleport(activator.Map, 15, 3)
MyInv = MyInv1
else:
MyInv = MyInv.Below
bank.deposit(activatorname, Value)
Difference = abs(Value - Total)
Fee = Difference - Difference / fees
bank.withdraw(activatorname, int(Fee))
whoami.Say('A Service charge of ' + str(int(Fee))
+ ' silver coins has been charged on this transaction.'
)
# ----------------------------------------------------------------------------
# Script execution begins here.
# Find out if the script is being run by a deposit box or an employee.
if whoami.Name.find('Deposit Box') > -1:
ScriptParm = Crossfire.ScriptParameters()
if ScriptParm == 'Close':
depositBoxClose()
else:
depositBoxOpen()
else:
text = Crossfire.WhatIsMessage().split() text = Crossfire.WhatIsMessage().split()
if text[0] == 'help' or text[0] == 'yes': if text[0] == 'help' or text[0] == 'yes':
message = \ message = \