cambridge-modpack/tetris/modes/fpviewer.lua

2081 lines
24 KiB
Lua

local GameMode = require 'tetris.modes.gamemode'
local FlashPointViewer = GameMode:extend()
FlashPointViewer.name = "FP Board Viewer"
FlashPointViewer.hash = "FPViewer"
FlashPointViewer.tagline = "See all of Flash Point's boards!"
local board_str = [[
CC
ZZ
ZZ
SSSS
SSSS
SSSS
TTTTTT
TTTTTT
TTTTTT
OOOOOOOO
OOOOOOOO
OOOOOOOO
Z Z Z Z
Z Z Z Z
Z Z Z Z
Z Z C Z
Z Z Z Z
Z Z Z Z
Z Z Z Z
Z Z Z Z
Z Z Z Z
LLLLL
C L
L
L
LLLLL
L
L
L
LLLLL
C Z
ZZ
ZZZ
ZZZZ
ZZZZZ
ZZZZZZ
ZZZZZZZ
ZZZZZZZZ
ZZZZZZZZZ
SS
SS
CC
SS
SS
SS
LL
LL
CC
LL
LL
LL
SSSSSSSS
SSSS SS
SS SS
CSSS SS
SSSSSSSS
C
L L
L L
LL LL
LL LL
LLL LLL
LLL LLL
LLLL LLLL
LLLL LLLL
JJJJ
J J
JC J
JJJJ
SSSSSSS
SSSSSSS
C
OO
OO
OOOO
OOOO
OOOOOO
OOOOOO
OOOO
OOOO
OO
CO
TTTT
T
T
T
TTTT
T C
T
T
TTTT
ZZ ZZ
ZZZZ ZZZZ
ZZ C ZZ
T T
T T
T T
T C
TT
I L
I L
I L
I L
I L
I L
I L
I L
C L
I L
I L
I L
I L
I L
I L
I L
I L
IIII
II
II
I II I
II
II
IIII
CII
II
I II I
II
II
Z Z
Z Z Z
C Z
Z
Z
ZZZZZ
Z
OOOO
OOOO
OOOO
OOOO
OOOO
OOOO
C
OOOO
OOOO
OOOO
OOOO
OOOO
OOOO
SS
SS SS
SS SS
SS SS
SS
C
C
Z Z
Z Z
Z Z
Z Z
ZZ ZZ
ZZ ZZ
ZZ ZZ
ZZ ZZ
ZZZ ZZZ
ZZZ ZZZ
ZZZ ZZZ
ZZZ ZZZ
ZZZZ ZZZZ
ZZZZ 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S
S
S
S
S
C
S
S
Z
Z ZZZZZ
Z Z Z
Z ZCZ Z
Z ZZZ Z
Z Z
ZZZZZZZ
SSSSSSS
S S
S SSS S
S SCS S
S S S
SSSSS S
S
Z S
Z S
Z S
Z S
ZS
TO
T O
T O
T O
T O
C
Z Z S S
C C
Z Z S S
T T O O
C C
T T O O
I I L L
C C
I I L L
Z Z
Z Z
Z Z
Z Z
Z Z Z Z
Z Z
Z Z
Z Z
Z Z
Z Z
Z Z
Z C Z
Z Z
ZZZ ZZZ
ZZZ ZZZ
ZCZ ZCZ
ZZZ ZZZ
ZZ
ZZ
ZZZZ
Z Z
Z Z
ZZZZ
CC CCCC
C C C
CCCC C
CCCCCCCCC
C C C
C C C
CCCCCCCCC
C C C
CCCCC C
CCCCCC
C CCC
CCCCCC
]]
local function parseMap(str, map)
local array = {}
local start = 220 * (map - 1)
for row = 5, 24 do
local row_array = {}
for col = 1, 10 do
local num = start + 11 * (row - 5) + col
local char = str:sub(num, num)
local insert_this = nil
if char == "I" then
insert_this = { skin = "2tie", colour = "C" }
elseif char == "J" then
insert_this = { skin = "2tie", colour = "B" }
elseif char == "L" then
insert_this = { skin = "2tie", colour = "O" }
elseif char == "O" then
insert_this = { skin = "2tie", colour = "Y" }
elseif char == "S" then
insert_this = { skin = "2tie", colour = "G" }
elseif char == "T" then
insert_this = { skin = "2tie", colour = "M" }
elseif char == "Z" then
insert_this = { skin = "2tie", colour = "R" }
elseif char == "C" then
insert_this = { skin = "gem", colour = "W" }
end
row_array[col] = insert_this
end
array[row] = row_array
end
return array
end
function FlashPointViewer:new()
self.super:new()
self.ready_frames = 1
self.next_queue_length = 0
self.current_map = 1
self.grid:applyMap(parseMap(board_str, 1))
end
function FlashPointViewer:advanceOneFrame(inputs, ruleset)
local prev_map = self.current_map
if inputs.right or (not self.prev_inputs.up and inputs.up) then
self.current_map = math.min(self.current_map + 1, 100)
elseif inputs.left or (not self.prev_inputs.down and inputs.down) then
self.current_map = math.max(self.current_map - 1, 1)
end
if prev_map ~= self.current_map then
self.grid:clear()
self.grid:applyMap(parseMap(board_str, self.current_map))
end
self.prev_inputs = inputs
return false
end
function FlashPointViewer:drawScoringInfo()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setFont(font_3x5_3)
love.graphics.print("FLASHPOINT BOARD VIEWER", 240, 120)
love.graphics.print(self.current_map, 240, 200)
love.graphics.setFont(font_3x5_2)
love.graphics.print("MAP", 240, 180)
love.graphics.print("UP/DOWN +/- 1\nLEFT/RIGHT FOR FAST SCROLL", 240, 260)
end
return FlashPointViewer