forked from reedlaw/ruby-mmo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
He's not very smart, but the man has values
- Loading branch information
Chandler Abraham
committed
Apr 11, 2012
1 parent
c8b812a
commit 3b36e98
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Chandler | ||
ONCE_OF_STRENGTH = 50 | ||
def to_s | ||
"*No rest for the wicked*" | ||
end | ||
|
||
def move | ||
if ounce_of_strength_left_in_me? | ||
[:attack, most_wicked_player] | ||
else | ||
[:rest] unless most_wicked_player == self #norest | ||
end | ||
end | ||
|
||
def ounce_of_strength_left_in_me? | ||
stats[:health] >= ONCE_OF_STRENGTH | ||
end | ||
|
||
def most_wicked_player | ||
opponents = Game.world[:players].select{ |player| player != self} | ||
opponents.sort!{|a,b| a.stats[:experience] <=> b.stats[:experience]}.first | ||
end | ||
end |