Module: GamesAndRpgParadise::GUI::GamebookModule

Extended by:
Base::ExtensionsForAGamebook
Includes:
Base::ExtensionsForAGamebook
Included in:
GamesAndRpgParadise::GUI::Gtk::Gamebook, Jruby::Gamebook, LibUI::Gamebook
Defined in:
lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb

Overview

GamesAndRpgParadise::GUI::GamebookModule

Constant Summary collapse

REGEX_FOR_FINDING_THE_NAME_OF_AN_OPPONENT =
#

REGEX_FOR_FINDING_THE_NAME_OF_AN_OPPONENT

This regex only works for the lone-wolf gamebook series.

#
/  (.+):
\s*COMBAT SKILL/
DIRECTORY_FOR_THE_GAMEBOOKS =
#

DIRECTORY_FOR_THE_GAMEBOOKS

#
::GamesAndRpgParadise.directory_to_the_gamebooks?
FILE_CIRCLE_OF_FIRE_COMPLETED =
#

FILE_CIRCLE_OF_FIRE_COMPLETED

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_fire_completed.png'
FILE_CIRCLE_OF_FIRE =
#

FILE_CIRCLE_OF_FIRE

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_fire.png'
FILE_CIRCLE_OF_SOLARIS =
#

FILE_CIRCLE_OF_SOLARIS

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_solaris.png'
FILE_CIRCLE_OF_SPIRIT_COMPLETED =
#

FILE_CIRCLE_OF_SPIRIT_COMPLETED

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_spirit_completed.png'
FILE_CIRCLE_OF_SPIRIT =
#

FILE_CIRCLE_OF_SPIRIT

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_spirit.png'
FILE_CIRCLE_OF_SOLARIS_COMPLETED =
#

FILE_CIRCLE_OF_SOLARIS_COMPLETED

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_solaris_completed.png'
FILE_CIRCLE_OF_LIGHT_COMPLETED =
#

FILE_CIRCLE_OF_LIGHT_COMPLETED

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_light_completed.png'
FILE_CIRCLE_OF_LIGHT =
#

FILE_CIRCLE_OF_LIGHT

#
GamesAndRpgParadise.project_base_directory?+
'images/gamebooks/misc/lone_wolf/'+
'circle_of_light.png'
USE_THIS_GAMEBOOK =
#

USE_THIS_GAMEBOOK

Designate which gamebook is to be loaded here by default.

#
DIRECTORY_FOR_THE_GAMEBOOKS+'13_stern_der_schmuggler/config.yml'
FILE_RED_SIX_SIDED_DIE =
#

FILE_RED_SIX_SIDED_DIE

#
"#{GamesAndRpgParadise.project_base_directory?}images/misc/red_six_sided_die.png"
PATH_TO_THE_PLUS_SYMBOL_IMAGE =
#

PATH_TO_THE_PLUS_SYMBOL_IMAGE

#
"#{::Gtk.project_base_directory?}images/misc/plus_symbol.png"
PATH_TO_THE_MINUS_SYMBOL_IMAGE =
#

PATH_TO_THE_MINUS_SYMBOL_IMAGE

#
"#{::Gtk.project_base_directory?}images/misc/minus_symbol.png"
PATH_TO_THE_DIE_IMAGE =
#

PATH_TO_THE_DIE_IMAGE

#
"#{::GamesAndRpgParadise.project_base_dir?}"\
"images/die.png"
FILE_RAUMSCHIFF_IMAGE =
#

FILE_RAUMSCHIFF_IMAGE

#
"#{::GamesAndRpgParadise.project_base_dir?}"\
"images/gamebooks/RAUMSCHIFF.png"
HINT_FOR_THE_BUTTON_WITH_THE_LEFT_ARROW_IMAGE =
#

HINT_FOR_THE_BUTTON_WITH_THE_LEFT_ARROW_IMAGE

#
"This button can be used to return to the last page, "\
"prior to the current one. It is a \"back\" button, sort of.\n\n"\
"In order for this to work, you need to have used a page already."
HASH_DESIGNATED_KEY_COMBINATIONS =
#

HASH_DESIGNATED_KEY_COMBINATIONS

Add useful key-combinations to the following Hash.

#
{
  'alt+1':  'button_number(1)',
  'alt+2':  'button_number(2)',
  'alt+3':  'button_number(3)',
  'alt+4':  'button_number(4)',
  'alt+5':  'button_number(5)',
  'alt+6':  'button_number(6)',
  'alt+7':  'button_number(7)',
  'strg+s': 'do_save_the_character'
}
USE_THESE_CSS_RULES =
#

USE_THESE_CSS_RULES

#
'
#scrolled_window_containing_the_special_image slider {
  /* Size of the slider */
  min-width:     18px;
  min-height:    14px;
  border-radius:  8px;

  /* Padding around the slider */
  border: 4px solid darkgreen;
}

#scrolled_window_containing_the_special_image trough {
  background-color: transparent;
  background-repeat:  no-repeat;
  background-position: center;
}

#padded_min_height paned separator {
  min-height: 30px;
}

#scrolled_window_containing_the_buttons_on_the_bottom_right_side {
 /* Size of the slider */
  min-width:     18px;
  min-height:    14px;
  border-radius:  8px;

  /* Padding around the slider */
  border: 0px solid springgreen;
}

#scrolled_window_containing_the_buttons_on_the_bottom_right_side {
  background-color: transparent;
  background-repeat:  no-repeat;
  background-position: center;
}

'
TITLE =
'Gamebook'
WIDTH =
'70% or minimum 480px'
HEIGHT =
'50% or minimum 450px'
LARGE_FONT =
:dejavu_condensed_17
USE_THIS_FONT =
:dejavu_condensed_15
SMALLER_FONT =
:dejavu_condensed_13
SMALLEST_FONT =
:dejavu_condensed_11
USE_N_CLICKABLE_BUTTONS =
6

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Instance Method Summary collapse

Methods included from Base::ExtensionsForAGamebook

available_gamebooks?, io_download, roll_this_die, use_gtk?, use_gtk?, wget, yaml_gamebooks_dir?

Methods included from Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Instance Method Details

#actionsheet_label?Boolean

#

actionsheet_label?

#

Returns:

  • (Boolean)


1734
1735
1736
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1734

def actionsheet_label?
  @actionsheet_label
end

#add_default_number_of_selbstlenkraketenObject Also known as: consider_adding_the_default_number_of_selbstlenkraketen

#

add_default_number_of_selbstlenkraketen

#


416
417
418
419
420
421
422
423
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 416

def add_default_number_of_selbstlenkraketen
  if science_fiction_widget?
    if @character
      @character.append_to_the_equipment("Selbstlenkraketen: 2\n")
    end
    append_to_the_equipment_buffer("Selbstlenkraketen: 2\n")
  end
end

#add_n_meals(i = 1) ⇒ Object

#

add_n_meals

#


2350
2351
2352
2353
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2350

def add_n_meals(i = 1)
  _ = n_meals? + i
  set_n_meals(_.to_s)
end

#add_to_the_path_traversal_history(this_id) ⇒ Object

#

add_to_the_path_traversal_history

#


615
616
617
618
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 615

def add_to_the_path_traversal_history(this_id)
  this_id = this_id.to_i
  @array_path_traversal_history << this_id
end

#append_to_the_equipment_buffer(i) ⇒ Object Also known as: add_to_equipment

#

append_to_the_equipment_buffer

This method can be used to append onto the equipment-buffer.

#


355
356
357
358
359
360
361
362
363
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 355

def append_to_the_equipment_buffer(i)
  if i.is_a? Symbol
    i = "#{i}\n"
  end
  if i.is_a? Array
    i = i.join("\n")
  end
  @equipment_buffer.append(i.to_s)
end

#append_to_the_main_buffer(i) ⇒ Object

#

append_to_the_main_buffer

#


3864
3865
3866
3867
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3864

def append_to_the_main_buffer(i)
  i = i.to_s
  buffer_holding_the_gamepage_content?.append(i)
end

#array_path_traversal_history?Boolean Also known as: history?

#

array_path_traversal_history?

#

Returns:

  • (Boolean)


472
473
474
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 472

def array_path_traversal_history?
  @array_path_traversal_history
end

#autoload_the_default_characterObject

#

autoload_the_default_character

#


2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2876

def autoload_the_default_character
  initialize_a_new_lone_wolf_character
  # We must now set various entries.
  _ = @character # Easier handle here.
  if first_argument? and File.exist?(first_argument)
    # ===================================================================== #
    # Loading the dataset from here.
    # ===================================================================== #
    _.load_dataset_from_this_file(_)
  end
  set_current_endurance(_.endurance?.to_s)
  set_n_gold(_.gold?)
  set_kai_disciplines(
    _.kai_disciplines?.join("\n")
  )
  set_combat_skill(_.combat_skill?.to_s)
  set_equipment_buffer(
    _.equipment?.join("\n")
  )
  @entry_for_laumspur_potions.set_text(
    _.n_laumspur_potions?.to_s
  )
end

#automatically_pick_up_items?Boolean

#

automatically_pick_up_items?

#

Returns:

  • (Boolean)


2619
2620
2621
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2619

def automatically_pick_up_items?
  @check_box_auto_pick_up_items.is_active?
end

#available_kai_disciplines?Boolean

#

available_kai_disciplines?

#

Returns:

  • (Boolean)


4385
4386
4387
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4385

def available_kai_disciplines?
  GamesAndRpgParadise::Gamebook::LoneWolf::Character.available_kai_disciplines?.sort
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


305
306
307
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 305

def border_size?
  0
end

#buffer_containing_the_kai_disciplines?Boolean

#

buffer_containing_the_kai_disciplines?

#

Returns:

  • (Boolean)


739
740
741
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 739

def buffer_containing_the_kai_disciplines?
  @text_view_for_the_kai_disciplines.text?
end

#buffer_holding_the_gamepage_content?Boolean Also known as: buffer_holding_the_gamepage_content, main_buffer?

#

buffer_holding_the_gamepage_content?

#

Returns:

  • (Boolean)


3872
3873
3874
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3872

def buffer_holding_the_gamepage_content?
  @buffer_holding_the_gamepage_content
end

#button_number(i = 1) ⇒ Object

#

button_number

This method exists so that we can add some nifty keybindings.

#


1446
1447
1448
1449
1450
1451
1452
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1446

def button_number(i = 1)
  i = (i.to_s.to_i - 1)
  button = @array_buttons[i]
  if button and !is_the_game_over?
    button.do_click_this_button
  end
end

#clear_the_history(history = array_path_traversal_history? ) ⇒ Object

#

clear_the_history

#


2557
2558
2559
2560
2561
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2557

def clear_the_history(
    history = array_path_traversal_history?
  )
  history.clear
end

#clear_the_main_pageObject

#

clear_the_main_page

#


465
466
467
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 465

def clear_the_main_page
  text_view_holding_the_gamepage_content?.clear
end

#combat_ratio(i = current_CS?.to_i - enemy_CS?.to_i) ⇒ Object

#

combat_ratio

#


2517
2518
2519
2520
2521
2522
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2517

def combat_ratio(
    i = current_CS?.to_i -
        enemy_CS?.to_i
  )
  ::GamesAndRpgParadise::Gamebook::LoneWolf.combat_ratio(i)
end

#comments?Boolean

#

comments?

#

Returns:

  • (Boolean)


2819
2820
2821
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2819

def comments?
  @notes_widget.text?.to_s
end

#connect_skeletonObject

#

connect_skeleton (connect tag)

#


4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4655

def connect_skeleton
  abort_on_exception
  left_side  = return_the_left_side_widget
  # ======================================================================= #
  # The right side contains the widget containing information about
  # the current-enemy, should one such enemy exist.
  # ======================================================================= #
  right_side = drag_via_left_to_right(
    return_the_right_side_widget, # This is the main notebook.
    return_the_widget_containing_information_about_the_enemy # This includes "Current Enemy".
  )
  right_side.position = max_width?+300
  draggable_widget = drag_via_left_to_right(left_side, right_side)
  draggable_widget.position = 700
  maximal(draggable_widget)
end

#consider_adding_all_relevant_information_from_the_characterObject

#

consider_adding_all_relevant_information_from_the_character (load tag)

This method will assign all important values from @character, onto the GUI.

#


4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4395

def consider_adding_all_relevant_information_from_the_character
  _ = @character
  if _
    # ===================================================================== #
    # First, set the two endurance values:
    # ===================================================================== #
    if _.respond_to? :current_endurance?
      set_current_endurance(_.current_endurance?.to_s)
    end
    # ===================================================================== #
    # === :maximal_endurance?
    # ===================================================================== #
    if _.respond_to? :maximal_endurance?
      set_maximal_endurance(_.maximal_endurance?.to_s)
    end
    set_n_gold(_.gold?)
    if _.respond_to?(:kai_disciplines?) and _.kai_disciplines?
      set_kai_disciplines(
        _.kai_disciplines?.join("\n") # Obtain the disciplines from the character dataset.
      )
      set_combat_skill(_.combat_skill?.to_s)
    end
    set_equipment_buffer(
      _.equipment?.join("\n")
    )
    # ===================================================================== #
    # Store the comments, aka notes, that may have been taken.
    # ===================================================================== #
    if _ and _.respond_to?(:comments?)
      comments = _.comments?
      if comments and !comments.empty?
        comments = comments.join("\n") if comments.is_a? Array
        @notes_widget.set_text(comments)
      end
    end
    @entry_for_laumspur_potions.set_text(
      _.n_laumspur_potions?.to_s
    ) if @entry_for_laumspur_potions
    if is_lone_wolf_series?
      set_n_meals(_.n_meals?)
    end
    if is_fantasy_theme?
      set_n_arrows(_.n_arrows?) if _.respond_to?(:n_arrows?)
      set_n_quivers(_.n_quivers?) if _.respond_to?(:n_quivers?)
    end
    if entry_current_combat_skill?
      set_current_combat_skill(
        _.current_combat_skill?.to_s
      )
    end
    if @scrolled_window_for_the_weapons
      @scrolled_window_for_the_weapons.set_text(
        _.weapons?.map {|entry|
          entry = entry.dup.rstrip
          case entry
          # =============================================================== #
          # === Summersword
          # =============================================================== #
          when 'Summersword'
            entry << ' # +8 CS'
          end
          # entry << ' #' unless entry.include?('#')
          # entry << ' carried'
          entry
        }.join("\n")
      )
    end
    if entry_initial_combat_skill? and _ and _.respond_to?(:initial_combat_skill?)
      entry_initial_combat_skill?.set_text(_.initial_combat_skill?.to_s)
    end
  end
end

#consider_loading_the_config_yml_fileObject

#

consider_loading_the_config_yml_file

This method will handle loading the config.yml file. That way users can modify the gamebook at hand, to some extent.

#


2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2840

def consider_loading_the_config_yml_file
  _ = path_to_the_file_config_yml
  if File.exist? _
    # ===================================================================== #
    # Load the config dataset next.
    # ===================================================================== #
    set_use_this_file(_)
    @config_dataset = YAML.load_file(_)
    # ===================================================================== #
    # Assign the theme next:
    # ===================================================================== #
    set_theme(@config_dataset[:theme])
    if @theme.nil?
      e 'A theme is currently mandatory. Please add a theme entry to '+
        steelblue('config.yml')
      exit
    else # else we assume the theme has been determined now
      # =================================================================== #
      # === @character
      #
      # The next clause has been disabled for now (February 2023). And
      # in March 2023 it has been re-enabled again.
      # =================================================================== #
      unless is_lone_wolf_series?
        create_the_default_gamebooks_character
      end
    end
    set_starting_page(@config_dataset[:starting_page]) # Simple setter call here.
  else
    no_file_exists_at(_)
  end
end

#consider_readjusting_the_gold_entryObject

#

consider_readjusting_the_gold_entry

#


2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2051

def consider_readjusting_the_gold_entry
  # ======================================================================= #
  # === :gold_entry_value_is
  #
  # The lone wolf series will rename this to "Gold Crowns".
  # ======================================================================= #
  if @config_dataset and @config_dataset.has_key? :gold_entry_value_is
    set_n_gold(@config_dataset[:gold_entry_value_is])
    if uses_DSA3?
      @spinbutton_for_geld.set_increments(1, 1)
    end
  end
end

#consider_renaming_the_entries_and_do_more_after_loading_the_gamebook_datasetObject

#

consider_renaming_the_entries_and_do_more_after_loading_the_gamebook_dataset

#


2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2903

def consider_renaming_the_entries_and_do_more_after_loading_the_gamebook_dataset
  return unless @config_dataset
  # ======================================================================= #
  # === :rename_gold_entry_to
  # ======================================================================= #
  if @config_dataset.has_key? :rename_gold_entry_to
    set_rename_gold_entry_to(@config_dataset[:rename_gold_entry_to])
  end
  # ======================================================================= #
  # === :rename_equipment_widget_to
  # ======================================================================= #
  if @config_dataset.has_key? :rename_equipment_widget_to
    set_rename_equipment_widget(@config_dataset[:rename_equipment_widget_to])
  end
  # ======================================================================= #
  # === :rename_gewandheit_entry_to
  # ======================================================================= #
  if @config_dataset.has_key? :rename_gewandheit_entry_to
    set_rename_gewandheit_entry_to(
      @config_dataset[:rename_gewandheit_entry_to]
    )
  end
  # ======================================================================= #
  # === :rename_stärke_entry_to
  # ======================================================================= #
  if @config_dataset.has_key? :rename_stärke_entry_to
    set_rename_stärke_entry_to(@config_dataset[:rename_stärke_entry_to])
  end
  # ======================================================================= #
  # === :font_to_use
  # ======================================================================= #
  if @config_dataset.has_key? :font_to_use
    set_font_to_use(@config_dataset[:font_to_use].to_sym)
    equipment_widget?.set_font(@config_dataset[:font_to_use].to_sym)
  end
  # ======================================================================= #
  # === :default_die
  # ======================================================================= #
  if @config_dataset.has_key? :default_die
    _ = @config_dataset[:default_die].to_s
    set_entry_containing_the_die(_)
  end
  # ======================================================================= #
  # === @image_to_use
  # ======================================================================= #
  @image_to_use = @config_dataset[:main_image]
  assumed_local_path = GamesAndRpgParadise.temp_dir?+
                       File.basename(@image_to_use)
  mkdir(File.dirname(assumed_local_path))
  # ======================================================================= #
  # Handle remote images here:
  # ======================================================================= #
  if @image_to_use.start_with?('http') and
    !File.exist?(assumed_local_path)
    # =================================================================== #
    # Download it and then use it.
    # =================================================================== #
    cd(GamesAndRpgParadise.temp_dir?)
    cd(File.dirname(assumed_local_path))
    # wget(@image_to_use)
    verbose_download_this_remote_image_into_that_assumed_local_path(@image_to_use, assumed_local_path)
    raw_filename = File.absolute_path(assumed_local_path)
    _ = raw_filename
  else
    _ = assumed_local_path
  end
  @image1.use_this_path = _
  if widget_switcher?
    widget_switcher?.widget1.use_this_path = _
  end
  consider_readjusting_the_gold_entry
end

#content_of?(this_page) ⇒ Boolean

#

content_of?

#

Returns:

  • (Boolean)


1179
1180
1181
1182
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1179

def content_of?(this_page)
  dataset = obtain_this_page_number(this_page)
  return dataset['content'] # obtain_entry(this_page)['content']
end

#context_menu?Boolean

#

context_menu?

#

Returns:

  • (Boolean)


1362
1363
1364
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1362

def context_menu?
  @context_menu
end

#continue_with_this_gamebook(i) ⇒ Object

#

continue_with_this_gamebook

#


2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2284

def continue_with_this_gamebook(i)
  @character.heal if @character.respond_to?(:heal) # Heal the character before a new gamebook.
  reset_the_game_state_to_the_default(0) # Starting page.
  array_result = load_the_dataset_for_the_gamebook(i)
  set_path_to_the_file_config_yml(array_result.last)
  consider_renaming_the_entries_and_do_more_after_loading_the_gamebook_dataset
  do_focus_on_the_text_view
  handle_game_book_specific_hooks_next
  set_the_title_of_the_gamebook_onto_the_corresponding_widget(
    GamesAndRpgParadise::Gamebooks.infer_title_of_this_gamebook_from_the_file_path(
      path_to_the_file_config_yml?
    )
  )
  visit_this_page(@starting_page)
