Fix bank deposit boxes
Deposit boxes are now truly deposit boxes rather than ATMs. When closed, they only deposit the value of items placed inside. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@19796 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
2d1dbf9876
commit
3c68ec9441
|
@ -161,152 +161,27 @@ def processCheck():
|
||||||
whoami.Say("It seems that %s doesn't have enough money." % payer)
|
whoami.Say("It seems that %s doesn't have enough money." % payer)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
def get_inventory(obj):
|
||||||
# Called when the deposit box (ATM) is opened.
|
"""An iterator for a given object's inventory."""
|
||||||
# TODO: Fix the ATM.
|
current_item = obj.Inventory
|
||||||
def depositBoxOpen():
|
while current_item != None:
|
||||||
balance = bank.getbalance(activatorname)
|
next_item = current_item.Below
|
||||||
Total = balance
|
yield current_item
|
||||||
|
current_item = next_item
|
||||||
|
|
||||||
if balance >= 1000000:
|
def deposit_box_close():
|
||||||
|
"""Find the total value of items in the deposit box and deposit."""
|
||||||
|
total_value = 0
|
||||||
|
for obj in get_inventory(whoami):
|
||||||
|
if obj.Name != 'Apply' and obj.Name != 'Close':
|
||||||
|
total_value += obj.Value * obj.Quantity
|
||||||
|
obj.Teleport(activator.Map, 15, 3)
|
||||||
|
|
||||||
t = whoami.CreateObject('imperial100')
|
# Calculate the amount of money actually deposited (due to fees).
|
||||||
|
deposit_value = int(total_value / fees)
|
||||||
bank.withdraw(activatorname, 1000000)
|
CFBank.deposit(activator, deposit_value)
|
||||||
balance = bank.getbalance(activatorname)
|
whoami.Say("A fee of %d silver has been charged on this transaction." \
|
||||||
if balance >= 1000000 / 2:
|
% (total_value - deposit_value))
|
||||||
t = whoami.CreateObject('ambercoin')
|
|
||||||
bank.withdraw(activatorname, 1000000 / 2)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 1000000 / 2:
|
|
||||||
t = whoami.CreateObject('ambercoin')
|
|
||||||
bank.withdraw(activatorname, 1000000 / 2)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
|
|
||||||
if balance >= 100000:
|
|
||||||
t = whoami.CreateObject('imperial10')
|
|
||||||
bank.withdraw(activatorname, 100000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 100000:
|
|
||||||
t = whoami.CreateObject('imperial10')
|
|
||||||
bank.withdraw(activatorname, 100000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 100000:
|
|
||||||
t = whoami.CreateObject('imperial10')
|
|
||||||
bank.withdraw(activatorname, 100000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 100000:
|
|
||||||
t = whoami.CreateObject('imperial10')
|
|
||||||
bank.withdraw(activatorname, 100000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 100000:
|
|
||||||
t = whoami.CreateObject('imperial10')
|
|
||||||
bank.withdraw(activatorname, 100000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000:
|
|
||||||
t = whoami.CreateObject('imperial')
|
|
||||||
bank.withdraw(activatorname, 10000)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000 / 2:
|
|
||||||
t = whoami.CreateObject('jadecoin')
|
|
||||||
bank.withdraw(activatorname, 10000 / 2)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 10000 / 2:
|
|
||||||
t = whoami.CreateObject('jadecoin')
|
|
||||||
bank.withdraw(activatorname, 10000 / 2)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 5000:
|
|
||||||
t = whoami.CreateObject('platinacoin')
|
|
||||||
bank.withdraw(activatorname, 5000)
|
|
||||||
t.Quantity = 100
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 1000:
|
|
||||||
t = whoami.CreateObject('goldcoin')
|
|
||||||
bank.withdraw(activatorname, 1000)
|
|
||||||
t.Quantity = 100
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
if balance >= 1000:
|
|
||||||
t = whoami.CreateObject('silvercoin')
|
|
||||||
bank.withdraw(activatorname, 1000)
|
|
||||||
t.Quantity = 1000
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
balance = bank.getbalance(activatorname)
|
|
||||||
Total = Total - balance
|
|
||||||
t = activator.CreateObject('force')
|
|
||||||
t.Name = 'SkudCtrl'
|
|
||||||
t.Title = str(Total)
|
|
||||||
|
|
||||||
# tnew=t.InserInto(whoami)
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
# Called when the deposit box (ATM) is closed.
|
|
||||||
# TODO: Fix the ATM.
|
|
||||||
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.'
|
|
||||||
)
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Print a help message for the player.
|
# Print a help message for the player.
|
||||||
|
@ -534,16 +409,8 @@ def cmd_cash(text):
|
||||||
# Find out if the script is being run by a deposit box or an employee.
|
# Find out if the script is being run by a deposit box or an employee.
|
||||||
if whoami.Name.find('Deposit Box') > -1:
|
if whoami.Name.find('Deposit Box') > -1:
|
||||||
ScriptParm = Crossfire.ScriptParameters()
|
ScriptParm = Crossfire.ScriptParameters()
|
||||||
|
|
||||||
# At the moment, the ATMs seem buggy and steal the players' money.
|
|
||||||
# Temporarily disable ATMs until we fix the issue.
|
|
||||||
|
|
||||||
if ScriptParm == 'Close':
|
if ScriptParm == 'Close':
|
||||||
#depositBoxClose()
|
deposit_box_close()
|
||||||
pass
|
|
||||||
else:
|
|
||||||
whoami.Say("We're sorry, ATMs are out of order.")
|
|
||||||
#depositBoxOpen()
|
|
||||||
else:
|
else:
|
||||||
text = Crossfire.WhatIsMessage().split()
|
text = Crossfire.WhatIsMessage().split()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue