Ejemplo n.º 1
0
        private void boardLogic_Move(Locat i_LocateThatChange, eCheckers i_ChangeToThisType)
        {
            string newTextToButton = string.Empty;

            switch (i_ChangeToThisType)
            {
            case eCheckers.Non:
                newTextToButton = string.Empty;
                break;

            case eCheckers.CheckerX:
                newTextToButton = "X";
                break;

            case eCheckers.CheckerO:
                newTextToButton = "O";
                break;

            case eCheckers.CheckerU:
                newTextToButton = "U";
                break;

            case eCheckers.CheckerK:
                newTextToButton = "K";
                break;
            }

            m_Ui.ChangeTextOnButton(i_LocateThatChange, newTextToButton);
        }
Ejemplo n.º 2
0
        /*
         * bool CanToMoveAndClearAround(byte[] i_IndexesToPlay, out byte[] i_IndexesThatLegal)
         * {
         *
         *
         *
         *  return;
         * }
         */

        /*
         * bool CanToMove(byte[] i_IndexesToPlay, out byte[] i_IndexesThatLegal)
         * {
         *
         *
         *
         *  return;
         * }
         */

        // goal is yaad
        private bool isHaveEnemyInCrossToEat(byte indexMiddleX, byte indexMiddleY, byte indexGoalX, byte indexGoalY)
        {
            eCheckers soildersTeam = soilderKind();
            eCheckers checker = (eCheckers)m_Mat[indexMiddleY, indexMiddleX], freeSpot = (eCheckers)m_Mat[indexGoalY, indexGoalX];

            return(freeSpot == eCheckers.Non && ((checker & soildersTeam) != checker && checker != eCheckers.Non));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 protected virtual void OnBoardLogicMove(Locat i_ThePlaceThatChange, eCheckers i_ChangeToType)
 {
     if (BoardLogicMove != null)
     {
         BoardLogicMove.Invoke(i_ThePlaceThatChange, i_ChangeToType);
     }
 }
Ejemplo n.º 5
0
        private bool isHaveEnemyInCrossToEat(Locat i_MiddleIndex, Locat i_DestintionIndex)
        {
            eCheckers soildersTeam = soilderKind();
            eCheckers checker = (eCheckers)m_Mat[i_MiddleIndex.Y, i_MiddleIndex.X], freeSpot = (eCheckers)m_Mat[i_DestintionIndex.Y, i_DestintionIndex.X];

            return(freeSpot == eCheckers.Non && ((checker & soildersTeam) != checker && checker != eCheckers.Non));
        }
Ejemplo n.º 6
0
        // end try


        private bool CanToMove(byte indexX, byte indexY)
        {
            byte start = 0, end = (byte)(m_Size - 1);

            bool foundGoodPlace = false;

            bool isRightUpSpotLegal = (indexX + 1 <= end) && (indexY - 1 >= start);
            bool isLeftUpSpotLegal  = (indexX - 1 >= start) && (indexY - 1 >= start);

            eCheckers kings = eCheckers.CheckerK | eCheckers.CheckerU, currentSoilder = (eCheckers)m_Mat[indexY, indexX];

            if (isRightUpSpotLegal)
            {
                eCheckers spotToCheck = (eCheckers)m_Mat[indexY - 1, indexX + 1];
                if (spotToCheck == eCheckers.Non)
                {
                    foundGoodPlace = true;
                }
            }

            if (isLeftUpSpotLegal && foundGoodPlace == false)
            {
                eCheckers spotToCheck = (eCheckers)m_Mat[indexY - 1, indexX - 1];
                if (spotToCheck == eCheckers.Non)
                {
                    foundGoodPlace = true;
                }
            }

            if (foundGoodPlace == false && ((currentSoilder & kings) == currentSoilder))
            {
                bool isRightDownSpotLegal = (indexX + 1 <= end) && (indexY + 1 <= end);
                bool isLeftDownSpotLegal  = (indexX - 1 >= start) && (indexY + 1 <= end);

                if (isRightDownSpotLegal)
                {
                    eCheckers spotToCheck = (eCheckers)m_Mat[indexY + 1, indexX + 1];
                    if (spotToCheck == eCheckers.Non)
                    {
                        foundGoodPlace = true;
                    }
                }

                if (isLeftDownSpotLegal && foundGoodPlace == false)
                {
                    eCheckers spotToCheck = (eCheckers)m_Mat[indexY + 1, indexX - 1];
                    if (spotToCheck == eCheckers.Non)
                    {
                        foundGoodPlace = true;
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 7
0
        private void choisesToPlay(eCheckers i_SoilderPlay, Locat i_SourceIndex, Locat i_DestintionIndex)
        {
            switch (i_SoilderPlay)
            {
            case eCheckers.CheckerO:
            case eCheckers.CheckerX:
                playRegularSoilderAndCheckMoveDirection(i_SourceIndex, i_DestintionIndex);
                break;

            case eCheckers.CheckerU:
            case eCheckers.CheckerK:
                eatOrMoveSoilder(i_SourceIndex, i_DestintionIndex);
                break;
            }
        }
Ejemplo n.º 8
0
        void choisesToPlay(eCheckers soilderPlay, byte vesselOneX, byte vesselOneY, byte vesselTwoX, byte vesselTwoY)
        {
            // bool isPlayed = false;

            switch (soilderPlay) // the vessel that going to play.
            {
            case eCheckers.CheckerO:
            case eCheckers.CheckerX:
                playRegularVesselAndCheckMoveDirection(vesselOneX, vesselOneY, vesselTwoX, vesselTwoY);
                break;

            case eCheckers.CheckerU:
            case eCheckers.CheckerK:
                eatOrMoveVessel(vesselOneX, vesselOneY, vesselTwoX, vesselTwoY);
                break;
            }

            //return isPlayed;
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        private bool canToMoveLeftDownInY(Locat i_IndexesToPlay, ref Locat io_IndexesThatLegal)
        {
            byte start = 0, end = (byte)(m_Mat.GetLength(0) - 1);
            bool isCanMoveleftDowninYLine = false;
            bool isLeftDownSpotLegal = (i_IndexesToPlay.X - 1 >= start) && (i_IndexesToPlay.Y + 1 <= end);

            if (isLeftDownSpotLegal)
            {
                eCheckers spotToCheck = (eCheckers)m_Mat[i_IndexesToPlay.Y + 1, i_IndexesToPlay.X - 1];
                if (spotToCheck == eCheckers.Non)
                {
                    io_IndexesThatLegal.X    = (byte)(i_IndexesToPlay.X - 1);
                    io_IndexesThatLegal.Y    = (byte)(i_IndexesToPlay.Y + 1);
                    isCanMoveleftDowninYLine = true;
                }
            }

            return(isCanMoveleftDowninYLine);
        }
Ejemplo n.º 11
0
        private bool canToMoveRightDownInY(Locat i_IndexesToPlay, ref Locat io_IndexesThatLegal)
        {
            byte end = (byte)(m_Mat.GetLength(0) - 1);
            bool isCanMoveRightDowninYLine = false;
            byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y;
            bool isRightDownSpotLegal = (indexX + 1 <= end) && (indexY + 1 <= end);

            if (isRightDownSpotLegal)
            {
                eCheckers spotToCheck = (eCheckers)m_Mat[indexY + 1, indexX + 1];
                if (spotToCheck == eCheckers.Non)
                {
                    io_IndexesThatLegal.X     = (byte)(indexX + 1);
                    io_IndexesThatLegal.Y     = (byte)(indexY + 1);
                    isCanMoveRightDowninYLine = true;
                }
            }

            return(isCanMoveRightDowninYLine);
        }
Ejemplo n.º 12
0
        public bool PlayingVessel(string i_MovePos) // maybe change to PlayingTurn .
        {
            // here add if  to cover all the method for right or wrong input ! .!!
            if (i_MovePos[2] != '>')
            {
                return(false);
            }

            IsEated = false;

            if (IsTurnPass == true)
            {
                changePlayer(); // change Player
            }

            IsTurnPass = false;

            byte vesselOneX, vesselOneY, vesselTwoX, vesselTwoY;

            charsToIndex(out vesselOneX, i_MovePos[0], out vesselOneY, i_MovePos[1]);
            charsToIndex(out vesselTwoX, i_MovePos[3], out vesselTwoY, i_MovePos[4]);

            eCheckers checkers      = (eCheckers)m_Mat[vesselOneY, vesselOneX];
            eCheckers soilderToPlay = soilderKind();

            // m_NowPlaying == 1 ? eCheckers.CheckerO | eCheckers.CheckerU : eCheckers.CheckerX | eCheckers.CheckerK;

            if ((checkers & soilderToPlay) == checkers && checkers != eCheckers.Non)
            {
                choisesToPlay(checkers, vesselOneX, vesselOneY, vesselTwoX, vesselTwoY);
            }
            else
            {
                Console.WriteLine("Not Your Vessel . try again.");
            }

            // return isTurnPass;

            return(IsTurnPass);
        }
Ejemplo n.º 13
0
        public bool Player2CanToEat(Locat i_IndexesToPlay, ref Locat io_IndexesThatLegal)
        {
            bool isHaveFreeSpot = false;
            byte end            = (byte)(m_Mat.GetLength(0) - 1);

            byte indexX = i_IndexesToPlay.X, indexY = i_IndexesToPlay.Y;

            if (canToEatInRightUpInY(i_IndexesToPlay, ref io_IndexesThatLegal))
            {
                isHaveFreeSpot = true;
            }

            if (isHaveFreeSpot == false)
            {
                if (canToEatInLeftUpInY(i_IndexesToPlay, ref io_IndexesThatLegal))
                {
                    isHaveFreeSpot = true;
                }
            }

            eCheckers kings = eCheckers.CheckerK | eCheckers.CheckerU, currentSoilder = (eCheckers)m_Mat[indexY, indexX];

            if (isHaveFreeSpot == false && ((currentSoilder & kings) == currentSoilder))
            {
                if (canToEatInRightDownInY(i_IndexesToPlay, ref io_IndexesThatLegal))
                {
                    isHaveFreeSpot = true;
                }

                if (isHaveFreeSpot == false)
                {
                    if (canToEatInLeftDownInY(i_IndexesToPlay, ref io_IndexesThatLegal))
                    {
                        isHaveFreeSpot = true;
                    }
                }
            }

            return(isHaveFreeSpot);
        }
Ejemplo n.º 14
0
        public void PlayingMove(Locat i_SourceIndex, Locat i_DestintionIndex)
        {
            m_IsEated    = false;
            m_IsTurnPass = false;
            eCheckers checkers      = (eCheckers)m_Mat[i_SourceIndex.Y, i_SourceIndex.X];
            eCheckers soilderToPlay = soilderKind();

            if ((checkers & soilderToPlay) == checkers && checkers != eCheckers.Non)
            {
                choisesToPlay(checkers, i_SourceIndex, i_DestintionIndex);
            }
            else
            {
                MessageBox.Show("not your vessel, try another", "Damka", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (m_IsEated)
            {
                checkingBounderisAndAbilityToEatAndEatingAutomatic(i_DestintionIndex);
            }

            checkIfBecomeKing(i_DestintionIndex);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        // MethodNew here. --==


        public bool CanToEat(byte[] i_IndexesToPlay, byte[] i_IndexesThatLegal)
        {
            bool foundGoodPlace = false;

            byte start = 0, end = (byte)(m_Size - 1);

            byte indexX = i_IndexesToPlay[0], indexY = i_IndexesToPlay[1];

            bool isRightUpSpotLegal = (indexX + 2 <= end) && (indexY - 2 >= start);
            bool isLeftUpSpotLegal  = (indexX - 2 >= start) && (indexY - 2 >= start);

            if (isRightUpSpotLegal)
            {
                if (isHaveEnemyInCrossToEat((byte)(indexX + 1), (byte)(indexY - 1), (byte)(indexX + 2), (byte)(indexY - 2)))
                {
                    i_IndexesThatLegal[0] = (byte)(indexX + 2);
                    i_IndexesThatLegal[1] = (byte)(indexY - 2);
                    foundGoodPlace        = true;
                }
            }

            if (isRightUpSpotLegal && foundGoodPlace == false)
            {
                if (isHaveEnemyInCrossToEat((byte)(indexX - 1), (byte)(indexY - 1), (byte)(indexX - 2), (byte)(indexY - 2)))
                {
                    i_IndexesThatLegal[0] = (byte)(indexX - 2);
                    i_IndexesThatLegal[1] = (byte)(indexY - 2);
                    foundGoodPlace        = true;
                }
            }

            eCheckers kings = eCheckers.CheckerK | eCheckers.CheckerU, currentSoilder = (eCheckers)m_Mat[indexY, indexX];

            if (foundGoodPlace == false && ((currentSoilder & kings) == currentSoilder))
            {
                bool isRightDownSpotLegal = (indexX + 2 <= end) && (indexY + 2 <= end);
                bool isLeftDownSpotLegal  = (indexX - 2 >= start) && (indexY + 2 <= end);

                if (isRightDownSpotLegal)
                {
                    if (isHaveEnemyInCrossToEat((byte)(indexX + 1), (byte)(indexY + 1), (byte)(indexX + 2), (byte)(indexY + 2)))
                    {
                        i_IndexesThatLegal[0] = (byte)(indexX + 2);
                        i_IndexesThatLegal[1] = (byte)(indexY + 2);
                        foundGoodPlace        = true;
                    }
                }

                if (isLeftDownSpotLegal && foundGoodPlace == false)
                {
                    if (isHaveEnemyInCrossToEat((byte)(indexX - 1), (byte)(indexY + 1), (byte)(indexX - 2), (byte)(indexY + 2)))
                    {
                        i_IndexesThatLegal[0] = (byte)(indexX - 2);
                        i_IndexesThatLegal[1] = (byte)(indexY + 2);
                        foundGoodPlace        = true;
                    }
                }
            }

            return(foundGoodPlace);
        }