From 6440ff0466b61cf35ba35e8517810a9a717f74c7 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sat, 15 Jul 2023 14:17:40 +0200 Subject: [PATCH 1/3] Hopefully fix berrydata bugs with new saves --- P3D/Network/Profiles/GamejoltSave.vb | 9 ++++++--- P3D/Screens/MainMenu/NewNewGameScreen.vb | 8 ++++++-- P3D/Screens/NewGameScreen.vb | 7 +++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/P3D/Network/Profiles/GamejoltSave.vb b/P3D/Network/Profiles/GamejoltSave.vb index 2480cff09..de0748b60 100644 --- a/P3D/Network/Profiles/GamejoltSave.vb +++ b/P3D/Network/Profiles/GamejoltSave.vb @@ -613,7 +613,7 @@ Namespace GameJolt Dim data As String = result.Remove(0, 22) data = data.Remove(data.LastIndexOf("""")) - _berries = data.Replace("\""", """") + _berries = data.Replace("\""", """").Replace("}{", "}" & Environment.NewLine & "{") Else _berries = GetBerryData() End If @@ -947,8 +947,11 @@ Namespace GameJolt If File.Exists(GameModeManager.GetContentFilePath("Data\BerryData.dat")) Then Dim Berries() As String = System.IO.File.ReadAllLines(GameModeManager.GetContentFilePath("Data\BerryData.dat")) - For Each line In Berries - s &= line + For i = 0 To Berries.Count - 1 + s &= Berries(i) + If i < Berries.Count - 1 Then + s &= Environment.NewLine + End If Next Else s = "{route29.dat|13,0,5|6|2|0|2012,9,21,4,0,0|1}" & Environment.NewLine & diff --git a/P3D/Screens/MainMenu/NewNewGameScreen.vb b/P3D/Screens/MainMenu/NewNewGameScreen.vb index 03d7ee8f5..5893bcc81 100644 --- a/P3D/Screens/MainMenu/NewNewGameScreen.vb +++ b/P3D/Screens/MainMenu/NewNewGameScreen.vb @@ -170,6 +170,7 @@ Core.Player.startRiding = False Core.Player.startRotation = CSng(MathHelper.Pi * (rot / 2)) + Core.Player.PokedexData = Pokedex.NewPokedex() Core.Player.BerryData = CreateBerryData() Core.Player.AddVisitedMap(map) Core.Player.SaveCreated = GameController.GAMEDEVELOPMENTSTAGE & " " & GameController.GAMEVERSION @@ -193,8 +194,11 @@ If File.Exists(GameModeManager.GetContentFilePath("Data\BerryData.dat")) Then Dim Berries() As String = System.IO.File.ReadAllLines(GameModeManager.GetContentFilePath("Data\BerryData.dat")) - For Each line In Berries - s &= line + For i = 0 To Berries.Count - 1 + s &= Berries(i) + If i < Berries.Count - 1 Then + s &= Environment.NewLine + End If Next Else s = "{route29.dat|13,0,5|6|2|0|2012,9,21,4,0,0|1}" & Environment.NewLine & diff --git a/P3D/Screens/NewGameScreen.vb b/P3D/Screens/NewGameScreen.vb index 56b86e832..bef061c30 100644 --- a/P3D/Screens/NewGameScreen.vb +++ b/P3D/Screens/NewGameScreen.vb @@ -446,8 +446,11 @@ If File.Exists(GameModeManager.GetContentFilePath("Data\BerryData.dat")) Then Dim Berries() As String = System.IO.File.ReadAllLines(GameModeManager.GetContentFilePath("Data\BerryData.dat")) - For Each line In Berries - s &= line + For i = 0 To Berries.Count - 1 + s &= Berries(i) + If i < Berries.Count - 1 Then + s &= Environment.NewLine + End If Next Else s = "{route29.dat|13,0,5|6|2|0|2012,9,21,4,0,0|1}" & Environment.NewLine & From 7699621036663d02026ac35951daaf66ab0e7471 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sat, 15 Jul 2023 14:18:00 +0200 Subject: [PATCH 2/3] Fix Whirlwind move logic --- P3D/Pokemon/Attacks/Normal/Whirlwind.vb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/P3D/Pokemon/Attacks/Normal/Whirlwind.vb b/P3D/Pokemon/Attacks/Normal/Whirlwind.vb index 6ca53ef73..7768aa1a1 100644 --- a/P3D/Pokemon/Attacks/Normal/Whirlwind.vb +++ b/P3D/Pokemon/Attacks/Normal/Whirlwind.vb @@ -74,7 +74,7 @@ If BattleScreen.Trainer.CountUseablePokemon > 1 Then Dim i As Integer = Core.Random.Next(0, BattleScreen.Trainer.Pokemons.count) While BattleScreen.Trainer.Pokemons(i).Status = Pokemon.StatusProblems.Fainted OrElse BattleScreen.OppPokemonIndex = i OrElse BattleScreen.Trainer.Pokemons(i).HP <= 0 - i = Core.Random.Next(0, BattleScreen.Trainer.Pokemons.Count - 1) + i = Core.Random.Next(0, BattleScreen.Trainer.Pokemons.Count) End While BattleScreen.Battle.SwitchOutOpp(BattleScreen, i, "") Else @@ -84,7 +84,7 @@ If Core.Player.CountFightablePokemon > 1 Then Dim i As Integer = Core.Random.Next(0, Core.Player.Pokemons.Count) While Core.Player.Pokemons(i).Status = Pokemon.StatusProblems.Fainted OrElse BattleScreen.OwnPokemonIndex = i OrElse Core.Player.Pokemons(i).HP <= 0 - i = Core.Random.Next(0, Core.Player.Pokemons.Count - 1) + i = Core.Random.Next(0, Core.Player.Pokemons.Count) End While BattleScreen.Battle.SwitchOutOwn(BattleScreen, i, -1) Else @@ -98,7 +98,11 @@ BattleScreen.BattleQuery.Add(New EndBattleQueryObject(False)) Else If Core.Player.CountFightablePokemon > 1 Then - BattleScreen.Battle.SwitchOutOwn(BattleScreen, -1, -1) + Dim i As Integer = Core.Random.Next(0, Core.Player.Pokemons.Count) + While Core.Player.Pokemons(i).Status = Pokemon.StatusProblems.Fainted OrElse BattleScreen.OwnPokemonIndex = i OrElse Core.Player.Pokemons(i).HP <= 0 + i = Core.Random.Next(0, Core.Player.Pokemons.Count) + End While + BattleScreen.Battle.SwitchOutOwn(BattleScreen, i, -1) Else BattleScreen.BattleQuery.Add(New TextQueryObject(Me.Name & " failed!")) End If From 6520377758423b5d3e03eef198779449a8420e97 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sat, 15 Jul 2023 16:12:17 +0200 Subject: [PATCH 3/3] DexForm progress --- P3D/Content/Pokemon/Data/863.dat | 1 + P3D/Player/Pokedex.vb | 8 +++++--- P3D/Screens/Pokedex/PokedexScreen.vb | 28 +++++++++++++++++----------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/P3D/Content/Pokemon/Data/863.dat b/P3D/Content/Pokemon/Data/863.dat index dce79f59e..c7a050027 100644 --- a/P3D/Content/Pokemon/Data/863.dat +++ b/P3D/Content/Pokemon/Data/863.dat @@ -51,3 +51,4 @@ Move|42,163 Move|48,319 Move|54,37 TradeValue|25 +DexForms|53 diff --git a/P3D/Player/Pokedex.vb b/P3D/Player/Pokedex.vb index 5ec760a63..f1e827dc6 100644 --- a/P3D/Player/Pokedex.vb +++ b/P3D/Player/Pokedex.vb @@ -155,6 +155,7 @@ IDs.Add(id) Next + Dim formIDs As New List(Of String) For Each id As String In IDs If id.Contains("_") = False Then Dim baseID As String = id.GetSplit(0, "_") @@ -164,15 +165,16 @@ Dim AdditionalDataForms As List(Of String) = PokemonForms.GetAdditionalDataForms(CInt(baseID)) If AdditionalDataForms IsNot Nothing Then - For i = 0 To AdditionalDataForms.Count - IDs.Add(id & ";" & AdditionalDataForms(i)) + For i = 0 To AdditionalDataForms.Count - 1 + formIDs.Add(baseID & ";" & AdditionalDataForms(i)) Next End If End If Next + IDs.AddRange(formIDs) PokemonCount = IDs.Count - PokemonIDs = (From id In IDs Order By CInt(id.GetSplit(0, "_"))).ToList() + PokemonIDs = (From id In IDs Order By CInt(id.GetSplit(0, "_").GetSplit(0, ";"))).ToList() For i = 0 To PokemonCount - 1 Dim entry As String = PokemonIDs(i) diff --git a/P3D/Screens/Pokedex/PokedexScreen.vb b/P3D/Screens/Pokedex/PokedexScreen.vb index ebba442a0..513a7a80e 100644 --- a/P3D/Screens/Pokedex/PokedexScreen.vb +++ b/P3D/Screens/Pokedex/PokedexScreen.vb @@ -1340,12 +1340,21 @@ Public Class PokedexViewScreen If Me.Pokemon.DexForms.Count > 0 Then For Each form As String In Me.Pokemon.DexForms - Dim formAD As String = "" + Dim formID As String = Me.Pokemon.Number.ToString If form <> " " Then + If StringHelper.IsNumeric(form) = False Then + formID &= "_" & form + Else + formID = form + End If + End If + + Dim formAD As String = "" + If form <> " " AndAlso StringHelper.IsNumeric(form) = False Then formAD = PokemonForms.GetAdditionalValueFromDataFile(Me.PokemonID.GetSplit(0, "_") & "_" & form) End If - Dim formpokemon As Pokemon = Pokemon.GetPokemonByID(CInt(Me.PokemonID.GetSplit(0, "_")), formAD) + Dim formpokemon As Pokemon = Pokemon.GetPokemonByID(CInt(Me.PokemonID.GetSplit(0, "_")), formAD, True) If formpokemon.EvolutionConditions.Count > 0 Then Dim evolutions As New List(Of String) For Each ev As EvolutionCondition In formpokemon.EvolutionConditions @@ -1365,10 +1374,7 @@ Public Class PokedexViewScreen If vS.maximumLevel < Me.Level + 1 Then vS.maximumLevel = Me.Level + 1 End If - Dim formID As String = Me.Pokemon.Number.ToString - If form <> " " Then - formID &= "_" & form - End If + Me.Forms.Add(New EvolutionLinePokemon(Me.Level + 1, formID, vS, "")) @@ -1707,9 +1713,11 @@ Public Class PokedexViewScreen Else Dim connections As New List(Of String) Dim levels As New Dictionary(Of Integer, Integer) + Dim levelsOffset As New Dictionary(Of Integer, Integer) For i = minimumLevel To maximumLevel levels.Add(i, 0) + levelsOffset.Add(i, 0) Next For i = 0 To EvolutionLines.Count - 1 @@ -1730,11 +1738,8 @@ Public Class PokedexViewScreen connections.Add("-2_-1|" & EvolutionLines(i).Devolution.Devolution.PokemonID.ToString() & "-" & EvolutionLines(i).Devolution.PokemonID.ToString()) levels(-2) += 1 End If - Else - If i > 0 AndAlso levels(1) = i + 1 Then - levels(0) += 1 - levels(1) -= 2 - End If + ElseIf EvolutionLines(i).Evolutions.Count > 0 Then + levels(0) += 1 End If For Each evolution As EvolutionLinePokemon In EvolutionLines(i).Evolutions @@ -1749,6 +1754,7 @@ Public Class PokedexViewScreen connections.Add("0_0|" & EvolutionLines(i).PokemonID.ToString() & "-" & EvolutionLines(i).PokemonID.ToString()) levels(0) += 1 End If + Next Dim levelDraws As New Dictionary(Of Integer, Integer)