end

#cover_image_URL?Boolean

#

cover_image_URL?

This method is only relevant if we have a remote cover-image. Since as of October 2022, having a remote cover-image is mandatory, even if it is only a decoy image.

#

Returns:

  • (Boolean)


1304
1305
1306
1307
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1304

def cover_image_URL?
  # @dataset['remote_image']
  @config_dataset[:main_image]
end

#create_ausrüstung_und_waffen_labelObject

#

create_ausrüstung_und_waffen_label

#


1393
1394
1395
1396
1397
1398
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1393

def create_ausrüstung_und_waffen_label
  # ======================================================================= #
  # === Ausrüstung und Waffen
  # ======================================================================= #
  @text_ausrüstung_label = bold_text('Ausrüstung')
end

#create_ausrüstung_und_waffen_widgetObject

#

create_ausrüstung_und_waffen_widget

#


1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1690

def create_ausrüstung_und_waffen_widget
  vbox = create_vbox
  path_to_the_backpack_image = "#{project_base_dir?}images/misc/Backpack.png"
  use_this_image = image(path_to_the_backpack_image)
  hint_to_use = 'The content below this image can be used to denote '\
                'the equipment carried by the main actor.'
  if is_a_lone_wolf_series?
    hint_to_use = hint_to_use.dup
    hint_to_use << "\n\nIn the lone wolf series one can not carry more "\
                   "than <b>eight</b> items in the backpack."
  end
  use_this_image.hint = hint_to_use
  # The next part does not seem to work that well, so it was commented
  # out in February 2023. May have to be re-enabled at a later time.
  # use_this_image.signal_connect(:query_tooltip) { |widget, x, y, keyboard_tip, tooltip|
  #   use_this_image.hint = hint_to_use
  #   true # Mandatory.
  # }
  vbox.minimal(@weapons_widget)
  hbox1 = create_hbox
  hbox1.minimal(use_this_image, 8)
  hbox1.minimal(@text_ausrüstung_label, 8)
  vbox.minimal(hbox1)
  vbox.minimal(@scrolled_window_for_the_equipment_buffer, 1)
  @ausrüstung_und_waffen_widget = vbox
end

#create_button_boxObject

#

create_button_box

#


1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1481

def create_button_box
  # ======================================================================= #
  # === @button_box
  # ======================================================================= #
  @button_box = create_vbox
  USE_N_CLICKABLE_BUTTONS.times {
    @array_buttons << return_main_button
  }
  # ======================================================================= #
  # Style the buttons next:
  # ======================================================================= #
  @array_buttons.each {|entry|
    entry.clear_background
    entry.set_border_width(1)
    entry.css_class('overlay')
    entry.pad8px
    @button_box.minimal(entry, 2)
    entry.hide
  }
end

#create_entry_for_the_diceObject

#

create_entry_for_the_dice

#


915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 915

def create_entry_for_the_dice
  # ======================================================================= #
  # === @entry_for_the_dice
  # ======================================================================= #
  @entry_for_the_dice = create_entry
  @entry_for_the_dice.bblack1
  @entry_for_the_dice.pad2px
  @entry_for_the_dice.center
  @entry_for_the_dice.lightblue_background
  @entry_for_the_dice.set_text('2W6')
  @entry_for_the_dice.make_bold
  @entry_for_the_dice.on_enter {
    do_handle_the_on_click_action_for_the_main_event_box
  }
  @entry_for_the_dice.hint =
    'This entry can be used to simulate the roll of some die. For '\
    'example, 3W6 means to roll 3 six-sided die, so the range will '\
    'be from 3 to 18. <b>2W6</b> means a range of 2-12 and so on.'
end

#create_entry_for_the_die_roll_resultObject

#

create_entry_for_the_die_roll_result

#


1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1533

def create_entry_for_the_die_roll_result
  # ======================================================================= #
  # === @entry_result_of_the_die_roll
  #
  # This entry will show the result of the die-roll.
  # ======================================================================= #
  @entry_result_of_the_die_roll = create_entry
  @entry_result_of_the_die_roll.bblack1
  @entry_result_of_the_die_roll.pad5px
  @entry_result_of_the_die_roll.center
  @entry_result_of_the_die_roll.lightblue_background
  @entry_result_of_the_die_roll.set_text('')
  @entry_result_of_the_die_roll.make_bold
  @entry_result_of_the_die_roll.hint =
    'This entry will show the result of the above die-roll. So, for '\
    'instance, if you had used a range of <b>2W6</b>, then the possible '\
    'range will be <b>from 2 to 12</b>.'
end

#create_entry_max_enduranceObject

#

create_entry_max_endurance

#


3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3538

def create_entry_max_endurance
  # ======================================================================= #
  # === @entry_max_endurance
  # ======================================================================= #
  @entry_max_endurance = create_entry
  @entry_max_endurance.center
  @entry_max_endurance.width_height(115, 20)
  @entry_max_endurance.bblack1
  @entry_max_endurance.pad2px
  @entry_max_endurance.set_font(SMALLEST_FONT)
  @entry_max_endurance.very_light_yellow_background
  @entry_max_endurance.make_bold
  @entry_max_endurance.hint =
    'This shows the <b>maximum endurance value</b>, with all '\
    'modifiers in place.'
end

#create_everything_pertaining_to_the_main_bufferObject

#

create_everything_pertaining_to_the_main_buffer

This method will ultimately create the main buffer.

#


1722
1723
1724
1725
1726
1727
1728
1729
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1722

def create_everything_pertaining_to_the_main_buffer
  create_the_main_text_buffer_and_then_create_the_main_text_view
  # ======================================================================= #
  # Now we can put @text_view_holding_the_gamepage_content into a
  # scrolled window.
  # ======================================================================= #
  create_the_sourceview_containing_the_content_of_the_gamebook_entry
end

#create_skeletonObject

#

create_skeleton (create tag, skeleton tag)

#


3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3004

def create_skeleton
  create_spinbutton_for_geld
  create_widget_for_glück_entry
  create_everything_pertaining_to_the_main_buffer
  create_text_containing_the_gewandheitspunkte_label
  create_text_keeping_the_gamebook_title # Call this before create_the_right_frame().
  create_the_equipment_widget
  create_ausrüstung_und_waffen_label
  create_stärke_label
  create_the_text_containing_the_money_label
  create_the_special_image
  create_the_main_image # This can come early.
  create_spinbutton_for_geld # (1) First, show some gold.
  create_button_box # This should be called before the entries are created.
  create_the_entries
  create_the_context_menu # Call this last.
  create_the_widget_switcher # Must be called before the right-frame is created.
  create_the_weapons_widget # This must come before create_ausrüstung_und_waffen_widget()
  create_ausrüstung_und_waffen_widget
  # ======================================================================= #
  # Next, we will create the left and right frame. These should come last.
  # ======================================================================= #
  create_the_left_frame
  create_the_right_frame
end

#create_spinbutton_for_geldObject

#

create_spinbutton_for_geld

#


746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 746

def create_spinbutton_for_geld
  # ======================================================================= #
  # And our cute little spinbutton.
  # ======================================================================= #
  @spinbutton_for_geld = create_spinbutton(0, 50_000, 100)
  @spinbutton_for_geld.set_value('5000')
  @spinbutton_for_geld.center
  # spinbutton.width_height(115, 20)
  @spinbutton_for_geld.bblack1
  @spinbutton_for_geld.pad2px
  @spinbutton_for_geld.make_bold
  @spinbutton_for_geld.light_pink_background
  @spinbutton_for_geld.hint =
    "This entry field can be used to keep track of money, gold, "\
    "\"Kopeken\", or however these are called in the respective "\
    "gamebook.\n\nNote that if you ever run out of money, while "\
    "having to pay something, the adventure will be over."
end

#create_stärke_labelObject

#

create_stärke_label

#


1403
1404
1405
1406
1407
1408
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1403

def create_stärke_label
  text = left_aligned_text('Stärke:'.ljust(22))
  text.set_font(SMALLEST_FONT)
  text.make_bold
  @text_containing_the_stärke_label = text
end

#create_text_containing_the_gewandheitspunkte_labelObject

#

create_text_containing_the_gewandheitspunkte_label

#


1144
1145
1146
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1144

def create_text_containing_the_gewandheitspunkte_label
  @text_containing_the_gewandheitspunkte_label = return_left_aligned_bold_text('Gewandheit:')
end

#create_text_keeping_the_gamebook_titleObject

#

create_text_keeping_the_gamebook_title

#


2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2209

def create_text_keeping_the_gamebook_title
  # ======================================================================= #
  # === @text_keeping_the_gamebook_title
  # ======================================================================= #
  @text_keeping_the_gamebook_title = text(" #{gamebook_title?}.yml ")
  @text_keeping_the_gamebook_title.use_this_font = LARGE_FONT
  @text_keeping_the_gamebook_title.make_bold
  @text_keeping_the_gamebook_title.width_height(400, 50)
  @text_keeping_the_gamebook_title.make_selectable
  return @text_keeping_the_gamebook_title
end

#create_the_context_menuObject

#

create_the_context_menu

This is the context-menu which will appear on a right-mouse click event.

#


1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1091

def create_the_context_menu
  # ======================================================================= #
  # === @context_menu
  # ======================================================================= #
  @context_menu = create_context_menu(self) {{
    actions: {
      '(1) Pick another font':  :pick_another_font,
      '(2) Roll the dice':      :roll_the_dice
    }
  }}
  @context_menu.make_bold
  @context_menu.set_font(:hack_18)
end

#create_the_default_gamebooks_characterObject

#

create_the_default_gamebooks_character

This is the default, but it should NOT be called when the user plays a lone-wolf series gamebook.

#


315
316
317
318
319
320
321
322
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 315

def create_the_default_gamebooks_character
  @character = ::GamesAndRpgParadise::Gamebooks::Character.new(
    {
      max_stärke:     10,
      current_stärke: 10
    }
  )
end

#create_the_entriesObject

#

create_the_entries (entries tag, entry tag)

#


1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1505

def create_the_entries
  create_entry_max_endurance
  create_the_stärke_entry
  # ======================================================================= #
  # === @entry_containing_the_number_of_the_subsection
  # ======================================================================= #
  create_the_entry_containing_the_number_of_the_subsection
  create_entry_for_the_dice # Create the entry for the dice.
  create_entry_for_the_die_roll_result
end

#create_the_entry_containing_the_number_of_the_subsectionObject

#

create_the_entry_containing_the_number_of_the_subsection

This should be moved into the module.

#


1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1459

def create_the_entry_containing_the_number_of_the_subsection
  # ======================================================================= #
  # === @entry_containing_the_number_of_the_subsection
  # ======================================================================= #
  @entry_containing_the_number_of_the_subsection = create_entry
  @entry_containing_the_number_of_the_subsection.bblack4
  @entry_containing_the_number_of_the_subsection.pad6px
  @entry_containing_the_number_of_the_subsection.center
  @entry_containing_the_number_of_the_subsection.light_green_background
  @entry_containing_the_number_of_the_subsection.set_text('0')
  @entry_containing_the_number_of_the_subsection.make_bold
  @entry_containing_the_number_of_the_subsection.deselect
  #@entry_containing_the_number_of_the_subsection.on_mouse_click_select_everything
  @entry_containing_the_number_of_the_subsection.hint =
    'This entry can be used to indicate which "page" is the currently '\
    'active page. For example, the number 5 would mean that we '\
    'would start at the gamebook entry number 5.'
end

#create_the_equipment_widgetObject

#

create_the_equipment_widget (equipment tag)

#


1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1758

def create_the_equipment_widget
  # ======================================================================= #
  # === @equipment_buffer
  # ======================================================================= #
  @equipment_buffer = create_text_buffer
  text_view_for_the_equipment_buffer = create_text_view(@equipment_buffer)
  text_view_for_the_equipment_buffer.pad2px
  # ======================================================================= #
  # === @scrolled_window_for_the_equipment_buffer
  # ======================================================================= #
  @scrolled_window_for_the_equipment_buffer = scrolled_window(text_view_for_the_equipment_buffer) { :no_scrolling }
  @scrolled_window_for_the_equipment_buffer.bblack2
  @scrolled_window_for_the_equipment_buffer.pad5px
  @scrolled_window_for_the_equipment_buffer.width_height(42, 160)
  @scrolled_window_for_the_equipment_buffer.set_use_this_font(smallest_font?)
  return @scrolled_window_for_the_equipment_buffer
end

#create_the_left_frameObject

#

create_the_left_frame

#


4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4552

def create_the_left_frame
  # ======================================================================= #
  # === outer_vbox
  #
  # This is the primary box on the left-widget side.
  # ======================================================================= #
  outer_vbox = create_vbox
  outer_vbox.set_border_width(4)
  text_for_the_control_panel = create_text('Control Panel')
  text_for_the_control_panel.css_class('royalblue')
  text_for_the_control_panel.set_use_this_font(largest_font?)
  text_for_the_control_panel.make_bold
  outer_vbox.minimal(text_for_the_control_panel)
  outer_vbox.minimal(hspacer)
  # ======================================================================= #
  # === hbox_containing_the_entry_containing_the_number_of_the_subsection_as_well_as_the_left_arrow_widget
  # ======================================================================= #
  hbox_containing_the_entry_containing_the_number_of_the_subsection_as_well_as_the_left_arrow_widget = create_hbox
  hbox_containing_the_entry_containing_the_number_of_the_subsection_as_well_as_the_left_arrow_widget.minimal(
    return_the_event_box_containing_the_new_game_icon
  )
  hbox_containing_the_entry_containing_the_number_of_the_subsection_as_well_as_the_left_arrow_widget.maximal(
    @entry_containing_the_number_of_the_subsection
  )
  hbox_containing_the_entry_containing_the_number_of_the_subsection_as_well_as_the_left_arrow_widget.minimal(
    return_left_arrow_widget
  )
  # ======================================================================= #
  # The next hbox contains the number of the subsection, as well as the
  # left arrow widget.
  # ======================================================================= #
  outer_vbox.minimal(hbox_containing_the_entry_containing_the_number_of_the_subsection_as_well_as_the_left_arrow_widget)
  outer_vbox.minimal(hspacer)
  # ======================================================================= #
  # Add the grid containing GE, ST and GL:
  # ======================================================================= #
  outer_vbox.minimal(return_grid_containing_GE_ST_and_GL, 1)
  outer_vbox.minimal(hspacer)
  if use_science_fiction_widget?
    # ===================================================================== #
    # Add the "Raumschiff" next.
    # ===================================================================== #
    outer_vbox.minimal(return_raumschiff_widget, 1)
    outer_vbox.minimal(hspacer)
  end
  outer_vbox.minimal(grid)
  outer_vbox.minimal(hspacer)
  # ======================================================================= #
  # === Next add the roll-a-die event box and associated entries to
  #     the outer-vbox. As of 09.03.2023 this is now a single
  #     hbox instead.
  # ======================================================================= #
  hbox_for_the_die_image = create_hbox
  hbox_for_the_die_image.minimal(entry_for_the_dice?, 2)
  hbox_for_the_die_image.minimal(vspacer)
  hbox_for_the_die_image.maximal(return_event_box_for_the_die_image)
  hbox_for_the_die_image.minimal(vspacer)
  hbox_for_the_die_image.minimal(@entry_result_of_the_die_roll, 2)
  outer_vbox.minimal(hbox_for_the_die_image)
  # ======================================================================= #
  # Next, add lone-wolf specific parts, via a draggable widget.
  # ======================================================================= #
  if is_lone_wolf?
    # ===================================================================== #
    # === widget1
    # ===================================================================== #
    widget1 = create_vbox
    widget1.maximal(return_kai_disciplines_widget_for_the_one_lone_wolf_series)
    widget1.minimal(hspacer)
    small_hbox_containing_n_meals_and_n_laumspur_tränke_and_n_alether_potions = create_hbox
    small_hbox_containing_n_meals_and_n_laumspur_tränke_and_n_alether_potions.maximal(return_n_meals,           4)
    small_hbox_containing_n_meals_and_n_laumspur_tränke_and_n_alether_potions.maximal(return_n_laumspur_tränke, 4)
    small_hbox_containing_n_meals_and_n_laumspur_tränke_and_n_alether_potions.maximal(return_n_alether_potions, 4)
    # ===================================================================== #
    # === widget2
    # ===================================================================== #
    widget2 = create_vbox
    widget2.minimal(small_hbox_containing_n_meals_and_n_laumspur_tränke_and_n_alether_potions)
    widget2.minimal(hspacer)
    widget2.minimal(return_quivers_and_arrows_widget)
    widget2.minimal(hspacer)
    draggable = draggable_via_up_and_down_movement(
      widget1, # kai disciplines widget.
      widget2  # hbox containing n-meals and n-laumspurtränke as well as quivers and arrows.
    )
    draggable.position = 180 # This determines the position above the "Meals" and "Laumspur" widget.
    outer_vbox.maximal(draggable)
  end
  # ======================================================================= #
  # vbox.minimal(@entry_for_the_dice, 5)
  # "Ausrüstung" aka equipment should be shown above the geld (money)
  # widget:
  # ======================================================================= #
  outer_vbox.minimal(return_ausrüstung_und_waffen_widget)
  outer_vbox.minimal(hspacer)
  outer_vbox.minimal(return_geld_widget) # The geld-widget will be the last widget here.
  outer_vbox.minimal(hspacer)
  @left_frame = outer_vbox
end

#create_the_main_imageObject

#

create_the_main_image

#


3834
3835
3836
3837
3838
3839
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3834

def create_the_main_image
  # ======================================================================= #
  # === @image1
  # ======================================================================= #
  @image1 = create_image
end

#create_the_main_text_bufferObject

#

create_the_main_text_buffer

#


3880
3881
3882
3883
3884
3885
3886
3887
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3880

def create_the_main_text_buffer
  # ======================================================================= #
  # === @buffer_holding_the_gamepage_content
  #
  # This text-buffer will carry the main content of the gamebook at hand.
  # ======================================================================= #
  @buffer_holding_the_gamepage_content = create_text_buffer
end

#create_the_main_text_buffer_and_then_create_the_main_text_viewObject

#

create_the_main_text_buffer_and_then_create_the_main_text_view

#


1555
1556
1557
1558
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1555

def create_the_main_text_buffer_and_then_create_the_main_text_view
  create_the_main_text_buffer # Call this one first here.
  create_the_main_text_view
end

#create_the_main_text_view(use_this_buffer = @buffer_holding_the_gamepage_content) ⇒ Object Also known as: create_the_text_view

#

create_the_text_view

This will create the text-view that will ultimately hold the main buffer for this widget.

#


3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3895

def create_the_main_text_view(
    use_this_buffer = @buffer_holding_the_gamepage_content
  )
  # ======================================================================= #
  # === @text_view_holding_the_gamepage_content
  # ======================================================================= #
  @text_view_holding_the_gamepage_content = create_text_view(
    use_this_buffer
  )
  @text_view_holding_the_gamepage_content.css_class('custom_text_view')
  @text_view_holding_the_gamepage_content.set_left_margin(10) # For a bit of padding.
  @text_view_holding_the_gamepage_content.set_right_margin(10) # For a bit of padding.
  @text_view_holding_the_gamepage_content.set_top_margin(4)
  @text_view_holding_the_gamepage_content.set_bottom_margin(4)
end

#create_the_right_frameObject

#

create_the_right_frame

This is the right frame that sits on top.

#


3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3201

