Class: Zarta::StartScreen

Inherits:
Object
  • Object
show all
Defined in:
lib/zarta/main.rb

Instance Method Summary collapse

Constructor Details

#initialize(dungeon) ⇒ StartScreen

Returns a new instance of StartScreen.



39
40
41
42
43
44
# File 'lib/zarta/main.rb', line 39

def initialize(dungeon)
  @dungeon = dungeon
  @prompt = TTY::Prompt.new
  @pastel = Pastel.new
  show_splash
end

Instance Method Details

#leaderboardObject



77
78
79
80
# File 'lib/zarta/main.rb', line 77

def leaderboard
  puts 'Leaderboard not implemented yet...'
  gets
end

#load_gameObject



72
73
74
75
# File 'lib/zarta/main.rb', line 72

def load_game
  puts 'Load Game not implemented yet...'
  gets
end

#new_gameObject



66
67
68
69
70
# File 'lib/zarta/main.rb', line 66

def new_game
  player_name = @prompt.ask("What's your name, adventurer?", required: true)
  @dungeon.player.name = player_name
  Zarta::Screen.new(@dungeon)
end

#show_splashObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/zarta/main.rb', line 46

def show_splash
  loop do
    system 'clear'
    a = Artii::Base.new font: 'isometric3'
    title = a.asciify('Zarta')
    puts @pastel.red.bold(title)
    splash_option = @prompt.select('') do |menu|
      menu.choice 'New Game'
      menu.choice 'Load Game'
      menu.choice 'Leaderboards'
      menu.choice 'Quit'
    end

    new_game if splash_option == 'New Game'
    load_game if splash_option == 'Load Game'
    leaderboard if splash_option == 'Leaderboards'
    exit[0] if splash_option == 'Quit' && @prompt.yes?('Are you sure?')
  end
end