count and list available matches

This commit is contained in:
2022-09-13 22:06:15 +00:00
parent b02cd2ee4e
commit 01425e8526

View File

@@ -836,4 +836,23 @@
(entryCreationWindow.hide)
(when entryWindow
(set entryWindow.keyboardEnabled true)
(entryWindow.show)))
(entryWindow.show)))
(defMacro withConnectedAndMatching [forOrDoFor &body body]
`(,forOrDoFor s rewardSprites.members
(let [id (dictGet indexMap s)
connectedPieces (dictGet connectedPieces id)
matchingPieces (filter (for map [matchingPiecesLeft matchingPiecesRight matchingPiecesUp matchingPiecesDown]
(dictGet map id)))]
,@body)))
(method countAvailableMatches []
(iHalf
(apply +
(withConnectedAndMatching for
(- matchingPieces.length connectedPieces.length)))))
(method :Array<Array<KissExtendedSprite>> listAvailableMatches []
(apply concat (the Array<Array<Array<KissExtendedSprite>>> (withConnectedAndMatching for
(for piece (filter matchingPieces ->p !(contains connectedPieces p))
[s piece])))))