Refactor C4Board.hasWon() and fix variable scope leak error