예제 #1
0
        //匹配要求名字严格相同
        private void CardMatch(string name)
        {
            if (name == "")
            {
                return;
            }

            CardDescription card = null;

            //按缩写名匹配
            card = cardLibrary.GetCardByShortName(name);
            if (card != null)
            {
                AddToResultList(card);
            }

            //按卡名匹配
            if (nametable.Contains(name))
            {
                int i = int.Parse(nametable[name].ToString());
                AddToResultList(cardLibrary.GetCardByID(i));
            }

            //按日文名匹配
            if (japnametable.Contains(name))
            {
                int i = int.Parse(japnametable[name].ToString());
                AddToResultList(cardLibrary.GetCardByID(i));
            }

            //按英文名匹配
            if (ennametable.Contains(name))
            {
                int i = int.Parse(ennametable[name].ToString());
                AddToResultList(cardLibrary.GetCardByID(i));
            }

            //按曾用名匹配
            card = cardLibrary.GetCardByOldName(name);
            if (card != null)
            {
                AddToResultList(card);
            }
        }
예제 #2
0
        public string AddCard(int id, int index)
        {
            if (decklist.Count >= Capacity && Capacity > 0)
            {
                return("卡组已满!");
            }

            int count = 0;

            if (cardcount[id] != null)
            {
                count = (int)cardcount[id];
            }
            CardDescription card = cardLibrary.GetCardByID(id);

            if (!string.Equals(CLConfig.GetInstance().GetSetting("AllowForbiddenCard"), "True", StringComparison.OrdinalIgnoreCase))
            {
                LimitNum = card.limit;
            }
            if (count >= LimitNum)
            {
                return(string.Format("卡片[{0}]超出限制数量!", card.name));
            }

            if (index >= 0 && index < decklist.Count)
            {
                decklist.Insert(index, new Card(id, Index++));
            }
            else
            {
                decklist.Add(new Card(id, Index++));
            }
            cardcount[id] = ++count;
            isChanged     = true;

            return(null);
        }
예제 #3
0
        public bool SaveFileForCGI(string filename)
        {
            try
            {
                StreamWriter sw          = new StreamWriter(filename, false, System.Text.Encoding.Unicode);
                CardLibrary  cardLibrary = CardLibrary.GetInstance();

                Card[] Cards = MainDeck.GetList();
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    string          s  = CharacterSet.JPDBCToSBC(cd.japName);
                    sw.WriteLine(s);
                }

                Cards = SideDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("####");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine(CharacterSet.JPDBCToSBC(cd.japName));
                }

                Cards = FusionDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("====");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine(CharacterSet.JPDBCToSBC(cd.japName));
                }

                Cards = TempDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("$$$$");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine(CharacterSet.JPDBCToSBC(cd.japName));
                }

                sw.Close();

                DeckName             = Regex.Replace(filename, @".[^.]*$", "");
                DeckName             = Regex.Replace(DeckName, @"^.*\\", "");
                MainDeck.isChanged   = false;
                SideDeck.isChanged   = false;
                FusionDeck.isChanged = false;
                TempDeck.isChanged   = false;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #4
0
        public bool SaveFileForPRO(string filename)
        {
            try
            {
                StreamWriter sw          = new StreamWriter(filename, false, System.Text.Encoding.ASCII);
                CardLibrary  cardLibrary = CardLibrary.GetInstance();

                sw.WriteLine("#created by DeckBuilder2");

                //Êä³öÖ÷¿¨×é
                Card[] Cards = MainDeck.GetList();
                sw.WriteLine("#main");
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine(cd.cheatcode);
                }

                //Êä³ö¶îÍ⿨×é
                Cards = ExtraDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("#extra");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine(cd.cheatcode);
                }

                //Êä³ö¸±¿¨×é
                Cards = SideDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("!side");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine(cd.cheatcode);
                }

                //Êä³öºòÑ¡¿¨±í
                Cards = TempDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("#wait list");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    sw.WriteLine("#" + cd.cheatcode);
                }

                sw.Close();

                deckname            = Regex.Replace(filename, @".[^.]*$", "");
                deckname            = Regex.Replace(deckname, @"^.*\\", "");
                MainDeck.isChanged  = false;
                SideDeck.isChanged  = false;
                ExtraDeck.isChanged = false;
                TempDeck.isChanged  = false;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #5
