mirror of
https://github.com/SashLilac/cambridge.git
synced 2025-04-19 10:22:55 -05:00
refactored to love.math.random
This commit is contained in:
parent
784c768c57
commit
db4f8b52e7
2
main.lua
2
main.lua
@ -1,5 +1,5 @@
|
||||
function love.load()
|
||||
math.randomseed(os.time())
|
||||
--math.randomseed(os.time())
|
||||
highscores = {}
|
||||
require "load.rpc"
|
||||
require "load.graphics"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user