diff --git a/darcap/darcap/shops/bank_darcap b/darcap/darcap/shops/bank_darcap index 92829b6bd..739e02821 100644 --- a/darcap/darcap/shops/bank_darcap +++ b/darcap/darcap/shops/bank_darcap @@ -9,7 +9,7 @@ enter_y 16 msg Created: 1993-10-10 skud the great (tvangod@ecst.csuchico.edu) Idea credited to Eric Mehlhaff. -Modified: 2012-09-03 Rick Tanner +Modified: 2017-07-26 Kevin Zheng endmsg end arch cobblestones2 @@ -3091,18 +3091,11 @@ x 17 y 3 end arch depositbox -name Deposit Box x 17 y 3 -arch event_apply -name Apply -title Python -slaying /python/IPO/banksay.py -end arch event_close -name Close title Python -slaying /python/IPO/banksay.py +slaying /python/items/deposit_box.py end end arch dungeon_magic @@ -3449,10 +3442,7 @@ x 19 y 3 end arch sign_w -name ATM -msg -Note. There is a service charge of 1% placed on deposits and withdrawls. -endmsg +name deposit box x 19 y 3 end diff --git a/dragonisland/shops/bank_stoneville b/dragonisland/shops/bank_stoneville index 073798126..c5d9cf71c 100644 --- a/dragonisland/shops/bank_stoneville +++ b/dragonisland/shops/bank_stoneville @@ -8,7 +8,7 @@ enter_x 10 enter_y 11 msg Created: 2012-09-03 Rick Tanner -Modified: 2014-10-04 Kevin Zheng +Modified: 2017-07-26 Kevin Zheng endmsg end arch grass_only @@ -1387,7 +1387,7 @@ x 10 y 9 end arch sign_e -name ATM +name deposit box x 10 y 9 end @@ -1544,18 +1544,11 @@ x 11 y 9 end arch depositbox -name Deposit Box x 11 y 9 -arch event_apply -name Apply -title Python -slaying /python/IPO/banksay.py -end arch event_close -name Close title Python -slaying /python/IPO/banksay.py +slaying /python/items/deposit_box.py end end arch dungeon_magic diff --git a/editor/pickmaps/indoor b/editor/pickmaps/indoor index 0fcc4ab6c..f330825cc 100644 --- a/editor/pickmaps/indoor +++ b/editor/pickmaps/indoor @@ -5,7 +5,7 @@ width 7 height 20 msg Created: 2002-08-28 -Modified: 2009-07-12 Andreas Kirschbaum +Modified: 2017-07-26 Kevin Zheng endmsg end arch pentagram @@ -135,6 +135,10 @@ end arch depositbox x 2 y 9 +arch event_close +title Python +slaying /python/items/deposit_box.py +end end arch dresser x 2 diff --git a/pup_land/lone_town/bank b/pup_land/lone_town/bank index c00257db5..58d0154c3 100644 --- a/pup_land/lone_town/bank +++ b/pup_land/lone_town/bank @@ -8,7 +8,7 @@ enter_x 9 enter_y 18 msg Created: 1996-01-29 -Modified: 2011-12-05 Rick Tanner +Modified: 2017-07-26 Kevin Zheng endmsg end arch afloor_right @@ -299,18 +299,11 @@ x 1 y 18 end arch depositbox -name Deposit Box x 1 y 18 -arch event_apply -name Apply -title Python -slaying /python/IPO/banksay.py -end arch event_close -name Close title Python -slaying /python/IPO/banksay.py +slaying /python/items/deposit_box.py end end arch afloor_right @@ -471,10 +464,7 @@ x 2 y 18 end arch sign_w -name ATM -msg -Note. A service charge of 1% is placed on deposits and withdrawals. -endmsg +name deposit box x 2 y 18 end diff --git a/python/IPO/banksay.py b/python/IPO/banksay.py index d961c4a21..ec389f8b5 100644 --- a/python/IPO/banksay.py +++ b/python/IPO/banksay.py @@ -2,7 +2,7 @@ Created by: Joris Bontje This module implements banking in Crossfire. It provides the 'say' event for -bank tellers, as well as a deposit box for quickly depositing money. +bank tellers. """ import random @@ -70,14 +70,6 @@ def getExchangeRate(coinName): else: return None -def get_inventory(obj): - """An iterator for a given object's inventory.""" - current_item = obj.Inventory - while current_item != None: - next_item = current_item.Below - yield current_item - current_item = next_item - def do_deposit(player, amount): """Deposit the given amount for the player.""" with CFBank.open() as bank: @@ -85,15 +77,6 @@ def do_deposit(player, amount): whoami.Say("%s credited to your account." \ % Crossfire.CostStringFromValue(amount)) -def deposit_box_close(): - """Find the total value of items in the deposit box and deposit.""" - total_value = 0 - for obj in get_inventory(whoami): - if obj.Name != 'Apply' and obj.Name != 'Close': - total_value += obj.Value * obj.Quantity - obj.Teleport(activator.Map, 15, 3) - do_deposit(activator, total_value) - def cmd_help(): """Print a help message for the player.""" whoami.Say("The Bank of Skud can help you keep your money safe. In addition, you will be able to access your money from any bank in the world! What would you like to do?") @@ -192,14 +175,8 @@ def main_employee(): whoami.Say("Hello, what can I help you with today?") Crossfire.AddReply("learn", "I want to learn how to use the bank.") -# Find out if the script is being run by a deposit box or an employee. -if whoami.Name.find('Deposit Box') > -1: - ScriptParm = Crossfire.ScriptParameters() - if ScriptParm == 'Close': - deposit_box_close() -else: - Crossfire.SetReturnValue(1) - try: - main_employee() - except ValueError: - whoami.Say("I don't know how much money that is.") +Crossfire.SetReturnValue(1) +try: + main_employee() +except ValueError: + whoami.Say("I don't know how much money that is.") diff --git a/python/items/deposit_box.py b/python/items/deposit_box.py new file mode 100644 index 000000000..e89f6a183 --- /dev/null +++ b/python/items/deposit_box.py @@ -0,0 +1,27 @@ +import CFBank +import Crossfire + +activator = Crossfire.WhoIsActivator() +whoami = Crossfire.WhoAmI() + +def get_inventory(obj): + """An iterator for a given object's inventory.""" + current_item = obj.Inventory + while current_item != None: + next_item = current_item.Below + yield current_item + current_item = next_item + +def deposit_box_close(): + """Find the total value of items in the deposit box and deposit.""" + total_value = 0 + for obj in get_inventory(whoami): + if obj.Name != 'event_close': + total_value += obj.Value * obj.Quantity + obj.Remove() + with CFBank.open() as bank: + bank.deposit(activator.Name, total_value) + whoami.Say("%s credited to your account." \ + % Crossfire.CostStringFromValue(total_value)) + +deposit_box_close() diff --git a/santo_dominion/shops/bank_santodominion b/santo_dominion/shops/bank_santodominion index ada985b7c..6849c56e1 100644 --- a/santo_dominion/shops/bank_santodominion +++ b/santo_dominion/shops/bank_santodominion @@ -9,7 +9,7 @@ enter_y 16 msg Created: 1993-10-10 skud the great (tvangod@ecst.csuchico.edu) Idea credited to Eric Mehlhaff. -Modified: 2012-08-30 Rick Tanner +Modified: 2017-07-26 Kevin Zheng endmsg end arch grass_only @@ -3227,18 +3227,11 @@ x 18 y 9 end arch depositbox -name Deposit Box x 18 y 9 -arch event_apply -name Apply -title Python -slaying /python/IPO/banksay.py -end arch event_close -name Close title Python -slaying /python/IPO/banksay.py +slaying /python/items/deposit_box.py end end arch dungeon_magic @@ -3429,10 +3422,7 @@ x 19 y 9 end arch sign_w -name ATM -msg -Note. There is a service charge of 1% placed on deposits and withdrawls. -endmsg +name deposit box x 19 y 9 end diff --git a/scorn/shops/bank b/scorn/shops/bank index e420637c3..799120b8d 100644 --- a/scorn/shops/bank +++ b/scorn/shops/bank @@ -9,7 +9,7 @@ enter_y 16 msg Created: 1993-10-10 skud the great (tvangod@ecst.csuchico.edu) Idea credited to Eric Mehlhaff. -Modified: 2015-02-22 Kevin Zheng +Modified: 2017-07-26 Kevin Zheng endmsg outdoor 1 end @@ -1717,13 +1717,11 @@ x 12 y 12 end arch depositbox -name Deposit Box x 12 y 12 arch event_close -name Close title Python -slaying /python/IPO/banksay.py +slaying /python/items/deposit_box.py end end arch dungeon_magic @@ -1910,10 +1908,7 @@ x 13 y 12 end arch sign_w -name Deposit Box -msg -Note: There is a 1% service charge on all deposits. -endmsg +name deposit box x 13 y 12 end