Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        protected virtual void CreateSubboard(string aResult, byte aUnrollCamel, int aDiceNb)
        {
            BoardByte subBoard = new BoardByte(this, aResult, aUnrollCamel, GetDiceHistoryUpdated(aUnrollCamel));

            m_SubBoard.Add(subBoard);
        }