From 6a00730d3a954ebc39329a53cfe3beb0016f5949 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 1 Aug 2022 20:25:45 +0000 Subject: [PATCH] habit puzzle logging to catch matching/depth bug --- .../source/HabitState.kiss | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index 12318fd8..a348535f 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -5,6 +5,8 @@ (prop &mut :FlxCamera uiCamera) (method &override :Void create [] + (add logTexts) + (set Prelude.printStr log) (set pieceCamera FlxG.camera) (set uiCamera (new FlxCamera)) (set uiCamera.bgColor FlxColor.TRANSPARENT) @@ -91,6 +93,7 @@ (prop &mut :FlxSave save null) (prop &mut :FlxTypedGroup entryTexts null) +(prop &mut :FlxTypedGroup logTexts (new FlxTypedGroup)) (prop &mut :FlxKeyShortcutHandler shortcutHandler null) (prop &mut :HabitModel model null) @@ -220,11 +223,11 @@ ->:Void [s x y] { (set draggingSprite null) - (checkMatches i) (dictSet (the Map save.data.storedPositions) i (new FlxPoint s.x s.y)) (doFor connected (recursivelyConnectedPieces s) (checkMatches (dictGet indexMap connected)) + (log "uh $(dictGet indexMap connected)") (dictSet (the Map save.data.storedPositions) (dictGet indexMap connected) (new FlxPoint connected.x connected.y))) (pieceCamera.calculateScrollBounds rewardSprites SCROLL_BOUND_MARGIN) @@ -334,6 +337,20 @@ (+= textY text.height) (entryTexts.add text))) +(method log [message] + (prop &mut logTextY 0) + (#when debug + (when (> logTextY FlxG.height) + (logTexts.clear) + (set logTextY 0)) + (let [text (new FlxText FlxG.width logTextY 0 message textSize)] + (set text.color color) + (set text.cameras [uiCamera]) + (+= logTextY text.height) + (-= text.x text.width) + (logTexts.add text)))) + +// TODO properly tune the match zones to bubbles (method :FlxRect matchZoneLeft [:FlxExtendedSprite s] (new FlxRect s.x (+ s.y s.origin.y) EDGE_LEEWAY EDGE_LEEWAY)) (method :FlxRect matchZoneRight [:FlxExtendedSprite s] @@ -345,8 +362,8 @@ (prop &mut c 0) (method :Void connectPiece [id self toSprite] - (let [thisConnectedPieces (dictGet connectedPieces id) - toConnectedPieces (dictGet connectedPieces (dictGet indexMap toSprite))] + (let [thisConnectedPieces (dictGet connectedPieces ~id) + toConnectedPieces (dictGet connectedPieces ~(dictGet indexMap toSprite))] (+= c 1) // Don't add duplicates (thisConnectedPieces.remove toSprite) @@ -378,13 +395,13 @@ (unless .isEmpty (mzl.intersection mzr) (connectPiece id s toRight))) (whenLet [toUp (dictGet matchingPiecesUp id) - mzu (matchZoneUp s) - mzd (matchZoneDown toUp)] + mzu ~(matchZoneUp s) + mzd ~(matchZoneDown toUp)] (unless .isEmpty (mzu.intersection mzd) (connectPiece id s toUp))) (whenLet [toDown (dictGet matchingPiecesDown id) - mzd (matchZoneDown s) - mzu (matchZoneUp toDown)] + mzd ~(matchZoneDown s) + mzu ~(matchZoneUp toDown)] (unless .isEmpty (mzu.intersection mzd) (connectPiece id s toDown)))))