Beispiel #1
0
        public string GetRankString()
        {
            byte[] rankByte = GetRank();
            string retval   = string.Empty;

            foreach (var rank in rankByte)
            {
                retval += GameRules.ByteToString(rank);
            }

            return(retval);
        }
Beispiel #2
0
        public void PopulateSubBoard()
        {
            if (IsCamelReachEnd)
            {
                return;
            }

            byte[] unRollCamel = GetUnrolledCamelByRank();

            if (unRollCamel.Length == 0)
            {
                SetAllCamelUnroll();
                unRollCamel = GetUnrolledCamelByRank();
            }

            List <Pattern> patterns = ToPattern();

            // i = pattern
            // j = movingCamel in pattern
            // k = result
            foreach (Pattern pattern in patterns)
            {
                string unrolledCamels = string.Empty;
                for (int j = 0; j < pattern.NbCamel && j < unRollCamel.Length; j++)
                {
                    byte unrollCamel = unRollCamel[j];
                    if (!pattern.CamelsIdentity.ToUpper().Contains(GameRules.ByteToString(unrollCamel).ToString().ToUpper()))
                    {
                        continue;
                    }

                    List <string> results = pattern.GetResultsForDice(GameRules.ByteToString(unrollCamel));
                    unrolledCamels += GameRules.ByteToString(unRollCamel[j]);
                    for (int k = 0; k < results.Count; k++)
                    {
                        CreateSubboard(results[k], unrollCamel, k + 1);
                    }
                }

                foreach (char unrollCamel in unrolledCamels)
                {
                    unRollCamel = RemoveByteFromBytesArray(unRollCamel, GameRules.StringToByte(unrollCamel));
                }

                unrolledCamels = string.Empty;
            }
        }
Beispiel #3
0
        private List <Pattern> ToPattern()
        {
            string board      = string.Empty;
            int    camelIndex = 0;

            foreach (byte token in BoardState)
            {
                if (GameRules.IsByteIdentityCamel(token))
                {
                    board += GameRules.PATTERN_CAMEL_NAME[camelIndex++];
                }
                else
                {
                    board += GameRules.ByteToString(token);
                }
            }

            List <string>  patterns = GameRules.PatternResultToPattern(board);
            List <Pattern> retval   = new List <Pattern>();

            byte[] camels      = GetRank();
            int    camelsIndex = 0;

            foreach (string pattern in patterns)
            {
                if (!PatternGenerator.Instance.Patterns.ContainsKey(pattern))
                {
                    PatternGenerator.Instance.StartGeneratePattern(pattern);
                }

                byte[]  camelIdentity = SubByteArray(camels, camelsIndex, PatternGenerator.Instance.Patterns[pattern].NbCamel);
                Pattern newPattern    = new Pattern(PatternGenerator.Instance.Patterns[pattern], camelIdentity);
                camelsIndex += newPattern.NbCamel;
                retval.Add(newPattern);
            }

            return(retval);
        }
Beispiel #4
0
 public Pattern(Pattern aPattern, byte[] aCamelIdentity) : this(aPattern, GameRules.ByteToString(aCamelIdentity))
 {
 }