| version 1.11 | | version 1.12 |
|---|
| | |
| | | |
| #EASILY SETTABLE PARAMETERS | | #EASILY SETTABLE PARAMETERS |
| service_charge=5 #service charges for transactions as a percent | | service_charge=5 #service charges for transactions as a percent |
| exchange_rate=10000 #exchange rate for silver (value 1) | | exchange_rate = 10000 # exchange rate of imperial to silver (value 1) |
| bankdatabase="ImperialBank_DB" | | bankdatabase="ImperialBank_DB" |
| | | |
| fees=(service_charge/100.0)+1 | | fees=(service_charge/100.0)+1 |
| bank = CFBank.CFBank(bankdatabase) | | bank = CFBank.CFBank(bankdatabase) |
| | | |
| text = string.split(Crossfire.WhatIsMessage()) | | text = string.split(Crossfire.WhatIsMessage()) |
| thanks_message = ['Thank you for banking the Imperial Way.', 'Thank you, please come \ | | thanks_message = [ \ |
| again.', 'Thank you, please come again.','Thank you for banking the Imperial Way.', \ | | 'Thank you for banking the Imperial Way.', \ |
| 'Thank you for your patronage.', 'Thank you, have a nice day.', 'Thank you. "Service" \ | | 'Thank you for banking the Imperial Way.', \ |
| is our middle name.', 'Thank you. "Service" is our middle name.', 'Thank you for your \ | | 'Thank you, please come again.', \ |
| patronage.', 'Thank you, have a nice day.', 'Thank you. Hows about a big slobbery kiss?'] | | 'Thank you, please come again.', \ |
| | | 'Thank you for your patronage.', \ |
| | | 'Thank you for your patronage.', \ |
| | | 'Thank you, have a nice day.', \ |
| | | 'Thank you, have a nice day.', \ |
| | | 'Thank you. "Service" is our middle name.', \ |
| | | 'Thank you. "Service" is our middle name.', \ |
| | | '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 ='You can:\n-deposit,-withdraw,-balance,-exchange \ | | message ='You can:\n-deposit,-withdraw,-balance,-exchange \ |
| \nAll transactions are in imperial notes\n(1 : 1000 gold coins). \ | | \nAll transactions are in imperial notes\n(1 : 1000 gold coins). \ |
| \nA service charge of %d percent will be placed on all deposits' \ | | \nA service charge of %d percent will be placed on all deposits.' \ |
| %(service_charge) | | %(service_charge) |
| | | |
| | | |
| elif text[0] == 'deposit': | | elif text[0] == 'deposit': |
| if len(text)==2: | | if len(text)==2: |
| if (activator.PayAmount(int((int(text[1])*exchange_rate)*fees))): | | amount = int(text[1]) |
| bank.deposit(activatorname, int(text[1])) | | if amount <= 0: |
| message = '%d received, %d imperials deposited to bank account. %s' \ | | message = 'Usage "deposit <amount in imperials>"' |
| %((int(text[1])*(exchange_rate/50))*fees,int(text[1]),random.choice(thanks_message)) | | elif amount > 10000: |
| | | message = 'Sorry, we do not accept more than 10000 imperials for one deposit.' |
| | | elif activator.PayAmount(int(amount*exchange_rate*fees)): |
| | | bank.deposit(activatorname, amount) |
| | | message = '%d platinum received, %d imperials deposited to bank account. %s' \ |
| | | %((amount*(exchange_rate/50))*fees, amount, random.choice(thanks_message)) |
| else: | | else: |
| message = 'You would need %d gold'%((int(text[1])*(exchange_rate/10))*fees) | | message = 'You would need %d gold'%((amount*(exchange_rate/10))*fees) |
| else: | | else: |
| message = 'Usage "deposit <amount in imperials>"' | | 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]))): | | amount = int(text[1]) |
| | | if amount <= 0: |
| | | message = 'Usage "withdraw <amount in imperials>"' |
| | | elif amount > 10000: |
| | | message = 'Sorry, we do not accept more than 10000 imperials for one withdraw.' |
| | | elif bank.withdraw(activatorname, amount): |
| message = '%d imperials withdrawn from bank account. %s' \ | | message = '%d imperials withdrawn from bank account. %s' \ |
| %(int(text[1]),random.choice(thanks_message)) | | %(amount, random.choice(thanks_message)) |
| id = activator.Map.CreateObject('imperial', (x, y)) | | id = activator.Map.CreateObject('imperial', x, y) |
| CFItemBroker.Item(id).add(int(text[1])) | | CFItemBroker.Item(id).add(amount) |
| | | activator.Take(id) |
| else: | | else: |
| message = 'Not enough imperials on your account' | | message = 'Not enough imperials on your account' |
| else: | | else: |
| message = 'Usage "withdraw <amount in imperials>"' | | message = 'Usage "withdraw <amount in imperials>"' |
| | | |
| | | |
| elif text[0] == 'exchange': | | elif text[0] == 'exchange': |
| if len(text)==2: | | if len(text)==2: |
| | | amount = int(text[1]) |
| | | if amount <= 0: |
| | | message = 'Usage "exchange <amount>" (imperials to platinum coins)' |
| | | elif amount > 10000: |
| | | message = 'Sorry, we do not exchange more than 10000 imperials all at once.' |
| | | else: |
| inv=activator.CheckInventory('imperial') | | inv=activator.CheckInventory('imperial') |
| if inv: | | if inv: |
| pay = CFItemBroker.Item(inv).subtract(int(text[1])) | | pay = CFItemBroker.Item(inv).subtract(amount) |
| if pay: | | if pay: |
| id = activator.Map.CreateObject('platinum coin', (x, y)) | | |
| CFItemBroker.Item(id).add(int(text[1])*(exchange_rate/50)) | | # Drop the coins on the floor, then try |
| | | # to pick them up. This effectively |
| | | # prevents the player from carrying too |
| | | # many coins. |
| | | id = activator.Map.CreateObject('platinum coin', x, y) |
| | | CFItemBroker.Item(id).add(amount*(exchange_rate/50)) |
| | | activator.Take(id) |
| | | |
| message = random.choice(thanks_message) | | message = random.choice(thanks_message) |
| else: | | else: |
| message = 'Sorry, you do not have %d imperials' %int(text[1]) | | message = 'Sorry, you do not have %d imperials'%(amount) |
| else: | | else: |
| message = 'Sorry, you do not have any imperials' | | message = 'Sorry, you do not have any imperials' |
| else: | | else: |
| message = 'Usage "exchange <amount>" (imperials to platimum coins)' | | message = 'Usage "exchange <amount>" (imperials to platinum coins)' |
| | | |
| | | |
| elif text[0] == 'balance': | | elif text[0] == 'balance': |
| balance = bank.getbalance(activatorname) | | balance = bank.getbalance(activatorname) |
| | |
| message = 'Amount in bank: %d imperial notes'%(balance) | | message = 'Amount in bank: %d imperial notes'%(balance) |
| else: | | else: |
| message = 'Sorry, you have no balance.' | | message = 'Sorry, you have no balance.' |
| | | |
| | | |
| else: | | else: |
| message = 'Do you need help?' | | message = 'Do you need help?' |
| | | |
| whoami.Say(message) | | whoami.Say(message) |
| | | Crossfire.SetReturnValue(1) |