-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathitem.rb
87 lines (73 loc) · 2.18 KB
/
item.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
module Klank
class Item
attr_reader :name
attr_reader :description
attr_reader :symbol
def initialize(game, hash)
@game = game
@name = hash["name"] || ""
@description = hash["description"] || ""
@symbol = hash["symbol"] || ""
@hash = hash
end
def playable()
play = [
"Potion of Greater Healing",
"Greater Skill Boost",
"Flash of Brilliance",
"Potion of Heroism",
"Potion of Healing",
"Potion of Swiftness",
"Potion of Strength",
"Skill Boost",
"Magic Spring"
]
play.any? { |i| i == @name }
end
def play(player)
played = true
if @hash.key?("heal")
player.heal(@hash["heal"])
end
if @hash.key?("skill")
player.skill += @hash["skill"]
end
if @hash.key?("draw")
player.draw(@hash["draw"])
end
if @hash.key?("move")
player.move += @hash["move"]
end
if @hash.key?("attack")
player.attack += @hash["attack"]
end
if @name == "Magic Spring"
played = player.trash_card()
end
if played
@game.broadcast("#{player.name} played #{name}!")
end
played
end
def points()
amount = 0
if @hash.key?("points")
amount = @hash["points"]
end
amount
end
def gain(player)
player.item << self
if @hash.key?("coins")
@game.map.bank += @hash["coins"] # <-- secrets don't count towards initial bank amount
player.collect_coins(@hash["coins"])
end
if @name == "Dragon Egg"
@game.dragon.anger()
end
end
def desc()
"#{@name} | #{@description}"
end
end
end