Class: GamesAndRpgParadise::CharGenerator

Inherits:
Object
  • Object
show all
Includes:
Colours::E, StdDsa
Defined in:
lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb

Overview

GamesAndRpgParadise::CharGenerator

Constant Summary collapse

N =
"\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(which_rpg_type = :dsa4) ⇒ CharGenerator

#

initialize

CharGenerator.new(:dsa4).generate_char

#


32
33
34
35
36
37
38
39
40
41
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 32

def initialize(
    which_rpg_type = :dsa4
  )
  @char_string = '' # keeps char info as string form
  @any_dice = AnyDice.new
  reset
  which_rpg_type = :dsa4 if which_rpg_type.nil?
  check_for_which_rpg_type(which_rpg_type.to_sym)
  generate_char
end

Instance Attribute Details

#hash_attributesObject (readonly)

Returns the value of attribute hash_attributes.



25
26
27
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 25

def hash_attributes
  @hash_attributes
end

Instance Method Details

#char_string?Boolean Also known as: char_string, string

#

char_string?

#

Returns:

  • (Boolean)


141
142
143
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 141

def char_string?
  @char_string
end

#check_for_which_rpg_type(which_rpg_type) ⇒ Object

#

check_for_which_rpg_type

Check for the RPG system. The dice can be found in: bl $RUBY_STD/rpg

#


57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 57

def check_for_which_rpg_type(which_rpg_type)
  case which_rpg_type
  when :dnd, :dungeons, :adnd
    @rpg_type = :dnd
  when :dsa, :dsa3
    @rpg_type = :dsa3
  when :dsa4
    @rpg_type = :dsa4
  else
    @rpg_type = :dsa4
  end
end

#displayObject

#

display

#


163
164
165
166
167
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 163

def display
  cliner if use_cliner?
  e @char_string
  cliner if use_cliner?
end

#generate_charObject

#

generate_char

$RUBY_RPG/char_generator.rb
bl $RUBY_MUD/std_name_generator.rb
#


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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 76

def generate_char
  case @rpg_type
  # ===================================================================== #
  # DSA TAG
  # ===================================================================== #
  when :dsa4, :dsa3 # hmmmmmmmmm
    @any_dice.determine_range('8-18')
    new_person = NameGenerator.new('tai', 1) # bl $RUBY_MUD/std_name_generator.rb
    @name   = new_person.full_name
    @gender = new_person.gender

    add_to_char_string 'Name: '+@name
    add_to_char_string 'Geschlecht: '+new_person.gender
    add_to_char_string 'Rasse: '+new_person.race
    add_to_char_string 'Profession: Krieger' #+new_person.gender

    @ha[:mu] = @any_dice.calc_complex.to_s
      add_to_char_string 'MU: ' + @ha[:mu]
    @ha[:kl] = @any_dice.calc_complex.to_s
      add_to_char_string 'KL: ' + @ha[:kl]
    @ha[:in] = @any_dice.calc_complex.to_s
      add_to_char_string 'IN: ' + @ha[:in]
    @ha[:ca] = @any_dice.calc_complex.to_s
      add_to_char_string 'CH: ' + @ha[:ca]
    @ha[:ff] = @any_dice.calc_complex.to_s
      add_to_char_string 'FF: ' + @ha[:ff]
    @ha[:ge] = @any_dice.calc_complex.to_s
      add_to_char_string 'GE: ' + @ha[:ge]
    @ha[:ko] = @any_dice.calc_complex.to_s
      add_to_char_string 'KO: ' + @ha[:ko]
    @ha[:kk] = @any_dice.calc_complex.to_s
      add_to_char_string 'KK: ' + @ha[:kk]
      add_to_char_string N # spacer macht das ganze netter :P
    @ha[:le] = @any_dice.calc_complex.to_s
      add_to_char_string 'LE: ' + @ha[:le]
    @ha[:au] = @any_dice.calc_complex.to_s
      add_to_char_string 'AU: ' + @ha[:au]
      # AT Basiswert: (M+G+K) / 5
      add_to_char_string 'AT-BAS ('+FORMEL_AT_BAS+'): '+
        ( (@ha[:mu].to_i+@ha[:ge].to_i+@ha[:kk].to_i) / 5.0).round.to_i.to_s
      # PA Basiswert: (I+G+K) / 5
      add_to_char_string 'PA-BAS ('+FORMEL_PA_BAS+'): '+
        ( (@ha[:in].to_i+@ha[:ge].to_i+@ha[:kk].to_i) / 5.0).round.to_i.to_s
      # FK Basiswert: (I+F+K) / 5
      add_to_char_string 'FK-BAS ('+FORMEL_FK_BAS+'): '+
        ( (@ha[:in].to_i+@ha[:ff].to_i+@ha[:kk].to_i) / 5.0).round.to_i.to_s
  when :dnd
    @any_dice.determine_range('3-18')
    new_person = NameGenerator.new('gobbo', 1)
    add_to_char_string 'Name: '+new_person.full_name
    add_to_char_string 'Geschlecht: '+new_person.gender
    add_to_char_string 'STR: '+@any_dice.calc_complex.to_s
    add_to_char_string 'DEX: '+@any_dice.calc_complex.to_s
    add_to_char_string 'INT: '+@any_dice.calc_complex.to_s
    add_to_char_string 'CHA: '+@any_dice.calc_complex.to_s
    add_to_char_string 'WIS: '+@any_dice.calc_complex.to_s
    add_to_char_string 'CON: '+@any_dice.calc_complex.to_s
  else
    add_to_char_string 'NOT FOUND'
  end
end

#resetObject

#

reset

#


46
47
48
49
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 46

def reset
  @ha = @hash_attributes = {} # this hash will store content
  @use_cliner = true
end

#use_cliner?Boolean

#

use_cliner?

#

Returns:

  • (Boolean)


156
157
158
# File 'lib/games_and_rpg_paradise/utility_scripts/char_generator/char_generator.rb', line 156

def use_cliner?
  @use_cliner
end