def create_the_right_frame
  @notebook = create_notebook
  @notebook.is_scrollable
  hbox1 = create_hbox
  # ======================================================================= #
  # (1) Add the "how to use this widget" info-button first
  # ======================================================================= #
  hbox1.minimal(return_widget_containing_usage_information)
  # ======================================================================= #
  # (2) Add the "create new character" widget next
  # ======================================================================= #
  hbox1.minimal(return_create_new_character_widget)
  # ======================================================================= #
  # (3) Next, add the widget for saving the character. This should
  #     come after the usage-info button.
  # ======================================================================= #
  hbox1.minimal(return_widget_save_the_character)
  # ======================================================================= #
  # (4) Add the gamebook title first
  # ======================================================================= #
  hbox1.minimal(@text_keeping_the_gamebook_title, 4)
  # ======================================================================= #
  # (5) The next event-box can be used to show the available gamebooks:
  # ======================================================================= #
  event_box1 = create_event_box(image_document_open)
  event_box1.css_classes 'pad2px mar2px'
  event_box1.hint =
    'Here you can select the gamebook that is to be used.'
  @popover_showing_the_available_gamebooks = return_popover(
    return_widget_containing_the_available_gamebooks,
    event_box1,
    35
  )
  @popover_showing_the_available_gamebooks.popdown
  event_box1.on_clicked {
    @popover_showing_the_available_gamebooks.popup
  }
  # ======================================================================= #
  # (5) Next add the event-box that shows the available
  #     local gamebooks
  # ======================================================================= #
  hbox1.minimal(event_box1) # Finally add the event box to the hbox.
  if @character and @character.is_lone_wolf?
    # ===================================================================== #
    # (6) And some more helper-widgets for the lone-wolf series:
    # ===================================================================== #
    hbox1.minimal(return_event_box_for_the_circle_of_fire)
    hbox1.minimal(return_event_box_for_the_circle_of_light)
    hbox1.minimal(return_event_box_for_the_circle_of_solaris)
    hbox1.minimal(return_event_box_for_the_circle_of_spirit)
  end
  hbox1.show_all # The four circles.
  # ======================================================================= #
  # Add the widget switcher next.
  # ======================================================================= #
  @notebook.add_tab(widget_switcher?, hbox1)
  # ======================================================================= #
  # === Actionsheet
  #
  # This should come before the Notes.
  # ======================================================================= #
  if lone_wolf_series?
    @actionsheet_label = text('Actionsheet')
    @actionsheet_label.darkblue
    @actionsheet_label.make_bold
    # ===================================================================== #
    # Add the actionsheet-widget next:
    # ===================================================================== #
    @notebook.add_tab(return_actionsheet_widget, @actionsheet_label)
  end
  # ======================================================================= #
  # === Notes
  # ======================================================================= #
  @notes_label = text('Notes')
  @notes_label.darkblue
  @notes_label.make_bold
  @notebook.add_tab(return_notes_widget, @notes_label)
  if is_on_roebe?
    # ===================================================================== #
    # On a roebe-system we will add an additional "Admin panel".
    # ===================================================================== #
    @admin_label = text('Admin panel')
    @admin_label.darkblue
    @admin_label.make_bold
    @notebook.add_tab(return_admin_panel, @admin_label)
  end
  @notebook.show_all
  hbox = create_hbox
  hbox.maximal(@notebook)
  @right_frame = hbox
  @right_frame.show_all
end

#create_the_sourceview_containing_the_content_of_the_gamebook_entryObject Also known as: create_the_scrolled_window

#

create_the_sourceview_containing_the_content_of_the_gamebook_entry

This should only be called after @text_view has been created.

#


1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1827

def create_the_sourceview_containing_the_content_of_the_gamebook_entry
  # ======================================================================= #
  # === @sourceview_containing_the_content_of_the_gamebook_entry
  # ======================================================================= #
  _ = create_scrolled_window(
    @text_view_holding_the_gamepage_content
  ) { :automatic }
  _.bblack1
  _.width_height(250, 500)
  _.set_name('main_scrolled_window')
  _.set_border_width(0)
  _.pad8px
  @sourceview_containing_the_content_of_the_gamebook_entry = _
end

#create_the_special_imageObject

#

create_the_special_image

#


3844
3845
3846
3847
3848
3849
3850
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3844

def create_the_special_image
  # ======================================================================= #
  # The @special_image may contain ad-hoc images. These images belong to
  # the actual gamebook.
  # ======================================================================= #
  @special_image = create_image
end

#create_the_stärke_entryObject

#

create_the_stärke_entry

#


3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3567

def create_the_stärke_entry
  # ======================================================================= #
  # === @entry_stärke
  # ======================================================================= #
  @entry_stärke = create_entry
  @entry_stärke.center
  @entry_stärke.width_height(115, 20)
  @entry_stärke.bblack1
  @entry_stärke.pad2px
  @entry_stärke.set_font(SMALLEST_FONT)
  @entry_stärke.yellow_background
  @entry_stärke.make_bold
  if is_lonewolf_series?
    @entry_stärke.hint =
      'This shows the <b>current endurance value</b>.'
  end
end

#create_the_text_containing_the_money_labelObject

#

create_the_text_containing_the_money_label

#


2093
2094
2095
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2093

def create_the_text_containing_the_money_label
  @text_containing_the_money_label = return_left_aligned_bold_text('Geld:')
end

#create_the_weapons_widgetObject

#

create_the_weapons_widget (weapons tag)

#


1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1779

def create_the_weapons_widget
  @weapons_widget = create_vbox
  swords_icon = create_image(
    GamesAndRpgParadise.project_base_directory?+
    'images/misc/crossed_swords_icon.png'
  )
  swords_icon.hint =
    'This widget can be used to denote weapons that are carried. '\
    'This is primarily for the lone wolf gamebook series.'
  label = bold_text('Weapons')
  hbox1 = create_hbox
  hbox1.minimal(swords_icon, 2)
  hbox1.minimal(label,       2)
  @weapons_widget_text_buffer = create_buffer
  text_view = create_text_view(@weapons_widget_text_buffer)
  @scrolled_window_for_the_weapons = create_scrolled_window(text_view)
  @scrolled_window_for_the_weapons.bblack2
  @scrolled_window_for_the_weapons.pad2px
  @scrolled_window_for_the_weapons.width_height(200, 60)
  @scrolled_window_for_the_weapons.set_use_this_font(smallest_font?)
  @weapons_widget.minimal(hbox1)
  @weapons_widget.maximal(@scrolled_window_for_the_weapons)
end

#create_the_widget_switcher(height = height? ) ⇒ Object

#

create_the_widget_switcher

Normally an image keeps the widget-switcher “hidden”.

#


4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4254

def create_the_widget_switcher(
    height = height?
  )
  # ======================================================================= #
  # Two widgets are part of the upper widget: the main scrolled window,
  # and the scrolled window below containing the special image.
  # ======================================================================= #
  # upper_widget = up_and_down_dragging(
  # upper_widget.position = height+100
  # ======================================================================= #
  # All the clickable buttons will be stored in a scrolled-window next:
  # ======================================================================= #
  scrolled_window_containing_the_button_box = scrolled_window(return_the_button_box)
  scrolled_window_containing_the_button_box.set_name(
    'scrolled_window_containing_the_buttons_on_the_bottom_right_side'
  )
  _ = up_and_down_dragging(
    the_primary_scrolled_window?,
    scrolled_window_containing_the_button_box
  )
  _.set_name('padded_min_height')
  _.position = height+150
  scrolled_window_containing_the_right_pane = create_scrolled_window(_)
  @widget_switcher = ::Gtk::WidgetSwitcher.new(
    [
      @image1,
      scrolled_window_containing_the_right_pane
    ]
  )
  @widget_switcher.widget1.hint =
    'Click on the image to "<b>open</b>" the first page '\
    'of this gamebook.'
end

#create_widget_for_glück_entryObject

#

create_widget_for_glück_entry

#


2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2986

def create_widget_for_glück_entry
  @entry_glück = create_entry(
    (
      roll_this_die('1W6').to_i+6
    ).to_s
  )
  @entry_glück.center
  @entry_glück.width_height(115, 20)
  @entry_glück.bblack1
  @entry_glück.pad4px
  @entry_glück.set_font(SMALLEST_FONT)
  @entry_glück.yellow_background
  @entry_glück.make_bold
end

#current_combat_skill_value?Boolean Also known as: current_CS?

#

current_combat_skill_value?

#

Returns:

  • (Boolean)


2510
2511
2512
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2510

def current_combat_skill_value?
  entry_current_combat_skill?.text?.to_i
end

#current_endurance_from_the_widget?Boolean Also known as: current_endurance?

#

current_endurance_from_the_widget?

#

Returns:

  • (Boolean)


1286
1287
1288
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1286

def current_endurance_from_the_widget?
  @entry_stärke.text?.to_i
end

#current_endurance_of_the_opponent?Boolean Also known as: current_endurance_of_the_enemy?

#

current_endurance_of_the_opponent?

#

Returns:

  • (Boolean)


3728
3729
3730
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3728

def current_endurance_of_the_opponent?
  opponent_endurance_entry?.text?.to_i
end

#current_glück_value?Boolean

#

current_glück_value?

#

Returns:

  • (Boolean)


1335
1336
1337
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1335

def current_glück_value?
  @entry_glück.text?.to_i
end

#current_page?Boolean

#

current_page?

#

Returns:

  • (Boolean)


1257
1258
1259
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1257

def current_page?
  main_entry?.text
end

#current_stärke?Boolean

#

current_stärke?

#

Returns:

  • (Boolean)


1115
1116
1117
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1115

def current_stärke?
  @character.current_stärke? if @character and @character.respond_to?(:current_stärke?)
end

#dataset_for_the_gamebook?Boolean Also known as: main_dataset?

#

dataset_for_the_gamebook?

#

Returns:

  • (Boolean)


2202
2203
2204
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2202

def dataset_for_the_gamebook?
  @dataset_for_the_gamebook
end

#dataset_has_this_page?(this_page) ⇒ Boolean

#

dataset_has_this_page?

#

Returns:

  • (Boolean)


2195
2196
2197
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2195

def dataset_has_this_page?(this_page)
  dataset_for_the_gamebook?.has_key?(this_page.to_i)
end

#deduct(how_much, which_attribute) ⇒ Object

#

deduct (deduct tag)

This method can be used to deduct a number from one of the attributes,

    1. “Glück”, “Stärke”“ and so forth.

#


3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3061

def deduct(
    how_much,
    which_attribute
  )
  case which_attribute
  # ======================================================================= #
  # === Stärkepunkt
  # ======================================================================= #
  when /^Stärkepunkt/
    current_value = @entry_stärke.text?
    if current_value.include? '/'
      current_value = current_value.split('/').first.to_s
    end
    new_value = current_value.to_i - how_much.to_i
    new_value = 0 if new_value < 0
    set_current_stärkepunkte(new_value)
    @character.set_current_stärkepunkte(new_value) if @character.respond_to?(:set_current_stärkepunkte)
    autoset_gtk_entry_stärke
  # ======================================================================= #
  # === Abwehrkraft
  # ======================================================================= #
  when /Abwehrkraft/
    e 'Deducting Abwehrkraft.'
    new_value = @entry_abwehrkraft.text?.to_i - how_much.to_i
    new_value = 0 if new_value < 0
    @entry_abwehrkraft.set_text(new_value.to_s)
    if new_value == 0
      the_game_is_over
    end
  # ======================================================================= #
  # === Gewandheitspunkt
  # ======================================================================= #
  when /^Gewandheitspunkt/
    new_value = @entry_gewandheitspunkte.text?.to_i - how_much.to_i
    new_value = 0 if new_value < 0
    @entry_gewandheitspunkte.set_text(new_value.to_s)
  else # Else we are not (yet) handling this event.
    e '-'*80
    e ::Colours.steelblue('Not handled in deduct(): '+which_attribute.to_s)
    e 'The original input in deduct() was:'
    pp how_much
    pp which_attribute
    e 'The page id was:'
    pp page_id?
    e '-'*80
  end
end

#deduct_n_endurance_points(i) ⇒ Object

#

deduct_n_endurance_points

#


3112
3113
3114
3115
3116
3117
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3112

def deduct_n_endurance_points(i)
  _  = current_endurance?.to_i
  _ -= i
  _ = 0 if _ < 0 # Low-cap it here.
  set_current_endurance(_)
end

#deduct_one_point_from_luckObject

#

deduct_one_point_from_luck

#


1583
1584
1585
1586
1587
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1583

def deduct_one_point_from_luck
  new_value = (@entry_glück.text?.to_i - 1).to_s
  new_value = 0 if new_value.to_i < 0
  @entry_glück.set_text(new_value.to_s)
end

#die_icon?Boolean

#

die_icon?

#

Returns:

  • (Boolean)


2979
2980
2981
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2979

def die_icon?
  @hbox_containing_the_die_images # @image_containing_the_die
end

#disable_this_button(i = 0) ⇒ Object

#

disable_this_button

This method can be used to disable one of the buttons.

#


1241
1242
1243
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1241

def disable_this_button(i = 0)
  @array_buttons[i].disable_the_button
end

#do_clear_the_main_text_buffer(buffer = :try_to_use_the_buffer_holding_the_gamepage_content) ⇒ Object

#

do_clear_the_main_text_buffer

#


1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1018

def do_clear_the_main_text_buffer(
    buffer = :try_to_use_the_buffer_holding_the_gamepage_content
  )
  case buffer
  # ======================================================================= #
  # === :try_to_use_the_buffer_holding_the_gamepage_content
  # ======================================================================= #
  when :try_to_use_the_buffer_holding_the_gamepage_content
    if does_the_main_sourceview_exist?
      buffer = buffer_holding_the_gamepage_content?
    else
      buffer = nil
    end
  end
  set_main_buffer_content('') if buffer
end

#do_debugObject

#

do_debug

#


1813
1814
1815
1816
1817
1818
1819
1820
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1813

def do_debug
  e ::Colours.violet(
     'Showing some debug-information about the main character next:'
    )
  e
  pp @character
  e
end

#do_focus_on_the_text_viewObject

#

do_focus_on_the_text_view

#


451
452
453
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 451

def do_focus_on_the_text_view
  @text_view_holding_the_gamepage_content.do_focus
end

#do_handle_the_on_click_action_for_the_main_event_boxObject Also known as: roll_the_main_die, roll_the_dice

#

do_handle_the_on_click_action_for_the_main_event_box

This is the method that is tied to @entry_for_the_dice, so when the user clicks on the die-image.

#


3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3453

def do_handle_the_on_click_action_for_the_main_event_box
  _ = @entry_for_the_dice.text?.to_s
  # e 'Roll the die: '+::Colours.steelblue(_) # This can be used for debugging still.
  result = roll_the_die(_).to_i
  @entry_result_of_the_die_roll.set_text(result.to_s)
  # ======================================================================= #
  # Next we can use this clause for any current combat situation, since
  # as of March 2023. We will only do so if the endurance-counter for
  # the opponent is higher than 0; a value of 0 means that the enemy is
  # dead.
  #
  # This will only work for the lone-wolf gamebook series presently.
  # ======================================================================= #
  if enemy_endurance_entry? and enemy_endurance_entry?.text?.to_i > 0
    @entry_current_combat_round.increment_by(1)
    difference = current_CS?.to_i - enemy_CS?.to_i
    hash_to_work_with = combat_ratio(difference)
    if hash_to_work_with.is_a? Array
      hash_to_work_with = hash_to_work_with.first
    end
    # ===================================================================== #
    # Now we have to determine the values to deduct from.
    # ===================================================================== #
    pointer = hash_to_work_with
    array = pointer[result]
    if array
      deduct_n1 = array.last
      deduct_n2 = array.first
      if deduct_n1 == 'Killed'
        deduct_n1 = current_endurance?.to_i
      end
      if deduct_n2 == 'Killed'
        deduct_n2 = current_endurance_of_the_opponent?.to_i
      end
      set_current_endurance(
        current_endurance?.to_i - deduct_n1.to_i
      ) { :can_not_go_below_zero }
      _ = current_endurance_of_the_enemy?.to_i - deduct_n2.to_i
      _ = 0 if _ < 0
      set_current_endurance_of_the_enemy(_)
    end
  end
end

#do_open_the_current_yaml_file_in_the_editorObject

#

do_open_the_current_yaml_file_in_the_editor

#


4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4774

def do_open_the_current_yaml_file_in_the_editor
  _ = yaml_file?.dup
  if is_on_roebe? # Use the "real" path in this case.
    _.sub!(
      Regexp.new(
        Regexp.quote('/usr/lib/ruby/site_ruby/3.2.0/')
      ),
      '/home/x/programming/ruby/src/games_and_rpg_paradise/lib/'
    )
  end
  if File.exist? _ # Delegate towards the 'open' gem next.
    Open.in_editor(_)
  elsif is_on_roebe?
    e 'No file was found at '+sfile(_)
  end
end

#do_pop_up_the_create_new_character_widgetObject

#

do_pop_up_the_create_new_character_widget

#


3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3392

def do_pop_up_the_create_new_character_widget
  @character = ::GamesAndRpgParadise::GUI::Gtk::LoneWolf::CreateNewCharacter.new # Always assign anew here.
  pop_up_widget(
    over_this_widget: die_icon?,
    custom_widget:    @character
  ).popup
  # ======================================================================= #
  # Next, sync the entries:
  # ======================================================================= #
  # This is missing right now. So it's a TODO entry.
  # ======================================================================= #
end

#do_popup_game_over_message(over_that_widget = scrolled_window?, , use_this_as_game_over_text = " <b>Das Abenteuer ist zu Ende</b>.\n\n "\ "Starte das Spielbuch von vorne, es sei denn es wurde erfolgreich "\ "beendet.\n"\ "Hierzu drücke auf das Bild ganz links oben.\n") ⇒ Object Also known as: the_game_is_over

#

do_popup_game_over_message

#


1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1428

def do_popup_game_over_message(
    over_that_widget           = scrolled_window?,
    use_this_as_game_over_text = " <b>Das Abenteuer ist zu Ende</b>.\n\n "\
      "Starte das Spielbuch von vorne, es sei denn es wurde erfolgreich "\
      "beendet.\n"\
      "Hierzu drücke auf das Bild ganz links oben.\n"
  )
  text = use_this_as_game_over_text
  popup_this_text_over_that_widget(
    text, over_that_widget
  )
end

#do_save_the_characterObject Also known as: save, save_the_character

#

do_save_the_character (save tag)

This method will save the character into a local .yml file.

#


4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4677

def do_save_the_character
  # ======================================================================= #
  # First we have to update the character dataset:
  # ======================================================================= #
  @character.set_n_gold(n_gold?) if spinbutton_for_geld?
  @character.set_n_meals(n_meals?) if @entry_for_meals
  @character.set_n_arrows(n_arrows?) if @entry_for_n_arrows
  if @entry_for_n_quivers
    @character.set_n_quivers(n_quivers?)
    @character.set_n_laumspur(n_laumspur?)
  end
  if @entry_for_alether_potions
    @character.set_n_alether_potions(n_alether_potions?)
  end
  if @entry_stärke
    @character.set_base_endurance(current_endurance?.to_i)
    @character.set_max_endurance(max_endurance?)
  end
  if entry_combat_skill1?
    @character.set_initial_combat_skill(entry_combat_skill1?.text?.to_i)
    @character.set_max_combat_skill(entry_combat_skill2?.text?.to_i)
    @character.set_comments(comments?)
  end
  if @equipment_buffer
    @character.set_equipment(equipment_buffer_content?)
    @character.set_kai_disciplines(
      buffer_containing_the_kai_disciplines?
    )
    if weapons_buffer?
      @character.set_weapons(weapons_buffer?.text?)
    end
  end

  saved_into = @character.do_save
  pop_up_widget(
    over_this_widget: die_icon?,
    custom_widget:    text('The character was saved into <b>'+saved_into.to_s+'</b>')
  ).popup
end

#do_show_info_how_to_use_this_widgetObject

#

do_show_info_how_to_use_this_widget

#


1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1047

def do_show_info_how_to_use_this_widget
  vbox = create_vbox
  # ======================================================================= #
  # Style this vbox a bit:
  # ======================================================================= #
  vbox.pad5px
  vbox.set_border_width(6)
  vbox.use_this_font = :hack_16
  larger_text = text(
    "<b>Information on how to use this widget</b>\n"
  )
  larger_text.use_this_font = :hack18
  vbox.add(larger_text)
  vbox.add_hspacer
  vbox.add(
    left_aligned_text(
      "First, click on the main image (if available).\n\n"\
      "Now you should be able to select the path to go through the "\
      "adventure, by clicking on the buttons on the bottom right side.\n\n"\
      "When you encounter a fight situation make use of the die to "\
      "the left hand side."
    )
  )
  vbox.add_hspacer
  pop_up_widget(
    over_this_widget: die_icon?,
    custom_widget:    vbox
  ).popup
end

#does_the_main_sourceview_exist?Boolean

#

does_the_main_sourceview_exist?

#

Returns:

  • (Boolean)


1631
1632
1633
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1631

def does_the_main_sourceview_exist?
  !@sourceview_containing_the_content_of_the_gamebook_entry.nil?
end

#does_this_gamebook_use_a_cover_image?Boolean

#

