- touchups for banking system

Bank now uses imperials (1000 gold) for withdrawls and can do enchanges
of currency to platinum.  Added a cleanup routine in the
python_remove script to delete account when players quit.
A transaction fee was implemented for deposits (default 5%)
requires use of new arch "imperial" (bank notes with no
intrinsic value)


git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@2350 282e977c-c81d-0410-88c4-b93c2d0d6712
master
temitchell 2003-09-28 16:49:09 +00:00
parent 07292180d0
commit 1c179567fc
3 changed files with 65 additions and 15 deletions

View File

@ -53,3 +53,12 @@ class CFBank:
return self.bankdb[user] return self.bankdb[user]
else: else:
return 0 return 0
def remove_account(self,user):
if self.bankdb.has_key(user):
del self.bankdb[user]
print "%s's bank account removed." %user
return 1
else:
return 0

View File

@ -1,4 +1,4 @@
# Script for say event of IPO employees # Script for say event of Imperial Bank Tellers
# #
# Copyright (C) 2002 Joris Bontje # Copyright (C) 2002 Joris Bontje
# #
@ -18,7 +18,7 @@
# #
# The author can be reached via e-mail at jbontje@suespammers.org # The author can be reached via e-mail at jbontje@suespammers.org
# #
#Updated to use new path functions in CFPython and broken apart by -Todd Mitchell #Updated to use new path functions in CFPython and broken and modified a bit by -Todd Mitchell
import CFPython import CFPython
@ -27,6 +27,7 @@ import sys
sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory()))
import string import string
import random
import CFBank import CFBank
activator=CFPython.WhoIsActivator() activator=CFPython.WhoIsActivator()
@ -35,39 +36,76 @@ whoami=CFPython.WhoAmI()
x=CFPython.GetXPosition(activator) x=CFPython.GetXPosition(activator)
y=CFPython.GetYPosition(activator) y=CFPython.GetYPosition(activator)
#EASILY SETTABLE PARAMETERS
service_charge=5 #service charges for transactions as a percent
exchange_rate=10000 #exchange rate for silver (value 1)
fees=(service_charge/100)+1
bank = CFBank.CFBank() bank = CFBank.CFBank()
text = string.split(CFPython.WhatIsMessage()) text = string.split(CFPython.WhatIsMessage())
thanks_message = ['Thank you for banking the Imperial Way.', 'Thank you, please come again.',\
'Thank you. "Service" is our middle name.', 'Thank you for your patronage.', 'Thank you, have a nice day.', \
'Thank you. Hows about a big slobbery kiss?']
if text[0] == 'help' or text[0] == 'yes': if text[0] == 'help' or text[0] == 'yes':
message = 'Here is a quick list of commands:\n\n- deposit\n- withdraw\n- balance\nAll transactions are in Imperials\n(1 Ip = 1000 platinum coins).' message ='You can:\n-deposit,-withdraw,-balance,-exchange \
CFPython.Say(whoami,message) \nAll transactions are in imperial notes\n(1 : 1000 gold coins). \
\nA service charge of %d percent will be placed on all deposits' %(service_charge)
elif text[0] == 'deposit': elif text[0] == 'deposit':
if len(text)==2: if len(text)==2:
if (CFPython.PayAmount(activator, int(text[1])*50000)): if (CFPython.PayAmount(activator, (int(text[1])*exchange_rate)*fees)):
bank.deposit(activatorname, int(text[1])) bank.deposit(activatorname, int(text[1]))
CFPython.Say(whoami, 'Deposited to bank account') message = '%d imperials deposited to bank account. %s' %(int(text[1]),random.choice(thanks_message))
else: else:
CFPython.Say(whoami, 'You need %d platinum'%(int(text[1])*1000)) message = 'You would need %d gold'%((int(text[1])*(exchange_rate/10))*fees)
else: else:
CFPython.Say(whoami, 'Usage "deposit <amount Ip>"') message = 'Usage "deposit <amount in imperials>"'
elif text[0] == 'withdraw': elif text[0] == 'withdraw':
if len(text)==2: if len(text)==2:
if (bank.withdraw(activatorname, int(text[1]))): if (bank.withdraw(activatorname, int(text[1]))):
CFPython.Say(whoami, 'Withdrawn from bank account') message = '%d imperials withdrawn from bank account. %s' %(int(text[1]),random.choice(thanks_message))
id = CFPython.CreateObject('platinum coin', (x, y)) id = CFPython.CreateObject('imperial', (x, y))
CFPython.SetQuantity(id, int(text[1])*1000) CFPython.SetQuantity(id, int(text[1]))
else: else:
CFPython.Say(whoami, 'Not enough Imperials on your account') message = 'Not enough imperials on your account'
else: else:
CFPython.Say(whoami, 'Usage "withdraw <amount Ip>"') message = 'Usage "withdraw <amount in imperials>"'
elif text[0] == 'exchange':
if len(text)==2:
inv=CFPython.CheckInventory(activator,'imperial')
if(inv):
available = CFPython.GetQuantity(inv)
remainder = available - int(text[1])
if remainder > int(text[1]):
CFPython.SetQuantity(inv, (available - int(text[1])))
id = CFPython.CreateObject('platinum coin', (x, y))
CFPython.SetQuantity(id, int(text[1])*(exchange_rate/50))
message = random.choice(thanks_message)
elif remainder == 0:
CFPython.RemoveObject(inv)
id = CFPython.CreateObject('platinum coin', (x, y))
CFPython.SetQuantity(id, int(text[1])*(exchange_rate/50))
message = random.choice(thanks_message)
else:
message = 'Sorry, you do not have %d imperials' %int(text[1])
else:
message = 'Sorry, you do not have %d imperials' %int(text[1])
else:
message = 'Usage "exchange <amount>" (imperials to platimum coins)'
elif text[0] == 'balance': elif text[0] == 'balance':
balance = bank.getbalance(activatorname) balance = bank.getbalance(activatorname)
CFPython.Say(whoami, 'Amount on bank: %d Ip'%balance) message = 'Amount in bank: %d Ip'%(balance)
else: else:
CFPython.Say(whoami, 'Do you need help?') message = 'Do you need help?'
CFPython.Say(whoami, message)

View File

@ -31,3 +31,6 @@ name = CFPython.GetName(activator)
log = CFLog.CFLog() log = CFLog.CFLog()
log.remove(name) log.remove(name)
bank = CFBank.CFBank()
bank.remove_account(name)