Class: GamesAndRpgParadise::Mud::AdminShell
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mud::AdminShell
- Includes:
- Colours, Mud::Constants, Mud::SharedData
- Defined in:
- lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb
Overview
GamesAndRpgParadise::Mud::AdminShell
Constant Summary collapse
- DEFAULT_PADDING =
#
DEFAULT_PADDING
#
' '
- NAME =
'MudAdminShell'
- STARTUP_ACTIONS =
Our actions at startup, as “if” we would have input them.
ENV['RUBY_MUD']+'/YAML/admin_shell_startup_actions.yml'
- ARRAY_STARTUP_ACTIONS =
YAML.load_file _
Constants included from Colours
Instance Attribute Summary collapse
-
#oc ⇒ Object
object combat.
Instance Method Summary collapse
-
#actor_action(do_this_action, extra_argument = '') ⇒ Object
# === actor_action.
-
#check_environment(optional_input = nil) ⇒ Object
# === check_environment Use this to look around the actor.
-
#check_for_complex_input(user_input) ⇒ Object
# === check_for_complex_input (complex tag, comp tag).
-
#check_for_predefined_input ⇒ Object
# === check_for_predefined_input.
-
#create_new_monster(name_of_monster) ⇒ Object
(also: #create_monster)
# === create_new_monster.
-
#create_settlement(which_settlement = :tai) ⇒ Object
# === create_settlement.
-
#display(input) ⇒ Object
# === display ========================================================================= #.
-
#display_file_listing(i) ⇒ Object
# === display_file_listing ========================================================================= #.
-
#display_prompt_string ⇒ Object
# === display_prompt_string.
-
#display_startup_notice ⇒ Object
# === display_startup_notice Displays a startup notice ========================================================================= #.
-
#drop_item(this_item = '') ⇒ Object
# === drop_item (drop tag).
-
#enter_loop ⇒ Object
# === enter_loop.
-
#feedback_help ⇒ Object
# === feedback_help (help tag).
-
#get_file_listing(from_this_dir, display_file_listing = false) ⇒ Object
# === get_file_listing ========================================================================= #.
-
#get_item(this_item = '') ⇒ Object
# === get_item (get tag).
-
#get_user_input ⇒ Object
# === get_user_input ========================================================================= #.
-
#improve_skill(which_skill) ⇒ Object
# === improve_skill.
-
#initialize ⇒ AdminShell
constructor
# === initialize.
-
#last_monster? ⇒ Boolean
# === last_monster?.
-
#load_yaml(_) ⇒ Object
# === load_yaml.
-
#match_action_from_variable ⇒ Object
# === match_action_from_variable (case tag, simple tag, sim tag).
-
#move_direction(this_way) ⇒ Object
# === move_direction.
-
#prepare_for_combat ⇒ Object
# === prepare_for_combat.
-
#register_objects ⇒ Object
# === register_objects.
-
#reset ⇒ Object
# === reset.
-
#scan_user_input ⇒ Object
# === scan_user_input.
-
#set_available_monsters ⇒ Object
# === set_available_monsters.
-
#shall_use_flag? ⇒ Boolean
# === shall_use_flag? returns true if any value is true else return false.
-
#show_rooms ⇒ Object
# === show_rooms ========================================================================= #.
-
#speak(i) ⇒ Object
# === speak (speak tag).
-
#start_combat ⇒ Object
# === start_combat.
-
#startup_tasks ⇒ Object
# === startup_tasks.
-
#verbose_exit(this_exit_message = 'Bye!') ⇒ Object
# === verbose_exit To exit this shell with an exit message.
-
#warn(i) ⇒ Object
# === warn ========================================================================= #.
-
#x ⇒ Object
# === x.
Methods included from Colours
#brown, #cfile, #convert_colour, convert_colour, #fancy, #normal, #pink, #red, #yel
Constructor Details
#initialize ⇒ AdminShell
#
initialize
On startup, we have already registered several objects.
#
36 37 38 39 40 41 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 36 def initialize reset # Reset all variables. # @i # Thats me but i guess its not needed anymore ;) startup_tasks # Our startup tasks. enter_loop end |
Instance Attribute Details
#oc ⇒ Object
object combat
19 20 21 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 19 def oc @oc end |
Instance Method Details
#actor_action(do_this_action, extra_argument = '') ⇒ Object
#
actor_action
This will become generic. If our actor does an action, he will check via this bottleneck method. Also, this method will broadcast into the current room. After that, we check if other actors can see it.
#
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 371 def actor_action(do_this_action, extra_argument = '') case do_this_action when :backflip case rand(2) when 0 e 'You fumble trying to do a backflip and land on your backside.' when 1 e 'You perform a backflip and land on your feet again.' end # here we wanna speak :) when :speak speak(extra_argument) when :search e 'You search and search ... ' when :smile, :moan # sm hap, moan disgr _ = 'You '+do_this_action.to_s # HASH_ADVERBS if HASH_ADVERBS.keys.include? extra_argument _ << ' ' << HASH_ADVERBS[extra_argument] end _ << '.' e _ when :swim e 'You swim.' when :juggle e 'You juggle with '+extra_argument+' balls.' end end |
#check_environment(optional_input = nil) ⇒ Object
#
check_environment
Use this to look around the actor.
#
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 271 def check_environment(optional_input = nil) _ = optional_input unless @environment.empty? display 'You glance around, noticing these things around you:' @environment.silently_display_inventory # splitted = optional_input.split(' ') # the_item = splitted[1] else display 'You see nothing of interest around you.' end if _ _ = _.gsub(/at /,'') # get rid of "at " # if @environment.include? _ # pp 'IST DABEI' # pp @environment.result # end# end end |
#check_for_complex_input(user_input) ⇒ Object
#
check_for_complex_input (complex tag, comp tag)
Invoked after the simple input hasnt yielded any result, and to pass extra arguments. It is also used to speak. Note that we use it ONLY when the user input includes ‘ ’.
Use it to, for example, do this (Usage example):
create ogres
#
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 450 def check_for_complex_input(user_input) user_input = user_input.strip # leading and trailing crap away # if our string contains a ' ' in between, we passed at least one arg if user_input.include? ' ' # then we split it at the ' ' splitted_string = user_input.split(' ') first_part = splitted_string[0] _ = splitted_string[1..-1].join(' ') # contains the rest if @debug warn "admin_shell.rb: DEBUG PART from the method "+ "check_for_complex_input, line: "+__LINE__.to_s+":" warn "first_part was `#{first_part}`" end case first_part when 'cr','create' if @hash_registered_monsters.has_key? _ create_monster(@hash_registered_monsters[_]) else e swarn('Monster: '+_+' was not found.') end when 'drop','dro','dr' drop_item _ when 'take','get','ge','tak','g' get_item _ when 'cast','ca' actor_action(:cast, _) when 'moan' actor_action(:moan, _) when 'swim' actor_action(:swim, _) when 'smile','smi','sm' actor_action(:smile, _) when 'search','sea' actor_action(:search, _) when 'say','speak','c' actor_action(:speak, _) when 'juggle','jug' actor_action(:juggle, _) when 'look at','l at','look','l' check_environment(_) when 'cd' change_directory _ else e "In method check_for_complex_input(). Input "+ "was: `#{_}` (not found)" end elsif @hash_with_flags['use_method_on_lou'] @hash_with_flags['use_method_on_lou'] = false this_method = user_input.gsub(/lou./, '') begin pp @lou.send(this_method.to_sym) rescue Exception => error warn 'Small error caught:' e swarn(error) end elsif @hash_with_flags['do_assignment'] @hash_with_flags['do_assignment'] = false @user_input = @user_input.gsub(/lou\./,'@lou.') @user_input = @user_input.gsub(/@@l/,'@l') e 'Eval this:' e @user_input eval @user_input else # Feedback user input here. cliner { e "User input was: `#{user_input}`" } unless user_input.empty? if user_input[0,1] == '@' cliner { # Fetch an instance variable here. e user_input+' might be an instance variable. ' var = instance_variable_get(user_input) e var # @array_monsters e var.class var.inspect pp var if user_input[1,3] == 'tai' e 'Tai:' # @tai.report_distance('fauxwen','siu') eval "#{user_input}" else eval "#{user_input}" end } elsif user_input[0,1] == '$' # could be a global var. cliner { var = eval user_input pp var if user_input[1,1] == 'x' cliner { pp @last_object_used e 'We used the global variable $x for this.' } end } end end end |
#check_for_predefined_input ⇒ Object
#
check_for_predefined_input
You can specify startup actions.
#
124 125 126 127 128 129 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 124 def check_for_predefined_input # user can specify tasks to run on startup ARRAY_STARTUP_ACTIONS.each { |action| @user_input = action match_action_from_variable } end |
#create_new_monster(name_of_monster) ⇒ Object Also known as: create_monster
#
create_new_monster
This method creates a new monster.
Example for this:
cr junglet
#
755 756 757 758 759 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 755 def create_new_monster(name_of_monster) new_monster = @factory.create_monster(name_of_monster) # bl $RUBY_MUD/factory.rb @array_monsters << new_monster @inventory.add(new_monster) end |
#create_settlement(which_settlement = :tai) ⇒ Object
#
create_settlement
ALSO creates whole continents. To test, do for example:
tai
#
723 724 725 726 727 728 729 730 731 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 723 def create_settlement(which_settlement=:tai) case which_settlement when :tai @tai = StdContinent.new e 'Now creating the continent-Tai: Name: -> '+sfancy(@tai.name) @tai.fill_in_with_settlement_data(STD_RPG_PATH+'tai_southern_island.yml') self.class.send :attr_accessor, :tai end end |
#display(input) ⇒ Object
#
display
#
694 695 696 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 694 def display(input) e input end |
#display_file_listing(i) ⇒ Object
#
display_file_listing
#
359 360 361 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 359 def display_file_listing(i) get_file_listing(from_this_dir, true) end |
#display_prompt_string ⇒ Object
#
display_prompt_string
Displays our prompt string.
#
703 704 705 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 703 def display_prompt_string print BOLD_YELLOW+@string_prompt+GREEN end |
#display_startup_notice ⇒ Object
#
display_startup_notice
Displays a startup notice
#
711 712 713 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 711 def display_startup_notice e BOLD_YELLOW+'You may now input data.'+rev end |
#drop_item(this_item = '') ⇒ Object
#
drop_item (drop tag)
Invoke this method only if you really drop something.
#
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 232 def drop_item(this_item = '') _ = @inventory.remove(this_item) unless _.nil? @move_object << _ @move_object.array.each { |entry| e 'You drop a '+entry.object_name+'.' } @environment.add(@move_object.output) else e 'But you do not carry a '+this_item+'.' end end |
#enter_loop ⇒ Object
#
enter_loop
Here we handle the user input.
#
71 72 73 74 75 76 77 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 71 def enter_loop loop { # via a loop do ... get_user_input # read in user input result = match_action_from_variable # - match the variable, assign return value break if result == :break # break the loop if symbol :break is returned } end |
#feedback_help ⇒ Object
#
feedback_help (help tag)
Here please register commands. If the user types in help, he will get that info.
#
739 740 741 742 743 744 745 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 739 def feedback_help %w( adverbs? god flag ? pwd o? tai q last monsters ).each { |member| e ' - '+member } end |
#get_file_listing(from_this_dir, display_file_listing = false) ⇒ Object
#
get_file_listing
#
350 351 352 353 354 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 350 def get_file_listing(from_this_dir, display_file_listing = false) Dir[from_this_dir].each {|file| e file, CFANCY if display_file_listing } end |
#get_item(this_item = '') ⇒ Object
#
get_item (get tag)
Invoke this method if you want to get something. The argument ‘all’ is a special argument.
#
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 216 def get_item(this_item = '') _ = @environment.remove(this_item) # unless _.nil? @move_object << _ @move_object.array.each { |entry| e 'You get a '+entry.object_name+'.' } @inventory.add(@move_object.output) else e 'But you do not see a '+this_item+'.' end end |
#get_user_input ⇒ Object
#
get_user_input
#
112 113 114 115 116 117 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 112 def get_user_input @user_input = Readline.readline('',true) # das 2. argument enabled history Readline::HISTORY.pop if @user_input =~ /^\s*$/ # ignore empty lines @array_history << @user_input @dump_object = '' # can be used to store assignment stuff. end |
#improve_skill(which_skill) ⇒ Object
#
improve_skill
Trigger this whenever a skill has improved.
#
203 204 205 206 207 208 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 203 def improve_skill(which_skill) case which_skill when :aim # passthru for now end e 'You improved your '+which_skill.to_s+' skill.' end |
#last_monster? ⇒ Boolean
#
last_monster?
Returns the last monster.
#
685 686 687 688 689 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 685 def last_monster? e 'The last monster(s) was/were:' pp @array_monsters.last @last_object_used = @array_monsters.last # also set new last object end |
#load_yaml(_) ⇒ Object
#
load_yaml
Use this to load a yaml file for the RubyMud project.
#
151 152 153 154 155 156 157 158 159 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 151 def load_yaml(_) if _.include? '$' pos = _.index('/') env_var = _[0, pos] replaced_var = ENV[env_var[1..-1]] _[0, pos] = replaced_var+'/' end YAML.load_file(_) end |
#match_action_from_variable ⇒ Object
#
match_action_from_variable (case tag, simple tag, sim tag)
Our main menu stuff goes in here.
#
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 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 552 def match_action_from_variable @string_prompt = DEFAULT_PROMPT case @user_input when 'n','ne','e','se','s','sw','w','nw' move_direction(@user_input) when 'x?','x','debug' x when 'll' when 'rooms','show_rooms' show_rooms when 'adverbs','adverbs?','a?' cliner { pp @adverbs_abbreviated e 'We found '+@adverbs_abbreviated.keys.size.to_s+' keys.' } when 'sundaal' sundaal = Sundaal.new; sundaal.pdescription? when 'limaal' limaal = Limaal.new; limaal.pdescription? when 'god' # @lou = @lou.fauxwen pp @lou.fauxwen when 'lou','lo' e @lou e @lou.name e @lou.fauxwen when 'shell?','s?' e SHELL_NAME when 'history','his','hi','history?' pp Readline::HISTORY.methods when 'pwd','dir?','p' e Dir.pwd #@string_prompt = N << Dir.pwd << N # Inspects last object. when 'inspect','ins','?' e 'Now inspecting the Settlement lou' @lou.methods.sort.each_with_index do |item, index| # lou is last object used _= '%03d' % index e "#{_}) #{item}",CFANCY end e pp @array_monsters # here the aliases from 1-9. # You can overrule them of course. when '1' check_for_complex_input('create ogre') when '2' check_for_complex_input('cr goblin') when '3' prepare_for_combat # 3 when 'rand' e 'Something suddenly happens ...' improve_skill(:aim) # help tag when 'help','h','fh','feedback','hilfe','fhelp', 'feedback_help','help?','he' feedback_help when 'wield' e 'Wield what?' when 'poison' e 'You have been poisoned!' when 'last_monster?','lmon','lmon?','last','la' last_monster? when 'look','l' check_environment when 'invenv' @environment.silently_display_inventory @inventory.display_inventory when 'env','env?','environment' @environment.silently_display_inventory when 'inv','inv?','show inventory','inventory','in','i','nv','ionv' @inventory.display_inventory when 'creatures','creatures?','monster','monsters', 'mons','monsters?','army','army?','mon','pp' pp @array_monsters e 'We have that many monsters instantiated:' efancy ' => '+@array_monsters.size.to_s e 'And we have that these monsters available (use "cr name" to clone a monster):' print ' ' efancy @hash_registered_monsters.values.uniq # some fun when 'sarlem','sarlem?','sarl' e 'cd /Users/x/DATA/RPG/SARLEM/' when 'flag?','flag' # this uses shall_use_flag? e 'Shall we use a flag: '+verbose_truth(shall_use_flag?) when 'objects?','o?','objects','objs','main_object', 'main_object?' list_all_specific_objects # will list all specific objects when 'hp','hp?' e 'You are physically slightly hurt and mentally somewhat degraded.' e 'You are bleeding.' e 'You are slightly alert.' when 'names','names?' # empty for now when 'q','exit','quit','ex','exi','rad','rda' return verbose_exit when 'drop','dro','dr','d' e 'Check... kein argument?? hmmm' check_for_complex_input 'drop' # complete to drop when 'say','c' e 'Say what?' when 'juggle' e 'Juggle with what?' when 'bflip','backflip' actor_action(:backflip) when :backflip when 'tai','create_tai' create_settlement(:tai) when 'comb','combat','start','scombat','fight','scomb', 'start_combat','scom','sc','sco' start_combat else # else tag. if @user_input.start_with? '@' e @user_input+' might be an instance variable.' e 'Trying to report its value now.' var = instance_variable_get(@user_input) pp var end _ = ::Rcfiles::DirectoryAliases.new(@user_input) # To expand our cd-aliases. if _._ # If we have found it. change_directory(_._) # My cd-aliases go in here. end end scan_user_input # do scan again before checking for more complex stuff check_for_complex_input(@user_input) display_prompt_string # display default prompt string again reset_variables # reset all variables. end |
#move_direction(this_way) ⇒ Object
#
move_direction
Move this direction.
#
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 248 def move_direction(this_way) case this_way when 'n' then this_way = 'north' when 'ne' then this_way = 'northeast' when 'e' then this_way = 'east' when 'se' then this_way = 'southeast' when 's' then this_way = 'south' when 'sw' then this_way = 'southwest' when 'w' then this_way = 'west' when 'nw' then this_way = 'northwest' # Now special directions: when 'nu' then this_way = 'northup' when 'eu' then this_way = 'eastup' when 'su' then this_way = 'southup' when 'wu' then this_way = 'westup' end e 'You move '+this_way+'.' end |
#prepare_for_combat ⇒ Object
#
prepare_for_combat
This method prepares our combat stuff.
#
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 187 def prepare_for_combat how_many = 2 cliner { e 'Now starting combat with '+how_many.to_s+' participants!' } _ = @array_monsters.last(how_many) object_combat = StdCombat.new(_[0], _[1]) @oc = object_combat @last_object_used = @oc end |
#register_objects ⇒ Object
#
register_objects
Registers some of our objects.
#
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 97 def register_objects @last_object_used = '' #points to last object used @object_tai_southern_island = StdContinent.new # bl $RUBY_MUD/std_continents.rb @object_tai_southern_island.fill_in_with_settlement_data( STD_RPG_PATH+'tai_southern_island.yml') @object_tai_southern_island.report_distance('siu','moar') pp @object_tai_southern_island.hash_positional_information @last_object_used = @object_tai_southern_island @lou = @last_object_used # lou is last object used end |
#reset ⇒ Object
#
reset
Reset all variables again.
#
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 48 def reset @array_last_directories = [] @array_monsters = [] # holds our monsters @array_history = [] # holds user-input history @hash_with_flags = {} # this hash may store flag options. # I think the flags are set inside scan_user_input @hash_with_flags.default = false # default is false. @user_input = '' # empty at startup @string_prompt = '' # empty at startup as well @dump_object = '' # this object may be used to dump a var into it @factory = Factory.new # std factory stuff. bl $RUBY_MUD/factory.rb @inventory = StdContainer.new 666 # the devil! its the admin. bl std_container.rb @environment = StdContainer.new 333 # @find_names = FindNames.new # @find_names.find_matches_to @move_object = MoveObject.new @debug = true # Shall we debug or not. end |
#scan_user_input ⇒ Object
#
scan_user_input
This scans the user input and sets various flag options.
#
305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 305 def scan_user_input _ = @user_input if _.include?('=') @hash_with_flags['do_assignment'] = true elsif _.include? '.' e ' => '+_+' ist eventuell eine methode hmmmmmmm',CEVAL if _.include?('lou.') e " => Also willst du eine methode anwenden.",CEVAL warn _.scan(/lou.(.*)/) # oder: [/oo (.*)/, 1] @user_input = _ @hash_with_flags['use_method_on_lou'] = true end end end |
#set_available_monsters ⇒ Object
#
set_available_monsters
Monsters are kept here:
bl $RUBY_MUD/YAML/monsters.yml
#
169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 169 def set_available_monsters yaml_file = load_yaml('$RUBY_MUD/YAML/monsters.yml') if yaml_file @hash_registered_monsters = yaml_file.keys.sort.abbrev # Here you can add extra options. @hash_registered_monsters['gobb'] = 'goblin' @hash_registered_monsters['gobbo'] = 'goblin' @hash_registered_monsters['g'] = 'goblin' else e 'But yaml_file did not exist.' end end |
#shall_use_flag? ⇒ Boolean
#
shall_use_flag?
returns true if any value is true else return false. If you want to test this method, do the following:
flag?; x=y; flag?
However, this doesnt seem to work hmm … must check later.
#
338 339 340 341 342 343 344 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 338 def shall_use_flag? @hash_with_flags.each { |word, content| e "DEBUG VAL: content war #{content}" return true if content } return false end |
#show_rooms ⇒ Object
#
show_rooms
#
428 429 430 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 428 def show_rooms cliner { display 'Now showing available rooms:'} end |
#speak(i) ⇒ Object
#
speak (speak tag)
Use this to speak.
#
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 405 def speak(i) @say_string = '' if i.include? '#' # assume adverbs given here. splitted = i.split('#') adverb = splitted[1] adverb = @adverbs_abbreviated[adverb.to_s] i = ' '+splitted[2..-1].join end @say_string << 'You say' @say_string << ' '+adverb if adverb @say_string << ':'+N @say_string << DEFAULT_PADDING sentence = i.strip unless sentence.end_with?('!') # ! and ? are exempt. sentence.append_unless('.') end @say_string << '"'+sentence+'"' e @say_string end |
#start_combat ⇒ Object
#
start_combat
This starts combat.
StdCombat can be found at:
bl $RUBY_MUD/std_combat.rb
#
141 142 143 144 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 141 def start_combat prepare_for_combat @oc.fight_round end |
#startup_tasks ⇒ Object
#
startup_tasks
All startup tasks are defined here. set_available_monsters inits our hash with monsters+shortcuts.
#
85 86 87 88 89 90 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 85 def startup_tasks register_objects # all important objects for our shell set_available_monsters display_startup_notice check_for_predefined_input # user can specify tasks to run on startup end |
#verbose_exit(this_exit_message = 'Bye!') ⇒ Object
#
verbose_exit
To exit this shell with an exit message.
#
295 296 297 298 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 295 def verbose_exit(='Bye!') e return :break end |
#warn(i) ⇒ Object
#
warn
#
435 436 437 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 435 def warn(i) e RED+i end |
#x ⇒ Object
#
x
throwaway function for testing stuff. debug stuff
#
325 326 327 328 |
# File 'lib/games_and_rpg_paradise/mud/admin_shell/admin_shell.rb', line 325 def x # create_new_monster :ogre cliner { pp @inventory.random_content.name } end |