Class: GamesParadise::Godmode::Gladiator

Inherits:
Base
  • Object
show all
Defined in:
lib/games_paradise/godmode/gladiator.rb

Overview

GamesParadise::Godmode::Gladiator

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect

Constants inherited from Base

Base::CONTROL_C_CODE, Base::N

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cat, #commandline_arguments?, #efancy, #eparse, #first_argument?, #forestgreen, #gold, #lightblue, #lightgreen, #mediumorchid, #mediumslateblue, #opnn, #peru, #register_sigint, #rev, #royalblue, #set_commandline_arguments, #sfile, #steelblue, #teal, #tomato, #yellow

Methods included from BaseModule

#cliner, #commandline_arguments?, #first_argument?, #infer_the_namespace, #namespace?, #rename_file, #reset_the_internal_hash, #return_pwd, #set_commandline_arguments

Constructor Details

#initialize(gladiator_name = 'Gladric', is_main_gladiator = true, run_already = true) ⇒ Gladiator

#

initialize

If the second argument, called is_main_gladiator is true, then we have a main gladiator. A merchant may have 1-5 main gladiators and 3-12 workers.

To raise speed from 8 to 9, you must pay 9 training points.

To raise a skill you must invest 2 training points. So you see its much easier to improve skills than attributes. Max attribute is 35 for humans, max skill is 100 although they MAY reach even higher skill.

You get training points either by training, or by doing cool tasks.

#


50
51
52
53
54
55
56
57
58
59
# File 'lib/games_paradise/godmode/gladiator.rb', line 50

def initialize(
    gladiator_name    = 'Gladric',
    is_main_gladiator = true,
    run_already       = true
  )
  reset
  set_name(gladiator_name)
  @is_main_gladiator = is_main_gladiator # der erste is der main gladiator
  run if run_already
end

Instance Attribute Details

#base_costObject (readonly)

Returns the value of attribute base_cost.



30
31
32
# File 'lib/games_paradise/godmode/gladiator.rb', line 30

def base_cost
  @base_cost
end

#gladiator_nameObject

Returns the value of attribute gladiator_name.



29
30
31
# File 'lib/games_paradise/godmode/gladiator.rb', line 29

def gladiator_name
  @gladiator_name
end

#hash_attributesObject (readonly)

Returns the value of attribute hash_attributes.



31
32
33
# File 'lib/games_paradise/godmode/gladiator.rb', line 31

def hash_attributes
  @hash_attributes
end

#hash_skillsObject (readonly)

Returns the value of attribute hash_skills.



32
33
34
# File 'lib/games_paradise/godmode/gladiator.rb', line 32

def hash_skills
  @hash_skills
end

Class Method Details

.[](i = '') ⇒ Object

#

GamesParadise::Godmode::Gladiator[]

#


159
160
161
# File 'lib/games_paradise/godmode/gladiator.rb', line 159

def self.[](i = '')
  new(i)
end

Instance Method Details

#all_namesObject

#

all_names

#


123
124
125
126
127
# File 'lib/games_paradise/godmode/gladiator.rb', line 123

def all_names
  @all_names = NameGenerator.new
  @all_names.sanitize_name_group('west')
  return @all_names
end

#output_gladiator_nameObject

#

output_gladiator_name

#


132
133
134
# File 'lib/games_paradise/godmode/gladiator.rb', line 132

def output_gladiator_name
  e 'The name of the Gladiator is: '+@name
end

#resetObject

#

reset (reset tag)

#


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/games_paradise/godmode/gladiator.rb', line 64

def reset
  super()
  # ======================================================================= #
  # === @hash_attributes
  # ======================================================================= #
  @hash_attributes = {
    str:   10+rand(2),
    dex:   12+rand(2),
    con:   14+rand(2),
    speed:  8+rand(2)
  }
  # ======================================================================= #
  # === @hash_attributes_sum
  # ======================================================================= #
  @hash_attributes_sum = 0
  @hash_attributes.each_pair { | key, value | 
    @hash_attributes_sum += value 
  } 
  @training_points_left = 0
  # This percentage tells us how effectively
  # a gladiator may fight.
  # If he has 100 % wounded, he is dead. 
  # From 80-100% wounded he cant fight. Else
  # the percentage affects how efficiently you 
  # can fight. Also, since this effects every
  # other stat, it can become PERMANENT
  # if he loses an arm for example.
  @percentage_wounded = 0
  @percentage_wounded_min_value = 0
  # ======================================================================= #
  # === @base_cost
  # ======================================================================= #
  @base_cost = 1_000 # in gold coins
  # ======================================================================= #
  # === @hash_skills
  #
  # puts "DEBUG Summe seiner skills: #{@hash_attributes_sum}"
  # Skill 100 means perfect skill. 50 is average but trained
  # 80 means very good.
  # ======================================================================= #
  @hash_skills = {
    sword:     65+rand(16),
    axe:       65+rand(16),
    polearm:   65+rand(16),
    awareness: 20+rand(20),
  }
end

#runObject

#

run (run tag)

#


151
152
153
154
# File 'lib/games_paradise/godmode/gladiator.rb', line 151

def run
  sanitize_data
  output_gladiator_name
end

#sanitize_dataObject

#

sanitize_data

ensure that data is correct here. If min value is lower than wounded value, we set it to new value.

#


142
143
144
145
146
# File 'lib/games_paradise/godmode/gladiator.rb', line 142

def sanitize_data
  if @percentage_wounded < @percentage_wounded_min_value
    @percentage_wounded = @percentage_wounded_min_value
  end     
end

#set_name(i) ⇒ Object

#

set_name

#


115
116
117
118
# File 'lib/games_paradise/godmode/gladiator.rb', line 115

def set_name(i)
  @name = i
  @name = all_names.generate_name_string # hardcore overrule for now.
end