Merge branch 'MillaBasset:main' into high-stacker

This commit is contained in:
Xx-Henry-xX 2023-07-12 18:09:41 +09:00 committed by GitHub
commit 152dd4a7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 130 additions and 287 deletions

View File

@ -561,7 +561,7 @@ function LifeGrid:advanceLife()
if (count == 3) and (newgrid[y][x] == empty) then if (count == 3) and (newgrid[y][x] == empty) then
newgrid[y][x] = { newgrid[y][x] = {
skin = "2tie", skin = "2tie",
colour = ({"R", "O", "Y", "G", "B", "C", "M"})[math.random(7)] colour = ({"R", "O", "Y", "G", "B", "C", "M"})[love.math.random(7)]
} }
end end
end end

View File

@ -44,7 +44,7 @@ local maps = {
function ComboChallenge:new() function ComboChallenge:new()
GameMode:new() GameMode:new()
self.grid = Grid(4, 24) self.grid = Grid(4, 24)
self.grid:applyMap(maps[math.random(#maps)]) self.grid:applyMap(maps[love.math.random(#maps)])
self.randomizer = BagRandomizer() self.randomizer = BagRandomizer()
self.lock_drop = false self.lock_drop = false
self.lock_hard_drop = false self.lock_hard_drop = false

View File

@ -27,7 +27,7 @@ function DemonModeGame:new()
self.lock_drop = true self.lock_drop = true
self.lock_hard_drop = true self.lock_hard_drop = true
self.next_queue_length = 6 self.next_queue_length = 6
if math.random() < 1/6.66 then if love.math.random() < 1/6.66 then
self.rpc_details = "Suffering" self.rpc_details = "Suffering"
end end
end end

View File

@ -127,33 +127,33 @@ function TheTrueHero:advanceOneFrame(inputs, ruleset)
self.section_frames = 0 self.section_frames = 0
self.attack_number = self.attack_number + 1 self.attack_number = self.attack_number + 1
local prev_attack = self.current_attack local prev_attack = self.current_attack
self.current_attack = -1 for i = 1, 3 do
local attack_rolls = 0
while ((
prev_attack == self.current_attack or
self.current_attack == 5
) and (attack_rolls < 2)) or attack_rolls == 0 do
attack_rolls = attack_rolls + 1
if self.attack_number > 20 then if self.attack_number > 20 then
self.current_attack = math.random(#self.attacks) self.current_attack = love.math.random(#self.attacks)
else else
self.current_attack = math.random(4) self.current_attack = love.math.random(4)
end
if (
prev_attack ~= self.current_attack and
self.current_attack ~= 5
) then
break
end end
end end
if self.current_attack == 1 then if self.current_attack == 1 then
self.var = math.floor(3 + math.random( self.var = math.floor(3 + love.math.random(
math.floor(self.attack_number / 4), math.floor(self.attack_number / 4),
math.floor(self.attack_number / 3) math.floor(self.attack_number / 3)
) * ) *
self.section_times[Mod1(self.attack_number, #self.section_times)] / 342) self.section_times[Mod1(self.attack_number, #self.section_times)] / 342)
elseif self.current_attack == 2 then elseif self.current_attack == 2 then
self.var = math.floor(1 + math.random( self.var = math.floor(1 + love.math.random(
math.floor(self.attack_number / 6), math.floor(self.attack_number / 6),
math.floor(self.attack_number / 4) math.floor(self.attack_number / 4)
) * ) *
self.section_times[Mod1(self.attack_number, #self.section_times)] / 342) self.section_times[Mod1(self.attack_number, #self.section_times)] / 342)
elseif self.current_attack == 3 then elseif self.current_attack == 3 then
self.var = math.max(10 - math.random( self.var = math.max(10 - love.math.random(
math.floor(self.attack_number / 8), math.floor(self.attack_number / 8),
math.floor(self.attack_number / 4) math.floor(self.attack_number / 4)
), 3) ), 3)
@ -198,21 +198,23 @@ end
function TheTrueHero:onPieceLock(piece, cleared_row_count) function TheTrueHero:onPieceLock(piece, cleared_row_count)
self.super:onPieceLock() self.super:onPieceLock()
if self.current_attack == 1 or self.current_attack == 3 then if self.current_attack == 1 or self.current_attack == 3 then
self.var = math.max(self.var - 1, 0) if self.var ~= math.floor(self.current_attack / 2) then
self:advanceBottomRow(1)
playSE("undyne", "ding")
elseif self.current_attack == 2 then
self.var = math.max(self.var - cleared_row_count, 0)
if cleared_row_count ~= 0 then
playSE("undyne", "ding") playSE("undyne", "ding")
end end
self.var = math.max(self.var - 1, 0)
self:advanceBottomRow(1)
elseif self.current_attack == 2 then
if cleared_row_count ~= 0 and self.var ~= 0 then
playSE("undyne", "ding")
end
self.var = math.max(self.var - cleared_row_count, 0)
end end
end end
function TheTrueHero:advanceBottomRow(dx) function TheTrueHero:advanceBottomRow(dx)
if self.var <= 0 and self.current_attack == 3 then if self.var <= 0 and self.current_attack == 3 then
self.grid:copyBottomRow() self.grid:copyBottomRow()
self.var = math.max(10 - math.random( self.var = math.max(10 - love.math.random(
math.floor(self.attack_number / 8), math.floor(self.attack_number / 8),
math.floor(self.attack_number / 4) math.floor(self.attack_number / 4)
), 3) ), 3)

View File

@ -50,6 +50,7 @@ local line_popup = {["y"]=0,["score"]=0,["lines"]=0}
function MarathonC99Game:new() function MarathonC99Game:new()
self.super:new() self.super:new()
self.grid = Grid(10, 22) self.grid = Grid(10, 22)
self.slots_random = love.math.newRandomGenerator(os.time())
self.randomizer = SegaRandomizer() self.randomizer = SegaRandomizer()
self.additive_gravity = false self.additive_gravity = false
@ -146,6 +147,11 @@ function MarathonC99Game:onPieceEnter()
self.piece.last_orientation = self.piece.rotation self.piece.last_orientation = self.piece.rotation
end end
function MarathonC99Game:onPieceLock()
playSE("lock")
self.score = self.score + (self.prev_inputs["down"] and 1 or 0)
end
function MarathonC99Game:advanceOneFrame(inputs, ruleset) function MarathonC99Game:advanceOneFrame(inputs, ruleset)
if self.clear then if self.clear then
if self.level == 17 then if self.level == 17 then
@ -282,6 +288,7 @@ function MarathonC99Game:drawScoringInfo()
love.graphics.printf("NEXT", 64, 40, 40, "left") love.graphics.printf("NEXT", 64, 40, 40, "left")
love.graphics.printf("LEVEL "..self.level, 240, 120, 80, "left") love.graphics.printf("LEVEL "..self.level, 240, 120, 80, "left")
love.graphics.printf("LINES", 240, 190, 200, "left") love.graphics.printf("LINES", 240, 190, 200, "left")
love.graphics.printf("TIMER", 240, 280, 200, "left")
love.graphics.printf(self.lines.."/300", 240, 210, 200, "left") love.graphics.printf(self.lines.."/300", 240, 210, 200, "left")
if(self.level ~= 15 and self.level ~= 17) then if(self.level ~= 15 and self.level ~= 17) then
@ -299,9 +306,12 @@ function MarathonC99Game:drawScoringInfo()
end end
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
love.graphics.setFont(font_3x5_4) love.graphics.setFont(font_8x11)
love.graphics.printf(formatBigNum(self.score), 64, 400, 160, "center") love.graphics.printf(
formatBigNum(string.format("%08d", self.score)),
44, 390, 200, "center"
)
if self.ready_frames == 0 then if self.ready_frames == 0 then
love.graphics.setColor( love.graphics.setColor(
((self.frames + self.roll_frames) % 4 < 2) and ((self.frames + self.roll_frames) % 4 < 2) and
@ -330,9 +340,9 @@ function MarathonC99Game:drawScoringInfo()
{1, 1, 1, 1} {1, 1, 1, 1}
) )
love.graphics.printf( love.graphics.printf(
(self.slots[1] and self.slots[1] or math.random(4)) .. " " .. (self.slots[1] or self.slots_random:random(4)) .. " " ..
(self.slots[2] and self.slots[2] or math.random(4)) .. " " .. (self.slots[2] or self.slots_random:random(4)) .. " " ..
math.random(4), self.slots_random:random(4),
240, 80, 100, "left") 240, 80, 100, "left")
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
end end
@ -341,8 +351,7 @@ function MarathonC99Game:drawScoringInfo()
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
level_names[17] = self.roll_frames == frameTime(3,19) and "THE EDGE OF THE WORLD" or formatTime(frameTime(3,19) - self.roll_frames) level_names[17] = self.roll_frames == frameTime(3,19) and "THE EDGE OF THE WORLD" or formatTime(frameTime(3,19) - self.roll_frames)
love.graphics.printf(level_names[self.level], 240, 137, 200, "left") love.graphics.printf(level_names[self.level], 240, 137, 200, "left")
love.graphics.setFont(font_3x5_2) love.graphics.setFont(font_3x5_4)
love.graphics.setFont(font_8x11)
love.graphics.printf(formatTime(self.frames), 240, 300, 160, "left") love.graphics.printf(formatTime(self.frames), 240, 300, 160, "left")
end end

View File

@ -93,7 +93,7 @@ function MarathonWCBGame:shuffleColours()
table.insert(temp_colours, colour) table.insert(temp_colours, colour)
end end
for piece in pairs(self.ruleset.colourscheme) do for piece in pairs(self.ruleset.colourscheme) do
self.ruleset.colourscheme[piece] = table.remove(temp_colours, math.random(#temp_colours)) self.ruleset.colourscheme[piece] = table.remove(temp_colours, love.math.random(#temp_colours))
end end
end end

View File

@ -33,7 +33,7 @@ end
function Minesweeper:initializeGrid() function Minesweeper:initializeGrid()
self.grid = Grid(width, height + 4) self.grid = Grid(width, height + 4)
self.flags = math.floor(0.15 * width * height) self.flags = math.floor(0.15 * width * height)
self.chosen_colour = ({ "R", "O", "Y", "G", "C", "B", "M" })[math.random(7)] self.chosen_colour = ({ "R", "O", "Y", "G", "C", "B", "M" })[love.math.random(7)]
for y = 1, height do for y = 1, height do
for x = 1, width do for x = 1, width do
self.grid.grid[y+4][x] = { skin = "2tie", colour = self.chosen_colour } self.grid.grid[y+4][x] = { skin = "2tie", colour = self.chosen_colour }
@ -45,8 +45,8 @@ function Minesweeper:initializeMines(sel_x, sel_y)
for i = 1, self.flags do for i = 1, self.flags do
local x, y local x, y
repeat repeat
x = math.random(1, width) x = love.math.random(1, width)
y = math.random(1, height) y = love.math.random(1, height)
until not (self:isMine(x, y) or (sel_x == x and sel_y == y)) until not (self:isMine(x, y) or (sel_x == x and sel_y == y))
table.insert(self.mines, {x=x, y=y}) table.insert(self.mines, {x=x, y=y})
end end

View File

@ -35,6 +35,8 @@ function PhantomManiaNXGame:new()
self.coolregret_message = "COOL!!" self.coolregret_message = "COOL!!"
self.coolregret_timer = 0 self.coolregret_timer = 0
self.section_cools = { [0] = 0 }
self.section_regrets = { [0] = 0 }
end end
function PhantomManiaNXGame:getARE() function PhantomManiaNXGame:getARE()
@ -118,6 +120,11 @@ function PhantomManiaNXGame:advanceOneFrame()
end end
return false return false
elseif self.roll_frames > 3238 then elseif self.roll_frames > 3238 then
if self:qualifiesForGMRoll() then
self.roll_points = self.roll_points + 160
else
self.roll_points = self.roll_points + 50
end
switchBGM(nil) switchBGM(nil)
self.completed = true self.completed = true
end end
@ -209,11 +216,15 @@ function PhantomManiaNXGame:updateSectionTimes(old_level, new_level)
table.insert(self.section_times, section_time) table.insert(self.section_times, section_time)
self.section_start_time = self.frames self.section_start_time = self.frames
if section_time >= frameTime(1,00) then if section_time >= frameTime(1,00) then
self.last_section_cool = false --self.last_section_cool = false
self.coolregret_message = "REGRET!!" self.coolregret_message = "REGRET!!"
self.coolregret_timer = 300 self.coolregret_timer = 300
self.grade = self.grade - 1 self.grade = self.grade - 1
elseif self.last_section_cool then table.insert(self.section_regrets, 1)
else
table.insert(self.section_regrets, 0)
end
if self.last_section_cool then
self.cools = self.cools + 1 self.cools = self.cools + 1
end end
self.grade = self.grade + 1 self.grade = self.grade + 1
@ -227,8 +238,10 @@ function PhantomManiaNXGame:updateSectionTimes(old_level, new_level)
self.last_section_cool = true self.last_section_cool = true
self.coolregret_message = "COOL!!" self.coolregret_message = "COOL!!"
self.coolregret_timer = 300 self.coolregret_timer = 300
table.insert(self.section_cools, 1)
else else
self.last_section_cool = false self.last_section_cool = false
table.insert(self.section_cools, 0)
end end
end end
end end
@ -291,11 +304,7 @@ end
function PhantomManiaNXGame:getAggregateGrade() function PhantomManiaNXGame:getAggregateGrade()
local grade_cap local grade_cap
if self:qualifiesForGMRoll() then if self:qualifiesForGMRoll() then
if self.roll_frames > 3238 then
grade_cap = 42 grade_cap = 42
else
grade_cap = 41
end
else else
grade_cap = 26 grade_cap = 26
end end
@ -308,7 +317,7 @@ end
local master_grades = {"M", "MK", "MV", "MO"} local master_grades = {"M", "MK", "MV", "MO"}
local function getLetterGrade(grade) local function getLetterGrade(grade, roll_frames)
if grade == 0 then if grade == 0 then
return "1" return "1"
elseif grade <= 13 then elseif grade <= 13 then
@ -317,13 +326,25 @@ local function getLetterGrade(grade)
return "M" .. tostring(grade - 13) return "M" .. tostring(grade - 13)
elseif grade <= 30 then elseif grade <= 30 then
return master_grades[grade - 26] return master_grades[grade - 26]
elseif grade <= 41 then elseif grade <= 41 or roll_frames <= 3238 then
return "MM-" .. tostring(grade - 30) return "MM-" .. tostring(grade - 30)
else else
return "GM" return "GM"
end end
end end
function PhantomManiaNXGame:sectionColourFunction(section)
if self.section_cools[section] == 1 and self.section_regrets[section] == 1 then
return { 1, 1, 0, 1 }
elseif self.section_cools[section] == 1 then
return { 0, 1, 0, 1 }
elseif self.section_regrets[section] == 1 then
return { 1, 0, 0, 1 }
else
return { 1, 1, 1, 1 }
end
end
function PhantomManiaNXGame:drawScoringInfo() function PhantomManiaNXGame:drawScoringInfo()
PhantomManiaNXGame.super.drawScoringInfo(self) PhantomManiaNXGame.super.drawScoringInfo(self)
@ -351,7 +372,7 @@ function PhantomManiaNXGame:drawScoringInfo()
love.graphics.setFont(font_3x5_3) love.graphics.setFont(font_3x5_3)
if self.roll_frames > 3238 then love.graphics.setColor(1, 0.5, 0, 1) if self.roll_frames > 3238 then love.graphics.setColor(1, 0.5, 0, 1)
elseif self.level >= 1300 then love.graphics.setColor(0, 1, 0, 1) end elseif self.level >= 1300 then love.graphics.setColor(0, 1, 0, 1) end
love.graphics.printf(getLetterGrade(self:getAggregateGrade()), text_x, 140, 90, "left") love.graphics.printf(getLetterGrade(self:getAggregateGrade(), self.roll_frames), text_x, 140, 90, "left")
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
love.graphics.printf(self.score, text_x, 220, 90, "left") love.graphics.printf(self.score, text_x, 220, 90, "left")
love.graphics.printf(self.level, text_x, 340, 50, "right") love.graphics.printf(self.level, text_x, 340, 50, "right")

View File

@ -1,189 +0,0 @@
require 'funcs'
local GameMode = require 'tetris.modes.gamemode'
local Piece = require 'tetris.components.piece'
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls_35bag'
local ScoreDrainGame = GameMode:extend()
ScoreDrainGame.name = "Score Drain"
ScoreDrainGame.hash = "ScoreDrain"
ScoreDrainGame.tagline = "Your score goes down over time! Avoid hitting 0 points, or your game is over!"
function ScoreDrainGame:new()
self.super:new()
self.score = 3000
self.drain_rate = 50
self.combo = 1
self.randomizer = History6RollsRandomizer()
self.lock_drop = true
self.lock_hard_drop = true
self.enable_hold = true
self.next_queue_length = 3
end
function ScoreDrainGame:getARE()
if self.level < 700 then return 27
elseif self.level < 800 then return 18
elseif self.level < 1000 then return 14
elseif self.level < 1100 then return 8
elseif self.level < 1200 then return 7
else return 6 end
end
function ScoreDrainGame:getLineARE()
if self.level < 600 then return 27
elseif self.level < 700 then return 18
elseif self.level < 800 then return 14
elseif self.level < 1100 then return 8
elseif self.level < 1200 then return 7
else return 6 end
end
function ScoreDrainGame:getDasLimit()
if self.level < 500 then return 15
elseif self.level < 900 then return 9
else return 7 end
end
function ScoreDrainGame:getLineClearDelay()
if self.level < 500 then return 40
elseif self.level < 600 then return 25
elseif self.level < 700 then return 16
elseif self.level < 800 then return 12
elseif self.level < 1100 then return 6
elseif self.level < 1200 then return 5
else return 4 end
end
function ScoreDrainGame:getLockDelay()
if self.level < 900 then return 30
elseif self.level < 1100 then return 17
else return 15 end
end
function ScoreDrainGame:getGravity()
if (self.level < 30) then return 4/256
elseif (self.level < 35) then return 6/256
elseif (self.level < 40) then return 8/256
elseif (self.level < 50) then return 10/256
elseif (self.level < 60) then return 12/256
elseif (self.level < 70) then return 16/256
elseif (self.level < 80) then return 32/256
elseif (self.level < 90) then return 48/256
elseif (self.level < 100) then return 64/256
elseif (self.level < 120) then return 80/256
elseif (self.level < 140) then return 96/256
elseif (self.level < 160) then return 112/256
elseif (self.level < 170) then return 128/256
elseif (self.level < 200) then return 144/256
elseif (self.level < 220) then return 4/256
elseif (self.level < 230) then return 32/256
elseif (self.level < 233) then return 64/256
elseif (self.level < 236) then return 96/256
elseif (self.level < 239) then return 128/256
elseif (self.level < 243) then return 160/256
elseif (self.level < 247) then return 192/256
elseif (self.level < 251) then return 224/256
elseif (self.level < 300) then return 1
elseif (self.level < 330) then return 2
elseif (self.level < 360) then return 3
elseif (self.level < 400) then return 4
elseif (self.level < 420) then return 5
elseif (self.level < 450) then return 4
elseif (self.level < 500) then return 3
else return 20
end
end
function ScoreDrainGame:advanceOneFrame()
if self.ready_frames == 0 then
self.frames = self.frames + 1
self.score = math.max(0, self.score - self.drain_rate / 60)
self.game_over = self.score <= 0 and true or false
end
return true
end
function ScoreDrainGame:onPieceEnter()
if (self.level % 100 ~= 99) and self.frames ~= 0 then
self.level = self.level + 1
end
end
local cleared_row_levels = {1, 2, 4, 6}
function ScoreDrainGame:onLineClear(cleared_row_count)
local new_level = self.level + cleared_row_levels[cleared_row_count]
self.drain_rate = math.floor(self.level / 100) < math.floor(new_level / 100) and self.drain_rate * 1.5 or self.drain_rate
self.level = new_level
end
function ScoreDrainGame:updateScore(level, drop_bonus, cleared_lines)
if cleared_lines > 0 then
self.combo = self.combo + (cleared_lines - 1) * 2
self.score = self.score + (
(math.ceil((level + cleared_lines) / 4) + drop_bonus) *
cleared_lines * self.combo
)
else
self.combo = 1
end
self.drop_bonus = 0
end
function ScoreDrainGame:drawGrid()
self.grid:draw()
if self.piece ~= nil and self.level < 100 then
self:drawGhostPiece(ruleset)
end
end
function ScoreDrainGame:drawScoringInfo()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setFont(font_3x5_2)
love.graphics.print(
self.das.direction .. " " ..
self.das.frames .. " " ..
strTrueValues(self.prev_inputs)
)
love.graphics.printf("NEXT", 64, 40, 40, "left")
love.graphics.printf("DRAIN RATE", 240, 90, 80, "left")
love.graphics.printf("SCORE", 240, 170, 40, "left")
love.graphics.printf("TIME LEFT", 240, 250, 80, "left")
love.graphics.printf("LEVEL", 240, 320, 40, "left")
love.graphics.setFont(font_3x5_3)
love.graphics.printf(math.floor(self.drain_rate).."/s", 240, 110, 120, "left")
local frames_left = self.score / self.drain_rate * 60
if frames_left <= 600 and frames_left % 4 < 2 and not self.game_over then love.graphics.setColor(1, 0.3, 0.3, 1) end
love.graphics.printf(formatTime(frames_left), 240, 270, 120, "left")
love.graphics.setColor(1, 1, 1, 1)
love.graphics.printf(math.floor(self.score), 240, 190, 90, "left")
love.graphics.printf(self.level, 240, 340, 50, "right")
love.graphics.printf(self:getSectionEndLevel(), 240, 370, 50, "right")
love.graphics.setFont(font_8x11)
love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center")
end
function ScoreDrainGame:getHighscoreData()
return {
level = self.level,
frames = self.frames,
}
end
function ScoreDrainGame:getSectionEndLevel()
return math.floor(self.level / 100 + 1) * 100
end
function ScoreDrainGame:getBackground()
return math.floor(self.level / 100)
end
return ScoreDrainGame

View File

@ -59,8 +59,8 @@ end
function Snake:generateGem() function Snake:generateGem()
repeat repeat
self.gem.x = math.random(1, 25) self.gem.x = love.math.random(1, 25)
self.gem.y = math.random(5, 24) self.gem.y = love.math.random(5, 24)
until not self:isInSnake({x=self.gem.x, y=self.gem.y}) until not self:isInSnake({x=self.gem.x, y=self.gem.y})
end end

View File

@ -55,8 +55,8 @@ function StackerGame:advanceOneFrame(inputs, ruleset)
self.are = self.are - 1 self.are = self.are - 1
return false return false
elseif self.are == 0 then elseif self.are == 0 then
self.position = math.random(1, 7 + self.block_width - 1) self.position = love.math.random(1, 7 + self.block_width - 1)
self.direction = ({-1, 1})[math.random(2)] self.direction = ({-1, 1})[love.math.random(2)]
self.are = -1 self.are = -1
end end
if not self.prev_inputs.up and inputs.up then if not self.prev_inputs.up and inputs.up then

View File

@ -10,7 +10,7 @@ function Bag5Randomizer:generatePiece()
if next(self.bag) == nil then if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "T"} self.bag = {"I", "J", "L", "O", "T"}
end end
local x = math.random(table.getn(self.bag)) local x = love.math.random(table.getn(self.bag))
return table.remove(self.bag, x) return table.remove(self.bag, x)
end end

View File

@ -11,10 +11,10 @@ function Bag5AltRandomizer:generatePiece()
if next(self.bag) == nil then if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "T"} self.bag = {"I", "J", "L", "O", "T"}
end end
local x = math.random(table.getn(self.bag)) local x = love.math.random(table.getn(self.bag))
local temp = table.remove(self.bag, x) local temp = table.remove(self.bag, x)
if temp == self.prev then if temp == self.prev then
local y = math.random(table.getn(self.bag)) local y = love.math.random(table.getn(self.bag))
temp = table.remove(self.bag, y) temp = table.remove(self.bag, y)
end end
self.prev = temp self.prev = temp

View File

@ -18,7 +18,7 @@ function Bag63Randomiser:generatePiece()
"O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O",
} }
end end
return table.remove(self.bag, math.random(#self.bag)) return table.remove(self.bag, love.math.random(#self.bag))
end end
return Bag63Randomiser return Bag63Randomiser

View File

@ -5,7 +5,7 @@ local Bag7Randomizer = Randomizer:extend()
function Bag7Randomizer:initialize() function Bag7Randomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"} self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self.extra = {"I", "J", "L", "O", "S", "T", "Z"} self.extra = {"I", "J", "L", "O", "S", "T", "Z"}
table.insert(self.bag, table.remove(self.extra, math.random(table.getn(self.extra)))) table.insert(self.bag, table.remove(self.extra, love.math.random(table.getn(self.extra))))
end end
function Bag7Randomizer:generatePiece() function Bag7Randomizer:generatePiece()
@ -14,9 +14,9 @@ function Bag7Randomizer:generatePiece()
end end
if next(self.bag) == nil then if next(self.bag) == nil then
self.bag = {"I", "J", "L", "O", "S", "T", "Z"} self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
table.insert(self.bag, table.remove(self.extra, math.random(table.getn(self.extra)))) table.insert(self.bag, table.remove(self.extra, love.math.random(table.getn(self.extra))))
end end
local x = math.random(table.getn(self.bag)) local x = love.math.random(table.getn(self.bag))
--print("Bag: "..table.concat(self.bag, ", ").." | Extra: "..table.concat(self.extra, ", ")) --print("Bag: "..table.concat(self.bag, ", ").." | Extra: "..table.concat(self.extra, ", "))
return table.remove(self.bag, x) return table.remove(self.bag, x)
end end

View File

@ -14,10 +14,10 @@ function BagKonoha:generatePiece()
if #self.bag == 0 then if #self.bag == 0 then
self.bag = {"I", "J", "L", "O", "T"} self.bag = {"I", "J", "L", "O", "T"}
end end
local x = math.random(#self.bag) local x = love.math.random(#self.bag)
local temp = table.remove(self.bag, x) local temp = table.remove(self.bag, x)
if temp == self.prev and not self.allowrepeat then if temp == self.prev and not self.allowrepeat then
local y = math.random(#self.bag) local y = love.math.random(#self.bag)
table.insert(self.bag, temp) -- should insert at the end of the bag, bag[y] doesnt change table.insert(self.bag, temp) -- should insert at the end of the bag, bag[y] doesnt change
temp = table.remove(self.bag, y) temp = table.remove(self.bag, y)
end end

View File

@ -58,7 +58,7 @@ function DTETRandomizer:generatePiece()
end end
-- pull piece from 21-bag and update drought counters -- pull piece from 21-bag and update drought counters
local generated = bag[math.random(#bag)] local generated = bag[love.math.random(#bag)]
self:updateDroughts(generated) self:updateDroughts(generated)
return generated return generated
end end

View File

@ -9,7 +9,7 @@ end
function EXRandomizer:generatePiece() function EXRandomizer:generatePiece()
local shapes = {"I", "J", "L", "O", "S", "T", "Z"} local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
for i = 1, 6 do for i = 1, 6 do
local x = math.random(7) local x = love.math.random(7)
if not inHistory(shapes[x], self.history) or i == 6 then if not inHistory(shapes[x], self.history) or i == 6 then
return self:updateHistory(shapes[x]) return self:updateHistory(shapes[x])
end end

View File

@ -14,7 +14,7 @@ end
function HistoryRandomizer:generatePiece() function HistoryRandomizer:generatePiece()
for i = 1, self.rolls do for i = 1, self.rolls do
local x = math.random(table.getn(self.allowed_pieces)) local x = love.math.random(table.getn(self.allowed_pieces))
if not inHistory(self.allowed_pieces[x], self.history) or i == self.rolls then if not inHistory(self.allowed_pieces[x], self.history) or i == self.rolls then
return self:updateHistory(self.allowed_pieces[x]) return self:updateHistory(self.allowed_pieces[x])
end end

View File

@ -12,19 +12,19 @@ function MasterOfBags:initialize()
end end
function MasterOfBags:generatePiece() function MasterOfBags:generatePiece()
local piece=math.random(({[true]=#self.bag,[false]=#self.bag+1})[#self.bag>14]) local piece=love.math.random(({[true]=#self.bag,[false]=#self.bag+1})[#self.bag>14])
if piece>#self.bag then if piece>#self.bag then
self.bag={} self.bag={}
for x=1,28 do for x=1,28 do
self.bag[x]=({"I", "J", "L", "O", "S", "T", "Z"})[(x-1)%7+1] self.bag[x]=({"I", "J", "L", "O", "S", "T", "Z"})[(x-1)%7+1]
end end
piece=math.random(#self.bag) piece=love.math.random(#self.bag)
end end
for i = 1, 6 do for i = 1, 6 do
if not inHistory(self.bag[piece], self.history) then if not inHistory(self.bag[piece], self.history) then
break break
end end
piece=math.random(#self.bag) piece=love.math.random(#self.bag)
end end
self:updateHistory(self.bag[piece]) self:updateHistory(self.bag[piece])

View File

@ -35,7 +35,7 @@ function MirrorRandomizer:generatePiece()
generated = table.remove(self.piece_stack) generated = table.remove(self.piece_stack)
else else
repeat repeat
generated = self.shapes[math.random(7)] generated = self.shapes[love.math.random(7)]
until not inHistory(generated, self.history) until not inHistory(generated, self.history)
table.remove(self.history, 1) table.remove(self.history, 1)
table.insert(self.history, generated) table.insert(self.history, generated)

View File

@ -8,9 +8,9 @@ function NES:initialize()
end end
function NES:generatePiece() function NES:generatePiece()
local x = math.random(8) local x = love.math.random(8)
if x == 8 or x == self.history then if x == 8 or x == self.history then
x = math.random(7) x = love.math.random(7)
end end
self.history = x self.history = x
return self.shapes[x] return self.shapes[x]

View File

@ -10,7 +10,7 @@ function RecursiveRandomizer:generatePiece()
--if next(self.bag) == nil then --if next(self.bag) == nil then
-- self.bag = {"I", "J", "L", "O", "S", "T", "Z"} -- self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
--end --end
local x = math.random(table.getn(self.bag) + 1) local x = love.math.random(table.getn(self.bag) + 1)
while x == table.getn(self.bag) + 1 do while x == table.getn(self.bag) + 1 do
--print("Refill piece pulled") --print("Refill piece pulled")
table.insert(self.bag, "I") table.insert(self.bag, "I")
@ -20,7 +20,7 @@ function RecursiveRandomizer:generatePiece()
table.insert(self.bag, "S") table.insert(self.bag, "S")
table.insert(self.bag, "T") table.insert(self.bag, "T")
table.insert(self.bag, "Z") table.insert(self.bag, "Z")
x = math.random(table.getn(self.bag) + 1) x = love.math.random(table.getn(self.bag) + 1)
end end
--print("Number of pieces in bag: "..table.getn(self.bag)) --print("Number of pieces in bag: "..table.getn(self.bag))
--print("Bag: "..table.concat(self.bag, ", ")) --print("Bag: "..table.concat(self.bag, ", "))

View File

@ -6,7 +6,7 @@ function SegaRandomizer:initialize()
self.bag = {"I", "J", "L", "O", "S", "T", "Z"} self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
self.sequence = {} self.sequence = {}
for i = 1, 1000 do for i = 1, 1000 do
self.sequence[i] = self.bag[math.random(table.getn(self.bag))] self.sequence[i] = self.bag[love.math.random(table.getn(self.bag))]
end end
self.counter = 0 self.counter = 0
end end

View File

@ -10,11 +10,11 @@ end
function SplitHistoryRandomizer:generatePiece() function SplitHistoryRandomizer:generatePiece()
if self.piece_count < 2 then if self.piece_count < 2 then
self.piece_count = self.piece_count + 1 self.piece_count = self.piece_count + 1
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)]) return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
else else
local shapes = {"I", "J", "L", "O", "S", "T", "Z"} local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
for i = 1, 4 do for i = 1, 4 do
local x = math.random(7) local x = love.math.random(7)
if not inHistory(shapes[x], self.history) or i == 4 then if not inHistory(shapes[x], self.history) or i == 4 then
return self:updateHistory(shapes[x]) return self:updateHistory(shapes[x])
end end

View File

@ -28,7 +28,7 @@ end
function TetraXRandomizer:generatePiece() function TetraXRandomizer:generatePiece()
local generated = nil local generated = nil
while true do while true do
generated = self.pieceselection[math.random(#self.pieceselection)] generated = self.pieceselection[love.math.random(#self.pieceselection)]
if not (self.lastseen[generated] == 0 or self.lastseen[generated] == 1) then if not (self.lastseen[generated] == 0 or self.lastseen[generated] == 1) then
break break
end end

View File

@ -8,13 +8,13 @@ CRAP.hash = "Completely Random Auto-Positioner"
CRAP.world = true CRAP.world = true
CRAP.colors={"C","O","M","R","G","Y","B"} CRAP.colors={"C","O","M","R","G","Y","B"}
CRAP.colourscheme = { CRAP.colourscheme = {
I = CRAP.colors[math.ceil(math.random(7))], I = CRAP.colors[math.ceil(love.math.random(7))],
L = CRAP.colors[math.ceil(math.random(7))], L = CRAP.colors[math.ceil(love.math.random(7))],
J = CRAP.colors[math.ceil(math.random(7))], J = CRAP.colors[math.ceil(love.math.random(7))],
S = CRAP.colors[math.ceil(math.random(7))], S = CRAP.colors[math.ceil(love.math.random(7))],
Z = CRAP.colors[math.ceil(math.random(7))], Z = CRAP.colors[math.ceil(love.math.random(7))],
O = CRAP.colors[math.ceil(math.random(7))], O = CRAP.colors[math.ceil(love.math.random(7))],
T = CRAP.colors[math.ceil(math.random(7))], T = CRAP.colors[math.ceil(love.math.random(7))],
} }
CRAP.softdrop_lock = true CRAP.softdrop_lock = true
CRAP.harddrop_lock = false CRAP.harddrop_lock = false
@ -111,8 +111,8 @@ end
function CRAP:attemptWallkicks(piece, new_piece, rot_dir, grid) function CRAP:attemptWallkicks(piece, new_piece, rot_dir, grid)
for i=1,20 do for i=1,20 do
dx=math.floor(math.random(11))-5 dx=math.floor(love.math.random(11))-5
dy=math.floor(math.random(11))-5 dy=math.floor(love.math.random(11))-5
if grid:canPlacePiece(new_piece:withOffset({x=dx, y=dy})) then if grid:canPlacePiece(new_piece:withOffset({x=dx, y=dy})) then
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
piece:setRelativeRotation(rot_dir):setOffset({x=dx, y=dy}) piece:setRelativeRotation(rot_dir):setOffset({x=dx, y=dy})
@ -147,13 +147,13 @@ function CRAP:get180RotationValue() return 2 end
function CRAP:randomizeColours() function CRAP:randomizeColours()
CRAP.colourscheme = { CRAP.colourscheme = {
I = CRAP.colors[math.ceil(math.random(7))], I = CRAP.colors[math.ceil(love.math.random(7))],
L = CRAP.colors[math.ceil(math.random(7))], L = CRAP.colors[math.ceil(love.math.random(7))],
J = CRAP.colors[math.ceil(math.random(7))], J = CRAP.colors[math.ceil(love.math.random(7))],
S = CRAP.colors[math.ceil(math.random(7))], S = CRAP.colors[math.ceil(love.math.random(7))],
Z = CRAP.colors[math.ceil(math.random(7))], Z = CRAP.colors[math.ceil(love.math.random(7))],
O = CRAP.colors[math.ceil(math.random(7))], O = CRAP.colors[math.ceil(love.math.random(7))],
T = CRAP.colors[math.ceil(math.random(7))], T = CRAP.colors[math.ceil(love.math.random(7))],
} }
end end

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local Cultris = SRS:extend() local Cultris = SRS:extend()

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local EARS = SRS:extend() local EARS = SRS:extend()

View File

@ -31,7 +31,7 @@ function H:attemptRotate(new_inputs, piece, grid, initial)
end end
function H:getDefaultOrientation() function H:getDefaultOrientation()
return math.random(4) return love.math.random(4)
end end
return H return H

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.ti_srs' local SRS = require 'tetris.rulesets.standard_ti'
local KRS = SRS:extend() local KRS = SRS:extend()

View File

@ -23,8 +23,8 @@ function RandomPieces:generateBlockOffsets()
local generated_offset = {} local generated_offset = {}
repeat repeat
generated_offset = { generated_offset = {
x = math.random(-1, 1), x = love.math.random(-1, 1),
y = math.random(-2, 0) y = love.math.random(-2, 0)
} }
until not containsPoint(offsets, generated_offset) until not containsPoint(offsets, generated_offset)
offsets[i] = generated_offset offsets[i] = generated_offset

View File

@ -89,7 +89,7 @@ function Shirase:onPieceMove(piece) piece.lock_delay = 0 end
function Shirase:onPieceRotate(piece) piece.lock_delay = 0 end function Shirase:onPieceRotate(piece) piece.lock_delay = 0 end
function Shirase:getDefaultOrientation() function Shirase:getDefaultOrientation()
return math.random(4) return love.math.random(4)
end end
return Shirase return Shirase

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local Tetra = SRS:extend() local Tetra = SRS:extend()

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.ti_srs' local SRS = require 'tetris.rulesets.standard_ti'
local TexyWorld = SRS:extend() local TexyWorld = SRS:extend()

View File

@ -1,4 +1,4 @@
local SRS = require 'tetris.rulesets.arika_srs' local SRS = require 'tetris.rulesets.standard_ace'
local TOD = SRS:extend() local TOD = SRS:extend()

View File

@ -35,7 +35,7 @@ end
function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid) function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid)
local pieces = {"I", "J", "L", "O", "S", "T", "Z"} local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
repeat repeat
new_piece.shape = pieces[math.random(7)] new_piece.shape = pieces[love.math.random(7)]
until piece.shape ~= new_piece.shape until piece.shape ~= new_piece.shape
local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}} local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}}