Esempio n. 1
0
        public CardDescription[] Read(Lucene.Net.Store.Directory dir, ReadProcessChangedInvoker processchanged)
        {
            ArrayList cards    = new ArrayList(MinCapacity);
            Query     query    = new MatchAllDocsQuery();
            Searcher  searcher = new IndexSearcher(dir, true);
            TopDocs   td       = searcher.Search(query, null, searcher.MaxDoc());

            ScoreDoc[] docs = td.scoreDocs;

            int length = docs.Length;

            for (int i = 0; i < length; i++)
            {
                Document doc = searcher.Doc(docs[i].doc);
                cards.Add(ParseCard(doc));
                if (processchanged != null)
                {
                    processchanged.Invoke(length, i + 1);
                }
            }

            searcher.Close();

            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 2
0
        public override CardDescription[] Read(string filename, ReadProcessChangedInvoker processchanged)
        {
            if (!File.Exists(filename))
            {
                return(new CardDescription[0]);
            }

            int total = File.ReadAllLines(filename).Length;

            StreamReader sr    = null;
            ArrayList    cards = new ArrayList(MinCapacity);

            sr = new StreamReader(filename, Encoding.GetEncoding("GB2312"));
            int i = 0;

            while (!sr.EndOfStream)
            {
                string s = sr.ReadLine();
                cards.Add(ParseCard(s));
                i++;
                if (processchanged != null)
                {
                    processchanged.Invoke(total, i);
                }
            }
            sr.Close();

            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
        public override CardDescription[] Read(string filename, ReadProcessChangedInvoker processchanged)
        {
            if (!File.Exists(filename))
            {
                return(new CardDescription[0]);
            }

            ArrayList cards = new ArrayList(MinCapacity);
            Hashtable ht    = new Hashtable(MinCapacity);

            //连接数据库
            SQLiteConnection con = new SQLiteConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + filename + ";Persist Security Info=False;");

            con.Open();

            //统计记录数
            SQLiteCommand    dcc     = new SQLiteCommand("Select Count(*) as iCount FROM [Datas]", con);
            SQLiteDataReader creader = dcc.ExecuteReader();

            creader.Read();
            int total = int.Parse(creader["iCount"].ToString());

            creader.Close();


            Hashtable htCheatCode = new Hashtable();

            dcc     = new SQLiteCommand(@"select * from datas t1 left join texts t2 on t1.id = t2.id ", con);
            creader = dcc.ExecuteReader();

            int i = 0;

            while (creader.Read())
            {
                CardDescription card = ParseCard(creader, cards);
                if (!ht.Contains(card.name))
                {
                    cards.Add(card);
                    ht.Add(card.name, card);
                }
                else
                {
                    CardDescription cd = (CardDescription)ht[card.name];
                    cd.cheatcode = cd.cheatcode + "," + card.cheatcode;
                }
                i++;
                processchanged.Invoke(total, i);
            }

            creader.Close();
            con.Close();
            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 4
0
        public override CardDescription[] Read(string dirname, ReadProcessChangedInvoker processchanged)
        {
            if (dirname == null || dirname.Length <= 0)
            {
                return(null);
            }

            if (!Directory.Exists(dirname))
            {
                return(null);
            }

            if (dirname[dirname.Length - 1] != '\\')
            {
                dirname += "\\";
            }

            ArrayList cards = new ArrayList(MinCapacity);
            Query     query = new MatchAllDocsQuery();

            Lucene.Net.Store.Directory dir = new Lucene.Net.Store.SimpleFSDirectory(new DirectoryInfo(dirname), new Lucene.Net.Store.SimpleFSLockFactory());
            Searcher searcher = new IndexSearcher(dir, true);

            TopDocs td = searcher.Search(query, null, searcher.MaxDoc());

            ScoreDoc[] docs = td.scoreDocs;

            int length = docs.Length;

            for (int i = 0; i < length; i++)
            {
                Document doc = searcher.Doc(docs[i].doc);
                cards.Add(ParseCard(doc));
                if (processchanged != null)
                {
                    processchanged.Invoke(length, i + 1);
                }
            }

            searcher.Close();

            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 5
0
        public override CardDescription[] Read(string filename, ReadProcessChangedInvoker processchanged)
        {
            if (!File.Exists(filename))
            {
                return(new CardDescription[0]);
            }

            int total = File.ReadAllLines(filename).Length;

            StreamReader sr    = null;
            ArrayList    cards = new ArrayList(MinCapacity);

            sr = new StreamReader(filename, Encoding.GetEncoding("GB2312"));

            int i = 0;

            while (!sr.EndOfStream)
            {
                string s = sr.ReadLine().Trim();
                if (s != "")
                {
                    CardDescription card = new CardDescription();
                    card.name     = s.Substring(1, s.Length - 2);
                    card.ID       = 60000 + i;
                    card.cardCamp = CardCamp.DIY;
                    card.limit    = -5;
                    s             = sr.ReadLine().Trim();
                    cards.Add(ParseCard(card, s));
                    i++;
                    if (processchanged != null)
                    {
                        processchanged.Invoke(total, i);
                    }
                }
            }
            sr.Close();

            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 6
0
        public override CardDescription[] Read(string filename, ReadProcessChangedInvoker processchanged)
        {
            ArrayList cards = new ArrayList(MinCapacity);


            //连接数据库
            SQLiteConnection con = new SQLiteConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + filename + ";Persist Security Info=False;");

            con.Open();

            //统计记录数
            SQLiteCommand    dcc     = new SQLiteCommand("Select Count(*) as iCount FROM [YGODATA]", con);
            SQLiteDataReader creader = dcc.ExecuteReader();

            creader.Read();
            int total = int.Parse(creader["iCount"].ToString());

            creader.Close();

            //读入卡片数据
            //OleDbCommand dc = new OleDbCommand("Select [CardID], [JPCardName], [SCCardName], [ENCardName], [SCCardType], [SCCardRace], [CardBagNum], [SCCardAttribute], [CardStarNum], [SCCardRare], [CardAtk], [CardDef], [SCCardDepict], [CardPass], [CardAdjust], [CardUnion], [SCCardBan] FROM [YGODATA] Order By [CardID]", con);
            SQLiteCommand dc = new SQLiteCommand("Select * FROM [YGODATA] Order By [id]", con);

            SQLiteDataReader reader = dc.ExecuteReader();

            int i = 0;

            while (reader.Read())
            {
                cards.Add(ParseCard(reader));
                i++;
                processchanged.Invoke(total, i);
            }

            reader.Close();
            con.Close();
            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 7
0
        public CardDescription[] Read(string filename, CardDescription[] oricards, ReadProcessChangedInvoker processchanged)
        {
            ArrayList cards = new ArrayList(oricards.Length);

            //连接数据库
            SQLiteConnection con = new SQLiteConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + filename + ";Persist Security Info=False;");

            con.Open();

            //读取同名卡数据
            Hashtable htCheatCode = new Hashtable();

            SQLiteCommand    dcc     = new SQLiteCommand(@"select t3.*, t4.[alias_list] as alias_list from
  (select t2.[id],case t2.[alias] when 0 then t2.[id] else t2.[alias] end as alias from datas t2) as t3
left join
  (select t1.[alias], t1.[alias] || ',' || group_concat(t1.[id]) as alias_list from datas t1 where t1.[alias] <> 0 group   by t1.[alias]) as t4
on t3.[alias] = t4.[alias]
where not t4.[alias_list] is null", con);
            SQLiteDataReader creader = null;

            try
            {
                creader = dcc.ExecuteReader();

                while (creader.Read())
                {
                    string cheatcode     = GetFieldString(creader, "id").PadLeft(8, '0');
                    string cheatcodelist = GetFieldString(creader, "alias_list");
                    htCheatCode.Add(cheatcode, cheatcodelist);
                }
                creader.Close();
            }
            catch
            {
            }

            //读取YGOPRO的效果分类数据
            Hashtable htEffectType = new Hashtable();

            dcc     = new SQLiteCommand("Select * FROM [datas]", con);
            creader = null;
            try
            {
                creader = dcc.ExecuteReader();

                while (creader.Read())
                {
                    string cheatcode = GetFieldString(creader, "id").PadLeft(8, '0');
                    int    Effect    = int.Parse(creader["category"].ToString());
                    htEffectType.Add(cheatcode, Effect);
                }
                creader.Close();
            }
            catch
            {
            }

            //更新同名卡数据和效果分类数据
            for (int i = 0; i < oricards.Length; i++)
            {
                CardDescription card = oricards[i];
                card.effectType = "";
                StringBuilder sb = new StringBuilder();

                int categorynum = 0;
                if (htEffectType.ContainsKey(card.cheatcode))
                {
                    categorynum = (int)htEffectType[card.cheatcode];
                }
                if (categorynum != 0)
                {
                    int index = 0;
                    int num;
                    for (num = 1; index < 0x20; num = num << 1)
                    {
                        if ((num & categorynum) != 0L)
                        {
                            sb.Append(EffectTypeDescription[index]);
                            sb.Append(",");
                        }
                        index++;
                    }

                    if (sb.Length > 0)
                    {
                        sb.Length--;
                    }
                    card.effectType = sb.ToString();
                }

                if (htCheatCode.ContainsKey(card.cheatcode))
                {
                    string[] ccl = ((string)htCheatCode[card.cheatcode]).Split(',');
                    sb = new StringBuilder();
                    for (int j = 0; j < ccl.Length; j++)
                    {
                        sb.Append(ccl[j].PadLeft(8, '0'));
                        sb.Append(',');
                    }
                    sb.Length--;
                    card.aliasList = sb.ToString();
                }

                cards.Add(card);
            }

            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 8
0
        public override CardDescription[] Read(string filename, ReadProcessChangedInvoker processchanged)
        {
            ArrayList cards = new ArrayList(MinCapacity);


            //连接数据库
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + filename + ";Persist Security Info=False;Jet OLEDB:Database [email protected];");

            con.Open();

            //读取效果种类列表
            ht = new Hashtable();

            OleDbCommand    dcc     = new OleDbCommand("Select * FROM [YGOEFFECT]", con);
            OleDbDataReader creader = null;

            try
            {
                //如果数据库中存在效果种类列表则优先读取数据库中的记录
                creader = dcc.ExecuteReader();

                while (creader.Read())
                {
                    string id = GetFieldString(creader, "ID");
                    string s  = MyTools.CharacterSet.SBCToDBC(GetFieldString(creader, "EFFECT"));
                    ht.Add(id, s);
                    if (id.Length == 1)
                    {
                        id = "0" + id;
                        ht.Add(id, s);
                    }
                }
                creader.Close();
            }
            catch
            {
            }

            //从补丁文件里补充效果种类列表
            try
            {
                string[] ss = File.ReadAllLines(Global.GetPath() + "Patch\\EffectTypeList.dat", System.Text.Encoding.GetEncoding("gb2312"));
                foreach (string s in ss)
                {
                    string[] ss2 = s.Split('\t');
                    if (!ht.ContainsKey(ss2[0]))
                    {
                        ht.Add(ss2[0], MyTools.CharacterSet.SBCToDBC(ss2[1]));
                    }
                }
            }
            catch
            {
            }

            //统计记录数
            dcc     = new OleDbCommand("Select Count(*) as iCount FROM [YGODATA]", con);
            creader = dcc.ExecuteReader();
            creader.Read();
            int total = int.Parse(creader["iCount"].ToString());

            creader.Close();

            //读入卡片数据
            //OleDbCommand dc = new OleDbCommand("Select [CardID], [JPCardName], [SCCardName], [ENCardName], [SCCardType], [SCCardRace], [CardBagNum], [SCCardAttribute], [CardStarNum], [SCCardRare], [CardAtk], [CardDef], [SCCardDepict], [CardPass], [CardAdjust], [CardUnion], [SCCardBan] FROM [YGODATA] Order By [CardID]", con);
            OleDbCommand dc = new OleDbCommand("Select * FROM [YGODATA] Order By [CardID]", con);

            OleDbDataReader reader = dc.ExecuteReader();

            reader.Read();

            int i = 0;

            while (reader.Read())
            {
                cards.Add(ParseCard(reader));
                i++;
                processchanged.Invoke(total, i);
            }

            reader.Close();
            con.Close();
            return((CardDescription[])cards.ToArray(typeof(CardDescription)));
        }
Esempio n. 9
0
 public virtual CardDescription[] Read(string source, ReadProcessChangedInvoker processchanged)
 {
     return(new CardDescription[] { });
 }