Top Level Namespace

Defined Under Namespace

Modules: Box Classes: Array, BettyNiño, BettyNiñoO, Bettys, Board, Point, Purse

Constant Summary collapse

Action =
Enum[{ Single: 1 }, :Double, :Triple, :Bettys]
SKYLINE_INDEX =
19
MINIMUM =
let **{
  HEIGHT: 24,
  WIDTH: 58,
}
COLOR =
{
  I: :CYAN,
  J: :BLUE,
  L: :YELLOW,
  O: :YELLOW,
  S: :GREEN,
  T: :MAGENTA,
  Z: :RED,
}
GAME_OVER_ART =
<<~ART.chomp.freeze
  ⠀⠀⠀⢀⣾⣦⣤⣤⣤⡀⣀⣤⣄⣀⣀⡄⠀⠀⠀⠀
  ⠀⣆⣴⣿⣿⣿⣿⣿⢏⣾⣿⣿⣿⣿⣿⣿⣤⡀⡀⠀
  ⠀⣼⡿⠛⠿⠍⠛⠟⠾⠛⢛⣿⠻⢿⣿⣿⣿⣿⡟⠀
  ⢠⡟⠋⢀⠌⠀⠀⠀⠀⠀⠒⢄⠀⠲⠟⣿⣿⣿⡇⠀
  ⠀⠘⡁⢊⣆⣄⡀⠀⠀⠀⠀⠈⠢⠀⠰⣼⣿⣿⠷⠃
  ⠀⢲⡟⣹⠀⢻⡆⠀⠀⢠⣂⢉⠆⢀⢀⣼⡿⠋⠀⠀
  ⠀⢿⣇⠀⠙⠉⠀⡄⠀⠈⠉⠉⠁⠘⣿⣿⡧⠀⠀⠀
  ⠀⠀⢤⡭⠶⢒⡠⢶⡦⠒⠤⣀⣀⠴⠫⣂⠇⠀⠀⠀
  ⠀⠀⠻⠱⣒⣲⢉⠜⠁⠀⠀⠀⢳⣄⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⡇⠸⠃⠀⡠⠒⠀⠀⠀⡏⠳⡀⠀⠀⠀⠀
  ⠀⠀⠀⠀⡇⠀⣠⣾⣷⣄⠀⠀⠀⢰⠀⡸⠀⠀⠀⠀
  ⠀⠀⠀⠀⠈⠉⠸⣿⣿⣿⣗⢤⡀⢸⣴⠃⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠛⠃⠛⠛⠃⠀⠀⠀
