mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-12-26 21:39:03 -06:00
Init
This commit is contained in:
parent
b22f671409
commit
9f570306f5
@ -63,6 +63,9 @@ function bigint.new(num)
|
||||
end,
|
||||
__le = function(lhs, rhs)
|
||||
return bigint.compare(lhs, rhs, "<=")
|
||||
end,
|
||||
__tostring = function()
|
||||
return bigint.unserialize(self, "s")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -139,8 +139,19 @@ function GameScene:onInputRelease(e)
|
||||
end
|
||||
|
||||
function submitHighscore(hash, data)
|
||||
function isHighscore(score, high)
|
||||
for k, _ in pairs(score) do
|
||||
if not high[k] or score[k] > high[k] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
if not highscores[hash] then highscores[hash] = {} end
|
||||
table.insert(highscores[hash], data)
|
||||
if isHighscore(data, highscores[hash]) then
|
||||
highscores[hash] = data
|
||||
end
|
||||
saveHighscores()
|
||||
end
|
||||
|
||||
|
@ -41,14 +41,14 @@ function ModeSelectScene:render()
|
||||
elseif self.menu_state.select == "ruleset" then
|
||||
love.graphics.setColor(1, 1, 1, 0.25)
|
||||
end
|
||||
love.graphics.rectangle("fill", 20, 258, 240, 22)
|
||||
love.graphics.rectangle("fill", 20, 198, 240, 22)
|
||||
|
||||
if self.menu_state.select == "mode" then
|
||||
love.graphics.setColor(1, 1, 1, 0.25)
|
||||
elseif self.menu_state.select == "ruleset" then
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
end
|
||||
love.graphics.rectangle("fill", 340, 258, 200, 22)
|
||||
love.graphics.rectangle("fill", 340, 198, 200, 22)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
|
||||
@ -56,13 +56,36 @@ function ModeSelectScene:render()
|
||||
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for idx, mode in pairs(game_modes) do
|
||||
if(idx >= self.menu_state.mode-9 and idx <= self.menu_state.mode+9) then
|
||||
love.graphics.printf(mode.name, 40, (260 - 20*(self.menu_state.mode)) + 20 * idx, 200, "left")
|
||||
if(idx >= self.menu_state.mode-6 and idx <= self.menu_state.mode+6) then
|
||||
love.graphics.printf(mode.name, 40, (200 - 20*(self.menu_state.mode)) + 20 * idx, 200, "left")
|
||||
end
|
||||
end
|
||||
for idx, ruleset in pairs(rulesets) do
|
||||
if(idx >= self.menu_state.ruleset-9 and idx <= self.menu_state.ruleset+9) then
|
||||
love.graphics.printf(ruleset.name, 360, (260 - 20*(self.menu_state.ruleset)) + 20 * idx, 160, "left")
|
||||
if(idx >= self.menu_state.ruleset-6 and idx <= self.menu_state.ruleset+6) then
|
||||
love.graphics.printf(ruleset.name, 360, (200 - 20*(self.menu_state.ruleset)) + 20 * idx, 160, "left")
|
||||
end
|
||||
end
|
||||
|
||||
-- mode description and highscore
|
||||
for midx, mode in pairs(game_modes) do
|
||||
for ridx, ruleset in pairs(rulesets) do
|
||||
if (midx == self.menu_state.mode) and (ridx == self.menu_state.ruleset) then
|
||||
love.graphics.printf(
|
||||
"Mode Description:\n\n" .. mode.tagline, 20, 350, 200, "left"
|
||||
)
|
||||
love.graphics.printf(
|
||||
ruleset.name .. " Highscore:", 240, 350, 200, "right"
|
||||
)
|
||||
local highscore_string = ""
|
||||
if highscores[mode.hash .. "-" .. ruleset.hash] then
|
||||
for k, v in ipairs(highscores[mode.hash .. "-" .. ruleset.hash]) do
|
||||
highscore_string = highscore_string .. k .. ": " .. v .. "\n"
|
||||
end
|
||||
else
|
||||
highscore_string = "You don't have any highscores yet!"
|
||||
end
|
||||
love.graphics.printf(highscore_string, 450, 350, 200, "left")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -66,24 +66,24 @@ function SurvivalA1Game:getGravity()
|
||||
end
|
||||
|
||||
local function getRankForScore(score)
|
||||
if score < 400 then return {rank = "9", next = 400}
|
||||
elseif score < 800 then return {rank = "8", next = 800}
|
||||
elseif score < 1400 then return {rank = "7", next = 1400}
|
||||
elseif score < 2000 then return {rank = "6", next = 2000}
|
||||
elseif score < 3500 then return {rank = "5", next = 3500}
|
||||
elseif score < 5500 then return {rank = "4", next = 5500}
|
||||
elseif score < 8000 then return {rank = "3", next = 8000}
|
||||
elseif score < 12000 then return {rank = "2", next = 12000}
|
||||
elseif score < 16000 then return {rank = "1", next = 16000}
|
||||
elseif score < 22000 then return {rank = "S1", next = 22000}
|
||||
elseif score < 30000 then return {rank = "S2", next = 30000}
|
||||
elseif score < 40000 then return {rank = "S3", next = 40000}
|
||||
elseif score < 52000 then return {rank = "S4", next = 52000}
|
||||
elseif score < 66000 then return {rank = "S5", next = 66000}
|
||||
elseif score < 82000 then return {rank = "S6", next = 82000}
|
||||
elseif score < 100000 then return {rank = "S7", next = 100000}
|
||||
elseif score < 120000 then return {rank = "S8", next = 120000}
|
||||
else return {rank = "S9", next = "???"}
|
||||
if score < 400 then return {rank = "9", next = 400, grade = 0}
|
||||
elseif score < 800 then return {rank = "8", next = 800, grade = 1}
|
||||
elseif score < 1400 then return {rank = "7", next = 1400, grade = 2}
|
||||
elseif score < 2000 then return {rank = "6", next = 2000, grade = 3}
|
||||
elseif score < 3500 then return {rank = "5", next = 3500, grade = 4}
|
||||
elseif score < 5500 then return {rank = "4", next = 5500, grade = 5}
|
||||
elseif score < 8000 then return {rank = "3", next = 8000, grade = 6}
|
||||
elseif score < 12000 then return {rank = "2", next = 12000, grade = 7}
|
||||
elseif score < 16000 then return {rank = "1", next = 16000, grade = 8}
|
||||
elseif score < 22000 then return {rank = "S1", next = 22000, grade = 9}
|
||||
elseif score < 30000 then return {rank = "S2", next = 30000, grade = 10}
|
||||
elseif score < 40000 then return {rank = "S3", next = 40000, grade = 11}
|
||||
elseif score < 52000 then return {rank = "S4", next = 52000, grade = 12}
|
||||
elseif score < 66000 then return {rank = "S5", next = 66000, grade = 13}
|
||||
elseif score < 82000 then return {rank = "S6", next = 82000, grade = 14}
|
||||
elseif score < 100000 then return {rank = "S7", next = 100000, grade = 15}
|
||||
elseif score < 120000 then return {rank = "S8", next = 120000, grade = 16}
|
||||
else return {rank = "S9", next = "???", grade = 17}
|
||||
end
|
||||
end
|
||||
|
||||
@ -208,10 +208,15 @@ end
|
||||
|
||||
function SurvivalA1Game:getHighscoreData()
|
||||
return {
|
||||
grade = self.grade,
|
||||
grade = (
|
||||
(self.gm_conditions["level300"] and
|
||||
self.gm_conditions["level500"] and
|
||||
self.gm_conditions["level999"]) and
|
||||
18 or getRankForScore(self.score).grade
|
||||
),
|
||||
frames = self.frames,
|
||||
score = self.score,
|
||||
level = self.level,
|
||||
frames = self.frames,
|
||||
}
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user