From 342ac2430a7dc2a85f781bc6ebe9834c1d4ad48c Mon Sep 17 00:00:00 2001 From: partmedia Date: Sat, 3 Aug 2013 00:25:47 +0000 Subject: [PATCH] Offload trivial commands to their separate functions. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@18857 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/IPO/banksay.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/python/IPO/banksay.py b/python/IPO/banksay.py index 1119ac66e..1a3522319 100644 --- a/python/IPO/banksay.py +++ b/python/IPO/banksay.py @@ -212,7 +212,7 @@ def depositBoxClose(): # ---------------------------------------------------------------------------- # Print a help message for the player. -def printHelp(): +def cmd_help(): message = "You can check your 'balance', 'deposit' or 'withdraw' money, 'exchange' your currency, 'cash' a check, 'transfer' funds, buy 'checks', or find out how much 'profits' this bank has made.\n\nAll transactions are in imperial notes (1 note = 1000 gold). A service charge of %d percent will be placed on all deposits." % service_charge if activator.DungeonMaster: @@ -220,6 +220,25 @@ def printHelp(): whoami.Say(message) +# ---------------------------------------------------------------------------- +# Show the profits made by the bank. +def cmd_show_profits(): + message = "To date, the Imperial Bank of Skud has made %s " \ + "pounds sterling in profit." % \ + str(bank.getbalance(Skuds)) + whoami.Say(message) + +# ---------------------------------------------------------------------------- +# Erase the profits made by the bank. +def cmd_zero_balance(): + if activator.DungeonMaster: + bank.withdraw(Skuds, bank.getbalance(Skuds)) + message = "Profits erased!" + else: + message = "Only the dungeon master can wipe our profits!" + + whoami.Say(message) + # ---------------------------------------------------------------------------- # Script execution begins here. @@ -236,14 +255,11 @@ else: message = "" if text[0] == 'help' or text[0] == 'yes': - printHelp() + cmd_help() elif text[0] == 'zero-balance': - bank.withdraw(Skuds, bank.getbalance(Skuds)) - message = 'Balance zeroed.' + cmd_zero_balance() elif text[0] == 'profits': - message = 'The Imperial Bank of Skud has made ' \ - + str(bank.getbalance(Skuds) * 0.029394968) \ - + ' pounds sterling in profit to date.' + cmd_show_profits() elif text[0] == 'deposit': if len(text) == 2: