Permalink
Browse files

Merge pull request #20 from southpolesteve/master

Adding my character
  • Loading branch information...
2 parents 0662e25 + f01b493 commit b8a0e44da2d4f4f47eaae5f7d6d9a77d59ca1740 @reedlaw reedlaw committed Apr 12, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 players/southpolesteve.rb
@@ -0,0 +1,28 @@
+module SouthPoleSteve
+ def to_s
+ "South Pole Steve"
+ end
+
+ def move
+ return [:attack, killable_opponents.select{ |p| p.stats[:health] < 30 }.pop] unless killable_opponents.empty?
+
+ return [:attack, opponents.first] if opponents.size == 1 || stats[:health] >= 100
+
+ [:rest]
+ end
+
+ private
+
+ def opponents
+ Game.world[:players].select{ |p| p != self }
+ end
+
+ def killable_opponents
+ opponents.select { |o| can_kill?(o) }
+ end
+
+ def can_kill?(player)
+ points = stats[:strength] - (player.stats[:defense] / 2)
+ player.stats[:health] <= points
+ end
+end

0 comments on commit b8a0e44

Please sign in to comment.