Exemple #1
0
 public SubRaceEditModel(SubRace cond, OGLContext context) : base(cond, context)
 {
     if (cond.RaceName == null)
     {
         cond.RaceName = "*";
     }
     ShowImage = new Command(async() =>
     {
         await Navigation.PushAsync(new ImageEditor(Image, Model.ImageData, SaveImage, "Image"));
     });
     SaveImage = new Command(async(par) =>
     {
         MakeHistory();
         Model.ImageData = par as byte[];
         OnPropertyChanged("Image");
         await Navigation.PopAsync();
     });
     SaveCostumRace = new Command((par) =>
     {
         if (par is string s)
         {
             Races.Add(s);
             ParentRace = s;
         }
     });
     Races.AddRange(context.RacesSimple.Keys);
     Races.Add("*");
     if (!Races.Contains(cond.RaceName))
     {
         Races.Add(cond.RaceName);
     }
     Races.Add(CUSTOM);
 }
    public QuestViewModel(IQuestTemplate template, IMiniIcons miniIcons)
    {
        RequiresConnector     = AddInputConnector(ConnectorAttachMode.Top, "", Colors.Aqua);
        IsRequiredByConnector = AddOutputConnector(ConnectorAttachMode.Bottom, "", Colors.Aqua);
        LeftInputConnector    = AddInputConnector(ConnectorAttachMode.Left, "", Colors.Red);
        RightOutputConnector  = AddOutputConnector(ConnectorAttachMode.Right, "", Colors.Red);
        Entry = template.Entry;
        Name  = template.Name;

        if (template.AllowableClasses != CharacterClasses.None &&
            !miniIcons.IsAllClasses(template.AllowableClasses))
        {
            Classes = new();
            foreach (var classMiniIconViewModel in miniIcons.SupportedClasses)
            {
                if (template.AllowableClasses.HasFlag(classMiniIconViewModel.Class))
                {
                    Classes.Add(classMiniIconViewModel);
                }
            }
        }

        foreach (var icon in miniIcons.GetRaceIcons(template.AllowableRaces))
        {
            Races ??= new();
            Races.Add(icon);
        }
    }
Exemple #3
0
        void AddNewRaceExec()
        {
            var newRace = new RacialBonus();

            CharacterManager.RacialBonuses.Add(newRace);
            Races.Add(new RaceViewModel(newRace));
            RaisePropertyChanged("Races");
        }
Exemple #4
0
        /// <summary>
        /// subscribed to event
        /// loads horses from the file data services
        /// async void eventhandler testing credits: https://stackoverflow.com/a/19415703/11027921
        /// delegates https://docs.microsoft.com/en-us/dotnet/api/system.eventhandler?view=netframework-4.8
        /// </summary>
        public async void OnLoadAllDataAsync()
        {
            string callersName = GetCallerName();

            CommandStartedControlsSetup(callersName);

            if (Horses.Count == 0 && Jockeys.Count == 0 && Races.Count == 0)
            {
                List <LoadedHorse> horses = await _dataServices.GetAllHorsesAsync();

                List <LoadedJockey> jockeys = await _dataServices.GetAllJockeysAsync();

                List <RaceDetails> races = await _dataServices.GetAllRacesAsync();

                foreach (var horse in horses)
                {
                    Horses.Add(new LoadedHorse
                    {
                        Name        = horse.Name,
                        Age         = horse.Age,
                        AllRaces    = horse.AllRaces,
                        AllChildren = horse.AllChildren,
                        Father      = horse.Father,
                        Link        = horse.Link,
                        FatherLink  = horse.FatherLink
                    });
                }

                Horses = Horses.OrderBy(o => o.Age).ToList();

                foreach (var jockey in jockeys)
                {
                    Jockeys.Add(new LoadedJockey
                    {
                        Name     = jockey.Name,
                        AllRaces = jockey.AllRaces,
                        Link     = jockey.Link
                    });
                }

                foreach (var race in races)
                {
                    Races.Add(new RaceDetails
                    {
                        RaceCategory = race.RaceCategory,
                        RaceDate     = race.RaceDate,
                        RaceDistance = race.RaceDistance,
                        RaceLink     = race.RaceLink,
                        HorseList    = race.HorseList
                    });
                }
            }

            PopulateLists();

            CommandCompletedControlsSetup();
            ResetControls();
        }
