From 10191afb9264a550a9f23a11c075b4cfb6f4a2ea Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Tue, 10 Oct 2023 22:03:52 +0200 Subject: [PATCH] Fixed bugs induced by pico8-ls formatter --- bg.lua | 2 +- board.lua | 34 ++++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/bg.lua b/bg.lua index a72abb1..5064e98 100644 --- a/bg.lua +++ b/bg.lua @@ -1,5 +1,5 @@ function draw_animated_bg(startx) - if (amplitude <= 0) return + if amplitude <= 0 then return end startx = startx or 0 fillp(0b0101101001011010) diff --git a/board.lua b/board.lua index 5197889..5b4a92e 100644 --- a/board.lua +++ b/board.lua @@ -124,19 +124,22 @@ function Board.new() -- check count if filled and count(row, BLUE) ~= count(row, YELLOW) then add(issues, { "row", "count", row, y }) - if (debug) printh("uneven count on row " .. y) if (not details) return issues + if debug then printh("uneven count on row " .. y) end + if not details then return issues end end -- check identical lines for k, other in ipairs(rows) do if filled and equal(other, row) and other ~= row then add(issues, { "row", "identical", row, y, k }) - if (debug) printh("equal rows " .. k) if (not details) return issues + if debug then printh("equal rows " .. k) end + if not details then return issues end end end -- check triples if self:count_consecutives(row) > 2 then add(issues, { "row", "triples", row, y }) - if (debug) printh("triples") if (not details) return issues + if debug then printh("triples") end + if not details then return issues end end end @@ -147,19 +150,22 @@ function Board.new() -- check count if filled and count(col, BLUE) ~= count(col, YELLOW) then add(issues, { "col", "count", col, x }) - if (debug) printh("uneven count") if (not details) return issues + if debug then printh("uneven count") end + if not details then return issues end end -- check identical lines for k, other in ipairs(cols) do if filled and equal(other, col) and other ~= col then add(issues, { "col", "identical", col, x, k }) - if (debug) printh("equal cols") if (not details) return issues + if debug then printh("equal cols") end + if not details then return issues end end end -- check triples if self:count_consecutives(col) > 2 then add(issues, { "col", "triples", col, x }) - if (debug) printh("triples") if (not details) return issues + if debug then printh("triples") end + if not details then return issues end end end return issues @@ -230,7 +236,8 @@ function Board.new() -- Set a random color local z = self:get_random_zero() self:fill(z, rnd({ BLUE, YELLOW })) - if (debug) printh("!!!!!!!!!!!!!!!!! RANDOM FILL AT " .. z) return "invalid" + if debug then printh("!!!!!!!!!!!!!!!!! RANDOM FILL AT " .. z) end + return "invalid" end return (changed or self:is_complete()) and "valid" or "invalid" end, @@ -263,7 +270,8 @@ function Board.new() -- do the surrounding for item in all(neighbors) do if item[1] then - if (debug) printh("Surrounding at " .. item[1]) self:fill(item[1], tiles[item[2]], true) + if debug then printh("Surrounding at " .. item[1]) end + self:fill(item[1], tiles[item[2]], true) end end end @@ -279,7 +287,8 @@ function Board.new() local prev = tiles[idx - 1] local next = tiles[idx + 1] if prev ~= 0 and prev == next then - if (debug) printh("Splitting at " .. idx) self:fill(idx, prev, true) + if debug then printh("Splitting at " .. idx) end + self:fill(idx, prev, true) end end @@ -288,7 +297,8 @@ function Board.new() local prev = tiles[idx - width] local next = tiles[idx + width] if prev ~= 0 and prev == next then - if (debug) printh("Splitting at " .. idx) self:fill(idx, prev, true) + if debug then printh("Splitting at " .. idx) end + self:fill(idx, prev, true) end end end @@ -321,7 +331,7 @@ function Board.new() end, fill_row = function(self, y, color) - if (debug) printh("Filling line " .. y .. " in " .. (color == BLUE and "blue" or "yellow")) + if debug then printh("Filling line " .. y .. " in " .. (color == BLUE and "blue" or "yellow")) end local idx = self:xy_idx(1, y) for i = idx, idx + width - 1 do if self:get_tile(i) == 0 then @@ -331,7 +341,7 @@ function Board.new() end, fill_col = function(self, x, color) - if (debug) printh("Filling column " .. x .. " in " .. (color == BLUE and "blue" or "yellow")) + if debug then printh("Filling column " .. x .. " in " .. (color == BLUE and "blue" or "yellow")) end local idx = self:xy_idx(x, 1) for i = idx, #tiles, width do if self:get_tile(i) == 0 then