Class: BloodChalice::Player
- Inherits:
-
Object
- Object
- BloodChalice::Player
- Includes:
- Movable, TileValues
- Defined in:
- lib/bloodchalice/player.rb
Constant Summary collapse
- MAX_LIFE =
100
- SPEED =
7
- ATTACK =
3
- VISION =
10
Constants included from Movable
Instance Attribute Summary collapse
-
#blood ⇒ Object
Returns the value of attribute blood.
-
#game ⇒ Object
Returns the value of attribute game.
-
#life ⇒ Object
Returns the value of attribute life.
-
#map ⇒ Object
Returns the value of attribute map.
-
#moves ⇒ Object
Returns the value of attribute moves.
-
#number ⇒ Object
Returns the value of attribute number.
-
#position ⇒ Object
Returns the value of attribute position.
-
#speed ⇒ Object
Returns the value of attribute speed.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #bite(human) ⇒ Object
- #dead? ⇒ Boolean
- #fight(enemy) ⇒ Object
-
#initialize(options = {}) ⇒ Player
constructor
A new instance of Player.
- #pour_blood(chalice) ⇒ Object
- #reacts_to(tile) ⇒ Object
- #to_s ⇒ Object
Methods included from TileValues
#chalice?, #empty?, #knight?, #peasant?, #player?, #wall?, #zombie?
Methods included from Movable
#hit, #move, #move!, #moves?, #reactions, #reset_moves
Constructor Details
#initialize(options = {}) ⇒ Player
Returns a new instance of Player.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bloodchalice/player.rb', line 13 def initialize( = {}) @position = [:position] @value = @number = [:number] @map = [:map] @game = [:game] @life = MAX_LIFE @moves = SPEED @blood = 0 @speed = SPEED end |
Instance Attribute Details
#blood ⇒ Object
Returns the value of attribute blood.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def blood @blood end |
#game ⇒ Object
Returns the value of attribute game.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def game @game end |
#life ⇒ Object
Returns the value of attribute life.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def life @life end |
#map ⇒ Object
Returns the value of attribute map.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def map @map end |
#moves ⇒ Object
Returns the value of attribute moves.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def moves @moves end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def number @number end |
#position ⇒ Object
Returns the value of attribute position.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def position @position end |
#speed ⇒ Object
Returns the value of attribute speed.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def speed @speed end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/bloodchalice/player.rb', line 6 def value @value end |
Instance Method Details
#bite(human) ⇒ Object
54 55 56 57 |
# File 'lib/bloodchalice/player.rb', line 54 def bite(human) human.bited @blood += 1 end |
#dead? ⇒ Boolean
59 60 61 |
# File 'lib/bloodchalice/player.rb', line 59 def dead? life < 1 end |
#fight(enemy) ⇒ Object
50 51 52 |
# File 'lib/bloodchalice/player.rb', line 50 def fight(enemy) enemy.hit(ATTACK) end |
#pour_blood(chalice) ⇒ Object
45 46 47 48 |
# File 'lib/bloodchalice/player.rb', line 45 def pour_blood(chalice) chalice.blood += @blood @blood = 0 end |
#reacts_to(tile) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bloodchalice/player.rb', line 24 def reacts_to(tile) if tile.wall? return :stop elsif tile.player? return :stop elsif tile.peasant? bite(tile) return :fight elsif tile.zombie? fight(tile) return :fight elsif tile.knight? fight(tile) return :fight elsif tile.chalice? pour_blood(tile) elsif tile.empty? return :move end end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/bloodchalice/player.rb', line 63 def to_s @number.to_s end |