fixed problems caused by svn up.

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13758 282e977c-c81d-0410-88c4-b93c2d0d6712
master
Alestan 2010-09-07 02:59:33 +00:00
parent bd21022abc
commit 89eff881a4
1 changed files with 127 additions and 215 deletions

View File

@ -1,4 +1,5 @@
#Script for paying Guild Dues
"""
Script for paying Guild Dues
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -15,12 +16,11 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# author:Avion temitchell@sourceforge.net
"""
import Crossfire,CFGuilds,CFItemBroker,random,string,sys,CFBank,CFMail,CFLog
from CFGuildClearance import CheckClearance
log = CFLog.CFLog()
priceMailScroll = 5
priceFactor = 50
CoinTypes={"SILVER":1,"GOLD":10,"PLATINUM":50,"JADE":5000,"AMBERIUM":500000, "IMPERIAL NOTE":10000,"TEN IMPERIAL NOTE":100000,"ONE HUNDRED IMPERIAL NOTE":1000000}
ArchType={"SILVER":"silvercoin","GOLD":"goldcoin","PLATINUM":"platinacoin","JADE":"jadecoin","AMBERIUM":"ambercoin", "IMPERIAL NOTE":"imperial","TEN IMPERIAL NOTE":"imperial10","ONE HUNDRED IMPERIAL NOTE":"imperial100"}
@ -39,238 +39,150 @@ ToolShed=Crossfire.ReadyMap(path+"guild_toolshed")
Rooms={"BBQ":(mymap,40,25),"AlchemyLab":(SecondFloor,22,12),"CrystalRoom":(SecondFloor,22,13),"Tannery":(SecondFloor,22,14),"ThaumaturgyRoom":(SecondFloor,21,13),"JewelrsRoom":(SecondFloor,22,14),"Bowyer":(ToolShed,22,16),"Smithy":(ToolShed,23,16)}
def find_mailbox(object):
while (object.Name != 'mailbox'):
object = object.Above
if not object:
return 0
return object
def FindCoin(object):
while (object.Name.find('silver coin')==-1):
object = object.Above
if not object:
return 0
return object
guildname=Crossfire.ScriptParameters()
bank = CFBank.CFBank(bankdatabase)
accountname=guildname+str(guildname.__hash__())
if (guildname):
if whoami.Name=='Jack':
guild = CFGuilds.CFGuild(guildname)
activator=Crossfire.WhoIsActivator()
X=activator.X
Y=activator.Y
bank = CFBank.CFBank(bankdatabase)
in_guild=CFGuilds.SearchGuilds(activator.Name)
text = Crossfire.WhatIsMessage().split()
if text[0].upper() == 'HELP' or text[0].upper() == 'YES':
message=('Let me know how much you want to pay. Say pay <amount> <cointype>\n\tValid coin types are '+', '.join(CoinTypes)+'.\nYou can also check the balance by saying "balance".\nGuild Masters can also purchase items with the "buy" command.\nI also provide mailscrolls at 10 plat each.')
elif text[0].upper()=="BUY":
try:
Item=text[1]
except:
Item=None
message="Syntax: Buy <item>\n Valid items are: "+', '.join([i +' - '+ str( Items[i]) for i in Items])+'.'
if Item!=None:
if ( not CheckClearance([guildname, "GuildMaster"],activator)):
message="Only guild masters and GMs can buy expansions for the guild."
else:
try:
Price=Items.get(Item)
except:
Item=None
Price=None
message="Syntax: Buy <item>\n Valid items are: "+', '.join(Items)+'.'
if Price!=None:
balance=bank.getbalance(accountname)
if Price<=balance:
Card=Cards.__contains__(Item)
if Card==True:
pack=activator.Map.CreateObject('package', 40, 29)
pack.Name = 'IPO-package F: ACME T: ' + guildname
card=mymap.CreateObject('diploma',40,29)
card.Name=Item
message = "Your card has been ordered and should arrive in the mail shortly."
mailbox=mymap.ObjectAt(12,21)
mailbox=find_mailbox(mailbox)
if mailbox==0:
mailbox=mymap.ObjectAt(30,5)
mailbox=find_mailbox(mailbox)
if mailbox==0:
message+=" The postman couldn't find the mailbox. Please contact a DM to install your mailbox."
else:
cardnew=card.InsertInto(pack)
packnew=pack.InsertInto(mailbox)
bank.withdraw(accountname, Price)
else:
Loc=Rooms.get(Item)
coin=Loc[0].ObjectAt(Loc[1],Loc[2])
coin=FindCoin(coin)
message="The guild already has this expansion!"
if (coin==0):
coin=mymap.CreateObject('silvercoin',40,29)
coin.Teleport(Loc[0],Loc[1],Loc[2])
#activator.Teleport(mymap,X,Y)
bank.withdraw(accountname, Price)
message="The new room has been unlocked.\n"
message+="The guild now has a balance of "
message+=str(bank.getbalance(accountname))+" silver coins."
else:
message="The guild does not have sufficient funds."
elif text[0] == 'mailscroll':
if len(text) == 2:
if log.info(text[1]):
if activator.PayAmount(priceMailScroll*priceFactor*2):
whoami.Say('Here is your mailscroll')
id = activator.Map.CreateObject('scroll', X, Y)
id.Name = 'mailscroll T: '+text[1]+' F: '+activator.Name
id.NamePl = 'mailscrolls T: '+text[1]+' F: '+activator.Name
id.Value = 0
else:
whoami.Say('You need %s platinum for a mailscroll'%priceMailScroll)
else:
whoami.Say('I don\'t know %s'%text[1])
else:
whoami.Say('Usage "mailscroll <friend>"')
elif text[0].upper()=='WITHDRAW':
if (not activator.DungeonMaster==1 and not CheckClearance([guildname,"Master"],activator)):
message="Only guild masters, masters, and DMs can withdraw funds from the guild."
else:
if whoami.Name=='Jack':
guild = CFGuilds.CFGuild(guildname)
activator=Crossfire.WhoIsActivator()
X=activator.X
Y=activator.Y
bank = CFBank.CFBank(bankdatabase)
in_guild=CFGuilds.SearchGuilds(activator.Name)
text = Crossfire.WhatIsMessage().split()
if text[0].upper() == 'HELP' or text[0].upper() == 'YES':
message=('Let me know how much you want to pay. Say pay <amount> <cointype>\n\tValid coin types are '+', '.join(CoinTypes)+'.\nYou can also check the balance by saying "balance".\nGuild Masters can also purchase items with the "buy" command.\nI also provide mailscrolls at 10 plat each.')
elif text[0].upper()=="BUY":
try:
Amount=int(text[1])
if Price!=None:
balance=bank.getbalance(accountname)
if Price<=balance:
Card=False
for i in Cards:
if i == Item:
Card=True
if Card==True:
pack=activator.Map.CreateObject('package', 40, 29)
pack.Name = 'IPO-package F: ACME T: ' + guildname
card=mymap.CreateObject('diploma',40,29)
card.Name=Item
message = "Your card has been ordered and should arrive in the mail shortly."
mailbox=mymap.ObjectAt(12,21)
mailbox=find_mailbox(mailbox)
if mailbox==0:
mailbox=mymap.ObjectAt(30,5)
mailbox=find_mailbox(mailbox)
if mailbox==0:
message+=" The postman couldn't find the mailbox. Please contact a DM to install your mailbox."
else:
cardnew=card.InsertInto(pack)
packnew=pack.InsertInto(mailbox)
bank.withdraw(accountname, Price)
else:
Loc=Rooms.get(Item)
activator.Teleport(Loc[0],Loc[1],Loc[2])
activator.Teleport(mymap,X,Y)
bank.withdraw(accountname, Price)
else:
message="The guild does not have sufficient funds. " +str(Price)+" jade needed."
elif text[0] == 'mailscroll':
if len(text) == 2:
if log.info(text[1]):
if activator.PayAmount(priceMailScroll*priceFactor*2):
whoami.Say('Here is your mailscroll')
id = activator.Map.CreateObject('scroll', X, Y)
id.Name = 'mailscroll T: '+text[1]+' F: '+activatorname
id.NamePl = 'mailscrolls T: '+text[1]+' F: '+activatorname
id.Value = 0
else:
whoami.Say('You need %s platinum for a mailscroll'%priceMailScroll)
else:
whoami.Say('I don\'t know %s'%text[1])
else:
whoami.Say('Usage "mailscroll <friend>"')
elif text[0].upper()=='WITHDRAW':
if activator.DungeonMaster==1:
ClearanceApproved=5
else:
if guild.info(activatorname)!=0:
text1=string.split(str(guild.info(activatorname)))
ClearanceApproved = (text1[5])
whoami.Say(repr(ClearanceApproved))
if ClearanceApproved=="'GuildMaster',":
ClearanceApproved=5
whoami.Say("Welcome Guild Master")
elif ClearanceApproved=="'Master',":
ClearanceApproved=4
else:
ClearanceApproved=0
else:
ClearanceApproved=0
if ClearanceApproved<4:
Item=text[1]
except:
message = "Syntax: Withdraw <quantity> {coin type=Silver}"
Amount=None
if Amount!=None:
balance=bank.getbalance(accountname)
try:
Type=' '.join(text[2:])
except:
Type="Silver"
Value=CoinTypes.get(Type.upper(),1)
if Value==1:
Type="SILVER"
if Amount*Value <= balance:
message=(str(Amount))
message+=" "+Type+" withdrawn.\nYour new present balance is "
id = activator.Map.CreateObject(ArchType.get(Type.upper()), activator.X, activator.Y)
bank.withdraw(accountname, Amount*Value)
CFItemBroker.Item(id).add(Amount)
activator.Take(id)
message+=str(bank.getbalance(accountname))+"."
Item=None
message="Syntax: Buy <item>\n Valid items are: "+', '.join([i +' - '+ str( Items[i]) for i in Items])+'.'
if Item!=None:
if ( not CheckClearance([guildname, "GuildMaster"],activator)):
message="Only guild masters and GMs can buy expansions for the guild."
else:
message="You only have "+str(bank.getbalance(accountname))+" silver coins on account."
elif text[0].upper()=='BALANCE':
balance=bank.getbalance(accountname)
message="The guild currently has %s silver coins on deposit" %(str(balance))
elif text[0].upper() == 'PAY':
if len(text)>2:
cost,conversionfactor=text[1],CoinTypes.get(' '.join(text[2:]).upper())
total=int(cost)*conversionfactor
if activator.PayAmount(total):
guild.pay_dues(activator.Name,total)
message = "%s, %s %s paid to the guild." %(random.choice(remarklist),cost, ' '.join(text[2:]))
bank.deposit(accountname, total)
try:
Price=Items.get(Item)
except:
Item=None
Price=None
message="Syntax: Buy <item>\n Valid items are: "+', '.join(Items)+'.'
if Price!=None:
balance=bank.getbalance(accountname)
if Price<=balance:
Card=Cards.__contains__(Item)
if Card==True:
pack=activator.Map.CreateObject('package', 40, 29)
pack.Name = 'IPO-package F: ACME T: ' + guildname
card=mymap.CreateObject('diploma',40,29)
card.Name=Item
message = "Your card has been ordered and should arrive in the mail shortly."
mailbox=mymap.ObjectAt(12,21)
mailbox=find_mailbox(mailbox)
if mailbox==0:
mailbox=mymap.ObjectAt(30,5)
mailbox=find_mailbox(mailbox)
if mailbox==0:
message+=" The postman couldn't find the mailbox. Please contact a DM to install your mailbox."
else:
cardnew=card.InsertInto(pack)
packnew=pack.InsertInto(mailbox)
bank.withdraw(accountname, Price)
else:
Loc=Rooms.get(Item)
coin=Loc[0].ObjectAt(Loc[1],Loc[2])
coin=FindCoin(coin)
message="The guild already has this expansion!"
if (coin==0):
coin=mymap.CreateObject('silvercoin',40,29)
coin.Teleport(Loc[0],Loc[1],Loc[2])
#activator.Teleport(mymap,X,Y)
bank.withdraw(accountname, Price)
message="The new room has been unlocked.\n"
message+="The guild now has a balance of "
message+=str(bank.getbalance(accountname))+" silver coins."
else:
message="The guild does not have sufficient funds."
elif text[0] == 'mailscroll':
if len(text) == 2:
if log.info(text[1]):
if activator.PayAmount(priceMailScroll*priceFactor*2):
whoami.Say('Here is your mailscroll')
id = activator.Map.CreateObject('scroll', X, Y)
id.Name = 'mailscroll T: '+text[1]+' F: '+activator.Name
id.NamePl = 'mailscrolls T: '+text[1]+' F: '+activator.Name
id.Value = 0
else:
whoami.Say('You need %s platinum for a mailscroll'%priceMailScroll)
else:
whoami.Say('I don\'t know %s'%text[1])
else:
if cost > 1:
message ="%s, you don't have %s %ss." %(random.choice(exclaimlist),cost,' '.join(text[2:]))
whoami.Say('Usage "mailscroll <friend>"')
elif text[0].upper()=='WITHDRAW':
if (not activator.DungeonMaster==1 and not CheckClearance([guildname,"Master"],activator)):
message="Only guild masters, masters, and DMs can withdraw funds from the guild."
else:
try:
Amount=int(text[1])
except:
message = "Useage: withdraw <quantity> {cointype=Silver}"
Amount=None
if Amount!=None:
balance=bank.getbalance(accountname)
try:
Type=' '.join(text[2:])
except:
Type="Silver"
Value=CoinTypes.get(Type.upper(),1)
if Value==1:
Type="SILVER"
if Amount*Value <= balance:
message=(str(Amount))
message+=" "+Type+" withdrawn.\nYour new present balance is "
id = activator.Map.CreateObject(ArchType.get(Type.upper()), activator.X, activator.Y)
bank.withdraw(accountname, Amount*Value)
CFItemBroker.Item(id).add(Amount)
activator.Take(id)
message+=str(bank.getbalance(accountname))+"."
else:
message="You only have "+str(bank.getbalance(accountname))+" silver coins on account."
elif text[0].upper()=='BALANCE':
balance=bank.getbalance(accountname)
message="The guild currently has %s silver coins on deposit" %(str(balance))
elif text[0].upper() == 'PAY':
if len(text)>2:
cost,conversionfactor=text[1],CoinTypes.get(' '.join(text[2:]).upper())
total=int(cost)*conversionfactor
if activator.PayAmount(total):
guild.pay_dues(activator.Name,total)
message = "%s, %s %s paid to the guild." %(random.choice(remarklist),cost, ' '.join(text[2:]))
bank.deposit(accountname, total)
else:
message ="You don't have any %s, %s." %(' '.join(text[2:]),random.choice(buddylist))
if cost > 1:
message ="%s, you don't have %s %ss." %(random.choice(exclaimlist),cost,' '.join(text[2:]))
else:
message ="You don't have any %s, %s." %(' '.join(text[2:]),random.choice(buddylist))
else:
message = "How much ya wanna pay %s?" %(random.choice(buddylist))
else:
message = "How much ya wanna pay %s?" %(random.choice(buddylist))
message = "Howdy %s, paying some guild dues today?" %(random.choice(buddylist))
whoami.Say(message)
else:
message = "Howdy %s, paying some guild dues today?" %(random.choice(buddylist))
whoami.Say(message)
else:
bank.deposit(accountname, 5000)
bank.deposit(accountname, 5000)
else:
activator.Write('dues Error, please notify a DM')
activator.Write('dues Error, please notify a DM')