Exemple #5
0
        public void SelectCourse(Course course)
        {
            if (Players.Keys.Count < Constants.NumCharacters)
            {
                throw new ApplicationException("Cannot select a course until all players have been created");
            }

            Races.Add(new Race(Players.Keys.ToArray(), course));
        }
        private void CmdConvertOldConfigFile(Player player, string cmd)
        {
            if (!player.HasPermission("RaceSystem.Modify"))
            {
                player.SendError(GetMessage("NoPermission", player)); return;
            }

            Races.Clear();

            var races = GetConfig("Races", "Names", new List <object> {
                "Dwarf", "Elf", "Human", "Orc"
            }).OfType <string>().ToList();

            foreach (var race in races)
            {
                var color = GetConfig("Colors", race, "[9f0000]");
                color = color.Replace("[", "");
                color = color.Replace("]", "");
                Races.Add(new Race(race, color));
            }

            try
            {
                var oldData = Interface.Oxide.DataFileSystem.ReadObject <Dictionary <ulong, OldPlayerData> >("RaceSystem");
                if (oldData != null)
                {
                    foreach (var data in oldData)
                    {
                        if (data.Value.Race.IsNullOrEmpty())
                        {
                            continue;
                        }
                        var race = Races.FirstOrDefault(r => string.Equals(r.Name, data.Value.Race, StringComparison.CurrentCultureIgnoreCase));
                        if (race != null)
                        {
                            Data.Add(data.Key, new PlayerData(data.Value.CanChange, race));
                        }
                    }
                }
            }
            catch
            {
                Puts("Could not load old data file.");
            }

            player.SendMessage(GetMessage("DefaultRestored", player), ChangeTime);

            SaveRaceData();
        }
Exemple #7
0
        private async Task UpdateRacesAsync(string jobType, int id)
        {
            RaceDetails race = new RaceDetails();

            race = await _scrapDataService.ScrapGenericObject <RaceDetails>(id, jobType);

            //if the race is from 2018
            if (race != null)
            {
                if (race.RaceDate.Year == 2018)
                {
                    lock (((ICollection)Races).SyncRoot)
                    {
                        Races.Add(race);
                    }
                }
            }
        }
        private void AddRace(Player player, string[] args)
        {
            if (!player.HasPermission("RaceSystem.Modify"))
            {
                player.SendError(GetMessage("NoPermission", player)); return;
            }

            if (args.Length != 1)
            {
                player.SendError(GetMessage("InvalidArgs", player)); return;
            }

            var name = args[0];

            if (Races.FirstOrDefault(r => string.Equals(r.Name, name, StringComparison.CurrentCultureIgnoreCase)) != null)
            {
                player.SendError(GetMessage("RaceExists", player)); return;
            }

            Races.Add(new Race(name, "9f0000"));
            player.SendMessage(GetMessage("RaceAdded", player), name);

            SaveRaceData();
        }
Exemple #9
0
        protected async override void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            _userDialogs.ShowLoading("Retrieving All Races");
            var user = await _userManager.GetUser();

            if (_userManager.IsAnonymous(user))
            {
                Races.Clear();
            }
            else if (Races.Count == 0)
            {
                var races = await _dataService.GetRaces(user);

                var orderedRaces = races.OrderBy(x => x.RaceDate);
                foreach (var race in orderedRaces)
                {
                    Races.Add(race);
                }
            }
            SelectedRace = null;
            _userDialogs.HideLoading();
        }
Exemple #10
0
        /// <summary>
        /// Reads the Races.lsx file and converts it into a Race list.
        /// </summary>
        /// <param name="pak">The pak to search in.</param>
        /// <returns>Whether the root template was read.</returns>
        private bool ReadRaces(string pak)
        {
            var raceFile = FileHelper.GetPath($"{pak}\\Public\\{pak}\\Races\\Races.lsx");

            if (File.Exists(raceFile))
            {
                using (XmlReader reader = XmlReader.Create(raceFile))
                {
                    Race race = null;
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                            var id = reader.GetAttribute("id");
                            if (id == "Race")
                            {
                                race = new Race {
                                    Components = new List <Component>()
                                };
                            }
                            var value = reader.GetAttribute("value");
                            if (reader.Depth == 5)     // top level
                            {
                                switch (id)
                                {
                                case "Description":
                                    race.DescriptionHandle = value;
                                    // TODO load description
                                    break;

                                case "DisplayName":
                                    race.DisplayNameHandle = value;
                                    // TODO load display name
                                    break;

                                case "Name":
                                    race.Name = value;
                                    break;

                                case "ParentGuid":
                                    race.ParentGuid = value;
                                    break;

                                case "ProgressionTableUUID":
                                    race.ProgressionTableUUID = value;
                                    break;

                                case "UUID":
                                    race.UUID = new Guid(value);
                                    break;
                                }
                            }
                            if (reader.Depth == 6)     // eye colors, hair colors, tags, makeup colors, skin colors, tattoo colors, visuals
                            {
                                race.Components.Add(new Component {
                                    Type = id
                                });
                            }
                            if (reader.Depth == 7)     // previous level values
                            {
                                race.Components.Last().Guid = value;
                            }
                            break;

                        case XmlNodeType.EndElement:
                            if (reader.Depth == 4)
                            {
                                Races.Add(race);
                            }
                            break;
                        }
                    }
                }
                return(true);
            }
            GeneralHelper.WriteToConsole($"Failed to load Races.lsx for {pak}.pak.\n");
            return(false);
        }