0
        public bool SaveFile(string filename)
        {
            this.filename = filename;

            try
            {
                StreamWriter sw          = new StreamWriter(filename, false, System.Text.Encoding.GetEncoding("gb2312"));
                CardLibrary  cardLibrary = CardLibrary.GetInstance();

                Card[] Cards = MainDeck.GetList();
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    if (card.Text.Length > 0)
                    {
                        sw.WriteLine("[" + cd.name + "]#" + card.Text + "#");
                    }
                    else
                    {
                        sw.WriteLine("[" + cd.name + "]");
                    }
                }

                Cards = SideDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("####");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    if (card.Text.Length > 0)
                    {
                        sw.WriteLine("[" + cd.name + "]#" + card.Text + "#");
                    }
                    else
                    {
                        sw.WriteLine("[" + cd.name + "]");
                    }
                }

                Cards = ExtraDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("====");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    if (card.Text.Length > 0)
                    {
                        sw.WriteLine("[" + cd.name + "]#" + card.Text + "#");
                    }
                    else
                    {
                        sw.WriteLine("[" + cd.name + "]");
                    }
                }

                Cards = TempDeck.GetList();
                if (Cards.Length > 0)
                {
                    sw.WriteLine("$$$$");
                }
                foreach (Card card in Cards)
                {
                    CardDescription cd = cardLibrary.GetCardByID(card.ID);
                    if (card.Text.Length > 0)
                    {
                        sw.WriteLine("[" + cd.name + "]#" + card.Text + "#");
                    }
                    else
                    {
                        sw.WriteLine("[" + cd.name + "]");
                    }
                }

                sw.Close();

                deckname            = Regex.Replace(filename, @".[^.]*$", "");
                deckname            = Regex.Replace(deckname, @"^.*\\", "");
                MainDeck.isChanged  = false;
                SideDeck.isChanged  = false;
                ExtraDeck.isChanged = false;
                TempDeck.isChanged  = false;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #6
0
        public SearchResult TopSearch(string SentenceString, int lLoc, int top)
        {
            SearchResult sr = new SearchResult();

            //转为简体
            //string simplesen = CharacterSet.BIG5ToGB(SentenceString);
            //这里应该是全角转半角
            string simplesen = CharacterSet.SBCToDBC(SentenceString);

            //过滤stopwords
            simplesen = stopwrods.Replace(simplesen, " ");
            //过滤标点符号
            StringBuilder sb   = new StringBuilder();
            int           skip = 0;

            for (int i = 0; i < simplesen.Length; i++)
            {
                if (Char.IsLetterOrDigit(simplesen[i]))
                {
                    sb.Append(simplesen[i]);
                }
                else
                {
                    sb.Append(' ');
                    if (i <= lLoc)
                    {
                        skip++;
                    }
                }
            }
            simplesen = sb.ToString();
            if (simplesen.Length == 0)
            {
                return(sr);
            }

            //清0
            for (int i = 0; i < Result.Count; i++)
            {
                if (i < cardLibrary.GetNonDIYCount())
                {
                    ((DictSearcherNode)Result[i]).ID = i + 1;
                }
                else
                {
                    ((DictSearcherNode)Result[i]).ID = i + 60000 - cardLibrary.GetNonDIYCount();
                }
                ((DictSearcherNode)Result[i]).Score = 0;
            }
            Hashtable SearchedKeyword = new Hashtable();
            string    lMainWord       = "";
            int       lMainWordLenth  = 0;
            string    rMainWord       = "";
            int       rMainWordLenth  = 0;

            for (int i = lLoc; i >= 0; i--)
            {
                string s     = simplesen.Substring(i, lLoc - i + 1);
                string trims = GetTokenizerText(s);
                if (trims.Length > 0 && !SearchedKeyword.ContainsKey(trims))
                {
                    SearchedKeyword.Add(trims, 0);
                    if (DoSearch(s) > 0)
                    {
                        if (trims.Length > lMainWordLenth)
                        {
                            int blank = 0;
                            while (s[blank] == ' ')
                            {
                                blank++;
                            }
                            lMainWord      = SentenceString.Substring(i + blank, lLoc - i + 1 - blank);
                            lMainWordLenth = trims.Length;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            for (int i = lLoc + 1; i < simplesen.Length; i++)
            {
                string s     = simplesen.Substring(lLoc, i - lLoc + 1);
                string trims = GetTokenizerText(s);
                if (trims.Length > 0 && !SearchedKeyword.ContainsKey(trims))
                {
                    SearchedKeyword.Add(trims, 0);
                    if (DoSearch(s) > 0)
                    {
                        if (trims.Length > rMainWordLenth)
                        {
                            int blank = 0;
                            while (s[blank] == ' ')
                            {
                                blank++;
                            }
                            rMainWord      = SentenceString.Substring(lLoc + blank, i - lLoc + 1 - blank);
                            rMainWordLenth = trims.Length;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            DictSearcherCompare dsc = new DictSearcherCompare();

            Result.Sort(dsc);

            sr.Cards = new CardDescription[top];
            if (rMainWord.Length > 1)
            {
                if (GetTokenizerText(SentenceString.Substring(lLoc, 1)).Length > 0)
                {
                    sr.KeyWord = lMainWord + rMainWord.Substring(1);
                }
                else
                {
                    sr.KeyWord = lMainWord + rMainWord;
                }
            }
            else
            {
                sr.KeyWord = lMainWord;
            }
            for (int i = 0; i < top; i++)
            {
                sr.Cards[i] = cardLibrary.GetCardByID(((DictSearcherNode)Result[i]).ID);
            }

            return(sr);
        }