Example #1
0
        public override bool ParseInput()
        {
            if (!FormsFunctions.ParseInputD(searchParams.Year, out year) ||
                !FormsFunctions.ParseInputD(searchParams.MinFrame, out minFrame) ||
                !FormsFunctions.ParseInputD(searchParams.MaxFrame, out maxFrame))
            {
                return(false);
            }

            months = new List <int>();
            for (int month = 1; month <= 12; month++)
            {
                if (searchParams.Months.CheckBoxItems[month].Checked)
                {
                    months.Add(month);
                }
            }

            if (months.Count == 0)
            {
                searchParams.Months.Focus();
                return(false);
            }

            generator = new DreamRadarGenerator();
            // todo: set parameters

            return(true);
        }
Example #2
0
        public Profile GetProfile()
        {
            ushort id, sid;
            uint   vcount, vframe, timer0min, timer0max, gxstat;
            ulong  mac;

            //validation
            if (!FormsFunctions.ParseInputD(maskedTextBoxID, out id) ||
                !FormsFunctions.ParseInputD(maskedTextBoxSID, out sid) ||
                !FormsFunctions.ParseInputH(textBoxMAC, out mac) ||
                !FormsFunctions.ParseInputH(textBoxVCount, out vcount) ||
                !FormsFunctions.ParseInputH(textBoxVFrame, out vframe) ||
                !FormsFunctions.ParseInputH(textBoxTimer0Min, out timer0min) ||
                !FormsFunctions.ParseInputH(textBoxTimer0Max, out timer0max) ||
                !FormsFunctions.ParseInputH(textBoxGxStat, out gxstat))
            {
                return(null);
            }
            var profile = new Profile
            {
                Name        = textBoxName.Text,
                ID          = id,
                SID         = sid,
                MAC_Address = mac,
                Version     = (Version)comboBoxVersion.SelectedIndex,
                Language    = (Language)comboBoxLanguage.SelectedIndex,
                DSType      = (DSType)comboBoxDSType.SelectedIndex,
                VCount      = vcount,
                VFrame      = vframe,
                Timer0Min   = timer0min,
                Timer0Max   = timer0max,
                GxStat      = gxstat,
                Keypresses  = GetKeypresses(),
                SoftReset   = checkBoxSoftReset.Checked,
                SkipLR      = checkBoxSkipLR.Checked,
                MemoryLink  = checkBoxMemoryLink.Checked
            };

            if (Nazos.Nazo(profile) == null)
            {
                MessageBox.Show("Warning: this version of the game is currently unsupported.",
                                "Unsupported game: " + profile.Version + " " + profile.Language + " " + profile.DSType,
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(profile);
        }
        public override bool ParseInput()
        {
            ushort openHollows;
            uint   maxAdvances;

            if (
                !(FormsFunctions.ParseInputD(searchParams.year, out year) &&
                  FormsFunctions.ParseInputD(searchParams.maxAdvances, out maxAdvances) &&
                  FormsFunctions.ParseInputD(searchParams.openHollows, out openHollows) && openHollows > 0 &&
                  openHollows < 21))
            {
                return(false);
            }
            generator = new HiddenHollowGenerator {
                OpenHollows = openHollows, MaxAdvances = maxAdvances
            };
            months = new List <int>();
            // todo: move this to forms functions
            for (int month = 1; month <= 12; month++)
            {
                if (searchParams.months.CheckBoxItems[month].Checked)
                {
                    months.Add(month);
                }
            }

            if (months.Count == 0)
            {
                searchParams.months.Focus();
                return(false);
            }

            keypresses = searchParams.profile.GetKeypresses();

            int dayTotal = 0;

            foreach (int month in months)
            {
                dayTotal += DateTime.DaysInMonth(year, month);
            }

            progressTotal =
                (ulong)
                (dayTotal * 86400 * keypresses.Count * (searchParams.profile.Timer0Max - searchParams.profile.Timer0Min + 1) *
                 (maxAdvances + 1));

            var slots = new List <ushort>();

            for (ushort i = 1; i < searchParams.Slots.CheckBoxItems.Count; ++i)
            {
                if (searchParams.Slots.CheckBoxItems[i].Checked)
                {
                    slots.Add((ushort)(i - 1));
                }
            }
            generator.Slots = slots.Count > 0 ? slots : null;

            var subslots = new List <ushort>();

            for (ushort i = 1; i < searchParams.SubSlots.CheckBoxItems.Count; ++i)
            {
                if (searchParams.SubSlots.CheckBoxItems[i].Checked)
                {
                    subslots.Add((ushort)(i - 1));
                }
            }
            generator.SubSlots = subslots.Count > 0 ? subslots : null;

            var hollows = new List <ushort>();

            for (ushort i = 1; i < searchParams.Hollows.CheckBoxItems.Count; ++i)
            {
                if (searchParams.Hollows.CheckBoxItems[i].Checked)
                {
                    hollows.Add((ushort)(i - 1));
                }
            }
            generator.Hollows = hollows.Count > 0 ? hollows : null;

            ushort genderRatio;

            ushort.TryParse(searchParams.GenderRatio.Text, out genderRatio);
            generator.GenderRatio = genderRatio;

            if (searchParams.Gender.Text.Length > 0)
            {
                generator.Gender = searchParams.Gender.Text[0];
            }

            /*float interval = ((float)24 / cpus + (float)0.05);
             *
             *  var hourMin = new int[cpus];
             *  var hourMax = new int[cpus];
             *
             *  jobs = new Thread[cpus];
             *  generators = new FrameGenerator[cpus];
             *  shinygenerators = new FrameGenerator[cpus];
             *  waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset);
             *
             *  for (int i = 0; i < jobs.Length; i++)
             *  {
             *      hourMin[i] = (int)(interval * i);
             *      hourMax[i] = (int)(interval * (i + 1) - 1);
             *
             *      if (hourMax[i] > 23)
             *      {
             *          hourMax[i] = 23;
             *      }
             *  }*/

            return(true);
        }
        public override bool ParseInput()
        {
            ushort openHollows;
            uint   maxAdvances;

            if (
                !(FormsFunctions.ParseInputD(searchParams.Year, out year) &&
                  FormsFunctions.ParseInputD(searchParams.MaxAdvances, out maxAdvances) &&
                  FormsFunctions.ParseInputD(searchParams.OpenHollows, out openHollows) && openHollows > 0 &&
                  openHollows < 21))
            {
                return(false);
            }
            generator = new HiddenGrottoGenerator {
                OpenHollows = openHollows, MaxAdvances = maxAdvances
            };
            months = new List <int>();
            // todo: move this to forms functions
            for (int month = 1; month <= 12; month++)
            {
                if (searchParams.Months.CheckBoxItems[month].Checked)
                {
                    months.Add(month);
                }
            }

            if (months.Count == 0)
            {
                searchParams.Months.Focus();
                return(false);
            }

            keypresses = searchParams.Profile.GetKeypresses();

            int dayTotal = months.Sum(month => DateTime.DaysInMonth(year, month));

            progressTotal =
                (ulong)
                (dayTotal * 86400 * keypresses.Count * (searchParams.Profile.Timer0Max - searchParams.Profile.Timer0Min + 1) *
                 (maxAdvances + 1));

            var slots = new List <ushort>();

            for (ushort i = 1; i < searchParams.Slots.CheckBoxItems.Count; ++i)
            {
                if (searchParams.Slots.CheckBoxItems[i].Checked)
                {
                    slots.Add((ushort)(i - 1));
                }
            }
            generator.Slots = slots.Count > 0 ? slots : null;

            var subslots = new List <ushort>();

            for (ushort i = 1; i < searchParams.SubSlots.CheckBoxItems.Count; ++i)
            {
                if (searchParams.SubSlots.CheckBoxItems[i].Checked)
                {
                    subslots.Add((ushort)(i - 1));
                }
            }
            generator.SubSlots = subslots.Count > 0 ? subslots : null;

            var hollows = new List <ushort>();

            for (ushort i = 1; i < searchParams.Hollows.CheckBoxItems.Count; ++i)
            {
                if (searchParams.Hollows.CheckBoxItems[i].Checked)
                {
                    var hollow = (ushort)(i - 1);
                    // check to make sure it's possible to hit this hollow
                    if (hollow >= openHollows)
                    {
                        MessageBox.Show(
                            string.Format("It's impossible to hit hollow number {0} with {1} open hollows!", hollow,
                                          openHollows), "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    hollows.Add(hollow);
                }
            }
            generator.Hollows = hollows.Count > 0 ? hollows : null;

            ushort genderRatio;

            ushort.TryParse(searchParams.GenderRatio.Text, out genderRatio);
            generator.GenderRatio = genderRatio;

            if (searchParams.Gender.Text.Length > 0)
            {
                generator.Gender = searchParams.Gender.Text[0];
            }

            /*float interval = ((float)24 / cpus + (float)0.05);
             *
             *  var hourMin = new int[cpus];
             *  var hourMax = new int[cpus];
             *
             *  jobs = new Thread[cpus];
             *  generators = new FrameGenerator[cpus];
             *  shinygenerators = new FrameGenerator[cpus];
             *  waitHandle = new EventWaitHandle(true, EventResetMode.ManualReset);
             *
             *  for (int i = 0; i < jobs.Length; i++)
             *  {
             *      hourMin[i] = (int)(interval * i);
             *      hourMax[i] = (int)(interval * (i + 1) - 1);
             *
             *      if (hourMax[i] > 23)
             *      {
             *          hourMax[i] = 23;
             *      }
             *  }*/

            return(true);
        }
        public override bool ParseInput()
        {
            // passes each of the fields into a function to parse the input
            // also validates the ranges
            // min/max frame can be larger in the input box than the limit of a uint but it's low priority to fix that
            if (!(FormsFunctions.ParseInputD(searchParams.minFrame, out minFrame) &&
                  FormsFunctions.ParseInputD(searchParams.maxFrame, out maxFrame) &&
                  minFrame <= maxFrame &&
                  FormsFunctions.ParseInputD(searchParams.minHour, out minHour) &&
                  FormsFunctions.ParseInputD(searchParams.maxHour, out maxHour) &&
                  minHour <= maxHour && maxHour <= 23 &&
                  FormsFunctions.ParseInputD(searchParams.minMinute, out minMinute) &&
                  FormsFunctions.ParseInputD(searchParams.maxMinute, out maxMinute) &&
                  minMinute <= maxMinute && maxMinute <= 59))
            {
                return(false);
            }
            //parse the id/sid defaulting to 0
            FormsFunctions.ParseInputD(searchParams.id, out id);
            FormsFunctions.ParseInputD(searchParams.sid, out sid);

            // everything from here on should always be valid input
            seedDate = searchParams.date.Value;
            bool     shiny    = searchParams.isShiny.Checked;
            bool     synch    = searchParams.isSynch.Checked;
            IVFilter ivfilter = searchParams.ivfilters.IVFilter;

            List <int> encounterSlots = null;

            if (searchParams.encounterSlot.Text != "Any" && searchParams.encounterSlot.CheckBoxItems.Count > 0)
            {
                encounterSlots = new List <int>();
                for (int i = 0; i < searchParams.encounterSlot.CheckBoxItems.Count; i++)
                {
                    if (searchParams.encounterSlot.CheckBoxItems[i].Checked)
                    {
                        // We have to subtract 1 because this custom control contains a hidden item for text display
                        encounterSlots.Add(i - 1);
                    }
                }
            }

            List <uint> natures = null;

            if (searchParams.nature.Text != "Any" && searchParams.nature.CheckBoxItems.Count > 0)
            {
                natures =
                    (from t in searchParams.nature.CheckBoxItems
                     where t.Checked
                     select(uint) ((Nature)t.ComboBoxItem).Number).ToList();
            }

            frameCompare = new FrameCompare(ivfilter, natures,
                                            (int)((ComboBoxItem)searchParams.ability.SelectedItem).Reference, shiny,
                                            synch, false, encounterSlots,
                                            (GenderFilter)(searchParams.gender.SelectedItem));

            EncounterMod currentMod = synch ? EncounterMod.Synchronize : EncounterMod.None;

            generator = new FrameGenerator
            {
                FrameType =
                    (FrameType)((ComboBoxItem)searchParams.frameType.SelectedItem).Reference,
                EncounterMod = currentMod
            };
            if (currentMod == EncounterMod.Synchronize && natures == null)
            {
                generator.EncounterMod = EncounterMod.None;
            }

            generator.SynchNature = ((Nature)searchParams.synchNature.SelectedItem).Number;

            generator.EncounterType = EncounterTypeCalc.EncounterString(searchParams.encounterType.Text);

            return(true);
        }