Class: GamesAndRpgParadise::Mud::NameGenerator
- Defined in:
- lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb
Overview
GamesAndRpgParadise::Mud::NameGenerator
Constant Summary collapse
- CREATE_N_NAMES =
#
CREATE_N_NAMES
#
1
- FILE_CONAPE_NAMES =
#
FILE_CONAPE_NAMES
#
::GamesAndRpgParadise.project_base_dir?+'sarlem/yaml/the_western_realm/maraalar_conape_names.yml'
- FILE_GOBLINOID_NAMES =
#
FILE_GOBLINOID_NAMES
#
::GamesAndRpgParadise.project_base_dir?+'yaml/sarlem/goblinoid_names.yml'
- DEFAULT_NAME_GROUP =
#
DEFAULT_NAME_GROUP
#
'conape'
- DEFAULT_CHOICE =
DEFAULT_NAME_GROUP
- RPG =
"#{HOME_DIRECTORY_OF_USER_X}DATA/RPG/"
- SARLEM =
Else we can use the constant for RPG.
RPG+'SARLEM/'
- SARLEM_YAML =
#
SARLEM_YAML
#
SARLEM+'YAML/'
- FILE_SHADOWRUN_NAMES =
#
FILE_SHADOWRUN_NAMES
bl $RPG/SR/YAML/shadowrun_names.yml
#
::GamesAndRpgParadise.project_yaml_dir?+ 'shadowrun/names.yml'
- SHADOWRUN_NAMES =
#
SHADOWRUN_NAMES
#
YAML.load_file(FILE_SHADOWRUN_NAMES)
- SHADOWRUN_SURNAMES =
#
SHADOWRUN_SURNAMES
#
SHADOWRUN_NAMES['shadowrun_surnames']
- SHADOWRUN_MALE_NAMES =
#
SHADOWRUN_MALE_NAMES
#
SHADOWRUN_NAMES['shadowrun_male_names']
- SHADOWRUN_FEMALE_NAMES =
#
SHADOWRUN_FEMALE_NAMES
#
SHADOWRUN_NAMES['shadowrun_female_names']
- FILE_LANDERAL_NAMES =
#
FILE_LANDERAL_NAMES
#
::GamesAndRpgParadise.project_base_dir?+'sarlem/yaml/greater_landeral_names.yml'
- LANDERAL_NAMES =
#
LANDERAL_NAMES
bl $SARLEM/YAML/greater_landeral_names.yml
#
YAML.load_file(FILE_LANDERAL_NAMES)
- LANDERAL_MALE_NAMES =
LANDERAL_NAMES['greater_landeral_male_names']
- LANDERAL_FEMALE_NAMES =
LANDERAL_NAMES['greater_landeral_female_names']
- LANDERAL_SURNAMES =
LANDERAL_NAMES['greater_landeral_surnames']
- FILE_SANYAL_NAMES =
#
FILE_SANYAL_NAMES
#
::GamesAndRpgParadise.project_base_dir?+'sarlem/yaml/sanyal_names.yml'
- SANYAL_NAMES =
#
SANYAL NAMES
bl $SARLEM/YAML/sanyal_names.yml
#
YAML.load_file(FILE_SANYAL_NAMES)
- SANYAL_MALE_NAMES =
SANYAL_NAMES['sanyal_male_names']
- SANYAL_FEMALE_NAMES =
SANYAL_NAMES['sanyal_female_names']
- SANYAL_SURNAMES =
SANYAL_NAMES['sanyal_surnames']
- CONAPE_NAMES =
#
CONAPE_NAMES
bl $SARLEM/YAML/maraalar_conape_names.yml
#
YAML.load_file(FILE_CONAPE_NAMES)
- CONAPE_MALE_NAMES =
CONAPE_NAMES['conape_male_names']
- CONAPE_FEMALE_NAMES =
CONAPE_NAMES['conape_female_names']
- CONAPE_SURNAMES =
CONAPE_NAMES['conape_surnames']
- ARRAY_AVAILABLE_RACES =
#
ARRAY_AVAILABLE_RACES
#
%w( human dwarf elf )
- GOBLINOID_NAMES =
#
Load the Goblinoid/Gobb Names
bl $SARLEM/YAML/goblinoid_names.yml
#
YAML.load_file(FILE_GOBLINOID_NAMES)
- GOBLINOID_MALE_NAMES =
GOBLINOID_NAMES['goblinoid_male_names']
- GOBLINOID_FEMALE_NAMES =
GOBLINOID_NAMES['goblinoid_female_names']
- GOBLINOID_SURNAMES =
GOBLINOID_NAMES['goblinoid_surnames']
Class Method Summary collapse
-
.[](name = nil, n_times = 1) ⇒ Object
# === Mud::NameGenerator[].
Instance Method Summary collapse
-
#check_input_against_namegroups(i = input?) ) ⇒ Object
# === check_input_against_namegroups.
-
#do_output_the_result ⇒ Object
# === do_output_the_result ========================================================================= #.
-
#first_name? ⇒ Boolean
(also: #first_name)
# === first_name? ========================================================================= #.
-
#full_name? ⇒ Boolean
(also: #full_name, #result, #result?, #_, #name?, #to_s)
# === full_name? ========================================================================= #.
-
#gender? ⇒ Boolean
(also: #gender)
# === gender? ========================================================================= #.
-
#initialize(i = nil, n_names = CREATE_N_NAMES, run_already = true) ⇒ NameGenerator
constructor
# === initialize ========================================================================= #.
-
#input? ⇒ Boolean
(also: #input)
# === input? ========================================================================= #.
-
#menu(i) ⇒ Object
(also: #check_against_menu)
# === menu (menu tag) ========================================================================= #.
-
#n_times? ⇒ Boolean
# === n_times? ========================================================================= #.
-
#open_dataset ⇒ Object
# === open_dataset ========================================================================= #.
-
#race? ⇒ Boolean
(also: #race)
# === race? ========================================================================= #.
-
#report_the_result ⇒ Object
(also: #report)
# === report_the_result ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#return_random_conape_name ⇒ Object
# === return_random_conape_name.
-
#return_random_goblinoid_name ⇒ Object
# === return_random_goblinoid_name.
-
#return_random_landeral_name ⇒ Object
(also: #return_random_westreich_name)
# === return_random_landeral_name ========================================================================= #.
-
#return_random_sanyal_name ⇒ Object
# === return_random_sanyal_name.
-
#return_random_shadowrun_name ⇒ Object
# === return_random_shadowrun_name.
-
#return_random_tai_name ⇒ Object
(also: #random_tai_name)
# === return_random_tai_name.
-
#run ⇒ Object
(also: #output, #pgenerate_name_string)
# === run (run tag) ========================================================================= #.
-
#set_create_n_names(i = CREATE_N_NAMES) ⇒ Object
(also: #set_n_names, #set_n_times)
# === set_create_n_names ========================================================================= #.
-
#set_female ⇒ Object
# === set_female ========================================================================= #.
-
#set_first_name(i = '') ⇒ Object
(also: #set_name)
# === set_first_name ========================================================================= #.
-
#set_full_name(i = first_name?+' '+surname?.to_s) ⇒ Object
(also: #build_name, #build_full_name, #assemble_full_name, #generate_name_string)
# === set_full_name (build tag).
-
#set_gender(i = 'male') ⇒ Object
# === set_gender.
-
#set_input(i = nil) ⇒ Object
# === set_input ========================================================================= #.
-
#set_male ⇒ Object
# === set_male ========================================================================= #.
-
#set_race(i = ARRAY_AVAILABLE_RACES.sample) ⇒ Object
# === set_race ========================================================================= #.
-
#set_surname(i = '') ⇒ Object
# === set_surname ========================================================================= #.
-
#show_help ⇒ Object
# === show_help ========================================================================= #.
-
#surname? ⇒ Boolean
(also: #surname)
# === surname? ========================================================================= #.
Methods inherited from Base
#find_adverb_for, #lang_wnum, #sentence, #word_wrap
Constructor Details
#initialize(i = nil, n_names = CREATE_N_NAMES, run_already = true) ⇒ NameGenerator
#
initialize
#
212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 212 def initialize( i = nil, n_names = CREATE_N_NAMES, run_already = true ) reset set_n_names(n_names) # Must come before set_input(). set_input(i) case run_already when :do_not_run_yet, :dont_run_yet run_already = false end run if run_already end |
Class Method Details
.[](name = nil, n_times = 1) ⇒ Object
#
Mud::NameGenerator[]
Mud::NameGenerator[:gobbo, 5]
#
676 677 678 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 676 def self.[](name = nil, n_times = 1) Mud::NameGenerator.new(name, n_times) end |
Instance Method Details
#check_input_against_namegroups(i = input?) ) ⇒ Object
#
check_input_against_namegroups
This method is a selector, where you can select between different name groups, such as ‘default’, ‘tai’ or ‘gobbo’.
We only allow certain names.
‘std’ is an alias to ‘default’, gobbo is a shortcut for a “representative from the goblinoid race”.
It’s best to store the data for the names in a yaml file.
You can select from these valid groups:
std,tai,westreich,gobbo
#
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 538 def check_input_against_namegroups(i = input?) i = DEFAULT_NAME_GROUP if i.nil? i = i.to_s.downcase case i # case tag # ======================================================================= # # Choose a random name. (rand tag) # ======================================================================= # when 'rand' set_name_group( %w( tai sr barbarians landeral orc ).sample ) # ======================================================================= # # === Westreich # # Ist zur Zeit std Name stuff. # bl $SARLEM/YAML/greater_landeral_names.yml # ======================================================================= # when 'std','landeral','western','westreich','greater', 'greater landeral','west','westen','land' set_surname LANDERAL_SURNAMES.sample.capitalize case rand(2) when 0 set_male set_first_name LANDERAL_MALE_NAMES.sample.capitalize when 1 set_female set_first_name LANDERAL_FEMALE_NAMES.sample.capitalize end # ======================================================================= # # === Elfen in Sarlemn # # bl $SARLEM/YAML/sanyal_names.yml # ======================================================================= # when 'stdeld','elf','stdelf' set_surname SANYAL_SURNAMES.sample.force_encoding('ISO-8859-1').capitalize case rand(2) when 0 set_male set_first_name SANYAL_MALE_NAMES.sample.capitalize when 1 set_female set_first_name SANYAL_FEMALE_NAMES.sample.capitalize end # ======================================================================= # # === Tai # # Ostreich ist nicht ganz wie Tai hmm # ======================================================================= # when 'tai','ostreich','ost' set_surname TAI_SURNAMES.sample.capitalize case rand(2) when 0 set_male set_name TAI_MALE_NAMES.sample.capitalize when 1 set_female set_name TAI_FEMALE_NAMES.sample.capitalize end # ======================================================================= # # === Shadowrun # # Shadowrun tag. # ======================================================================= # when 'sha','sr','shadowrun','shadow' set_surname SHADOWRUN_SURNAMES.sample.capitalize # Random surname. case rand(2) when 0 set_male set_first_name SHADOWRUN_MALE_NAMES.sample when 1 set_female set_first_name SHADOWRUN_FEMALE_NAMES.sample end # ======================================================================= # # === Conape # # Barbaren auf der mittleren insel # ======================================================================= # when 'barbarians','northbarbarians','conape' set_surname CONAPE_SURNAMES.sample.capitalize case rand(2) when 0 set_male set_first_name CONAPE_MALE_NAMES.sample.capitalize when 1 set_female set_first_name CONAPE_FEMALE_NAMES.sample.capitalize end # ======================================================================= # # bl $SARLEM/YAML/goblinoid_names.yml # ======================================================================= # when 'orc','gobbo','goblinoid','ogre','g', 'goblin','oger','ogroid','gobolike_name' set_surname GOBLINOID_SURNAMES.sample.capitalize case rand(2) when 0 set_male set_first_name GOBLINOID_MALE_NAMES.sample.capitalize when 1 set_female set_first_name GOBLINOID_FEMALE_NAMES.sample.capitalize end end end |
#do_output_the_result ⇒ Object
#
do_output_the_result
#
243 244 245 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 243 def do_output_the_result @output_result = true end |
#first_name? ⇒ Boolean Also known as: first_name
#
first_name?
#
257 258 259 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 257 def first_name? @first_name end |
#full_name? ⇒ Boolean Also known as: full_name, result, result?, _, name?, to_s
#
full_name?
#
346 347 348 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 346 def full_name? @full_name end |
#gender? ⇒ Boolean Also known as: gender
#
gender?
#
393 394 395 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 393 def gender? @gender end |
#input? ⇒ Boolean Also known as: input
#
input?
#
290 291 292 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 290 def input? @input end |
#menu(i) ⇒ Object Also known as:
#
menu (menu tag)
#
297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 297 def (i) i = i.first if i.is_a? Array case i when 'HELP','help','--help' show_help exit when 'open' open_dataset exit end end |
#n_times? ⇒ Boolean
#
n_times?
#
458 459 460 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 458 def n_times? @create_n_names end |
#open_dataset ⇒ Object
#
open_dataset
#
337 338 339 340 341 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 337 def open_dataset esystem( 'bluefish '+SARLEM+'YAML/maraalar_conape_names.yml' ) end |
#race? ⇒ Boolean Also known as: race
#
race?
#
330 331 332 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 330 def race? @race end |
#report_the_result ⇒ Object Also known as: report
#
report_the_result
#
695 696 697 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 695 def report_the_result e result? if @output_result end |
#reset ⇒ Object
#
reset (reset tag)
#
230 231 232 233 234 235 236 237 238 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 230 def reset @array_full_names = [] # We keep track of all generated names here. @output_result = false # if true then we output the name set_create_n_names set_race set_first_name set_surname set_full_name # This will store our output. end |
#return_random_conape_name ⇒ Object
#
return_random_conape_name
This method will return a random sanyal name.
#
467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 467 def return_random_conape_name set_surname CONAPE_SURNAMES.sample.capitalize # Random surname. case rand(2) when 0 # Male first names go here. set_male set_first_name CONAPE_MALE_NAMES.sample.capitalize when 1 # Female first names go here. set_female set_first_name CONAPE_FEMALE_NAMES.sample.capitalize end _ = first_name?+' '+surname? set_full_name(_) return _ end |
#return_random_goblinoid_name ⇒ Object
#
return_random_goblinoid_name
This method will return a random Goblinoid name.
#
507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 507 def return_random_goblinoid_name set_surname GOBLINOID_SURNAMES.sample.capitalize # Random surname. case rand(2) when 0 # Male first names go here. set_male set_first_name GOBLINOIX_MALE_NAMES.sample.capitalize when 1 # Female first names go here. set_female set_first_name GOBLINOIX_FEMALE_NAMES.sample.capitalize end _ = first_name?+' '+surname? set_full_name(_) return _ end |
#return_random_landeral_name ⇒ Object Also known as: return_random_westreich_name
#
return_random_landeral_name
#
400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 400 def return_random_landeral_name set_surname LANDERAL_SURNAMES.sample.capitalize # Random surname. case rand(2) when 0 # Male first names go here. set_male set_first_name LANDERAL_MALE_NAMES.sample.capitalize when 1 # Female first names go here. set_female set_first_name LANDERAL_FEMALE_NAMES.sample.capitalize end _ = first_name?+' '+surname? set_full_name(_) return _ end |
#return_random_sanyal_name ⇒ Object
#
return_random_sanyal_name
This method will return a random sanyal name.
#
440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 440 def return_random_sanyal_name set_surname SANYAL_SURNAMES.sample.capitalize # Random surname. case rand(2) when 0 # Male first names go here. set_male set_first_name SANYAL_MALE_NAMES.sample.capitalize when 1 # Female first names go here. set_female set_first_name SANYAL_FEMALE_NAMES.sample.capitalize end _ = first_name?+' '+surname? set_full_name(_) return _ end |
#return_random_shadowrun_name ⇒ Object
#
return_random_shadowrun_name
This method will return a random shadowrun name.
#
420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 420 def return_random_shadowrun_name set_surname SHADOWRUN_SURNAMES.sample.capitalize # Random surname. case rand(2) when 0 # Male first names go here. set_male set_first_name SHADOWRUN_MALE_NAMES.sample.capitalize when 1 # Female first names go here. set_female set_first_name SHADOWRUN_FEMALE_NAMES.sample.capitalize end _ = first_name?+' '+surname? set_full_name(_) return _ end |
#return_random_tai_name ⇒ Object Also known as: random_tai_name
#
return_random_tai_name
This method will return a random Tai name.
#
487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 487 def return_random_tai_name set_surname(TAI_SURNAMES.sample.capitalize) # Random surname. case rand(2) when 0 # Male first names go here. set_male set_first_name TAI_MALE_NAMES.sample.capitalize when 1 # Female first names go here. set_female set_first_name TAI_FEMALE_NAMES.sample.capitalize end _ = first_name?+' '+surname? set_full_name(_) return _ end |
#run ⇒ Object Also known as: output, pgenerate_name_string
#
run (run tag)
#
683 684 685 686 687 688 689 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 683 def run n_times?.times.each { check_input_against_namegroups assemble_full_name report_the_result } end |
#set_create_n_names(i = CREATE_N_NAMES) ⇒ Object Also known as: set_n_names, set_n_times
#
set_create_n_names
#
663 664 665 666 667 668 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 663 def set_create_n_names(i = CREATE_N_NAMES) i = CREATE_N_NAMES if i.nil? i = i.to_s.to_i i = 1 if i == 0 @create_n_names = i end |
#set_female ⇒ Object
#
set_female
#
386 387 388 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 386 def set_female set_gender :female end |
#set_first_name(i = '') ⇒ Object Also known as: set_name
#
set_first_name
#
250 251 252 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 250 def set_first_name(i = '') @first_name = i end |
#set_full_name(i = first_name?+' '+surname?.to_s) ⇒ Object Also known as: build_name, build_full_name, assemble_full_name, generate_name_string
#
set_full_name (build tag)
This method will assemble the full name of the individual in question, with a proper ‘ ’ spacing in between the first name and the surname.
This will set the @full_name instance variable, which is a combination of @first_name and @surname, essentially.
#
650 651 652 653 654 655 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 650 def set_full_name(i = first_name?+' '+surname?.to_s) i = i.first if i.is_a? Array i = i.to_s.dup if i @array_full_names << i @full_name = i end |
#set_gender(i = 'male') ⇒ Object
#
set_gender
Use only this method when changing the @gender variable.
We will keep track of whether we have a male, female or neutral “name”.
#
362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 362 def set_gender(i = 'male') i = i.to_s i = 'male' if i.empty? # Set a default value in this case. case i # Some sanitizing. when 'n' i = 'neuter' when 'm' i = 'male' when 'f' i = 'female' end @gender = i end |
#set_input(i = nil) ⇒ Object
#
set_input
#
278 279 280 281 282 283 284 285 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 278 def set_input(i = nil) (i) if i =~ /^\d+$/ set_n_times(i) i = DEFAULT_CHOICE end @input = i end |
#set_male ⇒ Object
#
set_male
#
379 380 381 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 379 def set_male set_gender :male end |
#set_race(i = ARRAY_AVAILABLE_RACES.sample) ⇒ Object
#
set_race
#
323 324 325 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 323 def set_race(i = ARRAY_AVAILABLE_RACES.sample) @race = i end |
#set_surname(i = '') ⇒ Object
#
set_surname
#
264 265 266 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 264 def set_surname(i = '') @surname = i end |
#show_help ⇒ Object
#
show_help
#
312 313 314 315 316 317 318 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 312 def show_help e 'Specific Usage Example:' e e ' namegen of_this_race how_many' e ' namegen race 6' e ' namegen shadowrun 10' end |
#surname? ⇒ Boolean Also known as: surname
#
surname?
#
271 272 273 |
# File 'lib/games_and_rpg_paradise/mud/name_generator/name_generator.rb', line 271 def surname? @surname end |