Esempio n. 1
0
        public async Task <IActionResult> PutHopType(int id, HopType hopType)
        {
            if (id != hopType.HopTypeId)
            {
                return(BadRequest());
            }

            _context.Entry(hopType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HopTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult <HopType> > PostHopType(HopType hopType)
        {
            _context.HopType.Add(hopType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHopType", new { id = hopType.HopTypeId }, hopType));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Type")] HopType hopType)
        {
            if (id != hopType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hopType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HopTypeExists(hopType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hopType));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("Id,Type")] HopType hopType)
        {
            if (ModelState.IsValid)
            {
                hopType.Id = Guid.NewGuid();
                _context.Add(hopType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hopType));
        }
        /// <summary>
        /// Поменять текущее состояние в базе данных или содать это состояние.
        /// </summary>
        /// <param name="chatId"></param>
        /// <param name="hopType"></param>
        /// <param name="newStateName"></param>
        private static void ChangeCurrentChatState(long chatId, HopType hopType, string newStateName)
        {
            using (BotDbContext db = new BotDbContext(HelperDataBase.DB_OPTIONS))
            {
                //Возьмем значение состояния из базы
                ChatState chatState =
                    (from s in db.ChatState
                     where s.ChatId == chatId
                     select s).FirstOrDefault();

                string stateString = chatState?.State;

                //Если ячейка в базе пустая, то заполним её чем-нибудь и поменяем тип хопа чтобы потом переписать несусветицу.
                if (string.IsNullOrEmpty(stateString?.Trim(' ')))
                {
                    stateString = "___";
                    hopType     = HopType.RootLevelHope;
                }

                //Поменять состояние в базе данных.
                StateController stateCtrl = new StateController(stateString);

                //Будем изменять значение состояния в зависимости от типа перехода состояния.
                switch (hopType)
                {
                case HopType.NextLevelHope:
                    stateCtrl.AddStateAsNextState(newStateName);
                    break;

                case HopType.CurrentLevelHope:
                    stateCtrl.ChangeCurrentStateName(newStateName);
                    break;

                case HopType.RootLevelHope:
                    stateCtrl.SetRootState(newStateName);
                    break;
                }

                //получаем измененную строку состояния и сохраняем в базу
                string newStateString = stateCtrl.State;
                chatState.State = newStateString;
                db.SaveChanges();
            }
        }
