Example #1
0
 public static void Init(string fileName)
 {
     Banlists = new List<Banlist>();
     Banlist current = null;
     StreamReader reader = new StreamReader(fileName);
     while (!reader.EndOfStream)
     {
         string line = reader.ReadLine();
         if (line == null)
             continue;
         if (line.StartsWith("#"))
             continue;
         if (line.StartsWith("!"))
         {
             current = new Banlist();
             Banlists.Add(current);
             continue;
         }
         if (!line.Contains(" "))
             continue;
         if (current == null)
             continue;
         string[] data = line.Split(' ');
         int id = int.Parse(data[0]);
         int count = int.Parse(data[1]);
         current.Add(id, count);
     }
 }
 void Update()
 {
     if (loadedPicCode != cardData.Id)
     {
         Texture2D pic = GameTextureManager.get(cardData.Id, GameTextureType.card_picture);
         if (pic != null)
         {
             loadedPicCode = cardData.Id;
             gameObject.transform.FindChild("face").GetComponent <Renderer>().material.mainTexture = pic;
         }
     }
     if (Program.I().deckManager.currentBanlist != loaded_banlist)
     {
         ban_icon ico = GetComponentInChildren <ban_icon>();
         loaded_banlist = Program.I().deckManager.currentBanlist;
         if (loaded_banlist != null)
         {
             ico.show(loaded_banlist.GetQuantity(cardData.Id));
         }
         else
         {
             ico.show(3);
         }
     }
     if (isDraging)
     {
         gameObject.transform.position += (getGoodPosition(4) - gameObject.transform.position) * 0.3f;
     }
     if (Vector3.Distance(Vector3.zero, gameObject.transform.position) > 50 && bool_physicalON)
     {
         killIt();
     }
 }
Example #3
0
        public int Check(Banlist ban, bool ocg, bool tcg)
        {
            if (Main.Count < 40 || Main.Count > 60 || Extra.Count > 15 || Side.Count > 15)
                return 1;

            IDictionary<int, int> cards = new Dictionary<int, int>();

            IList<int>[] stacks = { Main, Extra, Side };
            foreach (IList<int> stack in stacks)
            {
                foreach (int id in stack)
                {
                    Card card = Card.Get(id);
                    AddToCards(cards, card);
                    if (!ocg && card.Ot == 1 || !tcg && card.Ot == 2)
                        return id;
                }
            }

            if (ban == null)
                return 0;

            foreach (var pair in cards)
            {
                int max = ban.GetQuantity(pair.Key);
                if (pair.Value > max)
                    return pair.Key;
            }

            return 0;
        }
Example #4
0
        public static void initialize(string fileName)
        {
            Banlists = new List <Banlist>();
            Banlist      current = null;
            StreamReader reader  = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                try
                {
                    if (line == null)
                    {
                        continue;
                    }
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    if (line.StartsWith("!"))
                    {
                        current      = new Banlist();
                        current.Name = line.Substring(1, line.Length - 1);
                        Banlists.Add(current);
                        continue;
                    }
                    if (!line.Contains(" "))
                    {
                        continue;
                    }
                    if (current == null)
                    {
                        continue;
                    }
                    string[] data  = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                    int      id    = int.Parse(data[0]);
                    int      count = int.Parse(data[1]);
                    current.Add(id, count);
                }
                catch (System.Exception e)
                {
                    UnityEngine.Debug.Log(line);
                    UnityEngine.Debug.Log(e);
                }
            }
            current      = new Banlist();
            current.Name = "N/A";
            Banlists.Add(current);

            #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
            //移动端显示问题,所以移动端只加载前8个
            if (Banlists.Count > 10)
            {
                for (int i = Banlists.Count - 8; i >= 2; i--)
                {
                    Banlists.RemoveAt(Banlists.Count - i);
                }
            }
            #endif
        }
 void Update()
 {
     if (Program.I().deckManager != null)
     {
         if (loaded_code != code)
         {
             Texture2D t = GameTextureManager.get(code, GameTextureType.card_picture, defaults);
             if (t != null)
             {
                 uiTexture.mainTexture = t;
                 uiTexture.aspectRatio = ((float)t.width) / ((float)t.height);
                 uiTexture.forceWidth((int)(uiTexture.height * uiTexture.aspectRatio));
                 loaded_code    = code;
                 loaded_banlist = null;
             }
         }
         if (loaded_banlist != Program.I().deckManager.currentBanlist)
         {
             loaded_banlist = Program.I().deckManager.currentBanlist;
             if (ico != null)
             {
                 if (loaded_banlist == null)
                 {
                     ico.show(3);
                     return;
                 }
                 ico.show(loaded_banlist.GetQuantity(code));
             }
         }
     }
 }
