mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 17:39:03 -06:00
Fixed Konoha randomiser and added ghost before lv100
This commit is contained in:
parent
5d34218b97
commit
5f7ea0648e
@ -3,8 +3,7 @@ require 'funcs'
|
|||||||
local GameMode = require 'tetris.modes.gamemode'
|
local GameMode = require 'tetris.modes.gamemode'
|
||||||
local Piece = require 'tetris.components.piece'
|
local Piece = require 'tetris.components.piece'
|
||||||
|
|
||||||
local Bag5Randomizer = require 'tetris.randomizers.bag5'
|
local KonohaRandomizer = require 'tetris.randomizers.bag_konoha'
|
||||||
local Bag5AltRandomizer = require 'tetris.randomizers.bag5alt'
|
|
||||||
|
|
||||||
local KonohaGame = GameMode:extend()
|
local KonohaGame = GameMode:extend()
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ KonohaGame.tagline = "Get as many bravos as you can under the time limit!"
|
|||||||
function KonohaGame:new()
|
function KonohaGame:new()
|
||||||
KonohaGame.super:new()
|
KonohaGame.super:new()
|
||||||
|
|
||||||
self.randomizer = Bag5AltRandomizer()
|
self.randomizer = KonohaRandomizer()
|
||||||
self.bravos = 0
|
self.bravos = 0
|
||||||
self.time_limit = 10800
|
self.time_limit = 10800
|
||||||
self.big_mode = true
|
self.big_mode = true
|
||||||
@ -69,8 +68,8 @@ end
|
|||||||
|
|
||||||
function KonohaGame:getGravity()
|
function KonohaGame:getGravity()
|
||||||
if (self.level < 30) then return 4/256
|
if (self.level < 30) then return 4/256
|
||||||
elseif (self.level < 35) then return 8/256
|
elseif (self.level < 35) then return 8/256
|
||||||
elseif (self.level < 40) then return 12/256
|
elseif (self.level < 40) then return 12/256
|
||||||
elseif (self.level < 50) then return 16/256
|
elseif (self.level < 50) then return 16/256
|
||||||
elseif (self.level < 60) then return 32/256
|
elseif (self.level < 60) then return 32/256
|
||||||
elseif (self.level < 70) then return 48/256
|
elseif (self.level < 70) then return 48/256
|
||||||
@ -111,6 +110,9 @@ end
|
|||||||
|
|
||||||
function KonohaGame:drawGrid(ruleset)
|
function KonohaGame:drawGrid(ruleset)
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
|
if self.piece ~= nil and self.level < 100 then
|
||||||
|
self:drawGhostPiece(ruleset)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cleared_row_levels = {2, 4, 6, 12}
|
local cleared_row_levels = {2, 4, 6, 12}
|
||||||
@ -132,8 +134,8 @@ function KonohaGame:onLineClear(cleared_row_count)
|
|||||||
self.bravos = self.bravos + 1
|
self.bravos = self.bravos + 1
|
||||||
if self.level < 1000 then self.time_limit = self.time_limit + bravo_bonus[cleared_row_count / 2]
|
if self.level < 1000 then self.time_limit = self.time_limit + bravo_bonus[cleared_row_count / 2]
|
||||||
else self.time_limit = self.time_limit + bravo_ot_bonus[cleared_row_count / 2]
|
else self.time_limit = self.time_limit + bravo_ot_bonus[cleared_row_count / 2]
|
||||||
if self.bravos == 11 then self.randomizer = Bag5Randomizer() end
|
end
|
||||||
end
|
if self.bravos == 11 then self.randomizer.allowrepeat = true end
|
||||||
elseif self.level < 1000 then
|
elseif self.level < 1000 then
|
||||||
self.time_limit = self.time_limit + non_bravo_bonus[cleared_row_count / 2]
|
self.time_limit = self.time_limit + non_bravo_bonus[cleared_row_count / 2]
|
||||||
end
|
end
|
||||||
|
28
tetris/randomizers/bag_konoha.lua
Normal file
28
tetris/randomizers/bag_konoha.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||||
|
|
||||||
|
local BagKonoha = Randomizer:extend()
|
||||||
|
|
||||||
|
function BagKonoha:initialize()
|
||||||
|
self.bag = {"I", "J", "L", "O", "T"}
|
||||||
|
self.prev = nil
|
||||||
|
self.allowrepeat = false
|
||||||
|
self.generated = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function BagKonoha:generatePiece()
|
||||||
|
self.generated = self.generated + 1
|
||||||
|
if #self.bag == 0 then
|
||||||
|
self.bag = {"I", "J", "L", "O", "T"}
|
||||||
|
end
|
||||||
|
local x = math.random(#self.bag)
|
||||||
|
local temp = table.remove(self.bag, x)
|
||||||
|
if temp == self.prev and not self.allowrepeat then
|
||||||
|
local y = math.random(#self.bag)
|
||||||
|
table.insert(self.bag, temp) -- should insert at the end of the bag, bag[y] doesnt change
|
||||||
|
temp = table.remove(self.bag, y)
|
||||||
|
end
|
||||||
|
self.prev = temp
|
||||||
|
return temp
|
||||||
|
end
|
||||||
|
|
||||||
|
return BagKonoha
|
Loading…
Reference in New Issue
Block a user