/
big_money_player.rb
54 lines (50 loc) · 1.35 KB
/
big_money_player.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require_relative 'player'
class BigMoneyPlayer < Player
def buy_something
case
when @treasure == 3 && !(@deck.includes("Silver"))
puts "I will buy a Silver"
buy(Silver)
when @treasure == 3 && @deck.includes("Silver")
puts "I will buy a village"
buy(Village)
when (@treasure == 4 || @treasure == 5) &&
(@deck.count("Smithy") <= @deck.count("Village"))
puts "I will buy a smithy"
buy(Smithy)
when @treasure == 6 || @treasure == 7
puts "I will buy a gold"
buy(Gold)
when @treasure >= 8
puts "I will buy a province"
buy(Province)
else
puts "I will buy nothing and try to engender pity in my opponents"
end
end
def play_cards
played = false
if(@hand.contains("Smithy") && @actions >= 2)
smithy = @hand.first("Smithy")
smithy.play(self)
@discard_pile << smithy
@actions = @actions - 1
played = true
elsif(@hand.contains("Village"))
village = @hand.first("Village")
village.play(self)
@discard_pile << village
@actions = @actions - 1
played = true
elsif(@hand.contains("Smithy"))
smithy = @hand.first("Smithy")
smithy.play(self)
@discard_pile << smithy
@actions = @actions - 1
played = true
end
if(@actions > 0 && played)
play_cards
end
end
end