Esempio n. 6
0
 public void Import(ClientSkill importObject, IEnumerable <FieldInfo> getters)
 {
     foreach (var fd in getters)
     {
         List <int> valueList   = new List <int>();
         int        fdNameStart = fd.Name.IndexOf('_');
         string     effectName  = fd.Name.Substring(0, fdNameStart);
         char       n           = effectName[effectName.Length - 1];
         e = Int32.Parse(n.ToString());
         string fdName = fd.Name.Substring(fdNameStart, fd.Name.Length - fdNameStart);
         if (fdName.StartsWith("_acc_mod"))
         {
             string ns     = fdName.Remove(0, 8);
             int    number = Int32.Parse(ns);
             if (accuracy_modifiers == null)
             {
                 accuracy_modifiers = new int?[number];
             }
             else if (number > accuracy_modifiers.Length)
             {
                 Array.Resize(ref accuracy_modifiers, number);
             }
             accuracy_modifiers[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName == "_basiclv")
         {
             basiclv = (int)fd.GetValue(importObject);
         }
         else if (fdName == "_checktime")
         {
             checktime = (int)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_critical_add_dmg_mod"))
         {
             string ns     = fdName.Remove(0, 21);
             int    number = Int32.Parse(ns);
             if (critical_add_dmg_modifiers == null)
             {
                 critical_add_dmg_modifiers = new int?[number];
             }
             else if (number > critical_add_dmg_modifiers.Length)
             {
                 Array.Resize(ref critical_add_dmg_modifiers, number);
             }
             critical_add_dmg_modifiers[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_critical_prob_mod"))
         {
             string ns     = fdName.Remove(0, 18);
             int    number = Int32.Parse(ns);
             if (critical_prob_modifiers == null)
             {
                 critical_prob_modifiers = new int?[number];
             }
             else if (number > critical_prob_modifiers.Length)
             {
                 Array.Resize(ref critical_prob_modifiers, number);
             }
             critical_prob_modifiers[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName == "_effectid")
         {
             effectid = (int)fd.GetValue(importObject);
         }
         else if (fdName == "_hidemsg")
         {
             hidemsg = (bool)fd.GetValue(importObject);
         }
         else if (fdName == "_hop_a")
         {
             hop_a = (int)fd.GetValue(importObject);
         }
         else if (fdName == "_hop_b")
         {
             hop_b = (int)fd.GetValue(importObject);
         }
         else if (fdName == "_hop_type")
         {
             string value = (string)fd.GetValue(importObject);
             if (value == null)
             {
                 hop_type = HopType.NONE;
             }
             else
             {
                 hop_type = (HopType)Enum.Parse(typeof(HopType), value, true);
             }
         }
         else if (fdName == "_noresist")
         {
             noresist = (bool)fd.GetValue(importObject);
         }
         else if (fdName == "_randomtime")
         {
             randomtime = (int)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_remain"))
         {
             string ns     = fdName.Remove(0, 7);
             int    number = Int32.Parse(ns);
             if (remain == null)
             {
                 remain = new int?[number];
             }
             else if (number > remain.Length)
             {
                 Array.Resize(ref remain, number);
             }
             remain[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName == "_reserved_cond1")
         {
             reserved_cond1 = (string)fd.GetValue(importObject);
         }
         else if (fdName == "_reserved_cond2")
         {
             reserved_cond2 = (string)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_reserved_cond1_prob"))
         {
             string ns     = fdName.Remove(0, 20);
             int    number = Int32.Parse(ns);
             if (reserved_cond1_prob == null)
             {
                 reserved_cond1_prob = new int?[number];
             }
             else if (number > reserved_cond1_prob.Length)
             {
                 Array.Resize(ref reserved_cond1_prob, number);
             }
             reserved_cond1_prob[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_reserved_cond2_prob"))
         {
             string ns     = fdName.Remove(0, 20);
             int    number = Int32.Parse(ns);
             if (reserved_cond2_prob == null)
             {
                 reserved_cond2_prob = new int?[number];
             }
             else if (number > reserved_cond2_prob.Length)
             {
                 Array.Resize(ref reserved_cond2_prob, number);
             }
             reserved_cond2_prob[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_reserved"))
         {
             string ns     = fdName.Remove(0, 9);
             int    number = Int32.Parse(ns);
             if (reserved == null)
             {
                 reserved = new string[number];
             }
             else if (number > reserved.Length)
             {
                 Array.Resize(ref reserved, number);
             }
             string value = (string)fd.GetValue(importObject);
             int    valueInt;
             if (value == null || number != 13 || Int32.TryParse(value, out valueInt))
             {
                 reserved[number - 1] = value;
             }
             else
             {
                 try {
                     Stat stat = (Stat)Enum.Parse(typeof(Stat), value, true);
                     ChangeStat           = stat;
                     reserved[number - 1] = stat.ToString();
                 } catch {
                     Debug.Print("Unknown reserved13: {0}", value);
                 }
             }
         }
         else if (fdName == "_target_type")
         {
             target_type = (string)fd.GetValue(importObject);
         }
         else if (fdName == "_type")
         {
             string value = (string)fd.GetValue(importObject);
             if (value == null)
             {
                 type = EffectType.None;
             }
             else
             {
                 try {
                     type = (EffectType)Enum.Parse(typeof(EffectType), value, true);
                 } catch {
                     Debug.Print("Unknown effect: {0}", value);
                 }
             }
         }
         else if (fdName.StartsWith("_cond_race_prob"))
         {
             string ns     = fdName.Remove(0, 15);
             int    number = Int32.Parse(ns);
             if (cond_race_prob == null)
             {
                 cond_race_prob = new int?[number];
             }
             else if (number > cond_race_prob.Length)
             {
                 Array.Resize(ref cond_race_prob, number);
             }
             cond_race_prob[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName == "_cond_race")
         {
             cond_race = (string)fd.GetValue(importObject);
         }
         else if (fdName.StartsWith("_cond_attack_dir_prob"))
         {
             string ns     = fdName.Remove(0, 21);
             int    number = Int32.Parse(ns);
             if (cond_attack_dir_prob == null)
             {
                 cond_attack_dir_prob = new int?[number];
             }
             else if (number > cond_attack_dir_prob.Length)
             {
                 Array.Resize(ref cond_attack_dir_prob, number);
             }
             cond_attack_dir_prob[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName == "_cond_attack_dir")
         {
             string value = (string)fd.GetValue(importObject);
             if (value != null)
             {
                 cond_attack_dir = value.Trim() != "0";
             }
         }
         else if (fdName.StartsWith("_cond_preeffect_prob"))
         {
             string ns     = fdName.Remove(0, 20);
             int    number = Int32.Parse(ns);
             if (cond_preeffect_prob == null)
             {
                 cond_preeffect_prob = new int?[number];
             }
             else if (number > cond_preeffect_prob.Length)
             {
                 Array.Resize(ref cond_preeffect_prob, number);
             }
             cond_preeffect_prob[number - 1] = (int?)fd.GetValue(importObject);
         }
         else if (fdName == "_cond_preeffect")
         {
             cond_preeffect = (PreeffectNumber)fd.GetValue(importObject);
         }
         else if (fdName == "_cond_status")
         {
             cond_status = (string)fd.GetValue(importObject);
         }
     }
 }
Esempio n. 7
0
        public TheNoobViewer()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            InitializeComponent();
            ZoomCombo.Items.Add("Zoom: 200%");
            ZoomCombo.Items.Add("Zoom: 100%");
            ZoomCombo.Items.Add("Zoom: 50%");
            ZoomCombo.Items.Add("Zoom: 25%");
            ZoomCombo.Items.Add("Zoom: 15%");
            ZoomCombo.SelectedIndex = 1;
            Hops = new List <Hop>();
            zoom = 1;
            path = Application.StartupPath;

            menuWebLink.Text = "The Noob Bot";
            ignorewater      = false;
            textBox1.Visible = false;
            Azeroth.Checked  = true;
            continent        = "Azeroth";
            toolStripStatusContinent.Text = "Current continent: Azeroth";
            // Open Sasc storage
            cascLoaded = false;
            cascLoader = new Thread(new ThreadStart(OpenSACS));
            cascLoader.Start();
            // Now load the npcdb
            try
            {
                System.IO.Stream fileStream = System.IO.File.Open("NpcDB.xml", System.IO.FileMode.Open);
                XmlTextReader    reader     = new XmlTextReader(fileStream);
                bool             good       = false;
                while (reader.Read())
                {
                    if (reader.Name == "ArrayOfNpc")
                    {
                        good = true;
                        break;
                    }
                }
                reader.Close();
                if (!good)
                {
                    return;
                }
                NpcDB = new List <Hop>();
                XmlDocument doc = new XmlDocument();
                doc.Load("NpcDB.xml");
                XmlNodeList AllNpcs = doc.SelectNodes("/ArrayOfNpc/Npc");;

                foreach (XmlNode OneNPC in AllNpcs)
                {
                    XmlNode position = OneNPC.SelectSingleNode("Position");
                    float   X        = float.Parse(position.SelectSingleNode("X").InnerText);
                    float   Y        = float.Parse(position.SelectSingleNode("Y").InnerText);
                    float   Z        = float.Parse(position.SelectSingleNode("Z").InnerText);

                    string faction = OneNPC.SelectSingleNode("Faction") != null?OneNPC.SelectSingleNode("Faction").InnerText : "";

                    string  basecontinent = OneNPC.SelectSingleNode("ContinentId").InnerText;
                    string  npccontinent;
                    HopType iFaction = HopType.Alliance;
                    switch (faction)
                    {
                    case "Horde":
                        iFaction = HopType.Horde;
                        break;

                    case "Alliance":
                        iFaction = HopType.Alliance;
                        break;

                    default:
                        iFaction = HopType.Neutral;
                        break;
                    }
                    switch (basecontinent)
                    {
                    case "Pandaria":
                        npccontinent = "HawaiiMainLand";
                        break;

                    case "Outland":
                        npccontinent = "Expansion01";
                        break;

                    case "Maelstrom":
                        npccontinent = "Deephome";
                        break;

                    default:
                        npccontinent = basecontinent;
                        break;
                    }
                    Hop h = new Hop {
                        Location = new Vector3(X, Y, Z), Continent = npccontinent, Type = iFaction
                    };
                    NpcDB.Add(h);
                }
            }
            catch (System.IO.IOException)
            {
            }
        }
Esempio n. 8
0
        /*
         *      [XmlAttribute]
         *      [DefaultValue("0")]
         *      public string preeffects_mask;
         *
         *      [XmlIgnore]
         *      public bool preeffects_mask_probSpecified;
         *
         *      [XmlAttribute]
         *      [DefaultValue(1)]
         *      public decimal critical_prob;
         *
         *      [XmlAttribute]
         *      [DefaultValue(TargetState.NONE)]
         *      public TargetState cond_effect;
         */

        //[XmlElement]
        //[DefaultValue(null)]
        //public Conditions conditions;

        #region IDynamicImport<ClientEffect> Members

        public virtual void Import(ClientEffect importObject, IEnumerable <FieldInfo> getters)
        {
            effectid = importObject.effectid;
            e        = importObject.e;
            basiclvl = importObject.basiclv;
            hoptype  = importObject.hop_type;
            hopa     = importObject.hop_a;
            hopb     = importObject.hop_b;
            if (importObject.remain[1].HasValue && importObject.remain[1].Value != 0)
            {
                duration = importObject.remain[1].Value;
            }
            if (importObject.remain[0].HasValue)
            {
                duration += importObject.remain[0].Value;
            }
            randomtime = importObject.randomtime;
            noresist   = importObject.noresist;

            if (importObject.accuracy_modifiers != null && importObject.accuracy_modifiers[0] != null)
            {
                acc_mod1 = importObject.accuracy_modifiers[0].Value;
            }

            /*
             *          if (importObject.accuracy_modifiers != null && importObject.accuracy_modifiers[1] != null)
             *                  acc_mod2 = importObject.accuracy_modifiers[1].Value;
             */
            if (this is OverTimeEffect || this is SpellAtkDrainEffect || this is DiseaseEffect)
            {
                checktime = importObject.checktime;
            }

            if (importObject.reserved[9] != null)
            {
                try {
                    element = (SkillElement)(Enum.Parse(typeof(SkillElement), importObject.reserved[9].Trim(), true));
                    if (!Enum.IsDefined(typeof(SkillElement), element))
                    {
                        element = SkillElement.NONE;
                    }
                }
                catch {
                    Debug.Print("R9: {0}", importObject.reserved[9]);
                }
            }

            /*
             *          if (importObject.cond_preeffect != null) {
             *                  this.preeffects_mask = importObject.cond_preeffect.Substring(1, importObject.cond_preeffect.Length -1);
             *          }
             *
             *           Moved to Conditions List Below
             *          if (importObject.critical_prob_modifiers[1] != null) {
             *                  this.critical_prob = importObject.critical_prob_modifiers[1].Value;
             *          }
             *          else {
             *                  this.critical_prob = 1;
             *          }
             *
             *          if (!String.IsNullOrEmpty(importObject.cond_status)) {
             *                  NamedEnum<TargetState> v = new NamedEnum<TargetState>(importObject.cond_status);
             *                  TargetState state = v;
             *                  this.cond_effect = state;
             *          }
             */

            //if (!String.IsNullOrEmpty(importObject.cond_status)) {
            //    NamedEnum<TargetState> v = new NamedEnum<TargetState>(importObject.cond_status);
            //    TargetState state = v;

            //    if (this.conditions == null)
            //        this.conditions = new Conditions();
            //    if (this.conditions.ConditionList == null)
            //        this.conditions.ConditionList = new List<Condition>();
            //    /*
            //    switch (state) {
            //        case TargetState.NON_FLYING: this.conditions.ConditionList.Add(new NoFlyCondition()); break;
            //        case TargetState.FLYING: this.conditions.ConditionList.Add(new TargetFlyingCondition()); break;
            //        default: this.conditions.ConditionList.Add(new AbnormalCondition(state)); break;
            //    }
            //     */
            //}
        }
Esempio n. 9
0
        public virtual void Import(ClientEffect importObject, IEnumerable <FieldInfo> getters)
        {
            effectid = importObject.effectid;
            e        = importObject.e;
            basiclvl = importObject.basiclv;
            hoptype  = importObject.hop_type;
            hopa     = importObject.hop_a;
            hopb     = importObject.hop_b;
            if (importObject.remain[1].HasValue && importObject.remain[1].Value != 0)
            {
                duration = importObject.remain[1].Value;
            }
            if (importObject.remain[0].HasValue)
            {
                duration += importObject.remain[0].Value;
            }
            randomtime = importObject.randomtime;
            noresist   = importObject.noresist;

            if (importObject.accuracy_modifiers != null && importObject.accuracy_modifiers[1] != null)
            {
                acc_mod = importObject.accuracy_modifiers[1].Value;
            }

            if (this is OverTimeEffect || this is SpellAtkDrainEffect || this is DiseaseEffect)
            {
                checktime = importObject.checktime;
            }
            if (importObject.reserved[8] != null)
            {
                onfly = importObject.reserved[8].Trim() == "1";
            }
            if (importObject.reserved[9] != null)
            {
                try {
                    element = (SkillElement)(Enum.Parse(typeof(SkillElement), importObject.reserved[9].Trim(), true));
                    if (!Enum.IsDefined(typeof(SkillElement), element))
                    {
                        element = SkillElement.NONE;
                    }
                } catch {
                    Debug.Print("R9: {0}", importObject.reserved[9]);
                }
            }

            if (importObject.cond_preeffect != PreeffectNumber.NONE)
            {
                this.preeffects_mask = (int)importObject.cond_preeffect;
                if (importObject.cond_preeffect_prob[1] != null)
                {
                    this.preeffect_prob = importObject.cond_preeffect_prob[1].Value / 100m;
                }
                else
                {
                    this.preeffect_prob = 1;
                }
            }

            if (this.preeffect_prob != 1 && e > 1)
            {
                this.preeffect_probSpecified = true;
            }

            if (importObject.critical_prob_modifiers[1] != null)
            {
                this.critical_prob = importObject.critical_prob_modifiers[1].Value / 100m;
            }
            else
            {
                this.critical_prob = 1;
            }

            if (!String.IsNullOrEmpty(importObject.cond_status))
            {
                NamedEnum <TargetState> v     = new NamedEnum <TargetState>(importObject.cond_status);
                TargetState             state = v;
                this.cond_effect = state;
            }
        }