ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/python/IPO/banksay.py
Revision: 1.1.1.1 (vendor branch)
Committed: Sun Feb 5 00:02:09 2006 UTC (18 years, 3 months ago) by root
Content type: text/x-python
Branch: UPSTREAM, MAIN
CVS Tags: post_fixaltar, last_stable, post_fixaltar2, rel-2_82, rel-2_81, rel-2_80, pre_coinconvert, UPSTREAM_2006_03_15, rel-3_0, rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_0, rel-2_1, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, UPSTREAM_2006_02_01, rel-2_53, pre_material_cfarch_normalize_run, rel-2_32, pre_fixconverter, post_coinconvert, pre_fixaltar2, pre_map_rename, UPSTREAM_2006_02_22, rel-2_90, rel-2_92, rel-2_93, rel-2_78, post_fixconverter, pre_fixaltar, rel-2_61, rel-2_43, rel-2_42, rel-2_41, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
Initial Import

File Contents

# Content
1 # Script for say event of Imperial Bank Tellers
2 #
3 # Copyright (C) 2002 Joris Bontje
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 # The author can be reached via e-mail at jbontje@suespammers.org
20 #
21 # Updated to use new path functions in CFPython and broken and
22 # modified a bit by -Todd Mitchell
23
24
25 import Crossfire
26
27 import string
28 import random
29 import CFBank
30 import CFItemBroker
31
32 activator = Crossfire.WhoIsActivator()
33 activatorname = activator.Name
34 whoami = Crossfire.WhoAmI()
35 x = activator.X
36 y = activator.Y
37
38
39 #EASILY SETTABLE PARAMETERS
40 service_charge = 5 # service charges for transactions as a percent
41 exchange_rate = 10000 # exchange rate of imperial to silver (value 1)
42 bankdatabase = "ImperialBank_DB"
43
44 fees = (service_charge/100.0)+1
45 bank = CFBank.CFBank(bankdatabase)
46
47 text = string.split(Crossfire.WhatIsMessage())
48 thanks_message = [ \
49 'Thank you for banking the Imperial Way.', \
50 'Thank you for banking the Imperial Way.', \
51 'Thank you, please come again.', \
52 'Thank you, please come again.', \
53 'Thank you for your patronage.', \
54 'Thank you for your patronage.', \
55 'Thank you, have a nice day.', \
56 'Thank you, have a nice day.', \
57 'Thank you. "Service" is our middle name.', \
58 'Thank you. "Service" is our middle name.', \
59 'Thank you. Hows about a big slobbery kiss?' ]
60
61
62 if text[0] == 'help' or text[0] == 'yes':
63 message ='You can:\n-deposit,-withdraw,-balance,-exchange \
64 \nAll transactions are in imperial notes\n(1 : 1000 gold coins). \
65 \nA service charge of %d percent will be placed on all deposits.' \
66 %(service_charge)
67
68
69 elif text[0] == 'deposit':
70 if len(text) == 2:
71 amount = int(text[1])
72 if amount <= 0:
73 message = 'Usage "deposit <amount in imperials>"'
74 elif amount > 10000:
75 message = 'Sorry, we do not accept more than 10000 imperials for one deposit.'
76 elif activator.PayAmount(int(amount*exchange_rate*fees)):
77 bank.deposit(activatorname, amount)
78 message = '%d platinum received, %d imperials deposited to bank account. %s' \
79 %((amount*(exchange_rate/50))*fees, amount, random.choice(thanks_message))
80 else:
81 message = 'You would need %d gold'%((amount*(exchange_rate/10))*fees)
82 else:
83 message = 'Usage "deposit <amount in imperials>"'
84
85
86 elif text[0] == 'withdraw':
87 if len(text) == 2:
88 amount = int(text[1])
89 if amount <= 0:
90 message = 'Usage "withdraw <amount in imperials>"'
91 elif amount > 10000:
92 message = 'Sorry, we do not accept more than 10000 imperials for one withdraw.'
93 elif bank.withdraw(activatorname, amount):
94 message = '%d imperials withdrawn from bank account. %s' \
95 %(amount, random.choice(thanks_message))
96 id = activator.Map.CreateObject('imperial', x, y)
97 CFItemBroker.Item(id).add(amount)
98 activator.Take(id)
99 else:
100 message = 'Not enough imperials on your account'
101 else:
102 message = 'Usage "withdraw <amount in imperials>"'
103
104
105 elif text[0] == 'exchange':
106 if len(text) == 2:
107 amount = int(text[1])
108 if amount <= 0:
109 message = 'Usage "exchange <amount>" (imperials to platinum coins)'
110 elif amount > 10000:
111 message = 'Sorry, we do not exchange more than 10000 imperials all at once.'
112 else:
113 inv = activator.CheckInventory('imperial')
114 if inv:
115 pay = CFItemBroker.Item(inv).subtract(amount)
116 if pay:
117
118 # Drop the coins on the floor, then try
119 # to pick them up. This effectively
120 # prevents the player from carrying too
121 # many coins.
122 id = activator.Map.CreateObject('platinum coin', x, y)
123 CFItemBroker.Item(id).add(amount*(exchange_rate/50))
124 activator.Take(id)
125
126 message = random.choice(thanks_message)
127 else:
128 message = 'Sorry, you do not have %d imperials'%(amount)
129 else:
130 message = 'Sorry, you do not have any imperials'
131 else:
132 message = 'Usage "exchange <amount>" (imperials to platinum coins)'
133
134
135 elif text[0] == 'balance':
136 balance = bank.getbalance(activatorname)
137 if balance == 1:
138 message = 'Amount in bank: 1 imperial note'
139 elif balance:
140 message = 'Amount in bank: %d imperial notes'%(balance)
141 else:
142 message = 'Sorry, you have no balance.'
143
144
145 else:
146 message = 'Do you need help?'
147
148 whoami.Say(message)
149 Crossfire.SetReturnValue(1)