Class: GamesAndRpgParadise::Mud::CharacterCreationProcess
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mud::CharacterCreationProcess
show all
- Includes:
- Colours
- Defined in:
- lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb
Overview
RpgParadise::Mud::CharacterCreationProcess
Constant Summary
collapse
- FORBIDDEN_NAMES =
YAML.load_file(RpgParadise::Mud::FILE_FORBIDDEN_NAMES)
Constants included
from Colours
Colours::WHITE
Instance Method Summary
collapse
-
#assign_age ⇒ Object
# === assign_age ========================================================================= #.
-
#debug ⇒ Object
# === debug ========================================================================= #.
-
#determine_character_name ⇒ Object
# === determine_character_name ========================================================================= #.
-
#hash? ⇒ Boolean
# === hash? ========================================================================= #.
-
#initialize(run_already = true) ⇒ CharacterCreationProcess
constructor
# === initialize ========================================================================= #.
-
#interactive? ⇒ Boolean
# === interactive? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#sanitize_the_gender ⇒ Object
# === sanitize_the_gender ========================================================================= #.
-
#set_interactive ⇒ Object
(also: #is_interactive)
# === set_interactive ========================================================================= #.
-
#store_dataset ⇒ Object
# === store_dataset ========================================================================= #.
Methods included from Colours
#brown, #cfile, #convert_colour, convert_colour, #fancy, #normal, #pink, #red, #yel
Constructor Details
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 40
def initialize(
run_already = true
)
reset
case run_already
when :interactive
is_interactive
end
run if run_already
end
|
Instance Method Details
#assign_age ⇒ Object
181
182
183
184
185
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 181
def assign_age
_ = get_user_input
_ = rand(30)+14 if _ =~ /ran/
return _
end
|
#debug ⇒ Object
172
173
174
175
176
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 172
def debug
opn; e 'Debugging now in '+sfile(__FILE__)
pp self
pp @hash
end
|
#determine_character_name ⇒ Object
#
determine_character_name
#
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 108
def determine_character_name
_ = get_user_input if FORBIDDEN_NAMES.include? _
e 'This name ('+_+') is not allowed. Please pick another name.'
determine_character_name
else
if _ if _.empty? or _ == 'random'
_ = NameGenerator.new._
end
_ = _.capitalize
@hash[:character_name] = _
end
end
end
|
#hash? ⇒ Boolean
101
102
103
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 101
def hash?
@hash
end
|
#interactive? ⇒ Boolean
87
88
89
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 87
def interactive?
@interactive
end
|
#reset ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 57
def reset
@hash = {} @interactive = false
end
|
#run ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 146
def run
if interactive? e 'Welcome to the character creation process.'
e 'What shall be the '+sfancy('name')+rev+' of your '+
'character? [input '+grey('"random"')+rev
e 'or leave blank so that we can auto-generate '+
'a random name for you'
e 'once the gender was defined.]'
result = determine_character_name
if result
opn; e sfancy('Gender')+' [male/female]'
@hash[:gender] = get_user_input
sanitize_the_gender
opn; e sfancy('Age')+' of your character [input "random" for a dice-roll]'
@hash[:age] = assign_age
store_dataset
else
e 'User interrupt - thus, we will not continue.'
exit
end
end
end
|
#sanitize_the_gender ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 71
def sanitize_the_gender
_ = @hash[:gender]
case _
when 'm','1','male','mal' @hash[:gender] = 'male'
when 'f','2','female','fem'
@hash[:gender] = 'female'
else
e 'Setting to male as default.' @hash[:gender] = 'male'
end
end
|
#set_interactive ⇒ Object
Also known as:
is_interactive
94
95
96
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 94
def set_interactive
@interactive = true
end
|
#store_dataset ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/games_and_rpg_paradise/mud/characters/character_creation_process.rb', line 127
def store_dataset
if @hash.empty?
opn; e 'We can not store as our dataset is empty.'
else
saved_characters_location = MUD_YAML_DIRECTORY+'saved_characters/'
mkdir(saved_characters_location)
save_here = saved_characters_location+
@hash[:character_name].downcase.gsub(/ /,'_')+
'.yml'
opn; e 'All done. We will store the result into'
opn; e ' '+sfile(save_here)+'.'
mkdir(MUD_YAML_DIRECTORY)
save_file(YAML.dump(hash?), save_here)
end
end
|