refactored to love.math.random

This commit is contained in:
Sławomir Śpiewak 2021-09-15 12:45:55 +02:00
parent 784c768c57
commit db4f8b52e7
9 changed files with 12 additions and 12 deletions

View File

@ -1,5 +1,5 @@
function love.load()
math.randomseed(os.time())
--math.randomseed(os.time())
highscores = {}
require "load.rpc"
require "load.graphics"

View File

@ -34,7 +34,7 @@ function TitleScene:new()
self.text_flag = false
DiscordRPC:update({
details = "In menus",
state = mainmenuidle[math.random(#mainmenuidle)],
state = mainmenuidle[love.math.random(#mainmenuidle)],
})
end

View File

@ -17,7 +17,7 @@ function BagRandomizer:generatePiece()
table.insert(self.bag, i)
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)
end

View File

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

View File

@ -6,7 +6,7 @@ function Bag7NoSZOStartRandomizer:shuffleBag()
local b = self.bag
local ln = #b
for i = 1, ln do
local j = math.random(i, ln)
local j = love.math.random(i, ln)
b[i], b[j] = b[j], b[i]
end
end

View File

@ -10,11 +10,11 @@ end
function History4RollsRandomizer:generatePiece()
if self.first then
self.first = false
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
else
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
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
return self:updateHistory(shapes[x])
end

View File

@ -10,11 +10,11 @@ end
function History6RollsRandomizer:generatePiece()
if self.first then
self.first = false
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
else
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
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
return self:updateHistory(shapes[x])
end

View File

@ -28,12 +28,12 @@ end
function History6Rolls35PoolRandomizer:generatePiece()
local index, x
if self.first then
index = math.random(20)
index = love.math.random(20)
x = self.pool[index]
self.first = false
else
for i = 1, 6 do
index = math.random(#self.pool)
index = love.math.random(#self.pool)
x = self.pool[index]
if not inHistory(x, self.history) or i == 6 then
break

View File

@ -18,7 +18,7 @@ end
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
function Randomizer:generatePiece()
return shapes[math.random(7)]
return shapes[love.math.random(7)]
end
return Randomizer