alestan python guild updates

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@12511 282e977c-c81d-0410-88c4-b93c2d0d6712
master
meflin2 2010-02-26 23:04:32 +00:00
parent 614e64549c
commit b0682c5cea
1 changed files with 34 additions and 22 deletions

View File

@ -21,12 +21,19 @@ import CFGuilds
import CFItemBroker import CFItemBroker
import random import random
import string import string
import sys
import CFBank
import CFMail
guildname=Crossfire.ScriptParameters() # 6 is say event guildname=Crossfire.ScriptParameters() # 6 is say event
if (guildname): if (guildname):
guild = CFGuilds.CFGuild(guildname) guild = CFGuilds.CFGuild(guildname)
activator=Crossfire.WhoIsActivator() activator=Crossfire.WhoIsActivator()
in_guild=CFGuilds.SearchGuilds(activator.Name) in_guild=CFGuilds.SearchGuilds(activator.Name)
gbfile="/usr/games/crossfire/share/crossfire/maps/python/guilds/balance.2/%s.txt" %(guildname)#location of the balance of dues paid, where it should go depends on your distribution, uses an absolute path. bankdatabase = "ImperialBank_DB"
bank = CFBank.CFBank(bankdatabase)
@ -52,20 +59,25 @@ if whoami.Name=='Jack':
remarklist = ['Excellent','Thank You','Thank You','Thank You', 'Thank You', 'Great', 'OK', 'Wonderful', 'Swell', 'Dude', 'Big Spender'] remarklist = ['Excellent','Thank You','Thank You','Thank You', 'Thank You', 'Great', 'OK', 'Wonderful', 'Swell', 'Dude', 'Big Spender']
exclaimlist = ['Hey','Hey','Hey','Hey', 'Now just a minute', 'AHEM', 'OK...Wait a minute', 'Look chowderhead'] exclaimlist = ['Hey','Hey','Hey','Hey', 'Now just a minute', 'AHEM', 'OK...Wait a minute', 'Look chowderhead']
buddylist = ['buddy','buddy','buddy','buddy','pal','friend','friend','friend','friend','dude','chum', 'sweetie'] buddylist = ['buddy','buddy','buddy','buddy','pal','friend','friend','friend','friend','dude','chum', 'sweetie']
guildname=Crossfire.ScriptParameters() # 6 is say event
text = Crossfire.WhatIsMessage().split()
guildname=Crossfire.ScriptParameters() # 6 is say event
accountname=guildname+str(guildname.__hash__())
text = Crossfire.WhatIsMessage().split()
if (guildname): if (guildname):
guild = CFGuilds.CFGuild(guildname) guild = CFGuilds.CFGuild(guildname)
cointype = "jadecoin" #What type of token are we using for guild dues? cointype = "jadecoin" #What type of token are we using for guild dues?
object = activator.CheckInventory(cointype) object = activator.CheckInventory(cointype)
if text[0] == 'help' or text[0] == 'yes': if text[0].upper() == 'HELP' or text[0].upper() == 'YES':
message='Let me know how many jade coins you want to pay. Say pay <amount>' message='Let me know how many jade coins you want to pay. Say pay <amount>\nYou can also check the balance by saying "balance".'
elif text[0].upper()=='WITHDRAW':
elif text[0] == 'pay': message='not implemented quite yet...'
elif text[0].upper()=='BALANCE':
balance=bank.getbalance(accountname)
message="The guild currently has %s Jade coins on deposit" %(str(balance))
elif text[0].upper() == 'PAY':
if len(text)==2: if len(text)==2:
cost = int(text[1]) cost = int(text[1])
if cost <0: if cost <0:
@ -75,14 +87,14 @@ if whoami.Name=='Jack':
if (pay): if (pay):
guild.pay_dues(activatorname,cost) guild.pay_dues(activatorname,cost)
message = "%s, %d %s paid to the guild." %(random.choice(remarklist),cost, cointype) message = "%s, %d %s paid to the guild." %(random.choice(remarklist),cost, cointype)
guildbalance = open(str(gbfile), 'r') bank.deposit(accountname, cost)
guildbalance2 = guildbalance.read()
guildbalance1 = int(guildbalance2) + int(cost)
guildbalance.close()
guildbalance3 = open(str(gbfile), 'w')
guildbalance4 = str(guildbalance1)
guildbalance3.write(guildbalance4)
print guildbalance4
else: else:
if cost > 1: if cost > 1:
@ -99,8 +111,10 @@ if whoami.Name=='Jack':
else: else:
activator.Write('Guildname Error, please notify a DM') activator.Write('Guildname Error, please notify a DM')
else: else:
guildbalance=open(str(gbfile), 'r') accountname=guildname+str(guildname.__hash__())
balance=guildbalance.read()
balance=bank.getbalance(accountname)
whoami.Say(str(balance))
x = activator.X x = activator.X
y = activator.Y y = activator.Y
amount=int(balance) amount=int(balance)
@ -109,11 +123,9 @@ else:
message = 'No dues have been paid.' message = 'No dues have been paid.'
else: else:
message = '%d dues withdrawn.' % amount message = '%d dues withdrawn.' % amount
bank.withdraw(accountname, amount)
id = activator.Map.CreateObject('jadecoin', x, y) id = activator.Map.CreateObject('jadecoin', x, y)
CFItemBroker.Item(id).add(amount) CFItemBroker.Item(id).add(amount)
activator.Take(id) activator.Take(id)
guildbalance.close()
guildbalance3= open(str(gbfile), 'w')
guildbalance3.write('0')
guildbalance3.close()