Permalink
Browse files

Cosmetic fixes

  • Loading branch information...
1 parent 4b261b1 commit 1a0bccb1f1fa9bc876b4fecceb55cea00f0ab945 @gabebw committed Sep 27, 2010
Showing with 14 additions and 11 deletions.
  1. +14 −11 player.rb
View
@@ -1,14 +1,11 @@
require './map'
class Player
- # When we have less than this % health, rest (unless we're not in a safe
- # space)
-
- ATTACK_POWER = 5
- MAX_HEALTH = 20
+ ATTACK_POWER = 5 # Damage warrior deals per turn
+ MAX_HEALTH = 20 # Maximum health of warrior
+ # We want to have at least this % health
MINIMUM_PERCENT_HEALTH = 50
def set_variables!(warrior)
- @warrior = warrior
@previous_health = current_health
# If true, then rest until at max health before continuing
@recuperating = false
@@ -21,9 +18,8 @@ def set_variables!(warrior)
attr_accessor :direction
def play_turn(warrior)
- # warrior.action returns [:latest_action, :direction_it_was_performed]
- set_variables!(warrior) unless @already_set_variables
@warrior = warrior # yes, you have to set this each time
+ set_variables!(warrior) unless @already_set_variables
@map.update!(warrior)
perform_action!(warrior)
@@ -104,7 +100,9 @@ def perform_action!(warrior)
end
end
- # STATE CHANGERS
+ ####################
+ # STATE CHANGERS #
+ ####################
def reverse_direction!
@direction = @map.opposite_direction_of(direction)
@@ -170,7 +168,9 @@ def low_on_health?
percent_health < MINIMUM_PERCENT_HEALTH
end
- # ACCESSORS
+ ###############
+ # ACCESSORS #
+ ###############
def current_health
@warrior.health
@@ -181,7 +181,10 @@ def direction
@direction ||= :backward
end
- # UTILITY
+ #############
+ # UTILITY #
+ #############
+
# Pass in an enemy location to determine how many turns it
# will take to kill it once you're next to it.
def turns_required_to_beat_enemy_at(enemy_location)

0 comments on commit 1a0bccb

Please sign in to comment.