Fix guild bank accounts
Use with statement to CFBank.open() so that close() is always correctly called. Change the guild account name to used the fixed string /guilds/ in front of the guild name to avoid hash codes changing between Python versions. DMs will need to manually move guild balances to the new account names.master^2
parent
376dd8683e
commit
0b0bc8440c
|
@ -159,7 +159,7 @@ class GuildDues:
|
||||||
return
|
return
|
||||||
|
|
||||||
Price = Items.get(item)
|
Price = Items.get(item)
|
||||||
bank = CFBank.open()
|
with CFBank.open() as bank:
|
||||||
balance = bank.getbalance(self.accountname)
|
balance = bank.getbalance(self.accountname)
|
||||||
if Price > balance:
|
if Price > balance:
|
||||||
whoami.Say("The guild does not have sufficient funds.")
|
whoami.Say("The guild does not have sufficient funds.")
|
||||||
|
@ -172,7 +172,6 @@ class GuildDues:
|
||||||
card.Value = 0
|
card.Value = 0
|
||||||
bank.withdraw(self.accountname, Price)
|
bank.withdraw(self.accountname, Price)
|
||||||
whoami.Say("Here is your card\nThe guild now has %s on account." %(formatted_amount(bank.getbalance(self.accountname))))
|
whoami.Say("Here is your card\nThe guild now has %s on account." %(formatted_amount(bank.getbalance(self.accountname))))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
Loc = Rooms.get(item)
|
Loc = Rooms.get(item)
|
||||||
|
@ -216,7 +215,7 @@ class GuildDues:
|
||||||
|
|
||||||
def do_balance(self):
|
def do_balance(self):
|
||||||
'''Handle the display of the guild's balance.'''
|
'''Handle the display of the guild's balance.'''
|
||||||
bank = CFBank.open()
|
with CFBank.open() as bank:
|
||||||
balance = bank.getbalance(self.accountname)
|
balance = bank.getbalance(self.accountname)
|
||||||
whoami.Say("The guild currently has %s on account." %(formatted_amount(balance)))
|
whoami.Say("The guild currently has %s on account." %(formatted_amount(balance)))
|
||||||
|
|
||||||
|
@ -240,7 +239,7 @@ class GuildDues:
|
||||||
guild = CFGuilds.CFGuild(self.guildname)
|
guild = CFGuilds.CFGuild(self.guildname)
|
||||||
guild.pay_dues(activator.Name,total)
|
guild.pay_dues(activator.Name,total)
|
||||||
whoami.Say("%s, %s %s paid to the guild." % (random.choice(remarklist), cost, currency))
|
whoami.Say("%s, %s %s paid to the guild." % (random.choice(remarklist), cost, currency))
|
||||||
bank = CFBank.open()
|
with CFBank.open() as bank:
|
||||||
bank.deposit(self.accountname, total)
|
bank.deposit(self.accountname, total)
|
||||||
else:
|
else:
|
||||||
if total == 0:
|
if total == 0:
|
||||||
|
@ -264,7 +263,7 @@ class GuildDues:
|
||||||
whoami.Say("Usage: withdraw <quantity> {cointype=silver}")
|
whoami.Say("Usage: withdraw <quantity> {cointype=silver}")
|
||||||
return
|
return
|
||||||
|
|
||||||
bank = CFBank.open()
|
with CFBank.open() as bank:
|
||||||
balance = bank.getbalance(self.accountname)
|
balance = bank.getbalance(self.accountname)
|
||||||
|
|
||||||
if len(text) > 2:
|
if len(text) > 2:
|
||||||
|
@ -331,15 +330,16 @@ class GuildDues:
|
||||||
activator.Write('dues error, please notify a DM')
|
activator.Write('dues error, please notify a DM')
|
||||||
return
|
return
|
||||||
|
|
||||||
bank = CFBank.open()
|
self.accountname = "/guilds/" + self.guildname
|
||||||
self.accountname = self.guildname + str(self.guildname.__hash__())
|
|
||||||
|
|
||||||
if whoami.Name == 'Jack':
|
if whoami.Name == 'Jack':
|
||||||
self.handle_jack()
|
self.handle_jack()
|
||||||
return
|
return
|
||||||
|
|
||||||
amount = Crossfire.WhoIsOther().Value * Crossfire.WhoIsOther().Quantity
|
amount = Crossfire.WhoIsOther().Value * Crossfire.WhoIsOther().Quantity
|
||||||
|
bank = CFBank.open()
|
||||||
bank.deposit(self.accountname, amount)
|
bank.deposit(self.accountname, amount)
|
||||||
|
bank.close()
|
||||||
|
|
||||||
dues = GuildDues()
|
dues = GuildDues()
|
||||||
dues.handle()
|
dues.handle()
|
||||||
|
|
Loading…
Reference in New Issue