Module: Bank

Defined in:
lib/lotrd/view/bank.rb

Class Method Summary collapse

Class Method Details

.balanceObject



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.menu
end

.deficitObject



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.menu
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.menu
end

.depositMenuObject



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

.invalidObject



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.menu
end

.leaveObject



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.menu
end


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lotrd/view/bank.rb', line 17

def menu 
	system 'clear'
 	puts "Hazelwood Bank" + "\n" + "=" * 40 + "\n"*2
	prompt = TTY::Prompt.new
       prompt.select("How can we be of service?") do |menu|
           menu.choice 'Check my balance'.colorize(:green), -> {::Bank.balance}
           menu.choice 'Make a deposit'.colorize(:yellow), -> {::Bank.depositMenu}
           menu.choice 'Make a withdrawal'.colorize(:blue), -> {::Bank.withdrawMenu}
           menu.choice 'Leave the bank'.colorize(:red), -> {::Bank.leave}
	end
end

.startObject



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)
	menu
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.menu
end

.withdrawMenuObject



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