Example #6
0
        public static void initialize(string fileName)
        {
            if (Banlists == null)
            {
                Banlists = new List <Banlist>();
            }
            Banlist      current = null;
            StreamReader reader  = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                try
                {
                    if (line == null)
                    {
                        continue;
                    }
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    if (line.StartsWith("!"))
                    {
                        current      = new Banlist();
                        current.Name = line.Substring(1, line.Length - 1);
                        Banlists.Add(current);
                        continue;
                    }
                    if (!line.Contains(" "))
                    {
                        continue;
                    }
                    if (current == null)
                    {
                        continue;
                    }
                    string[] data  = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                    int      id    = int.Parse(data[0]);
                    int      count = int.Parse(data[1]);
                    current.Add(id, count);
                }
                catch (System.Exception e)
                {
                    UnityEngine.Debug.Log(line);
                    UnityEngine.Debug.Log(e);
                }
            }
            current      = new Banlist();
            current.Name = "N/A";
            Banlists.Add(current);
        }
Example #7
0
        public static Banlist GetByHash(uint hash)
        {
            Banlist returnValue = Banlists[Banlists.Count - 1];

            foreach (var item in Banlists)
            {
                if (item.Hash == hash)
                {
                    returnValue = item;
                }
            }
            return(returnValue);
        }
Example #8
0
        public static Banlist GetByName(string name)
        {
            Banlist returnValue = Banlists[Banlists.Count - 1];

            foreach (var item in Banlists)
            {
                if (item.Name == name)
                {
                    returnValue = item;
                }
            }
            return(returnValue);
        }
