Пример #1
0
        public void GetHealed(int healin, List <Modifier> effects)
        {
            var currentHealing = healin;

            foreach (Modifier mod in ModsList)
            {
                if (mod.getHealed())
                {
                    if (mod.target.Equals(""))
                    {
                        currentHealing += mod.value;
                    }
                }
            }

            if (effects != null)
            {
                foreach (Modifier mod in effects)
                {
                    ModsList.Add(mod);
                }
            }

            CurrentHealth += currentHealing;
        }
Пример #2
0
 public void AddMod(Mod m)
 {
     if (m != null)
     {
         ModsList.Add(m);
         m.LinkedProfiles.Add(this);
     }
 }
Пример #3
0
        public void TakeDamage(int amount, string type, List <Modifier> effects)
        {
            var currentArmour  = BaseArmorValue;
            var currentWarding = BaseWarding;

            foreach (Modifier mod in ModsList)
            {
                if (mod.defend())
                {
                    if (mod.target.Equals("Armour"))
                    {
                        currentArmour += mod.value;
                    }
                    else if (mod.target.Equals("Warding"))
                    {
                        currentWarding += mod.value;
                    }
                    else if (mod.target.Equals("Health"))
                    {
                        CurrentHealth += mod.value;
                    }
                }
            }
            if (type.Equals("Physical"))
            {
                CurrentHealth -= amount * (int)((100 - currentArmour) / 100f);
            }
            else if (type.Equals("Magical"))
            {
                CurrentHealth -= amount * (int)((100 - currentWarding) / 100f);
            }

            if (effects != null)
            {
                foreach (Modifier mod in effects)
                {
                    ModsList.Add(mod);
                }
            }

            CheckDeath();
        }
Пример #4
0
        /// <summary>
        /// Gets Moddata from paks if not already in ModList
        /// </summary>
        #region GetModData
        /// <summary>
        /// Gets Moddata from paks if not already in ModList
        /// </summary>
        public async void GetModDataAsync()
        {
            string modDir = Path.Combine(Path.GetDirectoryName(Dos2.ModManager.Properties.Settings.Default.Mods), @"Mods");

            // checks
            #region checks
            if (!Directory.Exists(Dos2.ModManager.Properties.Settings.Default.WorkingDir) ||
                !Directory.Exists(modDir))
            {
                MessageBoxResult result = MessageBox.Show(
                    "No mod directory found. Please check your paths.",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                ParentViewModel.Logger.Status = "Finished With Errors.";
                return;
            }
            if (!Directory.GetFiles(modDir).ToList().Any())
            {
                return;
            }
            #endregion

            try
            {
                List <string> modFiles = Directory.GetFiles(modDir).ToList();

                //Logging Start
                ParentViewModel.Logger.ProgressValue   = 0;
                ParentViewModel.Logger.IsIndeterminate = false;
                ParentViewModel.Logger.LogString("Fetching Mod Data...");
                ParentViewModel.Logger.Status = "Fetching mod data...";

                for (int i = 0; i < modFiles.Count; i++)
                {
                    string modPath = modFiles[i];

                    //get UUID
                    string uuid = Path.GetFileNameWithoutExtension(modPath).Split('_').Last();
                    string meta = "";

                    //check if mod is already in ModList
                    // FIXME check for updates
                    if (!ModsList.Where(x => x.UUID.Equals(uuid)).Any())
                    {
                        meta = await Task.Run(() => ParentViewModel.pt.ExtractModMeta(modPath));

                        if (String.IsNullOrEmpty(meta))
                        {
                            continue;
                        }

                        //interpret meta.lsx
                        Dos2Mod mod = InterpretModMeta(meta);
                        mod.PakPath = modPath;

                        //add to modslist
                        ModsList.Add(mod);
                    }
                    else
                    {
                        //is updated
                        Dos2Mod oldmod = ModsList.FirstOrDefault(x => x.UUID.Equals(uuid));
                        if (oldmod.IsUpdated)
                        {
                            //extract meta.lsx and interpret

                            //replace existing mod
                            throw new NotImplementedException();
                        }
                        else
                        {
                            //do nothing.
                        }
                    }

                    //Logging Progress
                    int prg = Convert.ToInt32(100 / (modFiles.Count - 1) * i);
                    ParentViewModel.Logger.ProgressValue = prg;
                }

                //Logging End
                ParentViewModel.Logger.IsIndeterminate = false;
                ParentViewModel.Logger.Status          = "Finished.";
                ParentViewModel.Logger.LogString("Finished fetching mod data...");
                ParentViewModel.Logger.NotifyStatusChanged();

                // populate files list for mods
                GetModFilesAsync();
                ApplyModSettings(ParentViewModel.ActiveProfile);
            }
            catch (Exception e)
            {
                MessageBoxResult result = MessageBox.Show(
                    "Something went wrong when trying to load mod data. Please check your paths.",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ParentViewModel.Logger.Status = "Finished With Errors.";
                ParentViewModel.Logger.LogString("Something went wrong when trying to load mod data. Please check your paths.");
                ParentViewModel.Logger.LogString(e.ToString());
                return;
            }
        }
Пример #5
0
 public void Modify(Modifier mod)
 {
     ModsList.Add(mod);
 }