does_this_gamebook_use_a_cover_image?

This method will return true if the gamebook uses a cover image.

If a cover image is used then it will be shown, before the scrolled-window with the first entry will be displayed.

#

Returns:

  • (Boolean)


2003
2004
2005
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2003

def does_this_gamebook_use_a_cover_image?
  @config_dataset.has_key?(:main_image)
end

#empty_the_label_containing_the_name_of_the_opponentObject

#

empty_the_label_containing_the_name_of_the_opponent

#


3051
3052
3053
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3051

def empty_the_label_containing_the_name_of_the_opponent
  @label_name_of_the_opponent.set_text('')
end

#enemy_CS?Boolean

#

enemy_CS?

#

Returns:

  • (Boolean)


2527
2528
2529
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2527

def enemy_CS?
  @opponent_combat_skill_entry.text?.to_i
end

#entry_current_combat_skill?Boolean Also known as: entry_combat_skill2?

#

entry_current_combat_skill?

#

Returns:

  • (Boolean)


2503
2504
2505
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2503

def entry_current_combat_skill?
  @entry_current_combat_skill
end

#entry_for_the_dice?Boolean

#

entry_for_the_dice?

#

Returns:

  • (Boolean)


479
480
481
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 479

def entry_for_the_dice?
  @entry_for_the_dice
end

#entry_gewandheitspunkte?Boolean Also known as: entry_initial_combat_skill?, entry_combat_skill1?

#

entry_gewandheitspunkte?

#

Returns:

  • (Boolean)


1080
1081
1082
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1080

def entry_gewandheitspunkte?
  @entry_gewandheitspunkte
end

#entry_stärke?Boolean Also known as: current_endurance_entry?, entry_endurance?, endurance_entry?

#

entry_stärke?

#

Returns:

  • (Boolean)


3588
3589
3590
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3588

def entry_stärke?
  @entry_stärke
end

#equipment_buffer_content?Boolean

#

equipment_buffer_content?

#

Returns:

  • (Boolean)


375
376
377
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 375

def equipment_buffer_content?
  @equipment_buffer.text?.to_s
end

#exits_from?(page_number = 1) ⇒ Boolean

#

exits_from? (exits tag)

This method will return all exits of that particular subpage.

This will be a Hash such as:

{285=>"Aber ... in Travia's Namen ...\n",
 94=>"Sonst gehen Sie bei 94 weiter des Weges.\n"}
#

Returns:

  • (Boolean)


545
546
547
548
549
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 545

def exits_from?(
    page_number = 1
  )
  return obtain_entry(page_number.to_i)['exits']
end

#fantasy_lone_wolf?Boolean Also known as: lone_wolf?, is_lone_wolf?, is_part_of_the_lone_wolf_series?, is_lone_wolf_series?, is_on_lone_wolf?, is_a_lone_wolf_series?, lone_wolf_series?, is_lonewolf_series?

#

fantasy_lone_wolf?

This method is specifically for gamebooks in the “lone wolf” series.

#

Returns:

  • (Boolean)


3371
3372
3373
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3371

def fantasy_lone_wolf?
  @theme == :fantasy_lone_wolf
end

#fantasy_widget?Boolean Also known as: is_fantasy_theme?

#

fantasy_widget?

#

Returns:

  • (Boolean)


1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1984

def fantasy_widget?
  # (@theme == :fantasy) or
  # (@theme == :fantasy_DSA) or # A specialized widget for DSA.
  # (@theme == :fantasy_lone_wolf)
  # ======================================================================= #
  # Since as of November 2022 we assume that if the substring 'fantasy'
  # is part of @theme then it must be a fantasy widget.
  # ======================================================================= #
  @theme.to_s.include? 'fantasy'
end

#focus_on_the_first_tabObject

#

focus_on_the_first_tab

#


3297
3298
3299
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3297

def focus_on_the_first_tab
  @notebook.focus_on_the_first_tab
end

#gamebook_title?(i = path_to_the_file_config_yml? ) ⇒ Boolean

#

gamebook_title?

#

Returns:

  • (Boolean)


1264
1265
1266
1267
1268
1269
1270
1271
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1264

def gamebook_title?(
    i = path_to_the_file_config_yml?
  )
  if i.end_with? '.yml'
    i = File.basename(File.dirname(i))
  end
  return File.basename(i)
end

#handle_CSSObject Also known as: setup_css

#

handle_CSS (css tag)

All CSS-specific rules should be aggregated into this method here.

#


488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 488

def handle_CSS
  use_gtk_paradise_project_css_file
  _ = "#{project_base_dir?}gui/gtk3/gamebook/project.css"
  load_rules_from_the_project_css_file(_) # { :be_verbose_then_exit }
  more_CSS USE_THESE_CSS_RULES
  more_CSS '
  .custom_text_view {
    margin: 4px;
    padding: 0px;
    font-size: 1.2em; /* Set a proper font-size for the main view here. */
  }
  .custom_text_view text {
     background-color: #fffae2;
     background-position: center;
     background-image:url(
       "'+GamesAndRpgParadise.project_base_directory?+'images/misc/parchment_background.png"
     );
     margin:  8px;
     padding: 2px
    }
  '
  apply_the_CSS_rules # Note that super() in run() would call this method for us.
end

#handle_game_book_specific_hooks_nextObject

#

handle_game_book_specific_hooks_next (startup tag)

This method can be used to fine-tune and customize the widget, to fit to different gamebooks.

#


406
407
408
409
410
411
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 406

def handle_game_book_specific_hooks_next
  # ======================================================================= #
  # The next variant already checks for a science-fiction widget.
  # ======================================================================= #
  consider_adding_the_default_number_of_selbstlenkraketen
end

#handle_the_situation_caused_bei_Versuch_dein_GlückObject

#

handle_the_situation_caused_bei_Versuch_dein_Glück

#


895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 895

def handle_the_situation_caused_bei_Versuch_dein_Glück
  deduct_one_point_from_luck
  roll_the_main_die unless (current_glück_value?.to_i == 0)
  result = @entry_result_of_the_die_roll.text?.to_i
  if result <= current_glück_value?
    # ===================================================================== #
    # === This is "Glück".
    # ===================================================================== #
    disable_this_button(1) # Disable the second button.
  elsif result > current_glück_value?
    # ===================================================================== #
    # === This is "Pech".
    # ===================================================================== #
    disable_this_button(0) # Disable the first button.
  end
end

#hide_all_buttonsObject

#

hide_all_buttons (hide tag)

#


1187
1188
1189
1190
1191
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1187

def hide_all_buttons
  @array_buttons.each {|entry|
    entry.hide
  }
end

#indicate_to_the_user_that_the_lower_entry_is_importantObject

#

indicate_to_the_user_that_the_lower_entry_is_important

#


1369
1370
1371
1372
1373
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1369

def indicate_to_the_user_that_the_lower_entry_is_important
  @entry_result_of_the_die_roll.remove_css_class('bblack1')
  @entry_result_of_the_die_roll.remove_css_class('border_1px_black')
  @entry_result_of_the_die_roll.add_css_class('border_1px_red')
end

#initialize_a_new_lone_wolf_characterObject Also known as: initialize_the_character

#

initialize_a_new_lone_wolf_character

#


4071
4072
4073
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4071

def initialize_a_new_lone_wolf_character
  @character = GamesAndRpgParadise::Gamebook::LoneWolf::Character.new
end

#is_DSA_widget?Boolean Also known as: is_a_DSA_widget?, uses_DSA3?

#

is_DSA_widget?

#

Returns:

  • (Boolean)


436
437
438
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 436

def is_DSA_widget?
  @theme == :fantasy_DSA
end

#is_grey_star_the_wizard?Boolean Also known as: is_grey_star?

#

is_grey_star_the_wizard?

#

Returns:

  • (Boolean)


3385
3386
3387
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3385

def is_grey_star_the_wizard?
  @theme == :fantasy_grey_star_the_wizard
end

#is_the_game_over?Boolean

#

is_the_game_over?

#

Returns:

  • (Boolean)


1526
1527
1528
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1526

def is_the_game_over?
  @is_the_game_over
end

#largest_font?Boolean Also known as: larger_font?

#

largest_font?

#

Returns:

  • (Boolean)


389
390
391
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 389

def largest_font?
  LARGE_FONT
end

#let_the_entry_containing_the_number_of_the_subsection_respond_to_enter_eventsObject

#

let_the_entry_containing_the_number_of_the_subsection_respond_to_enter_events

#


1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1845

def let_the_entry_containing_the_number_of_the_subsection_respond_to_enter_events
  @entry_containing_the_number_of_the_subsection.on_enter {
    # ===================================================================== #
    # Obtain the number next:
    # ===================================================================== #
    use_this_id = @entry_containing_the_number_of_the_subsection.text?
    # ===================================================================== #
    # Next remove any HTML tags such as "<b></b>".
    # ===================================================================== #
    use_this_id = remove_html(use_this_id)
    if use_this_id.to_i > @max_id
      text = return_max_allowed_id_string
      popup_this_text_over_that_widget(
        text, @entry_containing_the_number_of_the_subsection
      )
    else
      unless use_this_id.include? 'fin' # fin means exit/final.
        the_button_was_clicked_for_this_subpage(use_this_id)
        # pointer = load_dataset_for_this_page(use_this_id)
        # add_to_the_path_traversal_history(use_this_id)
        # set_buffer(pointer['content'].lstrip)
      end
    end
  }
end

#load_the_dataset_for_the_gamebook(name_of_the_gamebook = :try_to_infer) ⇒ Object Also known as: load_the_dataset_from_the_yaml_file

#

load_the_dataset_for_the_gamebook (load tag)

#


2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2120

def load_the_dataset_for_the_gamebook(
    name_of_the_gamebook = :try_to_infer
  )
  case name_of_the_gamebook
  # ======================================================================= #
  # === :try_to_infer
  #
  # This is also the default.
  # ======================================================================= #
  when :try_to_infer,
       :default
    _ = File.dirname(@path_to_the_file_config_yml)
    if _.include? '/'
      name_of_the_gamebook = _.split('/').last # The name
    end
  end
  array_result = GamesAndRpgParadise::Gamebooks.load_dataset(name_of_the_gamebook)
  # ======================================================================= #
  # === @dataset_for_the_gamebook
  # ======================================================================= #
  @dataset_for_the_gamebook = array_result.first
  # ======================================================================= #
  # Also determine the max-ID entry next.
  # ======================================================================= #
  set_max_id(max_id?)
  return array_result # And return the result here.
end

#main_buffer_exists?Boolean

#

main_buffer_exists?

#

Returns:

  • (Boolean)


1638
1639
1640
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1638

def main_buffer_exists?
  !buffer_holding_the_gamepage_content?.nil?
end

#main_entry?Boolean Also known as: page_id?

#

main_entry? (main entry tag, main tag)

This is the entry that keeps track of the currently active “sub-page”.

#

Returns:

  • (Boolean)


1250
1251
1252
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1250

def main_entry?
  @entry_containing_the_number_of_the_subsection
end

#max_endurance?Boolean

#

max_endurance?

#

Returns:

  • (Boolean)


3597
3598
3599
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3597

def max_endurance?
  @entry_max_endurance.text?.to_i
end

#max_id?Boolean

#

max_id?

This will return the max-id of the gamebook at hand.

#

Returns:

  • (Boolean)


2078
2079
2080
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2078

def max_id?
  dataset_for_the_gamebook?.keys.map {|entry| entry.to_i }.max
end

#max_stärke?Boolean

#

max_stärke?

#

Returns:

  • (Boolean)


344
345
346
347
348
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 344

def max_stärke?
  if @character and @character.respond_to?(:max_stärke?)
    @character.max_stärke?
  end
end
#

menu (menu tag)

#


4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4002

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i
    # ===================================================================== #
    # === gtk-gamebook --grey-star1
    # ===================================================================== #
    when /^-?-?grey(-|_| )?star(-|_| )?(\d+)$/  # === $3
      _ = $3.to_s.dup
      case _.to_i
      when 1
        _ = '/home/x/programming/ruby/src/rpg_paradise/lib/rpg_paradise/yaml/gamebooks/world_of_lone_wolf_01_grey_star_the_wizard/grey_star_the_wizard.yml'
      when 2
        _ = '/home/x/programming/ruby/src/rpg_paradise/lib/rpg_paradise/yaml/gamebooks/world_of_lone_wolf_02_grey_star_the_wizard/grey_star_the_wizard.yml'
      else
        e 'Unhandled grey-star book.'
      end
      set_use_this_gamebook(_)
    # ===================================================================== #
    # === gamebook1
    # ===================================================================== #
    when /^-?-?gamebook(\d+)$/,  # === $1
         /^-?-?gamebook=(\d+)$/, # === $1
         /^-?-?use(-|_| )?gamebook=(\d+)$/  # === $2
      _ = $1.to_s.dup
      _ = $2.to_s.dup if $2
      set_use_this_gamebook(_)
    # ===================================================================== #
    # === gtk3_gamebook --help
    # ===================================================================== #
    when /^-?-?help$/i
      show_help
      exit
    else
      # =================================================================== #
      # Usage example for the following entry point:
      #
      #   prisoners_of_time /home/x/Temp/rpg_paradise/lone_wolf_character_lone_wolf_actor.yml
      #   prisoners_of_time --default
      #
      # =================================================================== #
      if i =~ /^-?-?default$/
        i = '/home/x/Temp/rpg_paradise/lone_wolf_character_lone_wolf_actor.yml'
        unless File.exist? i
          e 'No lone wolf character exists. Thus we will create one next.'
          initialize_a_new_lone_wolf_character
          @character.add_a_random_discipline
          @character.add_a_random_discipline
          @character.add_a_random_discipline
          save_the_character
        end
      end
      if i and File.exist? i
        e "#{rev}Loading the dataset for the character "\
          "from #{sfile(i)} #{rev}next."
        initialize_the_character
        @character.load_from_this_file(i)
      end
    end
  end
end

#n_alether_potions?Boolean

#

n_alether_potions?

#

Returns:

  • (Boolean)


4767
4768
4769
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4767

def n_alether_potions?
  @entry_for_alether_potions.text?.to_i
end

#n_arrows?Boolean

#

n_arrows?

This method will always return how many arrows the actor has.

#

Returns:

  • (Boolean)


2328
2329
2330
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2328

def n_arrows?
  @entry_for_n_arrows.text.to_s.to_i
end

#n_gold?Boolean

#

n_gold?

#

Returns:

  • (Boolean)


2452
2453
2454
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2452

def n_gold?
  spinbutton_for_geld?.text
end

#n_laumspur_potions?Boolean Also known as: n_laumspur?

#

n_laumspur_potions?

#

Returns:

  • (Boolean)


4471
4472
4473
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4471

def n_laumspur_potions?
  @entry_for_laumspur_potions.text?.to_i
end

#n_meals?Boolean

#

n_meals?

This method must return how many meals are assigned.

#

Returns:

  • (Boolean)


2360
2361
2362
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2360

def n_meals?
  @entry_for_meals.text?.to_i
end

#n_quivers?Boolean

#

n_quivers?

#

Returns:

  • (Boolean)


2335
2336
2337
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2335

def n_quivers?
  @entry_for_n_quivers.text.to_s.to_i
end

#name_of_the_gamebook?Boolean

#

name_of_the_gamebook?

This is similar to gamebook_title? but it will be guaranteed to have no file extension.

#

Returns:

  • (Boolean)


1566
1567
1568
1569
1570
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1566

def name_of_the_gamebook?
  _ = gamebook_title?
  extension = File.extname(_) # e. g. ".yml"
  return _.delete_suffix(extension)
end

#obtain_entry(this_id) ⇒ Object

#

obtain_entry (obtain tag, raw tag)

This method requires the ID of the subsection that you want to display in the main widget.

The difference between this method and the method called obtain_this_page_number() is that the former will automatically determine the correct exits for the given subpage. The method here does not do this at all.

#


530
531
532
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 530

def obtain_entry(this_id)
  main_dataset?[this_id.to_i]
end

#obtain_this_page_number(page_number = 1) ⇒ Object Also known as: load_dataset_for_this_page

#

obtain_this_page_number

#


2107
2108
2109
2110
2111
2112
2113
2114
2115
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2107

def obtain_this_page_number(
    page_number = 1
  )
  if @dataset_for_the_gamebook
    pointer = @dataset_for_the_gamebook[page_number.to_i]
    the_exits_of_this_page_number_must_be_determined_next(page_number)
    return pointer
  end
end

#opponent_endurance_entry?Boolean Also known as: enemy_endurance_entry?

#

opponent_endurance_entry?

#

Returns:

  • (Boolean)


3443
3444
3445
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3443

def opponent_endurance_entry?
  @opponent_endurance_entry
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


298
299
300
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 298

def padding?
  0
end

#parse_the_current_page_to_determine_the_enemy(content) ⇒ Object

#

parse_the_current_page_to_determine_the_enemy (parse tag)

This method will try to determine information about the given opponent in combat, such as the name, the combat skill, endurance, and so forth.

Presently this only works for enemies in the lone-wolf gamebook series, but we should make this more generic eventually.

#


3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3414

def parse_the_current_page_to_determine_the_enemy(content)
  if content.include? 'COMBAT SKILL:' # Only operate on these Strings.
    # ===================================================================== #
    # === (1) Obtain the COMBAT SKILL of the opponent next:
    # ===================================================================== #
    regex1 = /  COMBAT SKILL:\s*(\d{1,2})/
    content =~ regex1
    @opponent_combat_skill_entry.set_text($1.to_s.dup)
    # ===================================================================== #
    # === (2) Obtain the ENDURANCE of the opponent next:
    # ===================================================================== #
    regex2 = /  ENDURANCE:\s*(\d{1,3})/
    content =~ regex2
    # ===================================================================== #
    # Set these values onto the correct entries:
    # ===================================================================== #
    @opponent_endurance_entry.set_text($1.to_s.dup)
    @entry_current_combat_round.set_text('0') # Reset the combat round here.
    content =~ REGEX_FOR_FINDING_THE_NAME_OF_AN_OPPONENT
    @label_name_of_the_opponent.set_text($1.to_s.dup)
    @label_name_of_the_opponent.use_this_font = larger_font?
    @label_name_of_the_opponent.make_bold
    @label_name_of_the_opponent.css_class('darkblue')
  end
end

#path_to_the_file_config_yml?Boolean Also known as: path_to_the_file_config_yml, path_to_the_file_config?

#

path_to_the_file_config_yml?

#

Returns:

  • (Boolean)


2068
2069
2070
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2068

def path_to_the_file_config_yml?
  @path_to_the_file_config_yml
end

#pick_another_fontObject

#

pick_another_font

#


1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1413

def pick_another_font
  fontchooserdialog = font_chooser_dialog
  fontchooserdialog.set_title('Pick a font')
  response = fontchooserdialog.run
  case response
  when ::Gtk::ResponseType::OK
    @use_this_font = fontchooserdialog.font.to_s
    sync_the_fonts # Sync the change downwards.
  end
  fontchooserdialog.destroy
end

#project_base_directory?Boolean

#

project_base_directory?

#

Returns:

  • (Boolean)


515
516
517
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 515

def project_base_directory?
  ::Gtk.project_base_directory?
end

#reset_the_game_state_to_the_default(use_this_as_the_starting_page = 1) ⇒ Object Also known as: do_start_a_new_game

#

reset_the_game_state_to_the_default

#


587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 587

def reset_the_game_state_to_the_default(
    use_this_as_the_starting_page = 1
  )
  # ======================================================================= #
  # === @array_path_traversal_history
  # ======================================================================= #
  @array_path_traversal_history = []
  # ======================================================================= #
  # === @is_the_game_over
  # ======================================================================= #
  @is_the_game_over = false # This is the default, logically.
  # ======================================================================= #
  # === @starting_page
  #
  # Use a default starting page. config.yml can change this.
  # ======================================================================= #
  set_starting_page(use_this_as_the_starting_page)
  # ======================================================================= #
  # === @popup1
  # ======================================================================= #
  @popup1 = nil
  do_clear_the_main_text_buffer
  set_main_entry_to(@starting_page.to_s)
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

#


938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 938

