Compare commits
1 Commits
601e52d21e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
922aec35c1
|
@@ -19,6 +19,7 @@ local function insertInReadme()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local totalStars = 0
|
local totalStars = 0
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
for _, s in pairs(stats) do
|
for _, s in pairs(stats) do
|
||||||
if s.puzzle1 then totalStars = totalStars + 1 end
|
if s.puzzle1 then totalStars = totalStars + 1 end
|
||||||
if s.puzzle2 then totalStars = totalStars + 1 end
|
if s.puzzle2 then totalStars = totalStars + 1 end
|
||||||
|
|||||||
@@ -11,24 +11,14 @@ END_DATE = {day=12, month=12, year=2025}
|
|||||||
local json = require("json")
|
local json = require("json")
|
||||||
local dates = require("dates")
|
local dates = require("dates")
|
||||||
local days = require("days")
|
local days = require("days")
|
||||||
|
local utils = require("utils")
|
||||||
local progress = require "progress"
|
local progress = require "progress"
|
||||||
local today = os.date("*t")
|
local today = os.date("*t")
|
||||||
local aoc = {}
|
local aoc = {}
|
||||||
|
|
||||||
function aoc.loadStats(path)
|
function aoc.loadStats()
|
||||||
path = shell.resolve(path)
|
local data = utils.readFile(RES_PATH .. "/stats.json") or "{}"
|
||||||
if not fs.exists(path) then
|
return json.loads(data)
|
||||||
printError("Stats file not found (" .. path .. ")")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local file, err = fs.open(path, "r")
|
|
||||||
if not file then
|
|
||||||
printError("Cannot open stats file")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local data = json.loads(file.readAll())
|
|
||||||
file.close()
|
|
||||||
return data
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function aoc.printDateInfo()
|
function aoc.printDateInfo()
|
||||||
@@ -111,7 +101,7 @@ function aoc.printBanner()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function aoc.main()
|
function aoc.main()
|
||||||
local stats = aoc.loadStats("aoc/res/stats.json") or {}
|
local stats = aoc.loadStats() or {}
|
||||||
local selectedDay = math.max(1, math.min(END_DATE.day, today.day))
|
local selectedDay = math.max(1, math.min(END_DATE.day, today.day))
|
||||||
if not dates.isInDateRange(START_DATE, today, END_DATE) then
|
if not dates.isInDateRange(START_DATE, today, END_DATE) then
|
||||||
selectedDay = 1
|
selectedDay = 1
|
||||||
@@ -139,7 +129,7 @@ function aoc.main()
|
|||||||
dayStats.puzzle2
|
dayStats.puzzle2
|
||||||
)
|
)
|
||||||
day:show()
|
day:show()
|
||||||
stats = aoc.loadStats("aoc/res/stats.json") or {}
|
stats = aoc.loadStats() or {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ function Day:getTitle()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
fs.makeDir(self:cacheDir())
|
fs.makeDir(self:cacheDir())
|
||||||
local res = http.get("https://adventofcode.com/2024/day/" .. self.day)
|
local res = http.get("https://adventofcode.com/2025/day/" .. self.day)
|
||||||
local title = "Day " .. self.day
|
local title = "Day " .. self.day
|
||||||
if res then
|
if res then
|
||||||
local body = res.readAll() or ""
|
local body = res.readAll() or ""
|
||||||
|
|||||||
Reference in New Issue
Block a user