Exemple #11
0
            public void ImportRaces(ArrayList rows)
            {
                //	import all races
                NRace caucasian = new NRace(0, "Caucasian");

                Races.Add(caucasian);
                caucasian.MaleData.Import(AgeRanges, rows, "white male pop", "white male err");
                caucasian.FemaleData.Import(AgeRanges, rows, "white female pop", "white female err");

                NRace black = new NRace(1, "Black");

                Races.Add(black);
                black.MaleData.Import(AgeRanges, rows, "black male pop", "black male err");
                black.FemaleData.Import(AgeRanges, rows, "black female pop", "black female err");

                NRace nativeAmerican = new NRace(2, "Native American");

                Races.Add(nativeAmerican);
                nativeAmerican.MaleData.Import(AgeRanges, rows, "indian + alaska male pop", "indian + alaska male err");
                nativeAmerican.FemaleData.Import(AgeRanges, rows, "indian + alaska female pop", "indian + alaska female err");

                NRace asian = new NRace(3, "Asian");

                Races.Add(asian);
                asian.MaleData.Import(AgeRanges, rows, "asian male pop", "asian male err");
                asian.FemaleData.Import(AgeRanges, rows, "asian female pop", "asian female err");

                NRace pacificNatvies = new NRace(4, "Pacific Natives");

                Races.Add(pacificNatvies);
                pacificNatvies.MaleData.Import(AgeRanges, rows, "pacific male pop", "pacific male err");
                pacificNatvies.FemaleData.Import(AgeRanges, rows, "pacific female pop", "pacific female err");

                NRace otherSomeRace = new NRace(5, "Other Some Race");

                Races.Add(otherSomeRace);
                otherSomeRace.MaleData.Import(AgeRanges, rows, "race male pop", "race male err");
                otherSomeRace.FemaleData.Import(AgeRanges, rows, "race female pop", "race female err");

                NRace twoOrMoreRaces = new NRace(6, "Two or More Races");

                Races.Add(twoOrMoreRaces);
                twoOrMoreRaces.MaleData.Import(AgeRanges, rows, "mixed male pop", "mixed male err");
                twoOrMoreRaces.FemaleData.Import(AgeRanges, rows, "mixed female pop", "mixed female err");

                //	calculate the totals
                int rowsLength = rows.Count;

                for (int j = 0; j < rowsLength; j++)
                {
                    int totalMalePopulation   = 0;
                    int totalFemalePopulation = 0;
                    int totalMaleError        = 0;
                    int totalFemaleError      = 0;

                    int racesLength = Races.Count;
                    for (int i = 0; i < racesLength; i++)
                    {
                        totalMalePopulation   += Races[i].MaleData.Rows[j].Value;
                        totalFemalePopulation += Races[i].FemaleData.Rows[j].Value;
                        totalMaleError        += Races[i].MaleData.Rows[j].Error;
                        totalFemaleError      += Races[i].FemaleData.Rows[j].Error;
                    }

                    TotalMaleData.Rows.Add(new NPopulationDataEntry(AgeRanges[j], totalMalePopulation, totalMaleError));
                    TotalFemaleData.Rows.Add(new NPopulationDataEntry(AgeRanges[j], totalFemalePopulation, totalFemaleError));
                }
            }
