Class: GamesAndRpgParadise::Gamebooks::Sinatra

Inherits:
Sinatra::Base
  • Object
show all
Includes:
Colours, Colours::E, Cyberweb::BaseModule, Cyberweb::Sinatra::CustomExtensions, Base::ExtensionsForAGamebook, HtmlTags::BaseModule
Defined in:
lib/games_and_rpg_paradise/sinatra/gamebooks/gamebooks.rb

Overview

GamesAndRpgParadise::Gamebooks::Sinatra

Constant Summary collapse

AVAILABLE_GAMEBOOKS =
#

AVAILABLE_GAMEBOOKS

#
GamesAndRpgParadise.available_gamebooks?
USE_THIS_PORT =
'5580'
IS_ROEBE =
#

IS_ROEBE

#
true

Constants included from Base::ExtensionsForAGamebook

Base::ExtensionsForAGamebook::DIRECTORY_FOR_THE_GAMEBOOKS

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_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Constructor Details

#initializeSinatra

#

initialize

#


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/games_and_rpg_paradise/sinatra/gamebooks/gamebooks.rb', line 64

def initialize
  super()
  reset
  if IS_ROEBE
    require 'open'
    # ===================================================================== #
    # Tell us which port will be used:
    # ===================================================================== #
    target = "http://localhost:#{USE_THIS_PORT}/"
    e sfancy(target)
    Thread.new {
      sleep 1.0
      Open.in_browser(target)
    }
  end
end

Instance Method Details

#resetObject

#

reset (reset tag)

#


84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/games_and_rpg_paradise/sinatra/gamebooks/gamebooks.rb', line 84

def reset
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = GamesAndRpgParadise::Gamebooks.load_dataset(
    for_this_gamebook: 13
  )
  # ======================================================================= #
  # === @character
  # ======================================================================= #
  @character = GamesAndRpgParadise::Gamebooks::Character.new
end

#return_character_divObject

#

return_character_div

#


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/games_and_rpg_paradise/sinatra/gamebooks/gamebooks.rb', line 121

def return_character_div
  HtmlTags.div(
    'Character data: <br>'+
    Cyberweb.base64_image(
      GamesAndRpgParadise.project_base_directory?+'images/die.png'
    )+' <br>Stärke: <br>Gewandheitspunkte: <br>
    Glück: <b>'+@character.glück?.to_s+'</b>',
    css_style: '
      border: 2px solid black;
      padding: 8px;
      margin: 4px;
      font-size: 1.25em;
    '
  )
end

#return_main_indexObject

#

return_main_index

This method will return the main index that will be shown.

#


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/games_and_rpg_paradise/sinatra/gamebooks/gamebooks.rb', line 142

def return_main_index
  _ = ''.dup
  _ << HtmlTags.p('The following options are available:')+
       '<div style="margin-left: 2em">'+
       HtmlTags.a('/dice', content: :self)+'<br>'
  Dir[
    GamesAndRpgParadise.project_base_directory?+'yaml/gamebooks/*'
  ].select {|entry| File.directory?(entry) }.each {|this_entry|
    _ << a('/'+File.basename(this_entry), content: :self)+'<br>'
  }
  _ << '</div>'
  html_template(
    title: 'RPG-related web-functionality',
    css_style: '
      img {
        border:  2px solid black;
        padding: 2px;
      }
      body {
        font-size: 1.5em;
      }
      ',
    body: _,
    favicon: BeautifulUrl[:rpg_paradise_favicon]
  )
end