def reset_the_shared_module
  # ======================================================================= #
  # === @use_this_font
  # ======================================================================= #
  @use_this_font = USE_THIS_FONT
  # ======================================================================= #
  # === @max_id
  # ======================================================================= #
  set_max_id(0)
  # ======================================================================= #
  # === @theme
  # ======================================================================= #
  set_theme(nil) # This is the "primary" default value.
  # ======================================================================= #
  # === @array_buttons
  #
  # This Array will contain all the clickable buttons that will be
  # displayed on the bottom of the main GUI.
  # ======================================================================= #
  @array_buttons = []
  reset_the_game_state_to_the_default
end

#return_actionsheet_widgetObject

#

return_actionsheet_widget

This widget will only be used if we are playing a lone-wolf gamebook.

#


2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2484

def return_actionsheet_widget
  scrolled_window_for_the_actionsheet_widget = create_scrolled_window
  image1 = image(
    GamesAndRpgParadise.images_directory?+'gamebooks/misc/lone_wolf/Lone_Wolf_Action_Chart1.png'
  )
  image2 = image(
    GamesAndRpgParadise.images_directory?+'gamebooks/misc/lone_wolf/Lone_Wolf_Action_Chart2.png'
  )
  hbox = create_hbox
  hbox.minimal(image1, 12)
  hbox.minimal(image2, 12)
  hbox.pad5px
  scrolled_window_for_the_actionsheet_widget.add(hbox)
  return scrolled_window_for_the_actionsheet_widget
end

#return_admin_panelObject

#

return_admin_panel (admin tag)

#


2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2566

def return_admin_panel
  vbox = create_vbox
  vbox.pad8px
  # ======================================================================= #
  # === @button_open_the_currently_used_yaml_file_in_the_editor
  # ======================================================================= #
  @button_open_the_currently_used_yaml_file_in_the_editor = create_button(
    'Open the currently used .yml file in the editor'
  )
  @button_open_the_currently_used_yaml_file_in_the_editor.pad5px
  @button_open_the_currently_used_yaml_file_in_the_editor.clear_background
  @button_open_the_currently_used_yaml_file_in_the_editor.bblack3
  @button_open_the_currently_used_yaml_file_in_the_editor.on_hover(:lightyellow)
  @button_open_the_currently_used_yaml_file_in_the_editor.font = larger_font?
  @button_open_the_currently_used_yaml_file_in_the_editor.hint =
    'Clicking on this button will <b>open the current .yml file</b> '\
    'in the main editor in use.'
  @button_open_the_currently_used_yaml_file_in_the_editor.on_clicked {
    do_open_the_current_yaml_file_in_the_editor
  }
  mini_vbox = create_vbox
  mini_vbox.minimal(@button_open_the_currently_used_yaml_file_in_the_editor, 5)
  button_debug = button('Debug')
  button_debug.on_clicked { do_debug }
  button_debug.pad5px
  button_debug.clear_background
  button_debug.bblack3
  button_debug.on_hover(:lightyellow)
  button_debug.font = larger_font?

  mini_vbox.minimal(button_debug, 5)
  vbox.minimal(mini_vbox)
  frame_for_checkboxes = create_frame
  frame_for_checkboxes.header = 'Settings that can be toggled'
  @check_box_auto_pick_up_items = check_button('Automatically _pick up items')
  @check_box_auto_pick_up_items.is_checked
  @check_box_auto_pick_up_items.hint =
    'If this check-box is active then '\
    'the actor will automatically try to pick up items on '\
    'every gamebook section, as-is.'
  hbox1 = create_hbox
  hbox1.minimal(@check_box_auto_pick_up_items)
  hbox1.pad8px
  hbox1.mar4px
  frame_for_checkboxes.add(hbox1)
  vbox.minimal(frame_for_checkboxes, 25)
  vbox.show_all
  return vbox
end

#return_ausrüstung_und_waffen_widgetObject

#

return_ausrüstung_und_waffen_widget

This method will return the widget that keeps track of the equipment of the character at hand, e. g. the “Ausrüstung” and the weapons, aka “Waffen”.

#


881
882
883
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 881

def return_ausrüstung_und_waffen_widget
  return @ausrüstung_und_waffen_widget
end

#return_create_new_character_widgetObject

#

return_create_new_character_widget

#


3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3304

def return_create_new_character_widget
  _ = create_hbox
  image = create_image(
    GamesAndRpgParadise.project_directory?+'images/misc/small_hero_logo.png'
  )
  event_box = create_event_box(image)
  event_box.hint = "Click on this image to create a new character.\n\n"+
                   "Note that this will <b>overwrite</b> any old "\
                   "character stored at the same location."
  event_box.on_clicked {
    do_pop_up_the_create_new_character_widget
  }
  _.minimal(event_box, 5)
  return _
end

#return_event_box_for_the_circle_of_fireObject

#

return_event_box_for_the_circle_of_fire

#


2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2784

def return_event_box_for_the_circle_of_fire
  # ===================================================================== #
  # === Circle of Fire
  # ===================================================================== #
  circle_of_fire_explanation =
    "It will add <b>+1 to CS</b> and <b>+2 EP</b> when completed.\n\n"+
    "Its completion requires attaining the following Magnakai-abilities:\n\n"+
    "  <span weight=\"bold\" foreground=\"gold\">"\
    "#{GamesAndRpgParadise::Gamebook::LoneWolf::Character::ARRAY_CIRCLE_OF_FIRE.join(', ')}</span>\n"

  if @character.circle_of_fire_completed?
    image1 = create_image(FILE_CIRCLE_OF_FIRE_COMPLETED)
    image1.hint = 'The <b>Circle of Fire</b> has been <b>completed</b>. '+"\n\n"+
                   circle_of_fire_explanation+"\n"
    # @character.increase_combat_skill_by(1)
    # @character.increase_max_endurance_by(1)
  else
    image1 = create_image(FILE_CIRCLE_OF_FIRE)
    image1.hint = 'The <b>Circle of Fire</b> has '\
                  '<span weight="bold" foreground="crimson">NOT</span> been completed. '+"\n\n"+
                  circle_of_fire_explanation+"\n"
  end
  event_box = create_event_box(image1)
  event_box.signal_connect(:enter_notify_event) {
    image1.set_file(FILE_CIRCLE_OF_FIRE_COMPLETED)
  }
  event_box.signal_connect(:leave_notify_event) {
    image1.set_file(FILE_CIRCLE_OF_FIRE)
  }
  return event_box
end

#return_event_box_for_the_circle_of_lightObject

#

return_event_box_for_the_circle_of_light

#


2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2750

def return_event_box_for_the_circle_of_light
  # ======================================================================= #
  # === Circle of Light
  # ======================================================================= #
  circle_of_light_explanation =
    "It will add <b>+0 to CS</b> and <b>+3 EP</b> when completed.\n\n"+
    "Its completion requires attaining the following Magnakai-abilities:\n\n"+
    "  <span weight=\"bold\" foreground=\"gold\">"\
    "#{GamesAndRpgParadise::Gamebook::LoneWolf::Character::ARRAY_CIRCLE_OF_LIGHT.join(', ')}</span>\n"
  if @character.circle_of_light_completed?
    image2 = create_image(
      FILE_CIRCLE_OF_LIGHT_COMPLETED
    )
    image2.hint = 'The <b>Circle of Light</b> has been <b>completed</b>. '+"\n\n"+
                   circle_of_light_explanation
  else
    image2 = create_image(FILE_CIRCLE_OF_LIGHT)
    image2.hint = 'The <b>Circle of Light</b> has <b>NOT</b> been completed. '+"\n\n"+
                   circle_of_light_explanation
  end

  event_box = create_event_box(image2)
  event_box.signal_connect(:enter_notify_event) {
    image2.set_file(FILE_CIRCLE_OF_LIGHT_COMPLETED)
  }
  event_box.signal_connect(:leave_notify_event) {
    image2.set_file(FILE_CIRCLE_OF_LIGHT)
  }
  return event_box
end

#return_event_box_for_the_circle_of_solarisObject

#

return_event_box_for_the_circle_of_solaris

#


2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2684

def return_event_box_for_the_circle_of_solaris
  # ======================================================================= #
  # === Circle of Solaris
  # ======================================================================= #
  circle_of_solaris_explanation =
    "It will add <b>+1 to CS</b> and <b>+3 EP</b> when completed.\n\n"+
    "Its completion requires attaining the following Magnakai-abilities:\n\n"+
    "  <span weight=\"bold\" foreground=\"gold\">"\
    "#{GamesAndRpgParadise::Gamebook::LoneWolf::Character::ARRAY_CIRCLE_OF_SOLARIS.join(', ')}</span>\n"
  if @character.circle_of_solaris_completed?
    image3 = create_image(FILE_CIRCLE_OF_SOLARIS_COMPLETED)
    image3.hint = 'The <b>Circle of Solaris</b> has been <b>completed</b>. '+"\n\n"+
                   circle_of_solaris_explanation+"\n"
    # @character.increase_combat_skill_by(1) # +1 CS.
  else
    image3 = create_image(FILE_CIRCLE_OF_SOLARIS)
    image3.hint = 'The <b>Circle of Solaris</b> has '\
                  '<span weight="bold" foreground="crimson">NOT</span> '\
                  'been <b>completed</b>. '+"\n\n"+
                  circle_of_solaris_explanation+"\n"
  end
  event_box = create_event_box(image3)
  event_box.signal_connect(:enter_notify_event) {
    image3.set_file(FILE_CIRCLE_OF_SOLARIS_COMPLETED)
  }
  event_box.signal_connect(:leave_notify_event) {
    image3.set_file(FILE_CIRCLE_OF_SOLARIS)
  }
  return event_box
end

#return_event_box_for_the_circle_of_spiritObject

#

return_event_box_for_the_circle_of_spirit

#


2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2718

def return_event_box_for_the_circle_of_spirit
  # ======================================================================= #
  # === Circle of Spirit
  # ======================================================================= #
  circle_of_spirit_explanation =
    "It will add <b>+3 to CS</b> and <b>+3 EP</b> when completed.\n\n"+
    "Its completion requires attaining the following Magnakai-abilities:\n\n"+
    "  <span weight=\"bold\" foreground=\"gold\">"\
    "#{GamesAndRpgParadise::Gamebook::LoneWolf::Character::ARRAY_CIRCLE_OF_SPIRIT.join(', ')}</span>\n"
  if @character.circle_of_spirit_completed?
    image4 = create_image(FILE_CIRCLE_OF_SPIRIT_COMPLETED)
    image4.hint = 'The <b>Circle of Spirit</b> has been <b>completed</b>.'+"\n\n"+
                   circle_of_spirit_explanation
    # @character.increase_combat_skill_by(3) # +3 CS.
  else
    image4 = create_image(FILE_CIRCLE_OF_SPIRIT)
    image4.hint = 'The <b>Circle of Spirit</b> has <b>NOT</b> been <b>completed</b>.'+"\n\n"+
                   circle_of_spirit_explanation
  end
  event_box = create_event_box(image4)
  event_box.signal_connect(:enter_notify_event) {
    image4.set_file(FILE_CIRCLE_OF_SPIRIT_COMPLETED)
  }
  event_box.signal_connect(:leave_notify_event) {
    image4.set_file(FILE_CIRCLE_OF_SPIRIT)
  }
  return event_box
end

#return_event_box_for_the_die_imageObject

#

return_event_box_for_the_die_image

This method will return the area containing the die.

That event box should be padded between two hspacers, and then the two entries called @entry_for_the_dice and @entry_result_of_the_die_roll should be shown.

#


2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2641

def return_event_box_for_the_die_image
  # ======================================================================= #
  # === @hbox_containing_the_die_images
  # ======================================================================= #
  @hbox_containing_the_die_images = hbox
  # @hbox_containing_the_die_images.hcenter # This is a bit awkward as it shrinks the widget.
  # ======================================================================= #
  # === @image_containing_the_die
  # ======================================================================= #
  @image_containing_the_die = image(PATH_TO_THE_DIE_IMAGE)
  @image_containing_the_die.pad1px
  @hbox_containing_the_die_images.maximal(@image_containing_the_die)
  @hbox_containing_the_die_images.css_class('border_3px_dotted_black')
  @hbox_containing_the_die_images.css_class('lighter_background')
  @hbox_containing_the_die_images.css_class('rounded_corner')
  # ======================================================================= #
  # === @event_box_containing_the_gamebook_logo_for_the_die
  # ======================================================================= #
  @event_box_containing_the_gamebook_logo_for_the_die = event_box(@hbox_containing_the_die_images)
  @event_box_containing_the_gamebook_logo_for_the_die.css_class('background_for_a_fancy_hover_button_effect')
  @event_box_containing_the_gamebook_logo_for_the_die.hint =
    'Click on this die in order to roll '\
    'the dice specified in the entry above.'
  @event_box_containing_the_gamebook_logo_for_the_die.on_clicked {
    do_handle_the_on_click_action_for_the_main_event_box
    Thread.new {
      switch_to_the_red_border_for_the_die_image
      sleep 0.35 # Mandatory Delay.
      switch_to_the_no_border_for_the_die_image
    }
    Thread.new {
      sleep 0.30 # Mandatory Delay.
      indicate_to_the_user_that_the_lower_entry_is_important
      sleep 0.85
      revert_the_CSS_rules_of_the_lower_entry_again
    }
  }
  return @event_box_containing_the_gamebook_logo_for_the_die
end

#return_geld_widgetObject

#

return_geld_widget

This widget will keep track how much money the main actor has.

#


556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 556

def return_geld_widget
  outer_vbox = create_vbox
  widget_for_geld = create_hbox
  # ======================================================================= #
  # Add the 'Geld' text, to keep track how much money the player has
  # available. Actually this is now done via create_skeleton() instead.
  # ======================================================================= #
  if fantasy_widget?
    path_to_the_silver_coins = "#{project_base_dir?}images/misc/SILVER_COINS.png"
    widget_for_geld.minimal(
      image(path_to_the_silver_coins), 8
    )
  end
  widget_for_geld.minimal(@text_containing_the_money_label, 8) # Add the text-widget here.
  lower_hbox = create_hbox
  lower_hbox.maximal(spinbutton_for_geld?,1)
  outer_vbox.minimal(widget_for_geld)
  outer_vbox.maximal(lower_hbox)
  return outer_vbox
end

#return_grid_containing_GE_ST_and_GLObject

#

return_grid_containing_GE_ST_and_GL

Return the 2x3 grid containing GE, ST and GL. This grid will primarily contain all data from the player’s character.

#


3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3607

def return_grid_containing_GE_ST_and_GL
  @grid = create_grid
  @grid.set_column_spacing(2)
  @grid.set_row_spacing(2)
  # ======================================================================= #
  # === Gewandheitspunkte:
  # ======================================================================= #
  @grid.left(return_widget_for_gewandheitspunkte_text)
  @grid.right(return_widget_for_gewandheitspunkte_entry)
  @grid.new_row
  # ======================================================================= #
  # The next entry is only for DSA-widgets, that is, DSA-based gamebooks.
  # ======================================================================= #
  if is_a_DSA_widget?
    # ===================================================================== #
    # Add 'GE' widget next, for DSA-style gamebooks:
    # ===================================================================== #
    _ = return_left_aligned_bold_text('GE:')
    @grid.left(_)
    _ = create_entry(
          (
            roll_this_die('1W6').to_i+7
          ).to_s
        )
    _.center
    _.width_height(80, 18)
    _.bblack1
    _.pad4px
    _.set_font(SMALLEST_FONT)
    _.yellow_background
    _.make_bold
    @grid.right(_)
    @grid.new_row
    # ===================================================================== #
    # Add 'KK' widget next:
    # ===================================================================== #
    _ = return_left_aligned_bold_text('KK:')
    @grid.left(_)
    _ = create_entry(
          (
            roll_this_die('1W6').to_i+7
          ).to_s
        )
    _.center
    _.width_height(80, 18)
    _.bblack1
    _.pad4px
    _.set_font(SMALLEST_FONT)
    _.yellow_background
    _.make_bold
    @grid.right(_)
    @grid.new_row
  end # end for "if is_a_DSA_widget?" check.
  # ======================================================================= #
  # === Stärke:
  #
  # This entry is also called "ENDURANCE" in the lone-wolf series. Here
  # we distinguish between the "max-endurance" (maximum the character
  # is able to have) and the "current-endurance" (the value the character
  # currently has).
  # ======================================================================= #
  @grid.left(return_widget_for_stärke_text) # This is "ENDURANCE" too.
  @grid.right(return_widget_for_stärke_entry)
  # ======================================================================= #
  # === Glück:
  #
  # The lone-wolf series does not have this entry, so it will be skipped
  # when playing a lone-wolf gamebook.
  # ======================================================================= #
  unless is_lone_wolf_series?
    @grid.left(return_widget_for_glück_text)
    @grid.right(return_widget_for_glück_entry)
  end
  # ======================================================================= #
  # The next entry is specifically for gamebooks similar to "Stern der
  # Schmuggler".
  # ======================================================================= #
  if science_fiction_widget?
    # @grid.new_row
    @grid.left(return_widget_for_stärkepillen_text)
    @grid.right(return_widget_for_stärkepillen_entry)
  end
  return @grid
end

#return_image_to_the_six_sided_die(use_this_die = '1W10', associate_it_with_this_entry = :entry_combat_skill) ⇒ Object

#

return_image_to_the_six_sided_die

This method will simply return a gtk-image instance for the red-sided die. This die may appear when the player reads a lone-wolf series gamebook.

#


968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 968

def return_image_to_the_six_sided_die(
    use_this_die                 = '1W10',
    associate_it_with_this_entry = :entry_combat_skill
  )
  # ======================================================================= #
  # First, return the image to the red six-sided die:
  # ======================================================================= #
  _ = image(
    FILE_RED_SIX_SIDED_DIE
  )
  event_box = create_event_box(_)
  event_box.hint = 'You can click on this image to assign a new '\
                   'COMBAT SKILL value for the main actor.'
  event_box.on_clicked {
    result = roll_complex_die(use_this_die)
    case associate_it_with_this_entry
    # ===================================================================== #
    # === :entry_combat_skill
    # ===================================================================== #
    when :entry_combat_skill
      set_current_combat_skill_entry(result.to_s)
    # ===================================================================== #
    # === :entry_endurance
    # ===================================================================== #
    when :entry_endurance
      set_endurance_skill_entry(
        "#{result}"
      )
    end
  }
  return event_box
end

#return_kai_disciplines_widget_for_the_one_lone_wolf_series(available_kai_disciplines = available_kai_disciplines? ) ⇒ Object

#

return_kai_disciplines_widget_for_the_one_lone_wolf_series

This method will return the widget that will keep all kai-disciplines.

#


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
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 646

def return_kai_disciplines_widget_for_the_one_lone_wolf_series(
    available_kai_disciplines = available_kai_disciplines?
  )
  require 'games_and_rpg_paradise/gamebooks/lone_wolf/lone_wolf.rb'
  vbox = create_vbox
  text = bold_text("#{available_kai_disciplines.size} Tai Disciplines")
  text.hint = "<b>Available Tai "\
              "Disciplines are</b>:\n\n"+
              available_kai_disciplines.map {|entry|
                entry = entry.dup if entry.frozen?
                entry.prepend('  - ')
              }.join("\n")+"\n"
  vbox.minimal(text)
  buffer = text_buffer
  # ======================================================================= #
  # === @text_view_for_the_kai_disciplines
  # ======================================================================= #
  @text_view_for_the_kai_disciplines = create_text_view(buffer)
  @text_view_for_the_kai_disciplines.pad2px
  a_scrolled_window = create_scrolled_window(
    @text_view_for_the_kai_disciplines
  ) { :always_up_and_down }
  a_scrolled_window.width_height(225, 200)
  a_scrolled_window.clear_background
  a_scrolled_window.bblack1
  # ======================================================================= #
  # The hbox is kind of the "second" row:
  # ======================================================================= #
  hbox = create_hbox
  small_vbox = numbered_lines_widget # create_vbox
  small_vbox.no_arrows
  small_vbox.font = smaller_font?
  # ======================================================================= #
  # Basic Tai disciplines are always five minimum, which explains the
  # next line of code.
  # ======================================================================= #
  small_vbox.set_use_n_entries(5)
  if @character and @character.n_kai_disciplines?
    small_vbox.set_use_n_entries(@character.n_kai_disciplines?)
  end
  hbox.minimal(small_vbox,        1)
  hbox.maximal(a_scrolled_window, 1)
  another_scrolled_window = create_scrolled_window(hbox) { :only_up_and_down }
  another_scrolled_window.width_height(168, 52)
  if is_lone_wolf_series? # This check is not needed, I think - but it'll be retained for now.
    @dataset_containing_all_kai_disciplines = YAML.load_file(
      GamesAndRpgParadise::Gamebook::LoneWolf::Character.file_all_kai_disciplines
    )
    # ===================================================================== #
    # Create, and then append the combo box into the widget, containing
    # all kai-disciplines:
    # ===================================================================== #
    use_this_combo_box = combo_box_entry(
      available_kai_disciplines?
    )
    use_this_combo_box.clear_background
    use_this_combo_box.bblack1
    use_this_combo_box.font = smaller_font?
    use_this_combo_box.first_is_default
    use_this_combo_box.signal_connect(:query_tooltip) { |widget, x, y, keyboard_tip, tooltip|
      tooltip.markup = return_proper_tooltip_for_the_combo_box_containing_all_kai_disciplines(
        widget, keybord_tip, tooltip
      )
      true # Mandatory as well.
    }
    # Add the combo-box to the hbox created above.
    # hbox.minimal(
    #   use_this_combo_box
    # )
    if @character.nil? # Well, in this case, we should initialize a new lone-wolf-character.
      initialize_a_new_lone_wolf_character
    end
    if @character
      disciplines = @character.disciplines?
      disciplines.each {|this_discipline|
        buffer.append("#{this_discipline}\n")
      } if disciplines
    end
    _ = draggable_via_left_to_right_movement(
          another_scrolled_window,
          use_this_combo_box
        )
    _.position = 300
    vbox.maximal(_)
  else
    vbox.maximal(another_scrolled_window, 0)
  end
  return vbox
