Exemplo n.º 1
0
        public void ReloadData(FormMain main)
        {
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            dataTable.Clear();

            Dictionary <string, DataStoreWDB <DataStoreCrystarium, DataStoreIDCrystarium> > crystariums = new Dictionary <string, DataStoreWDB <DataStoreCrystarium, DataStoreIDCrystarium> >();
            Dictionary <string, Dictionary <DataStoreIDCrystarium, string> > displayNames = new Dictionary <string, Dictionary <DataStoreIDCrystarium, string> >();
            Dictionary <string, List <DataStoreIDCrystarium> > sorted = new Dictionary <string, List <DataStoreIDCrystarium> >();

            foreach (string name in RandoCrystarium.CharNames)
            {
                DataStoreWDB <DataStoreCrystarium, DataStoreIDCrystarium> cryst = new DataStoreWDB <DataStoreCrystarium, DataStoreIDCrystarium>();
                cryst.LoadData(File.ReadAllBytes($"{main.RandoPath}\\original\\db\\crystal\\crystal_{name}.wdb"));
                crystariums.Add(name, cryst);
                displayNames.Add(name, Crystarium.GetDisplayNames(cryst));

                List <DataStoreIDCrystarium> sortedList = cryst.IdList.Where(s => !s.ID.StartsWith("!")).ToList();
                sortedList.Sort((a, b) => a.CompareTo(b));
                sorted.Add(name, sortedList);
            }

            crystariums.Keys.ForEach(k => sorted[k].ForEach(s => AddEntry(s, k, crystariums[k][s.ID].Role.ToString(), displayNames[k][s])));
            foreach (DataRow row in dataTable.Rows)
            {
                DataStoreCrystarium cryst = crystariums[row.Field <string>(1)][row.Field <string>(0)];
                string name;
                if (cryst.Type == CrystariumType.Accessory)
                {
                    name = "Accessory";
                }
                else if (cryst.Type == CrystariumType.ATBLevel)
                {
                    name = "ATB Level";
                }
                else if (cryst.Type == CrystariumType.RoleLevel)
                {
                    name = "Role Level";
                }
                else if (cryst.Type == CrystariumType.Ability)
                {
                    Ability ability = Abilities.abilities.Find(a => a.GetIDs().Contains(cryst.AbilityName));
                    if (ability == null)
                    {
                        name = cryst.AbilityName;
                    }
                    else
                    {
                        name = ability.Name;
                    }
                }
                else
                {
                    name = $"{cryst.Type} +{cryst.Value}";
                }

                name += $" ({cryst.CPCost} CP)";

                row.SetField <string>(5, name);
            }
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Exemplo n.º 2
0
        public override void Randomize(BackgroundWorker backgroundWorker)
        {
            Dictionary <int, Dictionary <CrystariumType, List <int> > > statAverages = new Dictionary <int, Dictionary <CrystariumType, List <int> > >();

            if (Flags.CrystariumFlags.RandStats)
            {
                statAverages = GetStatAverages();
            }

            Dictionary <string, Dictionary <Role, List <Ability> > > nodes = GetNodeAbilities();

            Dictionary <string, Dictionary <string, Tuple <CrystariumType, Ability, int> > > plando = CharNames.ToDictionary(c => c, c => new Dictionary <string, Tuple <CrystariumType, Ability, int> >());

            if (Flags.CrystariumFlags.ShuffleNodes)
            {
                plando = main.crystariumPlando1.GetNodes();
                PlaceNodes(plando, nodes);
            }
            backgroundWorker.ReportProgress(10);
            if (Flags.CrystariumFlags.RandStats)
            {
                RandomizeStats(plando, statAverages);
            }

            backgroundWorker.ReportProgress(20);

            backgroundWorker.ReportProgress(40);

            RandomizeAbilities(plando);

            foreach (string name in CharNames)
            {
                foreach (DataStoreIDCrystarium id in crystariums[name].IdList.Where(id => !id.ID.StartsWith("!")))
                {
                    DataStoreCrystarium c = crystariums[name][id.ID];
                    if (c.Type == CrystariumType.Unknown)
                    {
                        throw new Exception($"{name.Substring(0, 1).ToUpper() + name.Substring(1)} {c.Role} Stage {c.Stage} Node {Crystarium.GetDisplayNames(crystariums[name])[id]} is invalid.");
                    }
                }
            }
            backgroundWorker.ReportProgress(70);

            if (Flags.CrystariumFlags.RandCP)
            {
                RandomizeCPCosts();
            }

            if (Tweaks.Boosts.HalfSecondaryCPCost)
            {
                ApplyHalfCPCosts();
            }

            if (Tweaks.Boosts.ScaledCPCost)
            {
                ApplyScaledCPCosts();
            }

            if (Flags.CrystariumFlags.RandCP)
            {
                ApplyPlandoCPCosts();
            }

            backgroundWorker.ReportProgress(100);
        }