// yosi public bool CanToMultiEat(Locat i_IndexesToPlay, out Locat o_IndexesThatLegal) //yossi end { bool foundGoodPlace = false; byte start = 0, end = (byte)(m_Size - 1); o_IndexesThatLegal = new Locat(); byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y; foundGoodPlace = CanToEatInRightDownInY(i_IndexesToPlay, out o_IndexesThatLegal); if (foundGoodPlace == false) { foundGoodPlace = CanToEatInLeftDownInY(i_IndexesToPlay, out o_IndexesThatLegal); } if (foundGoodPlace == false) { foundGoodPlace = CanToEatInRightUpInY(i_IndexesToPlay, out o_IndexesThatLegal); } if (foundGoodPlace == false) { foundGoodPlace = CanToEatInLeftUpInY(i_IndexesToPlay, out o_IndexesThatLegal); } return(foundGoodPlace); }
public bool CanToMoveLeftDownInY(Locat i_IndexesToPlay, out Locat o_IndexesThatLegal) { byte start = 0, end = (byte)(m_Size - 1); bool isCanMoveleftDowninYLine = false; o_IndexesThatLegal = new Locat(); byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y; bool isLeftDownSpotLegal = (indexX - 1 >= start) && (indexY + 1 <= end); if (isLeftDownSpotLegal) { eCheckers spotToCheck = (eCheckers)m_Mat[indexY + 1, indexX - 1]; if (spotToCheck == eCheckers.Non) { // yosi start //o_IndexesThatLegal[0] = (byte)(indexX - 1); //o_IndexesThatLegal[1] = (byte)(indexY + 1); o_IndexesThatLegal.X = (byte)(indexX - 1); o_IndexesThatLegal.Y = (byte)(indexY + 1); // yosi end isCanMoveleftDowninYLine = true; } } return(isCanMoveleftDowninYLine); }
public void resetGame() { m_GameOn = true; NowPlaying = k_Player1; //yosi start Locat currentVeesel = new Locat(); m_VellsOfPlayer1.Clear(); m_VellsOfPlayer2.Clear(); //yosi end //playerOnePoints = playerTwoPoints = (short)(((m_Size - 2) / 2) * (m_Size / 2)); for (int i = 0; i < m_Size; i++) { for (int j = 0; j < m_Size; j++) { if (i < (m_Size / 2 - 1) && (i + j) % 2 != 0) { m_Mat[i, j] = (byte)eCheckers.CheckerO; // yossi move vessel // yosi start currentVeesel.X = (byte)j; currentVeesel.Y = (byte)i; m_VellsOfPlayer1.Add(currentVeesel); // yosi end // list1 } else if (i >= (m_Size / 2 + 1) && (i + j) % 2 != 0) { m_Mat[i, j] = (byte)eCheckers.CheckerX; // yossi move vessel // yossi start currentVeesel.X = (byte)j; currentVeesel.Y = (byte)i; m_VellsOfPlayer2.Add(currentVeesel); //yosi end } else { m_Mat[i, j] = (byte)eCheckers.Non; } } } }
public bool Player1CanToMove(Locat i_IndexesToPlay, out Locat o_IndexesThatLegal) { byte start = 0, end = (byte)(m_Size - 1); bool foundGoodPlace = false; o_IndexesThatLegal = new Locat(); byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y; eCheckers kings = eCheckers.CheckerK | eCheckers.CheckerU, currentSoilder = (eCheckers)m_Mat[indexY, indexX]; if (CanToMoveRightDownInY(i_IndexesToPlay, out o_IndexesThatLegal)) { foundGoodPlace = true; } if (foundGoodPlace == false) { if (CanToMoveLeftDownInY(i_IndexesToPlay, out o_IndexesThatLegal)) { foundGoodPlace = true; } } if (foundGoodPlace == false && ((currentSoilder & kings) == currentSoilder)) { if (CanToMoveRightUpInY(i_IndexesToPlay, out o_IndexesThatLegal)) { foundGoodPlace = true; } if (foundGoodPlace == false) { if (CanToMoveLeftUpInY(i_IndexesToPlay, out o_IndexesThatLegal)) { foundGoodPlace = true; } } } return(foundGoodPlace); }
public bool CanToEatInRightUpInY(Locat i_IndexesToPlay, out Locat o_IndexesThatLegal) { bool isCanToEatInRightUpInY = false; byte start = 0, end = (byte)(m_Size - 1); o_IndexesThatLegal = new Locat(); byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y; bool isRightUpSpotLegal = (indexX + 2 <= end) && (indexY - 2 >= start); if (isRightUpSpotLegal) { if (isHaveEnemyInCrossToEat((byte)(indexX + 1), (byte)(indexY - 1), (byte)(indexX + 2), (byte)(indexY - 2))) { o_IndexesThatLegal.X = (byte)(indexX + 2); o_IndexesThatLegal.Y = (byte)(indexY - 2); isCanToEatInRightUpInY = true; } } return(isCanToEatInRightUpInY); }
private void eatEnemyVessel(byte i_IndexOfVesselOneX, byte i_IndexOfVesselOneY, byte i_IndexOfVesselTwoX, byte i_IndexOfVesselTwoY) { //// te bool return is for check if all did appened and not need replay turn . if the bool not needed so to replace to void . byte middleIndexX = (byte)((i_IndexOfVesselTwoX + i_IndexOfVesselOneX) / 2); byte middleIndexY = (byte)((i_IndexOfVesselOneY + i_IndexOfVesselTwoY) / 2); if (isHaveEnemyInCrossToEat(middleIndexX, middleIndexY, i_IndexOfVesselTwoX, i_IndexOfVesselTwoY)) { IsEated = true; ExuteMove(i_IndexOfVesselOneX, i_IndexOfVesselOneY, i_IndexOfVesselTwoX, i_IndexOfVesselTwoY); IsTurnPass = true; // yossi move vessel // if (Player == k_Player1) { } else { } //yosi start Locat original = new Locat(i_IndexOfVesselOneX, i_IndexOfVesselOneY); Locat newVessel = new Locat(i_IndexOfVesselTwoX, i_IndexOfVesselTwoY); Locat isEatedNow = new Locat(middleIndexX, middleIndexY); if (NowPlaying == k_Player1) { ChanghVeesslInList(m_VellsOfPlayer1, original, newVessel); sortListOfVesselBecomingFirst(m_VellsOfPlayer1); m_VellsOfPlayer2.Remove(isEatedNow); } else { ChanghVeesslInList(m_VellsOfPlayer2, original, newVessel); sortListOfVesselBecomingFirst(m_VellsOfPlayer2); m_VellsOfPlayer1.Remove(isEatedNow); } // yosi end } else { Console.WriteLine("Cant jump so far without Eat. - you cant eat nothing or yourself - . try again."); } }
private bool moveVessel(byte i_IndexOfVesselOneX, byte i_IndexOfVesselOneY, byte i_IndexOfVesselTwoX, byte i_IndexOfVesselTwoY) { bool isMoved = false; if (m_Mat[i_IndexOfVesselTwoY, i_IndexOfVesselTwoX] == (byte)eCheckers.Non) { ExuteMove(i_IndexOfVesselOneX, i_IndexOfVesselOneY, i_IndexOfVesselTwoX, i_IndexOfVesselTwoY); IsTurnPass = true; // yossi move vessel //yosi start Locat original = new Locat(i_IndexOfVesselOneX, i_IndexOfVesselOneY); Locat newVessel = new Locat(i_IndexOfVesselTwoX, i_IndexOfVesselTwoY); if (NowPlaying == k_Player1) { ChanghVeesslInList(m_VellsOfPlayer1, original, newVessel); //yosi check sortListOfVesselBecomingFirst(m_VellsOfPlayer1); // yosi end check } else { ChanghVeesslInList(m_VellsOfPlayer2, original, newVessel); // yosi check sortListOfVesselBecomingFirst(m_VellsOfPlayer2); //m_VellsOfPlayer2 // yosi end check } // yosi end // delete origin and add new place of vessel isMoved = true; } return(isMoved); }
public bool CanToMoveRightUpInY(Locat i_IndexesToPlay, out Locat o_IndexesThatLegal) { byte start = 0, end = (byte)(m_Size - 1); bool isCanMoveRightUpinYLine = false; o_IndexesThatLegal = new Locat(); byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y; bool isRightUpSpotLegal = (indexX + 1 <= end) && (indexY - 1 >= start); if (isRightUpSpotLegal) { eCheckers spotToCheck = (eCheckers)m_Mat[indexY - 1, indexX + 1]; if (spotToCheck == eCheckers.Non) { o_IndexesThatLegal.X = (byte)(indexX + 1); o_IndexesThatLegal.Y = (byte)(indexY - 1); isCanMoveRightUpinYLine = true; } } return(isCanMoveRightUpinYLine); }
public void ChanghVeesslInList(List <Locat> i_VellsOfPlayer, Locat i_CurrentVessel, Locat i_NewVessel) { i_VellsOfPlayer.Remove(i_CurrentVessel); i_VellsOfPlayer.Add(i_NewVessel); }