Module: Bank
- Defined in:
- lib/lotrd/view/bank.rb
Class Method Summary collapse
- .balance ⇒ Object
- .deficit ⇒ Object
- .depositConfirm(dep, gold, balance) ⇒ Object
- .depositMenu ⇒ Object
- .invalid ⇒ Object
- .leave ⇒ Object
- .menu ⇒ Object
- .start ⇒ Object
- .withdrawConfirm(wdw, gold, balance) ⇒ Object
- .withdrawMenu ⇒ Object
Class Method Details
.balance ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lotrd/view/bank.rb', line 29 def balance system 'clear' player = YAML.load(File.read(ENV['HOME'] + "/." + "playerdata.yml")) gold = player.gold balance = player.balance puts "Hazelwood Bank => Balance" + "\n" + "=" * 40 + "\n"*2 puts "You are currently holding #{gold} gold and have #{balance} gold stored with us." sleep(3) ::Bank. end |
.deficit ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/lotrd/view/bank.rb', line 72 def deficit system 'clear' puts "Hazelwood Bank" + "\n" + "=" * 40 + "\n"*2 puts "You do not have enough gold for this transaction!" sleep(3) ::Bank. end |
.depositConfirm(dep, gold, balance) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/lotrd/view/bank.rb', line 64 def depositConfirm(dep, gold, balance) system 'clear' puts "Hazelwood Bank => Deposited Gold" + "\n" + "=" * 40 + "\n"*2 puts "You have successfully deposited #{dep} gold. You are now holding #{gold} gold and have #{balance} gold stored with us." sleep(3) ::Bank. end |
.depositMenu ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/lotrd/view/bank.rb', line 56 def depositMenu system 'clear' puts "Hazelwood Bank => Deposit Gold" + "\n" + "=" * 40 + "\n"*2 puts "How much would you like to deposit?" dep = gets.chomp.to_i ::BankController.deposit(dep) end |
.invalid ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/lotrd/view/bank.rb', line 80 def invalid system 'clear' puts "Hazelwood Bank" + "\n" + "=" * 40 + "\n"*2 puts "That is not a valid amount for this transaction!" sleep(3) ::Bank. end |
.leave ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/lotrd/view/bank.rb', line 88 def leave system 'clear' puts "Hazelwood Bank" + "\n" + "=" * 40 + "\n"*2 puts "Take care out there, #{@player.name.colorize(:yellow)}" sleep(3) ::Town. end |
.menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lotrd/view/bank.rb', line 17 def system 'clear' puts "Hazelwood Bank" + "\n" + "=" * 40 + "\n"*2 prompt = TTY::Prompt.new prompt.select("How can we be of service?") do || .choice 'Check my balance'.colorize(:green), -> {::Bank.balance} .choice 'Make a deposit'.colorize(:yellow), -> {::Bank.depositMenu} .choice 'Make a withdrawal'.colorize(:blue), -> {::Bank.withdrawMenu} .choice 'Leave the bank'.colorize(:red), -> {::Bank.leave} end end |
.start ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/lotrd/view/bank.rb', line 8 def start system 'clear' puts "Hazelwood Bank" + "\n" + "=" * 40 + "\n"*2 @player = YAML.load(File.read(ENV['HOME'] + "/." + "playerdata.yml")) puts "#{@player.name.colorize(:yellow)}, welcome to Hazelwood bank!" sleep(3) end |
.withdrawConfirm(wdw, gold, balance) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/lotrd/view/bank.rb', line 48 def withdrawConfirm(wdw, gold, balance) system 'clear' puts "Hazelwood Bank => Withdrawn Gold" + "\n" + "=" * 40 + "\n"*2 puts "You have successfully withdrawn #{wdw} gold. You are now holding #{gold} gold and have #{balance} gold stored with us." sleep(3) ::Bank. end |
.withdrawMenu ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/lotrd/view/bank.rb', line 40 def withdrawMenu system 'clear' puts "Hazelwood Bank => Withdraw Gold" + "\n" + "=" * 40 + "\n"*2 puts "How much would you like to withdraw?" wdw = gets.chomp.to_i ::BankController.withdraw(wdw) end |