Ejemplo n.º 1
0
        /// <summary>
        /// おじゃまスライムの変換を行います。
        /// </summary>
        /// <param name="value">おじゃまスライムの文字列</param>
        /// <returns>変換したおじゃまスライム情報</returns>
        private static Dictionary <ObstructionSlime, int>[] ParseObstructionSlime(string value)
        {
            var result = new Dictionary <ObstructionSlime, int> [Player.Length];

            Func <char[], Dictionary <ObstructionSlime, int> > parse = (vals) =>
            {
                var dic = new Dictionary <ObstructionSlime, int>();
                foreach (var ob in Enum.GetValues(typeof(ObstructionSlime)))
                {
                    dic.Add((ObstructionSlime)ob, 0);
                }

                foreach (var val in vals)
                {
                    var key = SimpleText.ConvertObstructionSlime(val);
                    dic[key] += 1;
                }
                return(dic);
            };

            var values = value.Split(SimpleText.Separator.Player);

            result[(int)Player.Index.First]  = parse(values[(int)Player.Index.First].ToCharArray());
            result[(int)Player.Index.Second] = parse(values[(int)Player.Index.Second].ToCharArray());

            return(result);
        }