Created
February 17, 2015 20:33
-
-
Save ericcgu/c96c93795b94645c4b6a to your computer and use it in GitHub Desktop.
Win Condition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func checkWinCondition (column: Int, row: Int){ | |
| let alert = UIAlertView() | |
| alert.title = "Four In a Row! Game Over!" | |
| alert.addButtonWithTitle("OK") | |
| for row in 0..<gameBoard.rows { | |
| for column in 0..<gameBoard.columns { | |
| //horizontal | |
| if(isLinearMatch(column: column, row: row, stepX: 1, stepY: 0)){ | |
| isFinished = true | |
| alert.show() | |
| } | |
| //vertical | |
| if(isLinearMatch(column: column, row: row, stepX: 0, stepY: 1)){ | |
| isFinished = true | |
| alert.show() | |
| } | |
| //diagonal | |
| if(isLinearMatch(column: column, row: row, stepX: 1, stepY: 1)){ | |
| isFinished = true | |
| alert.show() | |
| } | |
| //second diagonal | |
| if(isLinearMatch(column: column, row: row, stepX: 1, stepY: -1)){ | |
| isFinished = true | |
| alert.show() | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment