Example #1
0
        private bool IsCamelRolled(byte aCamel)
        {
            byte UnrollCamel = GameRules.ByteUnrollToRoll(aCamel);

            foreach (var aByte in BoardState)
            {
                if (aByte == UnrollCamel)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        private BoardByte(BoardByte aInitialBoard, string aPattern, byte aRolledCamel, List <List <Byte> > aDiceHistory)
        {
            m_SubBoard = new List <IBoard>();
            byte[] pattern = GameRules.StringToByte(aPattern);
            byte[] camels  = aInitialBoard.GetCamelsNeighbouring(aRolledCamel);
            m_DicesHistoriesByte.AddRange(aDiceHistory);

            for (int i = 0; i < pattern.Length; i++)
            {
                if (GameRules.IsBytePatternCamel(pattern[i]))
                {
                    byte camel = camels[GameRules.PATTER_NAME_NUMBER_BYTE(pattern[i])];
                    pattern[i] = camel == aRolledCamel?GameRules.ByteUnrollToRoll(camel) : camel;
                }
            }

            int startingPos = GetBytePositionInArray(aInitialBoard.BoardState, camels[0]) - 1;

            byte[] newBoardState = (byte[])aInitialBoard.BoardState.Clone();

            newBoardState = RemoveByteArray(newBoardState, startingPos, Math.Min(pattern.Length, newBoardState.Length - startingPos));
            newBoardState = InsertBytesIntoBytes(newBoardState, startingPos, pattern);

            BoardState = newBoardState;

            Weight = aInitialBoard.Weight;

            CasesLandedOn = (int[])aInitialBoard.CasesLandedOn.Clone();

            int caseLanded = GetCamelPos(aRolledCamel);

            if (caseLanded < CasesLandedOn.Length && IsCamelLandEmptyCase(aRolledCamel))
            {
                CasesLandedOn[caseLanded]++;
            }

            PopulateNeighbouring();
        }