Example #9
0
 void Update()
 {
     if (coli != null)
     {
         if (Program.InputGetMouseButtonDown_0)
         {
             if (Program.pointedCollider == coli)
             {
                 ((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(code), GameTextureManager.myBack, "", true);
             }
         }
     }
     if (Program.I().deckManager != null)
     {
         if (loaded_code != code)
         {
             Texture2D t = GameTextureManager.get(code, GameTextureType.card_picture, defaults);
             if (t != null)
             {
                 uiTexture.mainTexture = t;
                 uiTexture.aspectRatio = ((float)t.width) / ((float)t.height);
                 uiTexture.forceWidth((int)(uiTexture.height * uiTexture.aspectRatio));
                 loaded_code    = code;
                 loaded_banlist = null;
             }
         }
         if (loaded_banlist != Program.I().deckManager.currentBanlist)
         {
             loaded_banlist = Program.I().deckManager.currentBanlist;
             if (ico != null)
             {
                 if (loaded_banlist == null)
                 {
                     ico.show(3);
                     return;
                 }
                 ico.show(loaded_banlist.GetQuantity(code));
             }
             if (ico_ot != null)
             {
                 //[1: OCG]、[2: TCG]、[3: OCG&TCG]、[4: Anime]
                 if (data.Ot == 2 || data.Ot == 4)
                 {
                     ico_ot.show(data.Ot);
                     return;
                 }
                 ico_ot.show(3);
             }
         }
     }
 }
Example #10
0
        public int Check(Banlist ban, bool ocg, bool tcg)
        {
            if (Main.Count < 40 ||
                Main.Count > 60 ||
                Extra.Count > 15 ||
                Side.Count > 15)
            {
                return(1);
            }

            IDictionary <int, int> cards = new Dictionary <int, int>();

            IList <int>[] stacks = { Main, Extra, Side };
            foreach (IList <int> stack in stacks)
            {
                foreach (int id in stack)
                {
                    Card card = Card.Get(id);
                    AddToCards(cards, card);
                    if (!ocg && card.Ot == 1 || !tcg && card.Ot == 2)
                    {
                        return(id);
                    }
                    if (card.HasType(CardType.Token))
                    {
                        return(id);
                    }
                }
            }

            if (ban == null)
            {
                return(0);
            }

            foreach (var pair in cards)
            {
                int max = ban.GetQuantity(pair.Key);
                if (pair.Value > max)
                {
                    return(pair.Key);
                }
            }

            return(0);
        }
Example #11
0
        public int Check(Banlist ban, bool ocg, bool tcg)
        {
            if (Main.Count < Config.GetInt("MainDeckMinSize", 40) ||
                Main.Count > Config.GetInt("MainDeckMaxSize", 60) ||
                Extra.Count > Config.GetInt("ExtraDeckMaxSize", 15) ||
                Side.Count > Config.GetInt("SideDeckMaxSize", 15))
            {
                return(1);
            }

            IDictionary <int, int> cards = new Dictionary <int, int>();

            IList <int>[] stacks = { Main, Extra, Side };
            foreach (IList <int> stack in stacks)
            {
                foreach (int id in stack)
                {
                    Card card = Card.Get(id);
                    AddToCards(cards, card);
                    if (!ocg && card.Ot == 1 || !tcg && card.Ot == 2)
                    {
                        return(id);
                    }
                }
            }

            if (ban == null)
            {
                return(0);
            }

            foreach (var pair in cards)
            {
                int max = ban.GetQuantity(pair.Key);
                if (pair.Value > max)
                {
                    return(pair.Key);
                }
            }

            return(0);
        }
Example #12
0
        public static void Init(string fileName)
        {
            Banlists = new List <Banlist>();
            Banlist      current = null;
            StreamReader reader  = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    continue;
                }
                if (line.StartsWith("#"))
                {
                    continue;
                }
                if (line.StartsWith("!"))
                {
                    current = new Banlist();
                    Banlists.Add(current);
                    continue;
                }
                if (!line.Contains(" "))
                {
                    continue;
                }
                if (current == null)
                {
                    continue;
                }
                string[] data  = line.Split(' ');
                int      id    = int.Parse(data[0]);
                int      count = int.Parse(data[1]);
                current.Add(id, count);
            }
        }
