Fix clearing rows
This commit is contained in:
		
							parent
							
								
									ec72607827
								
							
						
					
					
						commit
						82ca49321c
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -169,12 +169,12 @@ clearFullRows :: Game -> Game
 | 
				
			||||||
clearFullRows g = g & board %~ clearBoard
 | 
					clearFullRows g = g & board %~ clearBoard
 | 
				
			||||||
                    & rowClears %~ (|> rowCount)
 | 
					                    & rowClears %~ (|> rowCount)
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
    clearBoard           = M.mapKeys shiftCoordAbove . M.filterWithKey isInFullRow
 | 
					    clearBoard            = M.mapKeys shiftCoordAbove . M.filterWithKey notInFullRow
 | 
				
			||||||
    isInFullRow (_,y) _  = y `elem` fullRowIndices
 | 
					    notInFullRow (_,y) _  = y `notElem` fullRowIndices
 | 
				
			||||||
    rowCount             = length fullRowIndices
 | 
					    rowCount              = length fullRowIndices
 | 
				
			||||||
    fullRowIndices       = filter isFullRow [1..boardHeight]
 | 
					    fullRowIndices        = filter isFullRow [1..boardHeight]
 | 
				
			||||||
    isFullRow r          = boardWidth == (length . M.filterWithKey (inRow r) $ g ^. board)
 | 
					    isFullRow r           = boardWidth == (length . M.filterWithKey (inRow r) $ g ^. board)
 | 
				
			||||||
    inRow r (_, y) _     = r == y
 | 
					    inRow r (_, y) _      = r == y
 | 
				
			||||||
    shiftCoordAbove (x,y) =
 | 
					    shiftCoordAbove (x,y) =
 | 
				
			||||||
      let offset = length . filter (< y) $ fullRowIndices
 | 
					      let offset = length . filter (< y) $ fullRowIndices
 | 
				
			||||||
       in (x, y - offset)
 | 
					       in (x, y - offset)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue