2 Script for paying Guild Dues, and to handle Jack in the mainfloor.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 # author:Avion temitchell@sourceforge.net
20 # Heavily modified by Nicolas Weeger, 2010-11-14
29 from CFGuildClearance
import CheckClearance
38 "IMPERIAL NOTE":10000,
39 "TEN IMPERIAL NOTE":100000,
40 "ONE HUNDRED IMPERIAL NOTE":1000000 }
43 ArchType={
"SILVER":
"silvercoin",
"GOLD":
"goldcoin",
"PLATINUM":
"platinacoin",
"JADE":
"jadecoin",
"AMBERIUM":
"ambercoin",
"IMPERIAL NOTE":
"imperial",
"TEN IMPERIAL NOTE":
"imperial10",
"ONE HUNDRED IMPERIAL NOTE":
"imperial100"}
46 bankdatabase =
"ImperialBank_DB"
48 remarklist = [
'Excellent',
'Thank You',
'Thank You',
'Thank You',
'Thank You',
'Great',
'OK',
'Wonderful',
'Swell',
'Dude',
'Big Spender']
49 exclaimlist = [
'Hey',
'Hey',
'Hey',
'Hey',
'Now just a minute',
'AHEM',
'OK...Wait a minute',
'Look chowderhead']
50 buddylist = [
'buddy',
'buddy',
'buddy',
'buddy',
'pal',
'friend',
'friend',
'friend',
'friend',
'dude',
'chum',
'sweetie']
51 whoami=Crossfire.WhoAmI()
52 activator = Crossfire.WhoIsActivator()
55 """ Format a price as a string, giving full coin descriptions. Returns 'no money' if amount is 0. """
59 return Crossfire.CostStringFromValue(amount)
62 while (object.Name !=
'mailbox'):
69 while (object.Name.find(
'silver coin')==-1):
77 '''Standard constructor'''
81 '''Handle the 'help' and 'yes' commands.'''
85 gm =
'You can purchase guild extensions or new desks with the "buy" word.\n'
87 whoami.Say(
'Let me know how much you want to pay. Say pay <amount> <cointype>'
88 +
'\n\tValid coin types are '
89 +
', '.join(CoinTypes)
90 +
'.\nYou can check the balance by saying "balance".\n'
92 +
'I also provide mailscrolls at 10 platinum each, use "mailscroll".')
95 '''Handles buying a guild extension'''
98 whoami.Say(
"Only guild masters and GMs can buy extensions or new desks for the guild.")
105 "TanningDesk":5000*12,
106 "ThaumaturgyDesk":5000*12,
107 "JewelersBench":5000*24,
108 "BowyerBench":5000*10,
112 'AlchemyLab':500000*24,
113 "CrystalRoom":500000*12,
115 "JewelersRoom":500000*24,
116 "ThaumaturgyRoom":500000*12,
121 Cards = [
"Stove",
"Cauldron",
"TanningDesk",
"ThaumaturgyDesk",
"JewelersBench",
"BowyerBench",
"Forge"]
125 path = path.replace(
"mainfloor",
"")
126 SecondFloor = Crossfire.ReadyMap(path +
'secondfloor')
127 ToolShed = Crossfire.ReadyMap(path +
"guild_toolshed")
131 "BBQ": (mymap, 40, 25),
132 "AlchemyLab": (SecondFloor, 22, 12),
133 "CrystalRoom": (SecondFloor, 22, 13),
134 "Tannery": (SecondFloor, 22, 14),
135 "ThaumaturgyRoom": (SecondFloor, 21, 13),
136 "JewelersRoom": (SecondFloor, 21, 14),
137 "Bowyer": (ToolShed, 22, 16),
138 "Smithy": (ToolShed, 23, 16) }
141 help =
"Buy what?\nYou can buy:\n"
148 coin = Loc[0].ObjectAt(Loc[1], Loc[2])
160 if not item
in Items.keys():
161 whoami.Say(
"I don't know that item, sorry")
164 Price = Items.get(item)
168 whoami.Say(
"The guild does not have sufficient funds.")
172 card = activator.CreateObject(
'diploma')
174 card.Message =
'This enables you to buy a new ' + item +
' for your guild.'
181 Loc = Rooms.get(item)
182 coin = Loc[0].ObjectAt(Loc[1], Loc[2])
186 whoami.Say(
"The guild already has this expansion!")
189 coin = mymap.CreateObject(
'silvercoin',40,29)
190 coin.Teleport(Loc[0] ,Loc[1], Loc[2])
193 whoami.Say(
"The new room has been unlocked.\n"
197 '''Handle getting a mailscroll for a friend.'''
199 whoami.Say(
'Usage "mailscroll <friend>"')
204 if not log.info(text[1]):
205 whoami.Say(
'I don\'t know %s'%text[1])
211 if activator.PayAmount(priceMailScroll*priceFactor):
212 whoami.Say(
'Here is your mailscroll to %s'%text[1])
213 id = activator.CreateObject(
'scroll')
214 id.Name =
'mailscroll T: '+text[1]+
' F: '+activator.Name
215 id.NamePl =
'mailscrolls T: '+text[1]+
' F: '+activator.Name
218 whoami.Say(
'You need %s platinum for a mailscroll'%priceMailScroll)
221 '''Handle the display of the guild's balance.'''
224 whoami.Say(
"The guild currently has %s on account." %(
formatted_amount(balance)))
227 '''Handle player paying dues to the guild.'''
229 whoami.Say(
"How much ya wanna pay %s?\nYou can specify amounts in "%(random.choice(buddylist)) +
230 ', '.join(i.lower()
for i
in CoinTypes.keys()))
234 currency =
' '.join(text[2:])
235 ucurrency = currency.upper()
236 if not ucurrency
in CoinTypes.keys():
237 whoami.Say(
"Sorry, I don't know what %s are" % currency)
240 conversionfactor = CoinTypes.get(ucurrency)
241 total =
int(cost)*conversionfactor
242 if total
and activator.PayAmount(total):
244 guild.pay_dues(activator.Name,total)
245 whoami.Say(
"%s, %s %s paid to the guild." % (random.choice(remarklist), cost, currency))
250 whoami.Say(
"Uh? Ya wanna trick me, %s." % random.choice(buddylist))
253 if ucurrency.endswith(
'NOTE'):
255 whoami.Say(
"%s, you don't have %s %s%s." % (random.choice(exclaimlist), cost, currency, plural))
257 whoami.Say(
"You don't have any %s, %s." % (currency, random.choice(buddylist)))
261 whoami.Say(
"Only guild masters, masters, and DMs can withdraw funds from the guild.")
267 whoami.Say(
"Usage: withdraw <quantity> {cointype=silver}")
274 Type =
' '.join(text[2:])
278 if not Type.upper()
in CoinTypes.keys():
279 whoami.Say(
"Sorry, I have no clue what %s are"%Type)
282 Value = CoinTypes.get(Type.upper())
284 if Amount*Value <= balance:
285 message = (
str(Amount))
286 message +=
" " + Type +
" withdrawn.\nYour new present balance is "
288 id = activator.CreateObject(ArchType.get(Type.upper()))
298 '''Handle Jack, the guild helper'''
300 text = Crossfire.WhatIsMessage().
split()
301 command = text[0].lower()
307 if command ==
'mailscroll':
311 if command ==
'balance':
319 if command ==
'withdraw':
323 if command ==
'help' or command ==
'yes':
327 message =
"Howdy %s, paying some guild dues today?" %(random.choice(buddylist))
332 '''Main handling function'''
334 activator.Write(
'dues error, please notify a DM')
340 if whoami.Name ==
'Jack':
344 amount = Crossfire.WhoIsOther().Value * Crossfire.WhoIsOther().Quantity