Exemple #12
0
        public static Races GetRaces(DatabaseSettings databaseSettings)
        {
            Races returnValue = new Races();

            using (SqlConnection connection = new SqlConnection(databaseSettings.SqlClientConnectionString))
            {
                connection.Open();

                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "csRacesGet";
                    command.CommandType = CommandType.StoredProcedure;


                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read() == true)
                        {
                            Race r = new Race();

                            if (reader["RaceID"] is int)
                            {
                                r.RaceID = (int)reader["RaceID"];
                            }

                            if (reader["Name"] is string)
                            {
                                r.Name = (string)reader["Name"];
                            }

                            if (reader["RaceImage"] is string)
                            {
                                r.RaceImage = (string)reader["RaceImage"];
                            }

                            if (reader["AgeRange"] is string)
                            {
                                r.AgeRange = (string)reader["AgeRange"];
                            }

                            if (reader["Size"] is string)
                            {
                                r.Size = (string)reader["Size"];
                            }

                            if (reader["Speed"] is string)
                            {
                                r.Speed = (string)reader["Speed"];
                            }

                            if (reader["Languages"] is string)
                            {
                                r.Languages = (string)reader["Languages"];
                            }

                            if (reader["Subtypes"] is string)
                            {
                                r.Subtypes = (string)reader["Subtypes"];
                            }

                            returnValue.Add(r);
                        }
                    }
                }
            }

            return(returnValue);
        }
Exemple #13
0
 public void NieuweRace(Race race)
 {
     Races.Add(race);
 }
Exemple #14
0
/*		/// <summary>
 *              /// Updates any InfoVersion for the spells when the 2da loads. Ensures
 *              /// that spell-info does not have a CoreAI version if there's no other
 *              /// data and that it does have a CoreAI version if there is.
 *              /// NOTE: There won't be any SpellChanged structs at this point although
 *              /// this can create such changed-structs - which is the point.
 *              /// </summary>
 *              void InfoVersionLoad_spells()
 *              {
 *                      Spell spell;
 *
 *                      int spellinfo, ver;
 *
 *                      int total = Spells.Count;
 *                      for (int id = 0; id != total; ++id)
 *                      {
 *                              spell = Spells[id];
 *                              spellinfo = spell.spellinfo;
 *
 *                              if (spellinfo != 0)
 *                              {
 *                                      ver = (spellinfo & HENCH_SPELL_INFO_VERSION_MASK);
 *
 *                                      if (ver == 0) // insert the default spell-version if it doesn't exist
 *                                      {
 *                                              ver = HENCH_SPELL_INFO_VERSION;
 *                                      }
 *                                      else if (ver == spellinfo) // clear the spell-version if that's the only data in spellinfo
 *                                      {
 *                                              ver = 0;
 *                                      }
 *                                      else
 *                                              continue;
 *
 *
 *                                      spellinfo &= ~HENCH_SPELL_INFO_VERSION_MASK;
 *                                      spellinfo |= ver;
 *
 *                                      var spellchanged = new SpellChanged();
 *
 *                                      spellchanged.targetinfo   = spell.targetinfo;
 *                                      spellchanged.effectweight = spell.effectweight;
 *                                      spellchanged.effecttypes  = spell.effecttypes;
 *                                      spellchanged.damageinfo   = spell.damageinfo;
 *                                      spellchanged.savetype     = spell.savetype;
 *                                      spellchanged.savedctype   = spell.savedctype;
 *
 *                                      spellchanged.spellinfo = spellinfo;
 *
 *                                      SpellsChanged[id] = spellchanged;
 *
 *                                      spell.differ = bit_spellinfo;
 *                                      Spells[id] = spell;
 *
 *                                      Tree.Nodes[id].ForeColor = Color.Crimson;
 *                              }
 *                      }
 *
 *                      InfoVersionUpdate       =
 *                      applyGlobal    .Enabled =
 *                      gotoNextChanged.Enabled = (SpellsChanged.Count != 0);
 *              } */


        /// <summary>
        /// Loads a HenchRacial.2da file.
        /// </summary>
        /// <param name="rows"></param>
        /// <remarks>If the file is not a valid HenchRacial.2da then this should
        /// hopefully throw an exception at the user. If it doesn't all bets are
        /// off.</remarks>
        void Load_HenchRacial(string[] rows)
        {
            if (HenchControl != null)
            {
                HenchControl.Dispose();                 // <- also removes the control from its collection
            }
            HenchControl = new control_Racial(this);
            panel2width  = HenchControl.Width;              // cache that
            panel2height = HenchControl.Height;             // cache that
            splitContainer.Panel2.Controls.Add(HenchControl);

            Type = Type2da.Racial;

            ClearData();


            string[] fields;
            string   field;

            foreach (string row in rows)
            {
                if (!String.IsNullOrEmpty(row))
                {
                    fields = row.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

                    int id;
                    if (Int32.TryParse(fields[0], out id))                     // is a valid 2da row
                    {
                        var race = new Race();

                        race.id        = id;
                        race.isChanged = false;
                        race.differ    = control_Racial.bit_clean;

                        int col = 0;

                        if (hasLabels && (field = fields[++col]) != stars)
                        {
                            race.label = field;
                        }
                        else
                        {
                            race.label = String.Empty;
                        }

                        if ((field = fields[++col]) != stars)
                        {
                            race.flags = Int32.Parse(field);
                        }
                        else
                        {
                            race.flags = 0;
                        }

                        if ((field = fields[++col]) != stars)
                        {
                            race.feat1 = Int32.Parse(field);
                        }
                        else
                        {
                            race.feat1 = 0;
                        }

                        if ((field = fields[++col]) != stars)
                        {
                            race.feat2 = Int32.Parse(field);
                        }
                        else
                        {
                            race.feat2 = 0;
                        }

                        if ((field = fields[++col]) != stars)
                        {
                            race.feat3 = Int32.Parse(field);
                        }
                        else
                        {
                            race.feat3 = 0;
                        }

                        if ((field = fields[++col]) != stars)
                        {
                            race.feat4 = Int32.Parse(field);
                        }
                        else
                        {
                            race.feat4 = 0;
                        }

                        if ((field = fields[++col]) != stars)
                        {
                            race.feat5 = Int32.Parse(field);
                        }
                        else
                        {
                            race.feat5 = 0;
                        }

                        Races.Add(race);                                // race-structs can now be referenced in the 'Races' list by their
                    }                                                   // - Races[id]
                }                                                       // - HenchRacial.2da row#
            }                                                           // - SubRaceID (RacialSubtypes.2da row#)

            GrowTree(true);

            // check if any info-version(s) need to be updated in flags-int.
//			InfoVersionLoad_racial();

            bu_Apply.Text       = "apply this race\'s data";
            tree_Highlight.Text = "highlight blank Racial flags nodes";
        }
