Add RewardFile to HabitModel
This commit is contained in:
@@ -22,5 +22,10 @@ typedef Entry = {
|
|||||||
doneToday: Bool
|
doneToday: Bool
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef RewardFile = {
|
||||||
|
path: String,
|
||||||
|
startingPoints: Int
|
||||||
|
};
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@:build(kiss.Kiss.build())
|
||||||
class HabitModel {}
|
class HabitModel {}
|
@@ -1,6 +1,7 @@
|
|||||||
(prop :Array<Entry> dailyEntries [])
|
(prop :Array<Entry> dailyEntries [])
|
||||||
(prop :Array<Entry> bonusEntries [])
|
(prop :Array<Entry> bonusEntries [])
|
||||||
(prop :Array<Entry> todoEntries [])
|
(prop :Array<Entry> todoEntries [])
|
||||||
|
(prop :Array<RewardFile> rewardFiles [])
|
||||||
|
|
||||||
(defNew [&prop :String textFile]
|
(defNew [&prop :String textFile]
|
||||||
(let [s (Stream.fromFile textFile)
|
(let [s (Stream.fromFile textFile)
|
||||||
@@ -14,9 +15,18 @@
|
|||||||
(set lastHeader "BONUS"))
|
(set lastHeader "BONUS"))
|
||||||
((Some "TODO")
|
((Some "TODO")
|
||||||
(set lastHeader "TODO"))
|
(set lastHeader "TODO"))
|
||||||
|
((Some "FILES")
|
||||||
|
(set lastHeader "FILES"))
|
||||||
((when (apply = (concat ["-"] (line.split ""))) (Some line))
|
((when (apply = (concat ["-"] (line.split ""))) (Some line))
|
||||||
(continue))
|
(continue))
|
||||||
((Some "") (continue))
|
((Some "") (continue))
|
||||||
|
// Types won't unify with the next case, so this is its own:
|
||||||
|
((when (= lastHeader "FILES") (Some line))
|
||||||
|
(rewardFiles.push
|
||||||
|
(let [parts (line.split " ")
|
||||||
|
startingPoints (Std.parseInt (parts.pop))
|
||||||
|
path (parts.join " ")]
|
||||||
|
(objectWith path startingPoints))))
|
||||||
((Some line)
|
((Some line)
|
||||||
(.push
|
(.push
|
||||||
(case lastHeader
|
(case lastHeader
|
||||||
@@ -72,6 +82,9 @@
|
|||||||
"")$(.join (for label e.labels
|
"")$(.join (for label e.labels
|
||||||
"${label.label} $(* "|" label.points)") "/")")
|
"${label.label} $(* "|" label.points)") "/")")
|
||||||
|
|
||||||
|
(function :String stringifyRewardFile [:RewardFile rewardFile]
|
||||||
|
"${rewardFile.path} ${rewardFile.startingPoints}")
|
||||||
|
|
||||||
(method :Void save []
|
(method :Void save []
|
||||||
(localVar &mut content "DAILY\n-----\n")
|
(localVar &mut content "DAILY\n-----\n")
|
||||||
(+= content (.join (map dailyEntries stringify) "\n") "\n")
|
(+= content (.join (map dailyEntries stringify) "\n") "\n")
|
||||||
@@ -79,6 +92,8 @@
|
|||||||
(+= content (.join (map bonusEntries stringify) "\n") "\n")
|
(+= content (.join (map bonusEntries stringify) "\n") "\n")
|
||||||
(+= content "\nTODO\n----\n")
|
(+= content "\nTODO\n----\n")
|
||||||
(+= content (.join (map todoEntries stringify) "\n") "\n")
|
(+= content (.join (map todoEntries stringify) "\n") "\n")
|
||||||
|
(+= content "\nFILES\n-----\n")
|
||||||
|
(+= content (.join (map rewardFiles stringifyRewardFile) "\n") "\n")
|
||||||
(File.saveContent textFile
|
(File.saveContent textFile
|
||||||
content))
|
content))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user