Class: Radventure::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/radventure/player.rb

Overview

Represents the ingame player

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ Player

Constructor method

Parameters:

  • level (Integer)

    The starting level of the player



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/radventure/player.rb', line 15

def initialize(level)
  start_creation
  @first_name = create_first_name
  @last_name  = create_last_name
  @nickname   = create_nickname
  @age        = create_age
  @gender     = create_gender
  @race       = create_race
  @class      = create_class
  @level      = level.to_i
  end_creation
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



9
10
11
# File 'lib/radventure/player.rb', line 9

def age
  @age
end

#classObject (readonly)

Returns the value of attribute class.



9
10
11
# File 'lib/radventure/player.rb', line 9

def class
  @class
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



9
10
11
# File 'lib/radventure/player.rb', line 9

def first_name
  @first_name
end

#genderObject (readonly)

Returns the value of attribute gender.



9
10
11
# File 'lib/radventure/player.rb', line 9

def gender
  @gender
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



9
10
11
# File 'lib/radventure/player.rb', line 9

def last_name
  @last_name
end

#levelObject (readonly)

Returns the value of attribute level.



9
10
11
# File 'lib/radventure/player.rb', line 9

def level
  @level
end

#nicknameObject (readonly)

Returns the value of attribute nickname.



9
10
11
# File 'lib/radventure/player.rb', line 9

def nickname
  @nickname
end

#raceObject (readonly)

Returns the value of attribute race.



9
10
11
# File 'lib/radventure/player.rb', line 9

def race
  @race
end

Instance Method Details

#full_nameString

Returns the full name of the player character

Returns:

  • (String)

    The full name of the character



31
32
33
34
35
36
# File 'lib/radventure/player.rb', line 31

def full_name
  r = @first_name
  r += " (#{@nickname})" unless @nickname.empty?
  r += " #{@last_name}" unless @last_name.empty?
  r
end

#greeting_cardString

Returns a full (albeit short) description of the player character

Returns:

  • (String)

    A full (albeit short) description of the character



41
42
43
# File 'lib/radventure/player.rb', line 41

def greeting_card
  "#{full_name}, #{age}yo #{gender} #{race}, #{@class} #{level}"
end