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"}
45 remarklist = [
'Excellent',
'Thank You',
'Thank You',
'Thank You',
'Thank You',
'Great',
'OK',
'Wonderful',
'Swell',
'Dude',
'Big Spender']
46 exclaimlist = [
'Hey',
'Hey',
'Hey',
'Hey',
'Now just a minute',
'AHEM',
'OK...Wait a minute',
'Look chowderhead']
47 buddylist = [
'buddy',
'buddy',
'buddy',
'buddy',
'pal',
'friend',
'friend',
'friend',
'friend',
'dude',
'chum',
'sweetie']
48 whoami=Crossfire.WhoAmI()
49 activator = Crossfire.WhoIsActivator()
52 """ Format a price as a string, giving full coin descriptions. Returns 'no money' if amount is 0. """
56 return Crossfire.CostStringFromValue(amount)
59 while (object.Name !=
'mailbox'):
66 while (object.Name.find(
'silver coin')==-1):
74 '''Standard constructor'''
78 '''Handle the 'help' and 'yes' commands.'''
82 gm =
'You can purchase guild extensions or new desks with the "buy" word.\n'
84 whoami.Say(
'Let me know how much you want to pay. Say pay <amount> <cointype>'
85 +
'\n\tValid coin types are '
86 +
', '.join(CoinTypes)
87 +
'.\nYou can check the balance by saying "balance".\n'
89 +
'I also provide mailscrolls at 10 platinum each, use "mailscroll".')
92 '''Handles buying a guild extension'''
95 whoami.Say(
"Only guild masters can purchase guild extensions and replacement parts.")
102 "TanningDesk":5000*12,
103 "ThaumaturgyDesk":5000*12,
104 "JewelersBench":5000*24,
105 "BowyerBench":5000*10,
109 'AlchemyLab':500000*24,
110 "CrystalRoom":500000*12,
112 "JewelersRoom":500000*24,
113 "ThaumaturgyRoom":500000*12,
118 Cards = [
"Stove",
"Cauldron",
"TanningDesk",
"ThaumaturgyDesk",
"JewelersBench",
"BowyerBench",
"Forge"]
122 path = path.replace(
"mainfloor",
"")
123 SecondFloor = Crossfire.ReadyMap(path +
'secondfloor')
124 ToolShed = Crossfire.ReadyMap(path +
"guild_toolshed")
128 "BBQ": (mymap, 40, 25),
129 "AlchemyLab": (SecondFloor, 22, 12),
130 "CrystalRoom": (SecondFloor, 22, 13),
131 "Tannery": (SecondFloor, 22, 14),
132 "ThaumaturgyRoom": (SecondFloor, 21, 13),
133 "JewelersRoom": (SecondFloor, 21, 14),
134 "Bowyer": (ToolShed, 22, 16),
135 "Smithy": (ToolShed, 23, 16) }
138 help =
"Buy what? Extensions are unlockable areas for your guild. Cards are for replacing missing crafting equipment like caudrons and benches. You can buy:\n"
145 coin = Loc[0].ObjectAt(Loc[1], Loc[2])
157 if not item
in Items.keys():
158 whoami.Say(
"I don't know that item, sorry")
161 Price = Items.get(item)
165 whoami.Say(
"The guild does not have sufficient funds.")
169 card = activator.CreateObject(
'diploma')
171 card.Message =
'This enables you to buy a new ' + item +
' for your guild.'
177 Loc = Rooms.get(item)
178 coin = Loc[0].ObjectAt(Loc[1], Loc[2])
182 whoami.Say(
"The guild already has this expansion!")
185 coin = mymap.CreateObject(
'silvercoin',40,29)
186 coin.Teleport(Loc[0] ,Loc[1], Loc[2])
189 whoami.Say(
"The new room has been unlocked.\n"
193 '''Handle getting a mailscroll for a friend.'''
195 whoami.Say(
'Usage "mailscroll <friend>"')
200 if not log.info(text[1]):
201 whoami.Say(
'I don\'t know %s'%text[1])
207 if activator.PayAmount(priceMailScroll*priceFactor):
208 whoami.Say(
'Here is your mailscroll to %s'%text[1])
209 id = activator.CreateObject(
'scroll')
210 id.Name =
'mailscroll T: '+text[1]+
' F: '+activator.Name
211 id.NamePl =
'mailscrolls T: '+text[1]+
' F: '+activator.Name
214 whoami.Say(
'You need %s platinum for a mailscroll'%priceMailScroll)
217 '''Handle the display of the guild's balance.'''
220 whoami.Say(
"The guild currently has %s on account." %(
formatted_amount(balance)))
223 '''Handle player paying dues to the guild.'''
225 whoami.Say(
"How much ya wanna pay %s?\nYou can specify amounts in "%(random.choice(buddylist)) +
226 ', '.join(i.lower()
for i
in CoinTypes.keys()))
230 currency =
' '.join(text[2:])
231 ucurrency = currency.upper()
232 if not ucurrency
in CoinTypes.keys():
233 whoami.Say(
"Sorry, I don't know what %s are" % currency)
236 conversionfactor = CoinTypes.get(ucurrency)
237 total =
int(cost)*conversionfactor
238 if total
and activator.PayAmount(total):
240 guild.pay_dues(activator.Name,total)
241 whoami.Say(
"%s, %s %s paid to the guild." % (random.choice(remarklist), cost, currency))
246 whoami.Say(
"Uh? Ya wanna trick me, %s." % random.choice(buddylist))
249 if ucurrency.endswith(
'NOTE'):
251 whoami.Say(
"%s, you don't have %s %s%s." % (random.choice(exclaimlist), cost, currency, plural))
253 whoami.Say(
"You don't have any %s, %s." % (currency, random.choice(buddylist)))
257 whoami.Say(
"Only guild masters, masters, and DMs can withdraw funds from the guild.")
263 whoami.Say(
"Usage: withdraw <quantity> {cointype=silver}")
270 Type =
' '.join(text[2:])
274 if not Type.upper()
in CoinTypes.keys():
275 whoami.Say(
"Sorry, I have no clue what %s are"%Type)
278 Value = CoinTypes.get(Type.upper())
280 if Amount*Value <= balance:
281 message = (
str(Amount))
282 message +=
" " + Type +
" withdrawn.\nYour new present balance is "
284 id = activator.CreateObject(ArchType.get(Type.upper()))
294 '''Handle Jack, the guild helper'''
296 text = Crossfire.WhatIsMessage().
split()
297 command = text[0].lower()
303 if command ==
'mailscroll':
307 if command ==
'balance':
315 if command ==
'withdraw':
319 if command ==
'help' or command ==
'yes':
323 message =
"Howdy %s, paying some guild dues today?" %(random.choice(buddylist))
328 '''Main handling function'''
330 activator.Write(
'dues error, please notify a DM')
335 if whoami.Name ==
'Jack':
339 amount = Crossfire.WhoIsOther().Value * Crossfire.WhoIsOther().Quantity