private bool AddMyMoveToOnlineBoard(string c) { /*add 1 to the matrix*/ if (c == "c1") { GameBoard[0, cols[c]] = 1; } if (c == "c2") { GameBoard[1, cols[c]] = 1; } if (c == "c3") { GameBoard[2, cols[c]] = 1; } if (c == "c4") { GameBoard[3, cols[c]] = 1; } if (c == "c5") { GameBoard[4, cols[c]] = 1; } if (c == "c6") { GameBoard[5, cols[c]] = 1; } /*check if the this player won */ /*if yes then call AddMyMoveToBoard IHaveFour=true and return true*/ try { int count = 0; //col for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { if (GameBoard[i, j] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; } //row count = 0; for (int i = 0; i < 7; i++) { for (int j = 0; j < 6; j++) { if (GameBoard[j, i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; } count = 0; for (int i = 0; i < 6; i++) { if (GameBoard[i, i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 0; i < 5; i++) { if (GameBoard[i + 1, i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 0; i < 4; i++) { if (GameBoard[i + 2, i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 0; i < 6; i++) { if (GameBoard[i, i + 1] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 0; i < 5; i++) { if (GameBoard[i, i + 2] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 0; i < 4; i++) { if (GameBoard[i, i + 3] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 3; i >= 0; i--) { if (GameBoard[i, 3 - i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 4; i >= 0; i--) { if (GameBoard[i, 4 - i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 5; i >= 0; i--) { if (GameBoard[i, 5 - i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 5; i >= 0; i--) { if (GameBoard[i, 6 - i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 5; i > 0; i--) { if (GameBoard[i, 7 - i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } count = 0; for (int i = 5; i > 1; i--) { if (GameBoard[i, 8 - i] == 1) { count++; } else { count = 0; } if (count == 4) { Client.AddMyMoveToBoard(Username, GameId, c, true); return(true); } } /*else call AddMyMoveToBoard IHaveFour=false and return false*/ Client.AddMyMoveToBoard(Username, GameId, c, false); } catch (FaultException <LiveGameFault> fault) { thr.Abort(); MessageBox.Show(fault.Detail.Details, Username); CloseGame = true; this.Close(); } catch (TimeoutException) { thr.Abort(); MessageBox.Show(" connection unstable , it took to long to get a response this game is canceled", Username + " connection unstable"); CloseGame = true; this.Close(); } catch (CommunicationObjectFaultedException) { thr.Abort(); MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable"); CloseGame = true; this.Close(); } catch (Exception ex) { thr.Abort(); MessageBox.Show(ex.ToString(), Username); CloseGame = true; this.Close(); } return(false); }