Exemple #15
0
        private static void PrepareRaces()
        {
            string file = Path.Combine(AppContext.BaseDirectory, Race.FileName);

            if (File.Exists(file))
            {
                // Get races from json file
                Races = JsonConvert.DeserializeObject <Races>(File.ReadAllText(file));
                Console.WriteLine($"Races loaded: {Races.Count}");
            }
            else
            {
                // Create races and save to json
                Race human = new Race();
                human.Name = "Human";
                foreach (AttributeType type in ProjectBOT.Arena.Core.Attribute.AttributeTypes)
                {
                    human.AttributeModifiers.Add(type, 1);
                }

                Race elf = new Race();
                elf.Name = "Elf";
                elf.AttributeModifiers.Add(AttributeType.Dexterity, 2);

                Race dragonborn = new Race();
                dragonborn.Name = "Dragonborn";
                dragonborn.AttributeModifiers.Add(AttributeType.Strength, 2);
                dragonborn.AttributeModifiers.Add(AttributeType.Charisma, 1);

                Race dwarf = new Race();
                dwarf.Name = "Dwarf";
                dwarf.AttributeModifiers.Add(AttributeType.Constitution, 2);

                Race gnome = new Race();
                gnome.Name = "Gnome";
                gnome.AttributeModifiers.Add(AttributeType.Intelligence, 2);

                Race halforc = new Race();
                halforc.Name = "Half-Orc";
                halforc.AttributeModifiers.Add(AttributeType.Strength, 2);
                halforc.AttributeModifiers.Add(AttributeType.Constitution, 1);

                Race halfling = new Race();
                halfling.Name = "Halfling";
                halfling.AttributeModifiers.Add(AttributeType.Dexterity, 2);

                Race tiefling = new Race();
                tiefling.Name = "Tiefling";
                tiefling.AttributeModifiers.Add(AttributeType.Intelligence, 1);
                tiefling.AttributeModifiers.Add(AttributeType.Charisma, 2);

                Races.Add(dragonborn);
                Races.Add(dwarf);
                Races.Add(elf);
                Races.Add(gnome);
                Races.Add(halforc);
                Races.Add(halfling);
                Races.Add(human);
                Races.Add(tiefling);

                string path = Path.GetDirectoryName(file);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                File.WriteAllText(file, JsonConvert.SerializeObject(Races));
            }
        }