end

#return_left_aligned_bold_text(i = 'KK:') ⇒ Object

#

return_left_aligned_bold_text

#


1122
1123
1124
1125
1126
1127
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1122

def return_left_aligned_bold_text(i = 'KK:')
  _ = left_aligned_text(i.ljust(22))
  _.set_font(SMALLEST_FONT)
  _.make_bold
  return _
end

#return_left_arrow_widgetObject

#

return_left_arrow_widget

This will be part of the left-widget.

#


1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1153

def return_left_arrow_widget
  image = image_left_arrow
  event_box = create_event_box(image)
  event_box.hint = HINT_FOR_THE_BUTTON_WITH_THE_LEFT_ARROW_IMAGE
  event_box.on_clicked { # back tag
    history = history?
    unless history.empty?
      # =================================================================== #
      # Remove and return the last element.
      # =================================================================== #
      if history.size > 1
        last_element = history.pop
        last_element = history.last
        main_entry?.set_text(last_element.to_s)
        load_dataset_for_this_page(last_element)
        pointer = load_dataset_for_this_page(last_element)
        set_buffer(pointer['content'].lstrip)
      end
    end
  }
  return event_box
end

#return_main_buttonObject

#

return_main_button

This method will handle the on-click-button event.

#


793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 793

def return_main_button
  button = create_button
  button.width_height(40, 40)
  # ======================================================================= #
  # Let each button respond to the user on-clicked action next:
  # ======================================================================= #
  button.on_clicked {
    # ===================================================================== #
    # Autoclose the pop-up image widget if it still exists.
    # This is probably no longer needed as of October 2022.
    # @image_close_on_action = ::Gtk::ImageCloseOnClickAction.run(use_this_path)
    # ===================================================================== #
    # if @image_close_on_action
    #   @image_close_on_action.do_close
    #   @image_close_on_action = nil
    # end
    # ===================================================================== #
    # Obtain the number next:
    # ===================================================================== #
    @popup1.popdown if @popup1
    use_this_id = button.text?
    if use_this_id and !use_this_id.empty? and use_this_id.include?('|')
      use_this_id = use_this_id.split('|').first.strip
      use_this_id = remove_html(use_this_id)
    else
      # =================================================================== #
      # In this case we did not find anything.
      # =================================================================== #
      @popup1 = popup_this_text_over_that_widget(
        'This exit does not exist from the current path.',
        @entry_containing_the_number_of_the_subsection
      )
    end
    # ===================================================================== #
    # Next handle invalid input:
    # ===================================================================== #
    if use_this_id.to_i > @max_id
      text = return_max_allowed_id_string
      popup_this_text_over_that_widget(
        text, @entry_containing_the_number_of_the_subsection
      )
    else
      if use_this_id and !use_this_id.empty?
        case use_this_id
        when 'fin'
          # Do not handle anything here.
        else
          the_button_was_clicked_for_this_subpage(use_this_id)
        end
      end
    end
  }
  return button
end

#return_max_allowed_id_stringObject

#

return_max_allowed_id_string

#


1575
1576
1577
1578
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1575

def return_max_allowed_id_string
  "This ID is not part of the dataset - it is too high. "\
  "The max allowed value is <b>#{max_id?.to_s}</b>."
end

#return_n_alether_potionsObject

#

return_n_alether_potions

#


4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4721

def return_n_alether_potions
 vbox = create_vbox
  text_to_use = bold_text('Alether-potions')
  text_to_use.use_this_font = smallest_font?
  text_to_use.make_bold
  text_to_use.hint =
    'The Laumspur vial can heal injuries.'
  vbox.minimal(text_to_use)
  @entry_for_alether_potions = create_centered_entry('0')
  @entry_for_alether_potions.light_yellowish_background
  @entry_for_alether_potions.bblack2
  @entry_for_alether_potions.make_bold
  @entry_for_alether_potions.hint =
    'An alether potion will increase CS by <b>+2</b>.'
  hbox1 = create_hbox
  hbox1.maximal(@entry_for_alether_potions, 1)
  vbox2 = create_vbox
  eventbox1 = create_eventbox(
    create_image(PATH_TO_THE_PLUS_SYMBOL_IMAGE)
  )
  eventbox1.on_clicked { # Add +1.
    widget = @entry_for_alether_potions
    if widget
      _ = widget.text.to_s.to_i + 1
      widget.set_text(_.to_s)
    end
  }
  eventbox2 = create_eventbox(
    create_image(PATH_TO_THE_MINUS_SYMBOL_IMAGE)
  )
  eventbox2.on_clicked { # Subtract 1.
    _ = @entry_for_alether_potions.text?.to_s.to_i - 1
    _ = 0 if _ < 0
    _ = _.to_s
    @entry_for_alether_potions.set_text(_)
  }
  vbox2.minimal(eventbox1)
  vbox2.minimal(eventbox2)
  hbox1.minimal(vbox2)
  vbox.minimal(hbox1, 2)
  return vbox
end

#return_n_arrows_widgetObject

#

return_n_arrows_widget

#


2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2396

def return_n_arrows_widget
  vbox = create_vbox
  text_to_use = bold_text('Arrows')
  text_to_use.hint =
    'This entry can be used to denote how many arrows you have.'
  vbox.minimal(text_to_use)
  @entry_for_n_arrows = create_entry
  @entry_for_n_arrows.light_yellowish_background
  @entry_for_n_arrows.set_text('0')
  @entry_for_n_arrows.bblack2
  @entry_for_n_arrows.center
  @entry_for_n_arrows.pad2px
  @entry_for_n_arrows.make_bold
  @entry_for_n_arrows.hint =
    'This entry can be used to denote how many arrows you have.'

  hbox1 = create_hbox
  hbox1.maximal(@entry_for_n_arrows, 1)
  vbox2 = create_vbox
  eventbox1 = create_eventbox(
    create_image(PATH_TO_THE_PLUS_SYMBOL_IMAGE)
  )
  eventbox1.on_clicked { # Add +1.
    _ = n_arrows? + 1
    _ = 12 if _ > 13 # Cap it.
    set_n_arrows(_)
  }
  eventbox2 = create_eventbox(
    create_image(PATH_TO_THE_MINUS_SYMBOL_IMAGE)
  )
  eventbox2.on_clicked { # Subtract +1.
    _ = n_arrows? - 1
    _ = 0 if _ < 0
    _ = _.to_s
    set_n_arrows(_)
  }
  vbox2.minimal(eventbox1)
  vbox2.minimal(eventbox2)
  hbox1.minimal(vbox2)
  vbox.minimal(hbox1, 2)
  return vbox
end

#return_n_laumspur_tränkeObject

#

return_n_laumspur_tränke

This method is only used for gamebooks belonging to the lone-wolf series.

#


3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3758

def return_n_laumspur_tränke
  vbox = create_vbox
  text_to_use = bold_text('Laumspur')
  text_to_use.hint =
    'The Laumspur vial can heal injuries.'
  vbox.minimal(text_to_use)
  @entry_for_laumspur_potions = create_centered_entry('0')
  @entry_for_laumspur_potions.light_yellowish_background
  @entry_for_laumspur_potions.bblack2
  @entry_for_laumspur_potions.make_bold
  @entry_for_laumspur_potions.hint =
    'A Laumspur vial will restore <b>4</b> lost Endurance Points (EN).'
  hbox1 = create_hbox
  hbox1.maximal(@entry_for_laumspur_potions, 1)
  vbox2 = create_vbox
  eventbox1 = create_eventbox(
    create_image(PATH_TO_THE_PLUS_SYMBOL_IMAGE)
  )
  eventbox1.on_clicked { # Add +1.
    widget = @entry_for_laumspur_potions
    if widget
      _ = widget.text.to_s.to_i + 1
      widget.set_text(_.to_s)
    end
  }
  eventbox2 = create_eventbox(
    create_image(PATH_TO_THE_MINUS_SYMBOL_IMAGE)
  )
  eventbox2.on_clicked { # Subtract +1.
    _ = @entry_for_laumspur_potions.text.to_s.to_i - 1
    _ = 0 if _ < 0
    _ = _.to_s
    if entry_endurance?
      current_endurance_value = entry_endurance?.text?
      if current_endurance_value.include? '/'
        current_endurance_value = current_endurance_value.split('/').first.strip.to_i
      end
      @character.endurance = current_endurance_value
      @character.try_to_add_n_hitpoints(4) # Try to heal 4 Endurance Points here.
      if @entry_for_laumspur_potions
        @entry_for_laumspur_potions.set_text(_)
        current_endurance_entry?.set_text(
          @character.endurance?.to_s
        )
        if @entry_max_endurance
          @entry_max_endurance.set_text(
            @character.max_endurance?.to_s
          )
        end
      end
    end
  }
  vbox2.minimal(eventbox1)
  vbox2.minimal(eventbox2)
  hbox1.minimal(vbox2)
  vbox.minimal(hbox1, 2)
  return vbox
end

#return_n_mealsObject

#

return_n_meals (meals tag)

This widget keeps track how many meals the main actor has available.

Since as of March 2023 we will use class Gtk::FourComponentsEntry for this task.

#


4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4538

def return_n_meals
  @four_components_entry1 = ::Gtk::FourComponentsEntry.new {{
    bold_text: 'Meals'
  }}
  @entry_for_meals = @four_components_entry1.entry? # Obtain the main entry here.
  @entry_for_meals.light_yellowish_background
  @entry_for_meals.bblack2
  @entry_for_meals.make_bold
  return @four_components_entry1
end

#return_n_quivers_widgetObject

#

return_n_quivers_widget

#


2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2258

def return_n_quivers_widget
  @four_components_entry2 = ::Gtk::FourComponentsEntry.new {{
    bold_text: 'Quivers'
  }}
  @four_components_entry2.hint = 'This entry can be used to denote how '\
                                 'many quivers you have. A single quiver '\
                                 'can hold 6 arrows in the lone-wolf '\
                                 'gamebook series.'
  @entry_for_n_quivers = @four_components_entry2.entry?
  @entry_for_n_quivers.light_yellowish_background
  @entry_for_n_quivers.set_text('0')
  @entry_for_n_quivers.bblack2
  @entry_for_n_quivers.center
  @entry_for_n_quivers.pad2px
  @entry_for_n_quivers.make_bold
  @entry_for_n_quivers.hint =
    'This entry can be used to denote how many quivers you have. Each '\
    'quiver can hold a maximum of 6 arrows, so having two quivers '\
    'means you can carry a total of 12 arrows.'
  @four_components_entry2.cap_plus_at(12)
  return @four_components_entry2
end

#return_notes_widgetObject

#

return_notes_widget

#


2826
2827
2828
2829
2830
2831
2832
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2826

def return_notes_widget
  _ = text_view
  _.font = larger_font?
  @notes_widget = _
  scrolled_window = create_scrolled_window(_)
  return scrolled_window
end

#return_proper_tooltip_for_the_combo_box_containing_all_kai_disciplines(widget, keybord_tip, tooltip) ⇒ Object

#

return_proper_tooltip_for_the_combo_box_containing_all_kai_disciplines

This currently does not work. It seems as if gtk-combo-box can not, by default, respond to tooltip usage.

#


1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1965

def return_proper_tooltip_for_the_combo_box_containing_all_kai_disciplines(
    widget, keybord_tip, tooltip
  )
  # pp '1)'
  # pp widget
  # pp widget.class
  # pp '2)'
  # pp keyboard_tip
  # pp keyboard_tip.class
  # pp '3)'
  # pp tooltip
  # pp tooltip.class
  # @dataset_containing_all_kai_disciplines
  return '42' # This has to be fixed at some point in the future.
end

#return_quivers_and_arrows_widgetObject

#

return_quivers_and_arrows_widget

#


2442
2443
2444
2445
2446
2447
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2442

def return_quivers_and_arrows_widget
  hbox1 = create_hbox
  hbox1.maximal(return_n_quivers_widget, 1)
  hbox1.maximal(return_n_arrows_widget,  1)
  return hbox1
end

#return_raumschiff_widgetObject

#

return_raumschiff_widget

#


1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1895

def return_raumschiff_widget
  ::Gtk::Grid.reset # Must reset it again here.
  # ======================================================================= #
  # First, create the frame that holds the "Raumschiff" (aka spaceship).
  # ======================================================================= #
  frame = create_frame
  frame.use_this_font = LARGE_FONT
  frame.make_bold
  frame.set_border_width(4)
  hbox = create_hbox
  hbox.pad2px
  raumschiff_label = bold_label('Raumschiff ')
  raumschiff_label.use_this_font = LARGE_FONT
  raumschiff_label.make_bold
  raumschiff_label.hint = 'Dieser Teil zeigt den Status des '\
                          'Raumschiff an.'
  hbox.minimal(raumschiff_label,             1)
  hbox.minimal(image(FILE_RAUMSCHIFF_IMAGE), 1)
  frame.label_widget = hbox
  # ======================================================================= #
  # Define the inner grid next:
  # ======================================================================= #
  grid = create_grid
  grid.set_column_spacing(2)
  grid.set_row_spacing(2)
  text = bold_text('Waffenstärke '.ljust(20))
  text.use_this_font(smaller_font?)
  text.make_bold
  grid.left(text)
  @entry_waffenstärke = create_entry
  @entry_waffenstärke.use_this_font(smallest_font?)
  @entry_waffenstärke.set_text(
    (roll_this_die('1W6') + 6).to_s
  )
  @entry_waffenstärke.center
  @entry_waffenstärke.bblack1
  @entry_waffenstärke.make_bold
  @entry_waffenstärke.lightgreen_background
  grid.right(@entry_waffenstärke)
  grid.new_row
  text = bold_text('Abwehrkraft '.ljust(20))
  text.use_this_font(smaller_font?)
  text.make_bold
  grid.left(text)
  # ======================================================================= #
  # === @entry_abwehrkraft
  # ======================================================================= #
  @entry_abwehrkraft = create_entry
  @entry_abwehrkraft.use_this_font(smallest_font?)
  @entry_abwehrkraft.set_text(
    (roll_this_die('1W6')).to_s
  )
  @entry_abwehrkraft.center
  @entry_abwehrkraft.bblack1
  @entry_abwehrkraft.make_bold
  @entry_abwehrkraft.lightgreen_background
  grid.right(@entry_abwehrkraft)
  # ======================================================================= #
  # Add the grid onto the frame next.
  # ======================================================================= #
  frame.add(grid)
  return frame
end

#return_scrolled_window_containing_the_special_imageObject

#

return_scrolled_window_containing_the_special_image

#


4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4368

def return_scrolled_window_containing_the_special_image
  # ======================================================================= #
  # Add the scrolled-window for the special image next:
  # ======================================================================= #
  scrolled_window_containing_the_special_image = scrolled_window(
    return_the_event_box_for_the_special_image
  )
  scrolled_window_containing_the_special_image.set_name(
    'scrolled_window_containing_the_special_image'
  )
  scrolled_window_containing_the_special_image.css_class('BG_White')
  return scrolled_window_containing_the_special_image
end

#return_the_button_boxObject Also known as: return_button_box

#

return_the_button_box

#


2188
2189
2190
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2188

def return_the_button_box
  return @button_box
end

#return_the_event_box_containing_the_new_game_iconObject

#

return_the_event_box_containing_the_new_game_icon

This event box will be part of the left-widget, a bit below the “Control panel” text.

#


3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3036

def return_the_event_box_containing_the_new_game_icon
  image = create_image(project_base_dir?+'images/gamebooks/misc/new_game_icon.png')
  event_box_containing_the_gamebook_logo_for_the_die = event_box(image)
  # event_box_containing_the_gamebook_logo_for_the_die.bblack2
  event_box_containing_the_gamebook_logo_for_the_die.hint = 
    'Click on this image to start a new game.'
  event_box_containing_the_gamebook_logo_for_the_die.on_clicked {
    do_start_a_new_game
  }
  return event_box_containing_the_gamebook_logo_for_the_die
end

#return_the_event_box_for_the_special_imageObject

#

return_the_event_box_for_the_special_image

#


4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4229

def return_the_event_box_for_the_special_image
  event_box = event_box(@special_image)
  event_box.on_clicked {
    pointer = main_dataset?[current_page?.to_i]
    image = pointer['image']
    if image and image.start_with?('http')
      target = log_dir?+
               File.basename(image)
      target = File.absolute_path(target)
    else
      target = image
    end
    if image
      XorgBuffer.set(target) if Object.const_defined?(:XorgBuffer)
    end
  }
  @special_image.hide
  return event_box
end

#return_the_left_side_widgetObject Also known as: return_left_widget, return_the_widget_on_the_left_side, left_side?

#

return_the_left_side_widget (left tag)

#


2626
2627
2628
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2626

def return_the_left_side_widget
  @left_frame # Return the outer-vbox here.
end

#return_the_outer_frameObject Also known as: return_the_default_widget_on_the_right_side, return_the_right_side_widget, right_frame?, right_side?

#

return_the_outer_frame (right tag)

This method will tie together the logic for the right-side widget of the gamebook - that is, the right-frame widget - this is the widget that is situated on the right side of this application, as implied by this aptly chosen name.

#


2316
2317
2318
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2316

def return_the_outer_frame
  @right_frame
end

#return_the_widget_containing_information_about_the_enemyObject

#

return_the_widget_containing_information_about_the_enemy

This method will return the widget that contains information about the current enemy.

#


4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4294

def return_the_widget_containing_information_about_the_enemy
  grid = create_default_grid
  grid.pad8px
  if is_lone_wolf?
    # ===================================================================== #
    # === Current enemy
    #
    # This text is on top.
    # ===================================================================== #
    text_current_enemy = bold_text('Current enemy')
    text_current_enemy.font = larger_font?
    text_current_enemy.make_bold
    grid.full_line(text_current_enemy)
    # ===================================================================== #
    # === @label_name_of_the_opponent
    # ===================================================================== #
    @label_name_of_the_opponent = text
    grid.full_line(@label_name_of_the_opponent)
    # ===================================================================== #
    # === Combat Skill of the opponent
    # ===================================================================== #
    @opponent_combat_skill_entry = create_bold_entry
    @opponent_combat_skill_entry.center
    @opponent_combat_skill_entry.bblack1
    grid.left(bold_text('COMBAT SKILL'))
    grid.right(@opponent_combat_skill_entry)
    # ===================================================================== #
    # === Endurance of the opponent
    # ===================================================================== #
    grid.left(bold_text('ENDURANCE'))
    @opponent_endurance_entry = create_bold_entry
    @opponent_endurance_entry.center
    @opponent_endurance_entry.bblack1
    @opponent_endurance_entry.on_changed {
      the_opponent_endurance_entry_is_now_black
    }
    grid.right(@opponent_endurance_entry)
    # ===================================================================== #
    # === Current combat round
    #
    # This begins at 0. The first round of combat then sets this to 1,
    # then to 2 and so forth, until the enemy (or the hero) is dead.
    # ===================================================================== #
    grid.left(bold_text('Current combat round'))
    @entry_current_combat_round = create_bold_entry
    @entry_current_combat_round.is_read_only
    @entry_current_combat_round.center
    @entry_current_combat_round.bblack1
    grid.right(@entry_current_combat_round)
    button1 = button('_Reset')
    button1.clear_background
    button1.bblack1
    button1.pad8px
    button1.css_class('mar5px')
    button1.on_hover(:mintcream)
    button1.fancy_tip 'This will reset the form shown above.'
    button1.on_click {
      @label_name_of_the_opponent.set_text('')
      @opponent_combat_skill_entry.set_text('')
      @opponent_endurance_entry.set_text('')
      @entry_current_combat_round.set_text('')
    }
    grid.full_row(button1)
  end
  up_and_down_slider = up_and_down_dragging(
    grid,
    return_scrolled_window_containing_the_special_image
  )
  return up_and_down_slider
