Class: Radventure::Texts

Inherits:
Object
  • Object
show all
Defined in:
lib/radventure/texts.rb

Overview

Method for generic text functionalities

Class Method Summary collapse

Class Method Details

.clearvoid

This method returns an undefined value.

Clears the console screen



69
70
71
# File 'lib/radventure/texts.rb', line 69

def self.clear
  $stdout.clear_screen
end

.headerObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/radventure/texts.rb', line 46

def self.header
  # y, x = $stdout.winsize
  # puts Rainbow("+#{'=' * (x - 2)}+").italic
  #
  # i = 0
  # until i == (y - 2)
  #   puts '+'
  #   i += 1
  # end
end

.intro(meta) ⇒ void

This method returns an undefined value.

Outputs a simple intro to the game

Parameters:

  • meta (Hash)

    A hash containing the game metadata



13
14
15
16
17
18
19
20
21
22
# File 'lib/radventure/texts.rb', line 13

def self.intro(meta)
  puts Rainbow("## #{meta.title} ##").yellow.bright
  puts "Version #{meta.version}"
  puts "© #{meta.year}, #{meta.author}"
  puts "Available under #{meta.license}"
  puts ''
  puts meta.description
  wait_for_key
  clear
end

.prelude(meta) ⇒ void

This method returns an undefined value.

Outputs a simple intro to the game

Parameters:

  • meta (Hash)

    A hash containing the game metadata



28
29
30
31
32
33
34
# File 'lib/radventure/texts.rb', line 28

def self.prelude(meta)
  return unless meta.prelude != ''

  puts meta.prelude
  wait_for_key
  clear
end

.show_room(room) ⇒ void

This method returns an undefined value.

Outputs the room’s name and description

Parameters:

  • room (Room)

    The room to show



40
41
42
43
44
# File 'lib/radventure/texts.rb', line 40

def self.show_room(room)
  puts Rainbow("## #{room.name} ##").blue.bright
  puts room.description
  puts ''
end

.wait_for_keyvoid

This method returns an undefined value.

Prints a “press any key” message and waits for, well, any key



60
61
62
63
64
# File 'lib/radventure/texts.rb', line 60

def self.wait_for_key
  puts ''
  puts Rainbow('<Press any key>').color(:dimgray)
  gets
end