From 174e0a30fdb6cd917227f3c8786ede2efdcfc5a2 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 4 Feb 2022 15:47:01 -0700 Subject: [PATCH] HabitModel.totalPoints() --- projects/habit-puzzle-game/source/HabitModel.kiss | 3 +++ projects/habit-puzzle-game/source/HabitState.kiss | 1 + 2 files changed, 4 insertions(+) diff --git a/projects/habit-puzzle-game/source/HabitModel.kiss b/projects/habit-puzzle-game/source/HabitModel.kiss index 9626f84e..2849e22d 100644 --- a/projects/habit-puzzle-game/source/HabitModel.kiss +++ b/projects/habit-puzzle-game/source/HabitModel.kiss @@ -67,6 +67,9 @@ points (count (l.split "") ->c (= c "|"))))))) (otherwise (break)))))) +(method :Int totalPoints [] + (apply + (for l (flatten (for e (the Array (concat dailyEntries bonusEntries todoEntries)) e.labels)) l.points))) + (function :String stringify [:Entry e] "$(ifLet [(when !(= days.length 7) (Daily days)) e.type] (+ (.join (for day days diff --git a/projects/habit-puzzle-game/source/HabitState.kiss b/projects/habit-puzzle-game/source/HabitState.kiss index d50fb1ae..05cbc50f 100644 --- a/projects/habit-puzzle-game/source/HabitState.kiss +++ b/projects/habit-puzzle-game/source/HabitState.kiss @@ -11,6 +11,7 @@ (prop &mut :HabitModel model null) (method setModel [m] (set model m) + ~(m.totalPoints) (set shortcutHandler (new KeyShortcutHandler)) (when entryTexts (remove entryTexts))