end

#return_the_widget_switcherObject

#

return_the_widget_switcher

The widget-switcher basically has an event-box with a scrollable window, and the button-box on the bottom.

#


870
871
872
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 870

def return_the_widget_switcher
  return @widget_switcher
end

#return_widget_containing_the_available_gamebooksObject

#

return_widget_containing_the_available_gamebooks

This method will return the widget that contains all available gamebooks. These will typically be stored in a .yml file.

#


1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1648

def return_widget_containing_the_available_gamebooks
  array = available_gamebooks?.map {|entry|
    File.basename(entry).delete_suffix('.yml')
  }
  combo_box = combo_box_entry(array)
  combo_box.first_entry_is_active
  combo_box.on_changed {
    clear_the_history # Re-set the history.
    new_text = combo_box.text?
    set_the_title_of_the_gamebook_onto_the_corresponding_widget(" #{new_text} ")
    # ===================================================================== #
    # Also change @use_this_file next:
    # ===================================================================== #
    _ = "#{GamesAndRpgParadise.project_yaml_directory?}gamebooks/*#{new_text}/config.yml"
    possible_entries = Dir[_]
    _ = possible_entries.first
    # ===================================================================== #
    # Now it should be something like:
    #
    #   "/usr/lib/ruby/site_ruby/3.2.0/rpg_paradise/yaml/gamebooks/lone_wolf_04_the_chasm_of_doom/config.yml"
    #
    # ===================================================================== #
    set_path_to_the_file_config_yml(_)
    consider_loading_the_config_yml_file
    load_the_dataset_from_the_yaml_file
    go_to_page(:default_start_page)
    @popover_showing_the_available_gamebooks.popdown
  }
  return combo_box
end

#return_widget_containing_usage_informationObject

#

return_widget_containing_usage_information

#


768
769
770
771
772
773
774
775
776
777
778
779
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 768

def return_widget_containing_usage_information
  _ = create_hbox
  image = gtk_icon('dialog-information')
  event_box = create_event_box(image)
  event_box.hint = 'Click on this image to display information on '\
                   'how the widget should be used.'
  event_box.on_clicked {
    do_show_info_how_to_use_this_widget
  }
  _.minimal(event_box, 5)
  return _
end

#return_widget_for_gewandheitspunkte_entryObject

#

return_widget_for_gewandheitspunkte_entry

This is the entry that will contain the actual value of the “Gewandheitspunkte”. In lone wolf series this is called “COMBAT SKILL” instead.

#


4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4482

def return_widget_for_gewandheitspunkte_entry
  # ======================================================================= #
  # === @entry_gewandheitspunkte
  # ======================================================================= #
  @entry_gewandheitspunkte = create_entry(
    (
      roll_this_die('1W6').to_i+6
    ).to_s
  )
  @entry_gewandheitspunkte.center
  @entry_gewandheitspunkte.width_height(80, 18)
  @entry_gewandheitspunkte.bblack1
  @entry_gewandheitspunkte.pad4px
  @entry_gewandheitspunkte.set_font(SMALLEST_FONT)
  @entry_gewandheitspunkte.yellow_background
  @entry_gewandheitspunkte.make_bold
  hbox = create_hbox
  hbox.maximal(@entry_gewandheitspunkte)
  # ======================================================================= #
  # The following addition is only valid for the lone-wolf series. We
  # will add the "current combat skill" widget there, as well as
  # an image for a six-sided die.
  # ======================================================================= #
  if is_part_of_the_lone_wolf_series?
    @entry_gewandheitspunkte.hint = 'This shows the base combat skill value.'
    @entry_current_combat_skill = create_entry
    @entry_current_combat_skill.center
    @entry_current_combat_skill.width_height(80, 18)
    @entry_current_combat_skill.bblack1
    @entry_current_combat_skill.pad4px
    @entry_current_combat_skill.set_font(SMALLEST_FONT)
    @entry_current_combat_skill.very_light_yellow_background
    @entry_current_combat_skill.make_bold
    @entry_current_combat_skill.hint =
      'This shows the current combat skill value, with all '\
      'modifiers in place. Modifiers here include equipment, '\
      'such as weapon and shields, as well as completed circles '\
      'or activatable abilities, such as psi-surge.'
    hbox.minimal(
      @entry_current_combat_skill
    )
    hbox.minimal(
      return_image_to_the_six_sided_die('1W10+10', :entry_combat_skill) # This is for the "COMBAT SKILL" value.
    )
  end
  return hbox
end

#return_widget_for_gewandheitspunkte_textObject

#

return_widget_for_gewandheitspunkte_text

#


2100
2101
2102
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2100

def return_widget_for_gewandheitspunkte_text
  return @text_containing_the_gewandheitspunkte_label
end

#return_widget_for_glück_entryObject

#

return_widget_for_glück_entry

#


888
889
890
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 888

def return_widget_for_glück_entry
  return @entry_glück
end

#return_widget_for_glück_textObject

#

return_widget_for_glück_text

#


1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1004

def return_widget_for_glück_text
  _ = 'Glück'
  if is_DSA_widget?
    _ = 'LE' # Repurpose it in this case.
  end
  text = left_aligned_text("#{_}:".ljust(22))
  text.set_font(SMALLEST_FONT)
  text.make_bold
  return text
end

#return_widget_for_stärke_entryObject

#

return_widget_for_stärke_entry

This is also known as “ENDURANCE”, if playing on the lone wolf series.

#


3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3697

def return_widget_for_stärke_entry
  unless is_part_of_the_lone_wolf_series?
    # ===================================================================== #
    # For "regular" gamebooks, NOT gamebooks belonging to the lone-wolf
    # series.
    # ===================================================================== #
    new_value = roll_this_die('2W6').to_i+12
    set_max_stärke(new_value)
    set_current_stärke(new_value) # We do this only upon initialization.
  end
  set_the_value_for_stärke_on_the_proper_entry
  hbox = create_hbox
  hbox.maximal(@entry_max_endurance)
  # ======================================================================= #
  # The following addition is only valid for the lone-wolf series:
  # ======================================================================= #
  if is_part_of_the_lone_wolf_series?
    # ===================================================================== #
    # Add the max-endurance widget next.
    # ===================================================================== #
    hbox.minimal(@entry_stärke)
    hbox.minimal(
      return_image_to_the_six_sided_die('1W10+20', :entry_endurance) # This is for the "ENDURANCE" value.
    )
  end
  return hbox
end

#return_widget_for_stärke_textObject

#

return_widget_for_stärke_text

#


1881
1882
1883
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1881

def return_widget_for_stärke_text
  return @text_containing_the_stärke_label
end

#return_widget_for_stärkepillen_entryObject

#

return_widget_for_stärkepillen_entry

#


1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1592

def return_widget_for_stärkepillen_entry
  hbox = create_hbox
  @entry_stärkepillen = create_entry(4.to_s)
  @entry_stärkepillen.center
  @entry_stärkepillen.width_height(115, 20)
  @entry_stärkepillen.bblack1
  # @entry_stärkepillen.read_only
  @entry_stärkepillen.pad4px
  @entry_stärkepillen.set_font(SMALLEST_FONT)
  @entry_stärkepillen.yellow_background
  @entry_stärkepillen.make_bold
  hbox.maximal(@entry_stärkepillen, 1)
  button = create_button('x')
  button.bblack1
  button.hint = "Click on this button to use (eat) a Stärkepille, "\
                "for +6 Stärke.\n\n"\
                "This will only work if you have at the least "\
                "one Stärkepille and if your stärke-points are "\
                "below the maximum value."
  button.on_clicked {
    set_current_stärke( # Eating this gives a +6 Stärke boost.
      current_stärke?.to_i + 6
    )
    set_the_value_for_stärke_on_the_proper_entry
    old_result = @entry_stärkepillen.text?
    new_value = (old_result.to_i - 1)
    new_value = 0 if new_value < 0
    # Deduct 
    @entry_stärkepillen.set_text(
      new_value.to_s
    )
  }
  hbox.minimal(button, 1)
  return hbox
end

#return_widget_for_stärkepillen_textObject

#

return_widget_for_stärkepillen_text

#


1325
1326
1327
1328
1329
1330
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1325

def return_widget_for_stärkepillen_text
  text = left_aligned_text('Stärkepillen:'.ljust(22))
  text.set_font(SMALLEST_FONT)
  text.make_bold
  return text
end

#return_widget_save_the_characterObject

#

return_widget_save_the_character

#


2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2151

def return_widget_save_the_character
  button = create_button
  button.set_image(
    image_document_save_as_symbolic_symbolic
  )
  button.on_clicked {
    do_save_the_character
  }
  button.hint = 'Click on this button to <b>save</b> the character '\
                'into a local file.'
  return button
end

#revert_the_CSS_rules_of_the_lower_entry_againObject

#

revert_the_CSS_rules_of_the_lower_entry_again

#


1378
1379
1380
1381
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1378

def revert_the_CSS_rules_of_the_lower_entry_again
  @entry_result_of_the_die_roll.remove_css_class('border_1px_red')
  @entry_result_of_the_die_roll.add_css_class('border_1px_black')
end

#roll_n_die(i = 2) ⇒ Object

#

roll_n_die

The default is “Würfle mit zwei Würfeln.”.

#


3517
3518
3519
3520
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3517

def roll_n_die(i = 2)
  result = roll_this_die("#{i}W6")
  @entry_result_of_the_die_roll.set_text(result.to_s)
end

#roll_the_die(i = '1D10') ⇒ Object Also known as: roll_complex_die

#

roll_the_die

#


3525
3526
3527
3528
3529
3530
3531
3532
3533
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3525

def roll_the_die(
    i = '1D10'
  )
  i = i.to_s.dup
  unless i.end_with?('W','D')
    i << 'W' unless i[-1,1] =~ /\d{1}/
  end
  return GamesAndRpgParadise.silently_roll_this_die(i) # Return the result here.
end

#science_fiction_theme?Boolean Also known as: science_fiction_widget?, use_science_fiction_widget?

#

science_fiction_theme?

#

Returns:

  • (Boolean)


428
429
430
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 428

def science_fiction_theme?
  @theme == :"science-fiction"
end

#scrolled_window_for_the_equipment_buffer?Boolean Also known as: main_view?, equipment_widget?

#

scrolled_window_for_the_equipment_buffer?

#

Returns:

  • (Boolean)


1682
1683
1684
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1682

def scrolled_window_for_the_equipment_buffer?
  @scrolled_window_for_the_equipment_buffer
end

#set_combat_skill_entry(i) ⇒ Object Also known as: set_combat_skill

#

set_combat_skill_entry

#


1293
1294
1295
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1293

def set_combat_skill_entry(i)
  entry_gewandheitspunkte?.set_text(i.to_s)
end

#set_current_combat_skill_entry(i) ⇒ Object Also known as: set_current_combat_skill

#

set_current_combat_skill_entry

#


784
785
786
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 784

def set_current_combat_skill_entry(i)
  entry_current_combat_skill?.set_text(i.to_s)
end

#set_current_endurance(i, &block) ⇒ Object Also known as: set_endurance, set_endurance_skill_entry

#

set_current_endurance

#


2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2534

def set_current_endurance(i, &block)
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :can_not_go_below_zero
    # ===================================================================== #
    when :can_not_go_below_zero
      i = i.to_i
      i = 0 if i < 0
    end
  end
  i = i.to_s
  current_endurance_entry?.set_text(i)
end

#set_current_endurance_of_the_enemy(i) ⇒ Object

#

set_current_endurance_of_the_enemy

#


3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3501

def set_current_endurance_of_the_enemy(i)
  i = i.to_s
  opponent_endurance_entry?.set_text(i)
  if i == '0'
    # Make it red.
    the_opponent_endurance_entry_is_now_red
  else # Make it black.
    the_opponent_endurance_entry_is_now_black
  end
end

#set_current_stärke(i) ⇒ Object Also known as: set_current_stärkepunkte

#

set_current_stärke

#


1108
1109
1110
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1108

def set_current_stärke(i)
  @character.set_current_stärke(i) if @character
end

#set_entry_containing_the_die(i = '2W6') ⇒ Object Also known as: set_entry_for_n_die

#

set_entry_containing_the_die

#


2043
2044
2045
2046
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2043

def set_entry_containing_the_die(i = '2W6')
  i = i.to_s
  @entry_for_the_dice.set_text(i)
end

#set_equipment_buffer(i) ⇒ Object

#

set_equipment_buffer

#


368
369
370
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 368

def set_equipment_buffer(i)
  @equipment_buffer.set_text(i.to_s)
end

#set_kai_disciplines(i) ⇒ Object

#

set_kai_disciplines

#


634
635
636
637
638
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 634

def set_kai_disciplines(i)
  i = i.to_s
  widget = @text_view_for_the_kai_disciplines
  widget.set_text(i) if widget
end

#set_main_buffer_content(i) ⇒ Object Also known as: set_buffer

#

set_main_buffer_content (hooks tag)

#


3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3122

def set_main_buffer_content(i)
  return unless main_buffer_exists?
  i = i.to_s # Do not call .strip anymore since as of 2022.
  # ======================================================================= #
  # Next we can run some hooks, such as "Würfle mit zwei Würfeln." or
  # "Würfle mit einem Würfel".
  # ======================================================================= #
  if i.include?('zwei Würfeln')
    roll_n_die(2)
  elsif i.include?('Würfle mit einem Würfel.')
    roll_n_die(1)
    set_entry_for_n_die('1W6')
  end
  # ======================================================================= #
  # === "Versuch dein Glück"
  #
  # Sometimes it is this:
  #
  #  "Da er dich überraschte, versuch dein Glück"
  #
  # So we must also catch the lower-cap starting character.
  # ======================================================================= #
  if i.include?('ersuch dein Glück')
    handle_the_situation_caused_bei_Versuch_dein_Glück
    # ===================================================================== #
    # Also make the "Versuch dein Glück" text italic.
    # ===================================================================== #
    i.gsub!(/Versuch dein Glück/i, '<i>Versuch dein Glück</i>')
  end
  # ======================================================================= #
  # Deduct something:
  # ======================================================================= #
  if i.include?('Du verlierst ')
    # ===================================================================== #
    # "Du verlierst 1 Stärkepunkt."
    # "Du verlierst 1 Gewandheitspunkt."
    # "Du verlierst 1 Punkt deiner Abwehrkraft"
    # ===================================================================== #
    use_this_regex = /Du verlierst (\d+) \b(.+)\b/ # See: https://rubular.com/r/2GCDkvOsf57qF4
    how_much, which_attribute = i.scan(use_this_regex).flatten
    how_much = how_much.to_i
    deduct(how_much, which_attribute)
  end
  # ======================================================================= #
  # === Check for lost endurance points next
  #
  # This may be like this: "You lose 3 ENDURANCE\npoints".
  # ======================================================================= #
  if i.include?('lose ') and
     i.include?(' ENDURANCE') and
     i.include?('points') and
     is_on_lone_wolf?
    regex_to_use = /lose (\d{1,3}) ENDURANCE\s*points/ # See: https://rubular.com/r/zPcK1GxbjIrNKA
    i =~ regex_to_use
    _ = $1.to_s.dup.to_i
    deduct_n_endurance_points(_)
  end
  # ======================================================================= #
  # We will strip on the input, aka remove the last newline at the least.
  # Not sure if this will be retained, but I think it looks better if
  # the last newline does NOT show up in the main buffer.
  # ======================================================================= #
  buffer = buffer_holding_the_gamepage_content?
  buffer.set_text(i)
  buffer.do_markify
end

#set_main_entry_to(i) ⇒ Object

#

set_main_entry_to

#


1038
1039
1040
1041
1042
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1038

def set_main_entry_to(i)
  if @entry_containing_the_number_of_the_subsection
    @entry_containing_the_number_of_the_subsection.set_text(i.to_s)
  end
end

#set_max_gold(i) ⇒ Object

#

set_max_gold

#


2459
2460
2461
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2459

def set_max_gold(i)
  @spinbutton_for_geld.set_max_value(i)
end

#set_max_id(i) ⇒ Object

#

set_max_id

#


1874
1875
1876
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1874

def set_max_id(i)
  @max_id = i.to_i
end

#set_max_stärke(i) ⇒ Object

#

set_max_stärke

#


1386
1387
1388
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1386

def set_max_stärke(i)
  @character.set_max_stärke(i) if @character.respond_to?(:set_max_stärke)
end

#set_maximal_endurance(i = @character.max_endurance?) ⇒ Object

#

set_maximal_endurance

#


3558
3559
3560
3561
3562
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3558

def set_maximal_endurance(
    i = @character.max_endurance?
  )
  @entry_max_endurance.set_text(i.to_s)
end

#set_n_arrows(i) ⇒ Object

#

set_n_arrows

#


2085
2086
2087
2088
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2085

def set_n_arrows(i)
  i = i.to_s
  @entry_for_n_arrows.set_text(i) if @entry_for_n_arrows
end

#set_n_gold(i) ⇒ Object Also known as: set_n_gold_coins, n_gold=

#

set_n_gold

#


2466
2467
2468
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2466

def set_n_gold(i)
  @spinbutton_for_geld.set_value(i.to_s)
end

#set_n_meals(i) ⇒ Object

#

set_n_meals

#


2342
2343
2344
2345
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2342

def set_n_meals(i)
  widget = @entry_for_meals
  widget.set_text(i.to_s) if widget
end

#set_n_quivers(i) ⇒ Object

#

set_n_quivers

#


2303
2304
2305
2306
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2303

def set_n_quivers(i)
  i = i.to_s
  @entry_for_n_quivers.set_text(i) if @entry_for_n_quivers
end

#set_path_to_the_file_config_yml(i, try_to_find_a_config_yaml_file = false) ⇒ Object Also known as: set_path

#

set_path_to_the_file_config_yml

#


2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2010

def set_path_to_the_file_config_yml(
    i, 
    try_to_find_a_config_yaml_file = false
  )
  case try_to_find_a_config_yaml_file
  # ======================================================================= #
  # === :try_to_find_a_config_yaml_file
  # ======================================================================= #
  when :try_to_find_a_config_yaml_file
    try_to_find_a_config_yaml_file = true
  end
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    i = USE_THIS_GAMEBOOK
  end
  if try_to_find_a_config_yaml_file and !i.end_with?('config.yml')
    dirname = dirname_but_retains_the_trailing_slash(i)
    if File.file?("#{dirname}config.yml")
      # =================================================================== #
      # In this case we'll switch to that file instead.
      # =================================================================== #
      i = "#{dirname}config.yml"
    end
  end
  @path_to_the_file_config_yml = i
end

#set_rename_equipment_widget(i = ) ⇒ Object

#

set_rename_equipment_widget

#


1228
1229
1230
1231
1232
1233
1234
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1228

def set_rename_equipment_widget(
    i = @config_dataset[:rename_equipment_widget_to]
  )
  if @text_ausrüstung_label
    @text_ausrüstung_label.set_text(i.to_s)
  end
end

#set_rename_gewandheit_entry_to(i = ) ⇒ Object

#

set_rename_gewandheit_entry_to

#


1204
1205
1206
1207
1208
1209
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1204

def set_rename_gewandheit_entry_to(
    i = @config_dataset[:rename_gewandheit_entry_to]
  )
  widget = text_containing_the_gewandheit_label?
  widget.set_text(i.to_s) if widget
end

