示例#1
0
        public static IMineOwnership UpdateFromTiles(IMineOwnership mines, string tiles)
        {
            var index = 0;

            for (int p = 0; p < tiles.Length; p += 2)
            {
                if (tiles[p] == '$')
                {
                    switch (tiles[p + 1])
                    {
                    case '1': mines = mines.Set(index, PlayerType.Hero1); break;

                    case '2': mines = mines.Set(index, PlayerType.Hero2); break;

                    case '3': mines = mines.Set(index, PlayerType.Hero3); break;

                    case '4': mines = mines.Set(index, PlayerType.Hero4); break;

                    case '-':
                    default: break;
                    }
                    index++;
                }
            }
            return(mines);
        }
示例#2
0
        public static IMineOwnership Create(params PlayerType[] mines)
        {
            IMineOwnership ownership = MineOwnership20.Empty;

            for (int index = 0; index < mines.Length; index++)
            {
                if (mines[index] != PlayerType.None)
                {
                    ownership = ownership.Set(index, mines[index]);
                }
            }
            return(ownership);
        }