count and list available matches
This commit is contained in:
@@ -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])))))
|
Reference in New Issue
Block a user