Created
December 13, 2019 10:29
-
-
Save SidneyMachara/7f39e2ec0874d7df60e1734bb0f31f09 to your computer and use it in GitHub Desktop.
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
bool playerWon(List<int> playerMoves){ | |
bool won = false; | |
// first line horizontal | |
if(playerMoves.contains(0) && playerMoves.contains(1) && playerMoves.contains(2)){ | |
return won = true; | |
} | |
// second line horizontal | |
if(playerMoves.contains(3) && playerMoves.contains(4) && playerMoves.contains(5)){ | |
return won = true; | |
} | |
// third line horizontal | |
if(playerMoves.contains(6) && playerMoves.contains(7) && playerMoves.contains(8)){ | |
return won = true; | |
} | |
// first line vertical | |
if(playerMoves.contains(0) && playerMoves.contains(3) && playerMoves.contains(6)){ | |
return won = true; | |
} | |
// second line vertical | |
if(playerMoves.contains(1) && playerMoves.contains(4) && playerMoves.contains(7)){ | |
return won = true; | |
} | |
// third line vertical | |
if(playerMoves.contains(2) && playerMoves.contains(5) && playerMoves.contains(8)){ | |
return won = true; | |
} | |
// top 0 bottom 8 across | |
if(playerMoves.contains(0) && playerMoves.contains(4) && playerMoves.contains(8)){ | |
return won = true; | |
} | |
// top 2 bottom 6 across | |
if(playerMoves.contains(2) && playerMoves.contains(4) && playerMoves.contains(6)){ | |
return won = true; | |
} | |
return won; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment