From 85c2fc615e09563be95450b5c591c413b083f4aa Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 4 Aug 2022 04:04:13 +0000 Subject: [PATCH] groundwork for puzzle pack detection & choosing next puzzle --- .../source/HabitModel.hx | 14 ++++++++++++++ .../source/HabitModel.kiss | 4 ++++ .../source/HabitState.hx | 3 ++- .../source/HabitState.kiss | 15 +++++++++++++-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx index 810c7854..a52125bc 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx @@ -6,6 +6,7 @@ import kiss.Stream; import sys.io.File; import datetime.DateTime; import datetime.DateTimeInterval; +import haxe.ds.Option; enum EntryType { Daily(daysOfWeek:Array, lastDayDone:String); @@ -31,5 +32,18 @@ typedef RewardFile = { startingPoints: Int }; +typedef Puzzle = { + path:Null, + index:Int, + outOf:Int +} + +typedef PuzzlePack = { + path:String, + nextPuzzle:Option, + puzzlesDone:Int, + puzzlesTotal:Int +}; + @:build(kiss.Kiss.build()) class HabitModel {} diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss index 59881728..3b8154db 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.kiss @@ -215,4 +215,8 @@ ((Monthly _ _) monthlyEntries) (otherwise (throw ""))) (objectWith [labels (for label labels (objectWith [points 0] label))] type)) + (save)) + +(method addRewardFile [path startingPoints] + (rewardFiles.push (objectWith path startingPoints)) (save)) \ No newline at end of file diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx index dc4f94e7..92c88b3b 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx @@ -26,11 +26,12 @@ import kiss.Prelude; import kiss.List; import kiss_tools.FlxKeyShortcutHandler; import HabitModel; +import sys.FileSystem; import hx.strings.Strings; import datetime.DateTime; using kiss_flixel.CameraTools; using kiss_flixel.GroupTools; - +import haxe.ds.Option; import jigsawx.JigsawPiece; import jigsawx.Jigsawx; import jigsawx.math.Vec2; diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index b6469590..eef99c1b 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -4,6 +4,8 @@ (prop &mut :FlxCamera pieceCamera) (prop &mut :FlxCamera uiCamera) +(load "PuzzlePacks.kiss") + (method &override :Void create [] (#when debug (add cameraBounds)) @@ -154,8 +156,17 @@ (set rewardFileIndex i) (set currentRewardFile (nth m.rewardFiles i)) (set maxRewardFile i) - (if (>= ++i m.rewardFiles.length) - (break)))) + (when (>= ++i m.rewardFiles.length) + (let [lastStartingPoints .startingPoints (nth m.rewardFiles --i) + nextStartingPoints (+ lastStartingPoints TOTAL_PIECES)] + (if (> p nextStartingPoints) + { + // TODO give the player a puzzle pack choice using (availablePacks) + (m.addRewardFile .path (firstUnsolvedPuzzle m "puzzles/trentnelson") nextStartingPoints) + (setModel m) + (return) + } + (break)))))) (set save (new FlxSave)) (save.bind currentRewardFile.path)