예제 #1
0
        public void MakePuzzleDataEx(TagStroke tag, ExtraConstraint ecc)
        {
            Stroke stroke = new Stroke(tag.nbVerses, tag.nbAnchors);

            for (int i = 0; i < tag.nbVerses; ++i)
            {
                stroke.Verses[i] = new Verse(tag.LenVerses[i])
                {
                    Content = ecc.extraV[i]
                };
            }
            for (int i = 0; i < tag.nbAnchors; ++i)
            {
                stroke.Anchors[i] = new int[5];
            }
            for (int i = 0; i < tag.nbAnchors; ++i)
            {
                stroke.Anchors[i][0] = tag.Anchors[i][0];
                stroke.Anchors[i][1] = tag.Anchors[i][1];
                stroke.Anchors[i][2] = tag.Anchors[i][2];
                stroke.Anchors[i][3] = tag.Anchors[i][3];
                stroke.Anchors[i][4] = ecc.extraA[i];
                if (stroke.Verses[stroke.Anchors[i][0]].Content[0] != 0xFF)
                {
                    stroke.Anchors[i][4] = stroke.Verses[stroke.Anchors[i][0]].Content[stroke.Anchors[i][1]];
                }
                if (stroke.Verses[stroke.Anchors[i][2]].Content[0] != 0xFF)
                {
                    stroke.Anchors[i][4] = stroke.Verses[stroke.Anchors[i][2]].Content[stroke.Anchors[i][3]];
                }
            }
            puzzleData = stroke;
        }
예제 #2
0
 private bool CollectEx()
 {
     extraDesc       = new TagStroke();
     extraConstraint = GetExtraTable(table3, table4, extraDesc);
     int[] lens = extraDesc.LenVerses.ToArray();
     for (int k = 0; k < extraDesc.Anchors.Count; ++k)
     {
         int[] a = extraDesc.Anchors[k];
         int   ivs = a[0], ics = a[1], ive = a[2], ice = a[3];
         if (ics < 0 || ics >= lens[ivs] || ice < 0 || ice >= lens[ive])
         {
             return(false);
         }
         if (ivs >= ive)
         {
             return(false);
         }
     }
     for (int k = 0; k < extraConstraint.extraVerses.Count; ++k)
     {
         if (extraConstraint.extraVerses[k].Length != lens[k] && extraConstraint.extraVerses[k].Length > 0)
         {
             return(false);
         }
     }
     return(backend.ConvertChrShrEx(extraConstraint));
 }
예제 #3
0
 public bool ConvertChrShrEx(ExtraConstraint ec)
 {
     ec.extraA = new List <ushort>();
     foreach (string sa in ec.extraAnchors)
     {
         if (sa.Length == 0)
         {
             ec.extraA.Add(0xFF);
         }
         else
         {
             if (!dictChr2Shr.Keys.Contains(sa[0]))
             {
                 return(false);
             }
             ec.extraA.Add(dictChr2Shr[sa[0]]);
         }
     }
     ec.extraV = new List <ushort[]>();
     foreach (string sv in ec.extraVerses)
     {
         if (sv.Length == 0)
         {
             ec.extraV.Add(new ushort[] { 0xFF });
         }
         else
         {
             char[]   arr = sv.ToCharArray();
             ushort[] vs  = new ushort[arr.Length];
             for (int i = 0; i < arr.Length; ++i)
             {
                 if (!dictChr2Shr.Keys.Contains(arr[i]))
                 {
                     return(false);
                 }
                 vs[i] = dictChr2Shr[arr[i]];
             }
             int checkExist = dictDataMatrices[arr.Length].FindIndex(
                 (x) =>
             {
                 bool found = true;
                 for (int i = 0; i < arr.Length; ++i)
                 {
                     if (x[i] != vs[i])
                     {
                         found = false;
                         break;
                     }
                 }
                 return(found);
             });
             if (checkExist < 0)
             {
                 return(false);
             }
             ec.extraV.Add(vs);
         }
     }
     return(true);
 }
예제 #4
0
        private ExtraConstraint GetExtraTable(DataTable tb3, DataTable tb4, TagStroke tag)
        {
            List <string> extraAnchorInString = new List <string>(), extraVerseInString = new List <string>();

            tag.nbAnchors = tb3.Rows.Count;
            foreach (DataRow row in tb3.Rows)
            {
                int a0 = (int)row["VSIdxEx"], a1 = (int)row["CSIdxEx"], a2 = (int)row["VEIdxEx"], a3 = (int)row["CEIdxEx"];
                tag.Anchors.Add(new int[] { a0, a1, a2, a3 });
                extraAnchorInString.Add((string)row["AnchorCharEx"]);
            }
            tag.nbVerses = tb4.Rows.Count;
            foreach (DataRow row in tb4.Rows)
            {
                int    len = (int)row["VerseLenEx"];
                string s   = (string)row["VerseTextEx"];
                tag.LenVerses.Add(len);
                extraVerseInString.Add(s);
            }
            ExtraConstraint exc = new ExtraConstraint(extraVerseInString, extraAnchorInString);

            return(exc);
        }