Example #13
0
        internal static List <Card> searchAdvanced(
            string getName,
            int getLevel,
            int getAttack,
            int getDefence,
            int getP,
            int getYear,
            int getLevel_UP,
            int getAttack_UP,
            int getDefence_UP,
            int getP_UP,
            int getYear_UP,
            int getOT,
            string getPack,
            int getBAN,
            Banlist banlist,
            uint getTypeFilter,
            uint getRaceFilter,
            uint getAttributeFilter,
            uint getCatagoryFilter
            )
        {
            List <Card> returnValue = new List <Card>();

            foreach (var item in _cards)
            {
                Card card = item.Value;
                if ((card.Type & (uint)CardType.Token) == 0)
                {
                    if (getName == "" ||
                        Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase) != card.Name ||
                        Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc ||
                        Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase) != card.strSetName ||
                        card.Id.ToString() == getName
                        )
                    {
                        if (((card.Type & getTypeFilter)) == getTypeFilter || getTypeFilter == 0)
                        {
                            if ((card.Race & getRaceFilter) > 0 || getRaceFilter == 0)
                            {
                                if ((card.Attribute & getAttributeFilter) > 0 || getAttributeFilter == 0)
                                {
                                    if (((card.Category & getCatagoryFilter)) == getCatagoryFilter || getCatagoryFilter == 0)
                                    {
                                        if (judgeint(getAttack, getAttack_UP, card.Attack))
                                        {
                                            if (judgeint(getDefence, getDefence_UP, card.Defense))
                                            {
                                                if (judgeint(getLevel, getLevel_UP, card.Level))
                                                {
                                                    if (judgeint(getP, getP_UP, card.LScale))
                                                    {
                                                        if (judgeint(getYear, getYear_UP, card.year))
                                                        {
                                                            if (getBAN == -233 || banlist == null || banlist.GetQuantity(card.Id) == getBAN)
                                                            {
                                                                if (getOT == 0 || getOT == card.Ot)
                                                                {
                                                                    if (getPack == "" || card.packFullName == getPack)
                                                                    {
                                                                        returnValue.Add(card);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            nameInSearch = getName;
            returnValue.Sort(comparisonOfCard());
            nameInSearch = "";
            return(returnValue);
        }
Example #14
0
    string RoomNameFormatter(string roomname)
    {
        string        roomTag = String.Empty;
        List <string> tags    = new List <string>();

        if (Regex.IsMatch(roomname, @"^S,RANDOM#\d{1,}"))
        {
            roomTag = "[8AE57E][Duel] ";
            return(roomTag);
        }
        else if (Regex.IsMatch(roomname, @"^M,RANDOM#\d{1,}"))
        {
            roomTag = "[42C1EC][Match] ";
            return(roomTag);
        }
        else if (Regex.IsMatch(roomname, @"^AI#\S{0,},\d{1,}") || Regex.IsMatch(roomname, @"^AI\S{0,}#\d{1,}"))
        {
            roomTag = "[5E71FF][AI] ";
            return(roomTag);
        }

        if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}NF[,#])?(?(1)|(^NF[#,]))"))
        {
            tags.Add("[C63111][No Banlist] ");
        }
        if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}LF\d[,#])?(?(1)|(^LF\d[#,]))"))
        {
            int banlist            = (int)char.GetNumericValue(roomname[roomname.LastIndexOf("LF") + 2]);
            YGOSharp.Banlist blist = YGOSharp.BanlistManager.Banlists[banlist - 1];
            tags.Add("[DDDDAA][" + blist.Name + "]");
        }
        if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}OO[,#])?(?(1)|(^OO[#,]))"))
        {
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}OT[,#])?(?(1)|(^OT[#,]))"))
            {
                tags.Add("[11C69C][TCG/OCG]");
            }
            else
            {
                tags.Add("[B62FB2][OCG]");
            }
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}S[,#])?(?(1)|(^S[#,]))"))
            {
                tags.Add("[8AE57E][Duel] ");
            }
            else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}M[,#])?(?(1)|(^M[#,]))"))
            {
                tags.Add("[42C1EC][Match] ");
            }
            else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}T[,#])?(?(1)|(^T[#,]))"))
            {
                tags.Add("[D14291][TAG] ");
            }
        }
        else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}TO[,#])?(?(1)|(^TO[#,]))"))
        {
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}OT[,#])?(?(1)|(^OT[#,]))"))
            {
                tags.Add("[11C69C][TCG/OCG]");
            }
            else
            {
                tags.Add("[F58637][TCG]");
            }
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}S[,#])?(?(1)|(^S[#,]))"))
            {
                tags.Add("[8AE57E][Duel] ");
            }
            else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}M[,#])?(?(1)|(^M[#,]))"))
            {
                tags.Add("[42C1EC][Match] ");
            }
            else if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}T[,#])?(?(1)|(^T[#,]))"))
            {
                tags.Add("[D14291][TAG] ");
            }
        }
        else
        {
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}T[,#])?(?(1)|(^T[#,]))"))
            {
                tags.Add("[D14291][TAG]");
            }
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}M[,#])?(?(1)|(^M[#,]))"))
            {
                tags.Add("[42C1EC][Match]");
            }
            if (Regex.IsMatch(roomname, @"(\w{1,}[,^]{1}S[,#])?(?(1)|(^S[#,]))"))
            {
                tags.Add("[8AE57E][Duel]");
            }
        }

        roomTag = String.Join("", tags.ToArray()) + " ";
        if (roomTag == " ")
        {
            roomTag = "[ " + roomname + " ] ";
        }
        if (roomTag.Length > 150)
        {
            roomTag = "[CUSTOM] ";
        }
        return(roomTag);
    }
        internal static List <Card> searchAdvanced(
            string getName,
            int getLevel,
            int getAttack,
            int getDefence,
            int getP,
            int getYear,
            int getLevel_UP,
            int getAttack_UP,
            int getDefence_UP,
            int getP_UP,
            int getYear_UP,
            string getPack,
            int getBAN,
            Banlist banlist,
            uint getTypeFilter,
            uint getRaceFilter,
            uint getAttributeFilter,
            uint getCatagoryFilter
            )
        {
            List <Card> returnValue = new List <Card>();
            var         temp        = getTypeFilter;

            if (temp >= 0x8000000)
            {
                getTypeFilter -= 0x8000000;
            }
            foreach (var item in _cards)
            {
                Card card = item.Value;

                if (card.Id >= 800000000 || card.Id <= 70 || card.Id == 420 || card.Id == 500 || card.Id == 55555 || card.Id == 19558409 || card.Id == 26630260)
                {
                    continue;
                }

                if ((card.Type & (uint)CardType.Token) == 0)
                {
                    if (getName == "" ||
                        Regex.Replace(card.Name, getName, "miaowu", RegexOptions.IgnoreCase) != card.Name ||
                        Regex.Replace(card.Desc, getName, "miaowu", RegexOptions.IgnoreCase) != card.Desc ||
                        Regex.Replace(card.strSetName, getName, "miaowu", RegexOptions.IgnoreCase) != card.strSetName ||
                        card.Id.ToString() == getName
                        )
                    {
                        bool[] BolleanArrayOfCardType = card.Type.ToBooleanArray();
                        if ((temp >= 0x8000000 && ((BolleanArrayOfCardType.Count() >= 6 && !BolleanArrayOfCardType[BolleanArrayOfCardType.Count() - 6]) || BolleanArrayOfCardType.Count() < 6)) || temp <= 0x8000000)
                        {
                            if ((card.Type & getTypeFilter) == getTypeFilter || getTypeFilter == 0)
                            {
                                if ((card.Race & getRaceFilter) > 0 || getRaceFilter == 0)
                                {
                                    if ((card.Attribute & getAttributeFilter) > 0 || getAttributeFilter == 0)
                                    {
                                        if (((card.Category & getCatagoryFilter)) == getCatagoryFilter || getCatagoryFilter == 0)
                                        {
                                            if (judgeint(getAttack, getAttack_UP, card.Attack))
                                            {
                                                if (judgeint(getDefence, getDefence_UP, card.Defense))
                                                {
                                                    if (judgeint(getLevel, getLevel_UP, card.Level))
                                                    {
                                                        if (judgeint(getP, getP_UP, card.LScale))
                                                        {
                                                            if (judgeint(getYear, getYear_UP, card.year))
                                                            {
                                                                if (getBAN == -233 || banlist == null || banlist.GetQuantity(card.Id) == getBAN)
                                                                {
                                                                    if (getPack == "" || card.packFullName == getPack)
                                                                    {
                                                                        returnValue.Add(card);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            nameInSearch = getName;
            returnValue.Sort(comparisonOfCard());
            nameInSearch = "";
            return(returnValue);
        }