diff --git a/pk3DS.Core/Structures/Gen7/trdata7.cs b/pk3DS.Core/Structures/Gen7/trdata7.cs index 01484ae..d1e56a5 100644 --- a/pk3DS.Core/Structures/Gen7/trdata7.cs +++ b/pk3DS.Core/Structures/Gen7/trdata7.cs @@ -24,7 +24,8 @@ public trdata7(byte[] tr = null, byte[] tp = null) } } - public byte TrainerClass { get => trdata[0]; set => trdata[0] = value; } + public int TrainerClass { get => BitConverter.ToUInt16(trdata, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(trdata, 0x00); } + public BattleMode Mode { get => (BattleMode)trdata[2]; set => trdata[2] = (byte)value; } public int NumPokemon { get => trdata[3]; set => trdata[3] = (byte)(value%7); } public int Item1 { get => BitConverter.ToUInt16(trdata, 0x04); set => BitConverter.GetBytes((ushort)value).CopyTo(trdata, 0x04); } public int Item2 { get => BitConverter.ToUInt16(trdata, 0x06); set => BitConverter.GetBytes((ushort)value).CopyTo(trdata, 0x06); } @@ -44,4 +45,11 @@ public void Write(out byte[] tr, out byte[] pk) pk = dat; } } + + public enum BattleMode : byte + { + Singles, + Doubles, + Multi, + } } diff --git a/pk3DS/Subforms/Gen7/SMTE.Designer.cs b/pk3DS/Subforms/Gen7/SMTE.Designer.cs index d88159d..6f8372d 100644 --- a/pk3DS/Subforms/Gen7/SMTE.Designer.cs +++ b/pk3DS/Subforms/Gen7/SMTE.Designer.cs @@ -190,6 +190,8 @@ private void InitializeComponent() this.CHK_IgnoreSpecialClass = new System.Windows.Forms.CheckBox(); this.CHK_RandomClass = new System.Windows.Forms.CheckBox(); this.CHK_ForceFullyEvolved = new System.Windows.Forms.CheckBox(); + this.CB_Mode = new System.Windows.Forms.ComboBox(); + this.L_Mode = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.PB_Team1)).BeginInit(); this.mnuVSD.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PB_Team2)).BeginInit(); @@ -1476,6 +1478,8 @@ private void InitializeComponent() // // Tab_Trainer // + this.Tab_Trainer.Controls.Add(this.L_Mode); + this.Tab_Trainer.Controls.Add(this.CB_Mode); this.Tab_Trainer.Controls.Add(this.CHK_Flag); this.Tab_Trainer.Controls.Add(this.NUD_AI); this.Tab_Trainer.Controls.Add(this.L_AI); @@ -2159,6 +2163,32 @@ private void InitializeComponent() this.CHK_ForceFullyEvolved.Text = "Force Fully Evolved at Level"; this.CHK_ForceFullyEvolved.UseVisualStyleBackColor = true; // + // CB_Mode + // + this.CB_Mode.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.CB_Mode.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.CB_Mode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_Mode.FormattingEnabled = true; + this.CB_Mode.Items.AddRange(new object[] { + "Single", + "Double", + "Multi", + "3", + "4"}); + this.CB_Mode.Location = new System.Drawing.Point(214, 107); + this.CB_Mode.Name = "CB_Mode"; + this.CB_Mode.Size = new System.Drawing.Size(94, 21); + this.CB_Mode.TabIndex = 452; + // + // L_Mode + // + this.L_Mode.AutoSize = true; + this.L_Mode.Location = new System.Drawing.Point(169, 110); + this.L_Mode.Name = "L_Mode"; + this.L_Mode.Size = new System.Drawing.Size(37, 13); + this.L_Mode.TabIndex = 453; + this.L_Mode.Text = "Mode:"; + // // SMTE // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -2404,6 +2434,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox CHK_ForceHighPower; private System.Windows.Forms.NumericUpDown NUD_ForceHighPower; private System.Windows.Forms.CheckBox CHK_ReplaceMega; + private System.Windows.Forms.Label L_Mode; + private System.Windows.Forms.ComboBox CB_Mode; } } diff --git a/pk3DS/Subforms/Gen7/SMTE.cs b/pk3DS/Subforms/Gen7/SMTE.cs index 5e8193f..388c2f7 100644 --- a/pk3DS/Subforms/Gen7/SMTE.cs +++ b/pk3DS/Subforms/Gen7/SMTE.cs @@ -19,10 +19,10 @@ public partial class SMTE : Form private readonly trdata7[] Trainers; private string[][] AltForms; private static int[] SpecialClasses; - private static int[] ImportantTrainers = Main.Config.USUM ? Legal.ImportantTrainers_USUM : Legal.ImportantTrainers_SM; + private static readonly int[] ImportantTrainers = Main.Config.USUM ? Legal.ImportantTrainers_USUM : Legal.ImportantTrainers_SM; private static int[] FinalEvo = Legal.FinalEvolutions_7; - private static int[] Legendary = Main.Config.USUM ? Legal.Legendary_USUM : Legal.Legendary_SM; - private static int[] Mythical = Main.Config.USUM ? Legal.Mythical_USUM : Legal.Mythical_SM; + private static readonly int[] Legendary = Main.Config.USUM ? Legal.Legendary_USUM : Legal.Legendary_SM; + private static readonly int[] Mythical = Main.Config.USUM ? Legal.Mythical_USUM : Legal.Mythical_SM; private static Dictionary MegaDictionary; private int index = -1; private PictureBox[] pba; @@ -93,7 +93,7 @@ private void ClickView(object sender, EventArgs e) int slot = GetSlot(sender); if (pba[slot].Image == null) { SystemSounds.Exclamation.Play(); return; } - + // Load the PKM var pk = Trainers[index].Pokemon[slot]; if (pk.Species != 0) @@ -104,7 +104,9 @@ private void ClickView(object sender, EventArgs e) GetSlotColor(slot, Properties.Resources.slotView); } else + { SystemSounds.Exclamation.Play(); + } } private void ClickSet(object sender, EventArgs e) @@ -116,7 +118,9 @@ private void ClickSet(object sender, EventArgs e) var pk = PrepareTP7(); var tr = Trainers[index]; if (slot < tr.NumPokemon) + { tr.Pokemon[slot] = pk; + } else { tr.Pokemon.Add(pk); @@ -203,7 +207,7 @@ private void RefreshPKMSlotAbility() private void Setup() { - AltForms = forms.Select(f => Enumerable.Range(0, 100).Select(i => i.ToString()).ToArray()).ToArray(); + AltForms = forms.Select(_ => Enumerable.Range(0, 100).Select(i => i.ToString()).ToArray()).ToArray(); CB_TrainerID.Items.Clear(); for (int i = 0; i < trdata.Length; i++) CB_TrainerID.Items.Add(GetEntryTitle(trName[i] ?? "UNKNOWN", i)); @@ -226,7 +230,7 @@ private void Setup() specieslist[0] = "---"; abilitylist[0] = itemlist[0] = movelist[0] = "(None)"; pba = new[] { PB_Team1, PB_Team2, PB_Team3, PB_Team4, PB_Team5, PB_Team6 }; - + CB_Species.Items.Clear(); foreach (string s in specieslist) CB_Species.Items.Add(s); @@ -252,7 +256,7 @@ private void Setup() CB_Item.Items.Clear(); foreach (string s in itemlist) CB_Item.Items.Add(s); - + CB_Gender.Items.Clear(); CB_Gender.Items.Add("- / Genderless/Random"); CB_Gender.Items.Add("♂ / Male"); @@ -406,6 +410,7 @@ private void PopulateFieldsTD7(trdata7 tr) CB_Item_3.SelectedIndex = tr.Item3; CB_Item_4.SelectedIndex = tr.Item4; CB_Money.SelectedIndex = tr.Money; + CB_Mode.SelectedIndex = (int)tr.Mode; NUD_AI.Value = tr.AI; CHK_Flag.Checked = tr.Flag; PopulateTeam(tr); @@ -420,6 +425,7 @@ private void PrepareTR7(trdata7 tr) tr.Item3 = CB_Item_3.SelectedIndex; tr.Item4 = CB_Item_4.SelectedIndex; tr.Money = CB_Money.SelectedIndex; + tr.Mode = (BattleMode)CB_Mode.SelectedIndex; tr.AI = (int)NUD_AI.Value; tr.Flag = CHK_Flag.Checked; } @@ -452,24 +458,24 @@ private string GetTrainerString(trdata7 tr) { var sb = new StringBuilder(); sb.AppendLine("======"); - sb.AppendLine($"{tr.ID} - {trClass[tr.TrainerClass]} {tr.Name}"); + sb.Append(tr.ID).Append(" - ").Append(trClass[tr.TrainerClass]).Append(" ").AppendLine(tr.Name); sb.AppendLine("======"); - sb.AppendLine($"Pokemon: {tr.NumPokemon}"); + sb.Append("Pokemon: ").Append(tr.NumPokemon).AppendLine(); for (int i = 0; i < tr.NumPokemon; i++) { if (tr.Pokemon[i].Shiny) sb.Append("Shiny "); sb.Append(specieslist[tr.Pokemon[i].Species]); - sb.Append($" (Lv. {tr.Pokemon[i].Level}) "); + sb.Append(" (Lv. ").Append(tr.Pokemon[i].Level).Append(") "); if (tr.Pokemon[i].Item > 0) - sb.Append($"@{itemlist[tr.Pokemon[i].Item]}"); + sb.Append("@").Append(itemlist[tr.Pokemon[i].Item]); if (tr.Pokemon[i].Nature != 0) - sb.Append($" (Nature: {natures[tr.Pokemon[i].Nature]})"); + sb.Append(" (Nature: ").Append(natures[tr.Pokemon[i].Nature]).Append(")"); - sb.Append($" (Moves: {string.Join("/", tr.Pokemon[i].Moves.Select(m => m == 0 ? "(None)" : movelist[m]))})"); - sb.Append($" IVs: {string.Join("/", tr.Pokemon[i].IVs)}"); - sb.Append($" EVs: {string.Join("/", tr.Pokemon[i].EVs)}"); + sb.Append(" (Moves: ").Append(string.Join("/", tr.Pokemon[i].Moves.Select(m => m == 0 ? "(None)" : movelist[m]))).Append(")"); + sb.Append(" IVs: ").Append(string.Join("/", tr.Pokemon[i].IVs)); + sb.Append(" EVs: ").Append(string.Join("/", tr.Pokemon[i].EVs)); sb.AppendLine(); } return sb.ToString(); @@ -682,11 +688,14 @@ private void B_Randomize_Click(object sender, EventArgs e) if (tr.NumPokemon < NUD_RMin.Value) { for (int p = tr.NumPokemon; p < NUD_RMin.Value; p++) + { tr.Pokemon.Add(new trpoke7 { Species = rnd.GetRandomSpecies(avgSpec), Level = avgLevel, }); + } + tr.NumPokemon = (int)NUD_RMin.Value; } if (tr.NumPokemon > NUD_RMax.Value) @@ -697,11 +706,14 @@ private void B_Randomize_Click(object sender, EventArgs e) if (CHK_6PKM.Checked && ImportantTrainers.Contains(tr.ID)) { for (int g = tr.NumPokemon; g < 6; g++) + { tr.Pokemon.Add(new trpoke7 { Species = rnd.GetRandomSpecies(avgSpec), Level = avgLevel, }); + } + tr.NumPokemon = 6; } @@ -719,13 +731,12 @@ private void B_Randomize_Click(object sender, EventArgs e) // replaces Megas with another Mega (Dexio and Lysandre in USUM) if (MegaDictionary.Values.Any(z => z.Contains(pk.Item))) { - int species = pk.Species; - int[] mega = GetRandomMega(out species); + int[] mega = GetRandomMega(out int species); pk.Species = species; pk.Item = mega[Util.rand.Next(0, mega.Length)]; pk.Form = 0; // allow it to Mega Evolve naturally } - + // every other pkm else { @@ -747,7 +758,7 @@ private void B_Randomize_Click(object sender, EventArgs e) pk.IVs = new[] {31, 31, 31, 31, 31, 31}; if (CHK_MaxAI.Checked) tr.AI |= 7; - + if (CHK_ForceFullyEvolved.Checked && pk.Level >= NUD_ForceFullyEvolved.Value && !FinalEvo.Contains(pk.Species)) { int randFinalEvo() => (int)(Util.rnd32() % FinalEvo.Length); @@ -835,18 +846,11 @@ private void CHK_STAB_CheckedChanged(object sender, EventArgs e) private void CHK_RandomPKM_CheckedChanged(object sender, EventArgs e) { - if (!CHK_RandomPKM.Checked) - foreach (CheckBox c in new[] { CHK_G1, CHK_G2, CHK_G3, CHK_G4, CHK_G5, CHK_G6, CHK_G7, CHK_L, CHK_E, CHK_BST }) - { - c.Enabled = false; - c.Checked = false; - } - else - foreach (CheckBox c in new[] { CHK_G1, CHK_G2, CHK_G3, CHK_G4, CHK_G5, CHK_G6, CHK_G7, CHK_L, CHK_E, CHK_BST }) - { - c.Enabled = true; - c.Checked = true; - } + foreach (CheckBox c in new[] { CHK_G1, CHK_G2, CHK_G3, CHK_G4, CHK_G5, CHK_G6, CHK_G7, CHK_L, CHK_E, CHK_BST }) + { + c.Enabled = CHK_RandomPKM.Checked; + c.Checked = CHK_RandomPKM.Checked; + } } private void CHK_RandomClass_CheckedChanged(object sender, EventArgs e)