ART
GAME_OVER_MESSAGES =
[
  "Thanks for playing honey",
  "See you again sweetie!",
  "You did great darling!",
  "Come back soon love!",
  "That was beautiful babe!",
  "You're a star, gorgeous!",
  "Until next time cutie!",
  "What a ride sweetheart!",
  "You played your heart out!",
  "Rest up, you earned it!",
  "Until next time, sugar",
  "Sweet dreams, beautiful",
  "Come back soon, cutie",
  "You're a star, sweetheart",
  "Miss you already, babe",
  "That was fun, gorgeous",
  "You're amazing, love",
  "Lovely playing with you",
  "You light up my screen",
  "Be back soon, angel",

].freeze
PIECES =
%i[I J L O S T Z].freeze
Face =
Enum[:↑, :→, :↓, :←]
BLUEPRINT =
{
  I: [
    [[0, 0], [0, -1], [0, 1], [0, 2]],
    [[0, 0], [-1, 0], [1, 0], [2, 0]],
    [[0, 0], [0, -1], [0, -2], [0, 1]],
    [[0, 0], [-1, 0], [-2, 0], [1, 0]],
  ],
  J: [
    [[0, 0], [0, -1], [-1, -1], [0, 1]],
    [[0, 0], [-1, 0], [-1, 1], [1, 0]],
    [[0, 0], [0, 1], [1, 1], [0, -1]],
    [[0, 0], [1, 0], [1, -1], [-1, 0]],
  ],
  L: [
    [[0, 0], [0, -1], [-1, 1], [0, 1]],
    [[0, 0], [-1, 0], [1, 0], [1, 1]],
    [[0, 0], [0, -1], [0, 1], [1, -1]],
    [[0, 0], [-1, 0], [-1, -1], [1, 0]],
  ],
  O: [
    [[0, 0], [-1, 1], [-1, 0], [0, 1]],
    [[0, 0], [0, 1], [1, 0], [1, 1]],
    [[0, 0], [0, -1], [1, -1], [1, 0]],
    [[0, 0], [-1, 0], [0, -1], [-1, -1]],
  ],
  S: [
    [[0, 0], [-1, 1], [0, -1], [-1, 0]],
    [[0, 0], [-1, 0], [0, 1], [1, 1]],
    [[0, 0], [0, 1], [1, -1], [1, 0]],
    [[0, 0], [0, -1], [-1, -1], [1, 0]],
  ],
  T: [
    [[0, 0], [0, -1], [-1, 0], [0, 1]],
    [[0, 0], [-1, 0], [0, 1], [1, 0]],
    [[0, 0], [0, -1], [0, 1], [1, 0]],
    [[0, 0], [0, -1], [-1, 0], [1, 0]],
  ],
  Z: [
    [[0, 0], [-1, 0], [-1, -1], [0, 1]],
    [[0, 0], [-1, 1], [0, 1], [1, 0]],
    [[0, 0], [0, -1], [1, 0], [1, 1]],
    [[0, 0], [0, -1], [-1, 0], [1, -1]],
  ],
}.freeze
OFFSET =
{
  JLSTZ: {
    [Face., Face.] => [[0, 0], [0, -1], [1, -1], [-2, 0], [-2, -1]],
    [Face., Face.] => [[0, 0], [0, 1], [-1, 1], [2, 0], [2, 1]],
    [Face., Face.] => [[0, 0], [0, 1], [-1, 1], [2, 0], [2, 1]],
    [Face., Face.] => [[0, 0], [0, -1], [1, -1], [-2, 0], [-2, -1]],
    [Face., Face.] => [[0, 0], [0, 1], [1, 1], [-2, 0], [-2, 1]],
    [Face., Face.] => [[0, 0], [0, -1], [-1, -1], [2, 0], [2, -1]],
    [Face., Face.] => [[0, 0], [0, -1], [-1, -1], [2, 0], [2, -1]],
    [Face., Face.] => [[0, 0], [0, 1], [1, 1], [-2, 0], [-2, 1]],
  },
  I: {
    [Face., Face.] => [[0, 0], [0, -2], [0, 1], [-1, -2], [2, 1]],
    [Face., Face.] => [[0, 0], [0, 2], [0, -1], [1, 2], [-2, -1]],
    [Face., Face.] => [[0, 0], [0, -1], [0, 2], [2, -1], [-1, 2]],
    [Face., Face.] => [[0, 0], [0, 1], [0, -2], [-2, 1], [1, -2]],
    [Face., Face.] => [[0, 0], [0, 2], [0, -1], [1, 2], [-2, -1]],
    [Face., Face.] => [[0, 0], [0, -2], [0, 1], [-1, -2], [2, 1]],
    [Face., Face.] => [[0, 0], [0, 1], [0, -2], [-2, 1], [1, -2]],
    [Face., Face.] => [[0, 0], [0, -1], [0, 2], [2, -1], [-1, 2]],
  },
}.freeze
LOCK_DELAY =
0.5
MAX_LOCK_RESETS =
15

Instance Method Summary collapse

Instance Method Details

#err(message, *args) ⇒ Object



74
75
76
77
# File 'lib/consts.rb', line 74

def err(message, *args)
  $stderr.printf "Error: #{message}\n", *args
  exit 1
end

#originObject



79
80
81
82
83
84
# File 'lib/consts.rb', line 79

def origin
  [
    (Curses.lines - MINIMUM.HEIGHT) / 2,
    (Curses.cols - MINIMUM.WIDTH) / 2,
  ]
end

#typewriter(text, delay: 0.04) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/consts.rb', line 86

def typewriter(text, delay: 0.04)
  text.each_char do |c|
    print c
    $stdout.flush
    sleep delay
  end
end