#set_rename_gold_entry_to(i = ) ⇒ Object Also known as: consider_updating_the_text_containing_the_money_label

#

set_rename_gold_entry_to

#


1132
1133
1134
1135
1136
1137
1138
1139
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1132

def set_rename_gold_entry_to(
    i = @config_dataset[:rename_gold_entry_to]
  )
  text = text_containing_the_money_label?
  if text
    text.set_text(i.to_s)
  end
end

#set_rename_stärke_entry_to(i) ⇒ Object

#

set_rename_stärke_entry_to

#


1196
1197
1198
1199
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1196

def set_rename_stärke_entry_to(i)
  widget = text_containing_the_stärke_label?
  widget.set_text(i.to_s) if widget
end

#set_starting_page(i) ⇒ Object

#

set_starting_page

#


2167
2168
2169
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2167

def set_starting_page(i)
  @starting_page = i
end

#set_the_title_of_the_gamebook_onto_the_corresponding_widget(i) ⇒ Object

#

set_the_title_of_the_gamebook_onto_the_corresponding_widget

#


2224
2225
2226
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2224

def set_the_title_of_the_gamebook_onto_the_corresponding_widget(i)
  @text_keeping_the_gamebook_title.set_text(i)
end

#set_the_value_for_stärke_on_the_proper_entryObject Also known as: autoset_gtk_entry_stärke

#

set_the_value_for_stärke_on_the_proper_entry

#


1312
1313
1314
1315
1316
1317
1318
1319
1320
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1312

def set_the_value_for_stärke_on_the_proper_entry
  current_stärke = current_stärke?
  max_stärke     = max_stärke?
  if current_stärke.to_i > max_stärke.to_i
    current_stärke = max_stärke
  end
  _ = current_stärke.to_s+' / '+max_stärke.to_s
  @entry_stärke.set_text(_.to_s)
end

#set_theme(i = :lone_wolf) ⇒ Object

#

set_theme

#


327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 327

def set_theme(
    i = :lone_wolf
  )
  case i
  # ======================================================================= #
  # === :lone_wolf
  # ======================================================================= #
  when :lone_wolf,
       :default
    i = :fantasy_lone_wolf
  end
  @theme = i
end

#set_use_this_file(i) ⇒ Object

#

set_use_this_file

#


2174
2175
2176
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2174

def set_use_this_file(i)
  @use_this_file = File.absolute_path(i)
end

#set_use_this_gamebook(i = :default_gamebook_to_use) ⇒ Object

#

set_use_this_gamebook

#


3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3323

def set_use_this_gamebook(
    i = :default_gamebook_to_use
  )
  case i
  # ======================================================================= #
  # === :default_gamebook_to_use
  # ======================================================================= #
  when :default_gamebook_to_use,
       :default
    i = USE_THIS_GAMEBOOK
  end
  if i.is_a? Array
    i = i.first
  end
  i = i.to_s
  if i =~ /^\d{1,5}/
    # ===================================================================== #
    # If i is a leading number:
    # ===================================================================== #
    possibilities = Dir["#{yaml_gamebooks_dir?}*"].select {|entry|
      File.directory?(entry)
    }
    i = i.to_i - 1
    if (i+1) > possibilities.size
      i = possibilities.size - 1
    end
    basename = File.basename(possibilities[i])
    i = "#{yaml_gamebooks_dir?}#{basename}/config.yml"
  end
  i = i.dup if i.frozen?
  # ======================================================================= #
  # The next clause was modified in May 2023. We now trust the user if the
  # user passes in the file path of a .yml file.
  # ======================================================================= #
  i << 'config.yml' unless (i.end_with?('config.yml') or i.end_with?('.yml'))
  set_path_to_the_file_config_yml(i, :try_to_find_a_config_yaml_file)
  # ======================================================================= #
  # Calling this method must always invoke the next method as well:
  # ======================================================================= #
  load_the_dataset_for_the_gamebook
end

#show_helpObject

#

show_help (help tag)

#


623
624
625
626
627
628
629
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 623

def show_help
  e 'You can designate different gamebooks to use via:'
  e
  e '  --use-gamebook=1'
  e '  --use-gamebook=2'
  e
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


1888
1889
1890
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1888

def smaller_font?
  SMALLER_FONT
end

#smallest_font?Boolean

#

smallest_font?

#

Returns:

  • (Boolean)


382
383
384
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 382

def smallest_font?
  SMALLEST_FONT
end

#sourceview_containing_the_content_of_the_gamebook_entry?Boolean Also known as: scrolled_window?, the_primary_scrolled_window?, main_widget?

#

sourceview_containing_the_content_of_the_gamebook_entry?

#

Returns:

  • (Boolean)


3855
3856
3857
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3855

def sourceview_containing_the_content_of_the_gamebook_entry?
  @sourceview_containing_the_content_of_the_gamebook_entry
end

#spinbutton_for_geld?Boolean

#

spinbutton_for_geld?

#

Returns:

  • (Boolean)


580
581
582
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 580

def spinbutton_for_geld?
  @spinbutton_for_geld
end

#switch_to_the_no_border_for_the_die_image(use_this_new_css_class = 'border_3px_dotted_black') ⇒ Object

#

switch_to_the_no_border_for_the_die_image

#


1342
1343
1344
1345
1346
1347
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1342

def switch_to_the_no_border_for_the_die_image(
    use_this_new_css_class = 'border_3px_dotted_black'
  )
  @hbox_containing_the_die_images.remove_css_class('border_3px_dotted_red')
  @hbox_containing_the_die_images.css_class(use_this_new_css_class)
end

#switch_to_the_red_border_for_the_die_image(remove_this_old_css_class = 'border_3px_dotted_black') ⇒ Object

#

switch_to_the_red_border_for_the_die_image

#


1352
1353
1354
1355
1356
1357
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1352

def switch_to_the_red_border_for_the_die_image(
    remove_this_old_css_class = 'border_3px_dotted_black' # or: 'border_none'
  )
  @hbox_containing_the_die_images.remove_css_class(remove_this_old_css_class)
  @hbox_containing_the_die_images.css_class('border_3px_dotted_red')
end

#sync_the_fonts(use_this_font = @use_this_font, scrolled_window = scrolled_window? ) ⇒ Object

#

sync_the_fonts (fonts tag, font tag, sync tag)

#


2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2367

def sync_the_fonts(
    use_this_font   = @use_this_font,
    scrolled_window = scrolled_window?
  )
  scrolled_window.set_use_this_font(use_this_font)
  left_side?.set_use_this_font(use_this_font)
  if @text_view_for_the_kai_disciplines
    @text_view_for_the_kai_disciplines.font = smaller_font?
  end
  if actionsheet_label?
    actionsheet_label?.font = larger_font?
    actionsheet_label?.make_bold
  end
  if @admin_label
    @admin_label.font = larger_font?
    @admin_label.make_bold
    @button_open_the_currently_used_yaml_file_in_the_editor.font = larger_font?
  end
  @notes_label.font = larger_font?
  @notes_label.make_bold
  if @four_components_entry1
    @four_components_entry1.sync_this_font(use_this_font)
    @four_components_entry2.sync_this_font(use_this_font)
  end
end

#text_containing_the_gewandheit_label?Boolean

#

text_containing_the_gewandheit_label?

#

Returns:

  • (Boolean)


1214
1215
1216
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1214

def text_containing_the_gewandheit_label?
  @text_containing_the_gewandheitspunkte_label
end

#text_containing_the_money_label?Boolean

#

text_containing_the_money_label?

#

Returns:

  • (Boolean)


860
861
862
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 860

def text_containing_the_money_label?
  @text_containing_the_money_label
end

#text_containing_the_stärke_label?Boolean

#

text_containing_the_stärke_label?

#

Returns:

  • (Boolean)


1221
1222
1223
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1221

def text_containing_the_stärke_label?
  @text_containing_the_stärke_label
end

#text_view_holding_the_gamepage_content?Boolean

#

text_view_holding_the_gamepage_content?

#

Returns:

  • (Boolean)


458
459
460
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 458

def text_view_holding_the_gamepage_content?
  @text_view_holding_the_gamepage_content
end

#the_button_was_clicked_for_this_subpage(use_this_id) ⇒ Object

#

the_button_was_clicked_for_this_subpage

This method ties together all actions that occur when the player clicked on a button for a specific subpage.

#


3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3917

def the_button_was_clicked_for_this_subpage(
    use_this_id
  )
  use_this_id = remove_html(use_this_id.to_s.strip)
  pointer = load_dataset_for_this_page(use_this_id)
  # ======================================================================= #
  # Add to the traversal-history next:
  # ======================================================================= #
  add_to_the_path_traversal_history(use_this_id)
  main_entry?.set_text(use_this_id) if main_entry?
  if pointer.has_key? 'content'
    content = pointer['content'].lstrip
  else
    e tomato('Warning: the pointer for ID '+use_this_id.to_s+
      'does not have the keyword "content".')
  end
  # ======================================================================= #
  # === is_this_a_combat_page
  #
  # Determine whether we have a combat page, or whether we do not. This
  # only works for the lone-wolf gamebook series right now.
  # ======================================================================= #
  is_this_a_combat_page = content.include? ' ENDURANCE:'
  set_buffer(content)
  # ======================================================================= #
  # Check for the add_item entry next:
  # ======================================================================= #
  if pointer.has_key? 'add_item'
    if automatically_pick_up_items?
      @character.add_this_item_to_the_equipment(pointer['add_item'])
      update_the_equipment_widget
    end
  end
  # ======================================================================= #
  # Check for the add_n_gold_coins entry next:
  # ======================================================================= #
  if pointer.has_key? 'add_n_gold_coins'
    if automatically_pick_up_items?
      @character.add_n_gold_coins(pointer['add_n_gold_coins'])
      update_the_gold_coins_widget
    end
  end
  # ======================================================================= #
  # Check for the add_item_unless_it_exists_already entry next:
  # ======================================================================= #
  if pointer.has_key? 'add_item_unless_it_exists_already'
    if automatically_pick_up_items?
      _ = @character.equipment?
      _ = _.join("\n") if _.is_a? Array
      item_to_be_added = pointer['add_item_unless_it_exists_already']
      unless _.include? item_to_be_added
        @character.add_this_item_to_the_equipment(item_to_be_added)
        update_the_equipment_widget
      end
    end
  end
  if is_lone_wolf?
    # ===================================================================== #
    # === Operate on combat-pages next
    # ===================================================================== #
    if is_this_a_combat_page
      # =================================================================== #
      # Parse the opponent into the corresponding entry.
      # =================================================================== #
      parse_the_current_page_to_determine_the_enemy(content)
    else # else it is not a combat-page.
      empty_the_label_containing_the_name_of_the_opponent
      the_opponent_endurance_entry_is_now_black
    end
  end
  if is_lone_wolf? and use_this_id.to_i > 0 and
    !is_this_a_combat_page # We can only heal on non-combat pages.
    # ===================================================================== #
    # Add curing for the lone-wolf widget.
    # ===================================================================== #
    @character.set_current_endurance(current_endurance_from_the_widget?.to_i)
    if @character and (@character.has_healing_ability? or @character.has_curing_ability?)
      try_to_regenerate_n_hp(1)
    end
  end
end

#the_character_diesObject

#

the_character_dies

#


1519
1520
1521
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1519

def the_character_dies
  @character.dies if @character
end

#the_exits_of_this_page_number_must_be_determined_next(i = 0) ⇒ Object Also known as: determine_all_the_exits

#

the_exits_of_this_page_number_must_be_determined_next (exits tag)

The input should be the current page.

#


4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 4080

def the_exits_of_this_page_number_must_be_determined_next(
    i = 0
  )
  pointer = main_dataset?[i.to_i]
  index = 0
  begin
    image = pointer['image']
    # ===================================================================== #
    # Handle given images next:
    # ===================================================================== #
    if image
      if image.is_a? Array
        image = image.first # For now we only handle the first entry.
      end
      target = "#{project_base_directory?}images/gamebooks/#{image}"
      if image.start_with? 'http'
        target = log_dir?+
                 File.basename(target)
        unless File.exist? target
          # In this case download it, e. g. from imgur.
          cd(GamesAndRpgParadise.temp_dir?)
          cd(File.dirname(target))
          verbose_download_this_remote_image_into_that_assumed_local_path(
            image,
            target
          )
        end
      end
      if File.exist? target
        # ================================================================= #
        # We will update the image in this case.
        # ================================================================= #
        @special_image.path = target
        target = File.absolute_path(target)
        if File.exist?(target)
          @special_image.hint = "This image can be found at: "\
                                "\n\n  <b>#{target}</b>\n\n"
        end
        @special_image.show
      end
    else
      @special_image.hide
    end
    exits = pointer['exits']
    hide_all_buttons # Always hide all buttons, first.
    if exits
      exits.each {|this_exit_leads_to_that_number, this_exit_has_that_description|
        value   = this_exit_has_that_description
        content = "<b>#{this_exit_leads_to_that_number}</b> | #{this_exit_has_that_description}"
        # ================================================================= #
        # If "fin", which means finished, is used, then we will not show
        # any buttons. The adventure will have stopped at that moment
        # in time.
        # ================================================================= #
        if content.include?('fin') and
          !content.include?(' fin') and
          !(content =~ /[A-Za-z]fin[A-Za-z]/) and
          !(value.to_s =~ /\d+/)
          # =============================================================== #
          # Here we will distinguish two cases:
          #
          #  (1) the game is over
          #  (2) the game series can continue for the next gamebook, in
          #      particular for the lone-wolf gamebook series
          #
          # =============================================================== #
          if content.include? 'Continue with '
            if content.include? 'Proceed with '
              content.gsub!(
                /Proceed with /, 'Continue with '
              )
            end
            use_this_regex = /Continue with "(.+)"./ # See: https://rubular.com/r/bFMkKJb7D0WQ9T
            scanned = content.scan(use_this_regex)
            continue_with_this_gamebook(scanned.flatten.first)
            this_exit_leads_to_that_number = 0 # And rewrite the exit here.
            if @array_buttons[this_exit_leads_to_that_number]
              @array_buttons[this_exit_leads_to_that_number].enable_the_button
              content = '<b>0</b> | Continue your journey here, on a new adventure.'
              @array_buttons[this_exit_leads_to_that_number].set_text(content)
              @array_buttons[this_exit_leads_to_that_number].left_align
              @array_buttons[this_exit_leads_to_that_number].do_markify
              # =========================================================== #
              # Only show the next buttons if the main character is still alive.
              # =========================================================== #
              if @character.is_alive?
                @array_buttons[this_exit_leads_to_that_number].show
              end
            end
          else
            do_popup_game_over_message
            the_game_is_now_over
          end
        elsif content.include?('guess_correctly')
          # Here the player must guess the correct continuation.
        else
          # =============================================================== #
          # Change newlines a bit, since as of October 2022.
          # =============================================================== #
          value.gsub!(/\n/,' ') if value.include?("\n")
          # =============================================================== #
          # Parse the content of the exit-description next:
          # =============================================================== #
          if value.include?('Stichwort ')
            # ============================================================= #
            # Ok, in this case we append to the equipment buffer
            # ============================================================= #
            append_to_the_equipment_buffer(
              "\n"+
              value.scan(
                /(Stichwort [A-Za-z]+)/
              ).flatten.first.to_s
            )
          end
          if value.size > 80
            value = word_wrap(value).strip # Word-wrap it in this event.
            content = "<b>#{this_exit_leads_to_that_number}</b> | #{value}"
          end
          if @array_buttons[index]
            @array_buttons[index].enable_the_button
            @array_buttons[index].set_text(content)
            @array_buttons[index].left_align
            @array_buttons[index].do_markify
            # ============================================================= #
            # Only show the next buttons if the main character is still alive.
            # ============================================================= #
            if @character.is_alive?
              @array_buttons[index].show
            end
          end
          index += 1
        end
      }
    else
      if exits.nil?
        e ::Colours.tomato(
            "The subpage at entry `#{i}` does not seem to have correct exits defined."
          )
      end
    end
  rescue Exception => error
    pp error
    pp "The subpage was: #{i}"
  end
end

#the_game_is_now_overObject

#

the_game_is_now_over

#


444
445
446
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 444

def the_game_is_now_over
  @is_the_game_over = true
end

#the_opponent_endurance_entry_is_now_black(i = opponent_endurance_entry? ) ⇒ Object

#

the_opponent_endurance_entry_is_now_black

#


3745
3746
3747
3748
3749
3750
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3745

def the_opponent_endurance_entry_is_now_black(
    i = opponent_endurance_entry?
  )
  i.add_css_class('black')
  i.remove_CSS_class('red')
end

#the_opponent_endurance_entry_is_now_red(i = opponent_endurance_entry? ) ⇒ Object

#

the_opponent_endurance_entry_is_now_red

#


3735
3736
3737
3738
3739
3740
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3735

def the_opponent_endurance_entry_is_now_red(
    i = opponent_endurance_entry?
  )
  i.add_css_class('red')
  i.remove_CSS_class('black')
end

#theme?Boolean

#

theme?

#

Returns:

  • (Boolean)


396
397
398
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 396

def theme?
  @theme
end

#try_to_regenerate_n_hp(i = 1) ⇒ Object

#

try_to_regenerate_n_hp

#


1276
1277
1278
1279
1280
1281
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1276

def try_to_regenerate_n_hp(
    i = 1
  )
  @character.try_to_regenerate_n_hp(i)
  set_current_endurance(@character.current_endurance?)
end

#update_the_equipment_widgetObject

#

update_the_equipment_widget

#


851
852
853
854
855
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 851

def update_the_equipment_widget
  set_equipment_buffer(
    @character.equipment?.join("\n")
  )
end

#update_the_gold_coins_widgetObject

#

update_the_gold_coins_widget

#


2474
2475
2476
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2474

def update_the_gold_coins_widget
  set_n_gold(@character.n_gold_coins?)
end

#use_this_file?Boolean Also known as: use_which_file?

#

use_this_file?

#

Returns:

  • (Boolean)


2181
2182
2183
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2181

def use_this_file?
  @use_this_file
end

#use_which_font?Boolean

#

use_which_font?

#

Returns:

  • (Boolean)


1741
1742
1743
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1741

def use_which_font?
  @use_which_font
end

#verbose_download_this_remote_image_into_that_assumed_local_path(image_to_use = @image_to_use, assumed_local_path) ⇒ Object

#

verbose_download_this_remote_image_into_that_assumed_local_path

#


3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3820

def verbose_download_this_remote_image_into_that_assumed_local_path(
   image_to_use = @image_to_use,
   assumed_local_path
 )
  e ::Colours.rev+
    'Downloading from `'+image_to_use+'` next into `'+
    sfile(assumed_local_path)+'`.'
  # remote_URL = URI.open(@image_to_use)
  io_download(image_to_use, assumed_local_path) # Use IO.download rather than wget now.
end

#visit_this_page(i = @starting_page) ⇒ Object Also known as: visit_this_subsection, go_to_page

#

visit_this_page

#


2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 2231

def visit_this_page(
    i = @starting_page
  )
  case i
  # ======================================================================= #
  # === :default_start_page
  # ======================================================================= #
  when :default_start_page,
       :default
    i = @starting_page
  end
  dataset = the_button_was_clicked_for_this_subpage(i)
  # ======================================================================= #
  # Set the content on the scrolled-window next:
  # ======================================================================= #
  if dataset.is_a?(Hash) and dataset.has_key?('content')
    scrolled_window?.set_text(
      dataset['content'].lstrip
    )
  end
  main_entry?.set_text(i.to_s)
end

#weapons_buffer?Boolean

#

weapons_buffer?

#

Returns:

  • (Boolean)


1806
1807
1808
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1806

def weapons_buffer?
  @weapons_widget_text_buffer
end

#widget_switcher?Boolean

#

widget_switcher?

#

Returns:

  • (Boolean)


3192
3193
3194
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 3192

def widget_switcher?
  @widget_switcher
end

#yaml_file?Boolean

#

yaml_file?

#

Returns:

  • (Boolean)


1748
1749
1750
1751
1752
1753
# File 'lib/games_and_rpg_paradise/gui/shared_code/gamebook/gamebook_module.rb', line 1748

def yaml_file?
  _ = File.dirname(@path_to_the_file_config_yml)
  globbed = Dir[_+'/*'].reject {|entry| entry.include? 'config.yml' }
  _ = globbed.first
  return _
end