Class: BloodChalice::Knight
- Inherits:
-
Object
- Object
- BloodChalice::Knight
- Includes:
- ArtificialIntelligence, Movable, TileValues
- Defined in:
- lib/bloodchalice/knight.rb
Constant Summary collapse
- MAX_LIFE =
5
- SPEED =
3
- ATTACK =
1
- VISION =
6
- MAXBLOOD =
1
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.
-
#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
-
#initialize(options = {}) ⇒ Knight
constructor
A new instance of Knight.
- #reacts_to(tile) ⇒ Object
- #to_s ⇒ Object
Methods included from ArtificialIntelligence
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 = {}) ⇒ Knight
Returns a new instance of Knight.
15 16 17 18 19 20 21 22 23 |
# File 'lib/bloodchalice/knight.rb', line 15 def initialize( = {}) @position = [:position] @map = [:map] @game = [:game] @life = MAX_LIFE @blood = MAXBLOOD @value = 'K' @speed = SPEED end |
Instance Attribute Details
#blood ⇒ Object
Returns the value of attribute blood.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def blood @blood end |
#game ⇒ Object
Returns the value of attribute game.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def game @game end |
#life ⇒ Object
Returns the value of attribute life.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def life @life end |
#map ⇒ Object
Returns the value of attribute map.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def map @map end |
#position ⇒ Object
Returns the value of attribute position.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def position @position end |
#speed ⇒ Object
Returns the value of attribute speed.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def speed @speed end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/bloodchalice/knight.rb', line 7 def value @value end |
Instance Method Details
#reacts_to(tile) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bloodchalice/knight.rb', line 25 def reacts_to(tile) if tile.wall? return :stop elsif tile.empty? return :move elsif tile.player? tile.hit(ATTACK) return :fight elsif tile.zombie? tile.hit(ATTACK) return :fight end end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/bloodchalice/knight.rb', line 39 def to_s @value.to_s end |