Class: GamesAndRpgParadise::Gamebooks::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/gamebooks/character.rb

Overview

GamesAndRpgParadise::Gamebooks::Character

Instance Method Summary collapse

Constructor Details

#initialize(optional_hash = {}) ⇒ Character

#

initialize

#


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 20

def initialize(
    optional_hash = {}
  )
  reset
  _ = optional_hash
  if _.is_a? Hash
    # ===================================================================== #
    # === :max_stärke
    # ===================================================================== #
    if _.has_key? :max_stärke
      @max_stärke = _[:max_stärke]
    end
    # ===================================================================== #
    # === :current_stärke
    # ===================================================================== #
    if _.has_key? :current_stärke
      @current_stärke = _[:current_stärke]
    end
  end
end

Instance Method Details

#append_to_the_equipment(i) ⇒ Object

#

append_to_the_equipment

#


62
63
64
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 62

def append_to_the_equipment(i)
  @equipment << i
end

#current_stärke?Boolean

#

current_stärke?

#

Returns:

  • (Boolean)


121
122
123
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 121

def current_stärke?
  @current_stärke
end

#equipment?Boolean

#

equipment?

#

Returns:

  • (Boolean)


69
70
71
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 69

def equipment?
  @equipment
end

#glück?Boolean

#

glück?

#

Returns:

  • (Boolean)


55
56
57
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 55

def glück?
  @glück
end

#is_alive?Boolean

#

is_alive?

This only works for the “traditional” gamebooks. For lone-wolf gamebooks we will use another Character-class.

#

Returns:

  • (Boolean)


107
108
109
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 107

def is_alive?
  !(@current_stärke == 0)
end

#is_dead?Boolean

#

is_dead?

#

Returns:

  • (Boolean)


142
143
144
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 142

def is_dead?
  !is_alive?
end

#is_lone_wolf?Boolean

#

is_lone_wolf?

#

Returns:

  • (Boolean)


114
115
116
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 114

def is_lone_wolf?
  false
end

#max_stärke?Boolean

#

max_stärke?

#

Returns:

  • (Boolean)


90
91
92
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 90

def max_stärke?
  @max_stärke
end

#n_gold?Boolean Also known as: gold?

#

n_gold?

#

Returns:

  • (Boolean)


83
84
85
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 83

def n_gold?
  @n_gold
end

#resetObject

#

reset (reset tag)

#


44
45
46
47
48
49
50
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 44

def reset
  @max_stärke = 0
  @current_stärke = 0
  @glück = 5
  @n_gold = 0 # For instance, Kopeken.
  @equipment = []
end

#set_current_stärke(i) ⇒ Object Also known as: set_current_stärkepunkte

#

set_current_stärke

This method will make sure that the current Stärke can never exceed the max Stärke value.

#


131
132
133
134
135
136
137
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 131

def set_current_stärke(i)
  i = i.to_i
  if i > max_stärke?
    i = max_stärke?
  end
  @current_stärke = i
end

#set_max_stärke(i) ⇒ Object

#

set_max_stärke

#


97
98
99
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 97

def set_max_stärke(i)
  @max_stärke = i.to_i
end

#weapons?Boolean

#

weapons?

#

Returns:

  • (Boolean)


76
77
78
# File 'lib/games_and_rpg_paradise/gamebooks/character.rb', line 76

def weapons?
  [] # For now this will simply return an empty Array.
end