-
Notifications
You must be signed in to change notification settings - Fork 102
/
manchego.rb
51 lines (42 loc) · 993 Bytes
/
manchego.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
module Manchego
def to_s
"Count Manchego"
end
# I AM A VAMPIRE
def alive
false
end
def move
action = if killable_enemies.size > 0
[:attack, killable_enemies.first]
elsif stats[:health] < 90
[:rest]
elsif self == apex_predator
[:attack, weakest_prey]
else
[:attack, apex_predator]
end
return action
end
def players
Game.world[:players]
end
def enemies
players.select { |p| p != self }
end
def apex_predator
players.sort_by { |e| -e.stats[:experience] }.first
end
def weakest_prey
enemies.sort_by { |e| e.stats[:health] }.first
end
def killable_enemies
enemies.select { |enemy| killable?(enemy) }.sort_by { |e| -e.stats[:experience] }
end
def killable?(player)
damage_vs(player) >= player.stats[:health]
end
def damage_vs(player)
stats[:strength] - (player.stats[:defense] / 2)
end
end