Beispiel #1
0
        private void updateWeapon(ref Wiki db)
        {
            var          responseString = CML.ComUrl.Post(API, Param.QueryWeapon, proxyip, proxyport);
            QueryWeapons tmp            = CML.ComUtility.FromJson <QueryWeapons>(responseString);

            foreach (string name in tmp.query.results.Keys)
            {
                Dictionary <string, object[]> props = tmp.query.results[name].printouts;

                dal.Weapon w = new dal.Weapon {
                    Name = name
                };

                w.Damage      = getPrintoutAsInt(props, "Might1");
                w.Effect      = db.weaponeffects.And(getPrintoutAsStr(props, "Effect1")).Id;
                w.Range       = getPrintoutAsInt(props, "Range1");
                w.Cost        = getPrintoutAsInt(props, "Cost1");
                w.IsExclusive = getPrintoutAsStr(props, "Is exclusive").ToUpper().Equals("T");

                db.weapons.And(w);
            }
        }
Beispiel #2
0
        private void updateHeroesStats(ref Wiki db)
        {
            var responseString   = CML.ComUrl.Post(API, Param.QueryHeroesStats, proxyip, proxyport);
            QueryHeroesStats tmp = CML.ComUtility.FromJson <QueryHeroesStats>(responseString);

            int[]    Lvs     = new int[] { 1, 40 };
            int[]    Raritys = new int[] { 3, 4, 5 };
            string[] Props   = new string[] { "HP", "ATK", "SPD", "DEF", "RES" };
            string[] Vars    = new string[] { "Bane", "Neut", "Boon" };

            foreach (string name in tmp.query.results.Keys)
            {
                dal.Hero h = CML.ComUtility.QueryFirst(from x in db.heroes.Query() where x.Name == name select x, null);
                if (h != null)
                {
                    foreach (int Lv in Lvs)
                    {
                        foreach (int Rarity in Raritys)
                        {
                            for (int i = 0; i < Vars.Length; i++)
                            {
                                dal.HeroEntity entity = new dal.HeroEntity()
                                {
                                    Level     = Lv,
                                    Rarity    = Rarity,
                                    HeroId    = h.Id,
                                    Variation = i - 1,
                                };

                                List <int> PropValue = new List <int>();

                                Dictionary <string, string[]> prints = tmp.query.results[name].printouts;

                                foreach (string Prop in Props)
                                {
                                    string key = string.Format("Lv{0}R{1}{2}{3}", Lv, Rarity, Prop, Vars[i]);
                                    if (prints.Keys.Contains(key) && prints[key].Length > 0)
                                    {
                                        if (prints[key].Length > 1)
                                        {
                                            Console.WriteLine("TooMany!");
                                        }
                                        PropValue.Add(CML.ComUtility.XInt(prints[key][0], 0));
                                    }
                                    else
                                    {
                                        PropValue.Add(0);
                                    }
                                }

                                entity.HP  = PropValue[0];
                                entity.ATK = PropValue[1];
                                entity.SPD = PropValue[2];
                                entity.DEF = PropValue[3];
                                entity.RES = PropValue[4];

                                dal.Weapon w = CML.ComUtility.QueryFirst(from x in db.weapons.Query()
                                                                         where x.Id == h.Weapon[Rarity - 1]
                                                                         select x, null);

                                if (w != null)
                                {
                                    entity.W_ATK = w.Damage;
                                    if (w.Effect == 15)
                                    {
                                        //Console.WriteLine(w.Name);
                                        entity.W_SPD = -5;
                                    }
                                }

                                if (entity.HP > 0 || entity.ATK > 0 || entity.SPD > 0 || entity.DEF > 0 || entity.RES > 0)
                                {
                                    if (entity.HP > 0 && entity.ATK > 0 && entity.SPD > 0 && entity.DEF > 0 && entity.RES > 0)
                                    {
                                        db.stats.And(entity);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Has Zero!");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }