File tree 1 file changed +73
-0
lines changed
1 file changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ module OwningTimeLOL
2
+
3
+ def to_s
4
+ "limekin"
5
+ end
6
+
7
+ def move
8
+
9
+ @players = sort_by_health ( get_alive_players )
10
+ @monsters = sort_by_health ( get_alive_monsters )
11
+
12
+ if self_last_hit?
13
+ return [ :rest ]
14
+ else
15
+ opponent = second_killable_player || second_killable_monster || strongest_player || strongest_monster
16
+ [ :attack , opponent ]
17
+ end
18
+ end
19
+
20
+
21
+ def get_alive_players
22
+ ( Game . world [ :players ] || [ ] ) . select do |player |
23
+ player . alive? and player != self
24
+ end
25
+ end
26
+
27
+ def get_alive_monsters
28
+ ( Game . world [ :monsters ] || [ ] ) . select do |monster |
29
+ monster . alive?
30
+ end
31
+ end
32
+
33
+ def sort_by_health ( opponents )
34
+ opponents . sort_by do |opponent |
35
+ fs ( opponent , :max_health )
36
+ end
37
+ end
38
+
39
+ def self_last_hit?
40
+ ( @players + @monsters ) . any? do |opponent |
41
+ fs ( opponent , :strength ) - fs ( self , :defense ) /2 == @health
42
+ end
43
+ end
44
+
45
+ def second_killable_player
46
+ killable_players = @players . select do |player |
47
+ fs ( player , :health ) == fs ( self , :strength ) - fs ( player , :defense ) /2
48
+ end || [ ]
49
+ killable_players [ 1 ]
50
+ end
51
+
52
+ def second_killable_monster
53
+ killable_monster = @monsters . select do |monster |
54
+ fs ( monster , :health ) == fs ( self , :strength ) - fs ( monster , :defense ) /2
55
+ end || [ ]
56
+ killable_monster [ 1 ]
57
+
58
+ end
59
+
60
+ def strongest_player
61
+ @players [ 0 ]
62
+ end
63
+
64
+ def strongest_monster
65
+ @monsters [ 0 ]
66
+ end
67
+
68
+ def fs ( opponent , attr )
69
+ opponent . stats [ attr ]
70
+ end
71
+
72
+
73
+ end
You can’t perform that action at this time.
0 commit comments