groundwork for puzzle pack detection & choosing next puzzle

This commit is contained in:
2022-08-04 04:04:13 +00:00
parent bb939bb3f0
commit 85c2fc615e
4 changed files with 33 additions and 3 deletions

View File

@@ -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<Int>, lastDayDone:String);
@@ -31,5 +32,18 @@ typedef RewardFile = {
startingPoints: Int
};
typedef Puzzle = {
path:Null<String>,
index:Int,
outOf:Int
}
typedef PuzzlePack = {
path:String,
nextPuzzle:Option<Puzzle>,
puzzlesDone:Int,
puzzlesTotal:Int
};
@:build(kiss.Kiss.build())
class HabitModel {}

View File

@@ -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))

View File

@@ -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;

View File

@@ -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)