allow for incomplete data strings for pokemon

checks for EXP, Atks, IVs, Ability, Nature, Gender, Friendship and Shiny, presets OT and Catch trainer to player and catch ball to pokeball before processing tags to load over them
This commit is contained in:
darkfire006 2022-04-24 17:47:40 -05:00
parent 024306c62b
commit 5a9fd6eded

View File

@ -1284,6 +1284,11 @@ Public Class Pokemon
PokemonID = CInt(Tags("Pokemon")) PokemonID = CInt(Tags("Pokemon"))
End If End If
Dim Level As Integer = 5
If Tags.ContainsKey("Level") = True Then
Level = CInt(Tags("Level"))
End If
Dim p As Pokemon = GetPokemonByID(PokemonID, NewAdditionalData) Dim p As Pokemon = GetPokemonByID(PokemonID, NewAdditionalData)
p.LoadData(InputData) p.LoadData(InputData)
@ -1534,6 +1539,14 @@ Public Class Pokemon
''' <param name="InputData">The input data.</param> ''' <param name="InputData">The input data.</param>
Public Sub LoadData(ByVal InputData As String) Public Sub LoadData(ByVal InputData As String)
Dim loadedHP As Boolean = False Dim loadedHP As Boolean = False
Dim loadedEXP As Boolean = False
Dim loadedAttacks As Boolean = False
Dim loadedIVs As Boolean = False
Dim loadedAbility As Boolean = False
Dim loadedGender As Boolean = False
Dim loadedNature As Boolean = False
Dim loadedFriendship As Boolean = False
Dim loadedShiny As Boolean = False
Dim Tags As New Dictionary(Of String, String) Dim Tags As New Dictionary(Of String, String)
Dim Data() As String = InputData.Replace("§", ",").Replace("«", "[").Replace("»", "]").Split(CChar("}")) Dim Data() As String = InputData.Replace("§", ",").Replace("«", "[").Replace("»", "]").Split(CChar("}"))
@ -1561,6 +1574,10 @@ Public Class Pokemon
End If End If
Next Next
Me.CatchTrainerName = Core.Player.Name
Me.OT = Core.Player.OT
Me.CatchBall = Item.GetItemByID(5)
For i = 0 To Tags.Count - 1 For i = 0 To Tags.Count - 1
Dim tagName As String = Tags.Keys(i) Dim tagName As String = Tags.Keys(i)
Dim tagValue As String = Tags.Values(i) Dim tagValue As String = Tags.Values(i)
@ -1570,6 +1587,7 @@ Public Class Pokemon
Me.OriginalNumber = CInt(tagValue) Me.OriginalNumber = CInt(tagValue)
Case "experience" Case "experience"
Me.Experience = CInt(tagValue) Me.Experience = CInt(tagValue)
loadedEXP = True
Case "gender" Case "gender"
Select Case CInt(tagValue) Select Case CInt(tagValue)
Case 0 Case 0
@ -1579,6 +1597,7 @@ Public Class Pokemon
Case 2 Case 2
Me.Gender = Genders.Genderless Me.Gender = Genders.Genderless
End Select End Select
loadedGender = True
Case "eggsteps" Case "eggsteps"
Me.EggSteps = CInt(tagValue) Me.EggSteps = CInt(tagValue)
Case "item" Case "item"
@ -1600,6 +1619,7 @@ Public Class Pokemon
'is this relevant for the client in PvP? 'is this relevant for the client in PvP?
SetOriginalAbility() SetOriginalAbility()
Me.NormalAbility = Ability Me.NormalAbility = Ability
loadedAbility = True
Case "status" Case "status"
Select Case tagValue Select Case tagValue
Case "BRN" Case "BRN"
@ -1621,6 +1641,7 @@ Public Class Pokemon
End Select End Select
Case "nature" Case "nature"
Me.Nature = ConvertIDToNature(CInt(tagValue)) Me.Nature = ConvertIDToNature(CInt(tagValue))
loadedNature = True
Case "catchlocation" Case "catchlocation"
Me.CatchLocation = tagValue Me.CatchLocation = tagValue
Case "catchtrainer" Case "catchtrainer"
@ -1631,12 +1652,15 @@ Public Class Pokemon
Me.CatchMethod = tagValue Me.CatchMethod = tagValue
Case "friendship" Case "friendship"
Me.Friendship = CInt(tagValue) Me.Friendship = CInt(tagValue)
loadedFriendship = True
Case "isshiny" Case "isshiny"
Me.IsShiny = CBool(tagValue) Me.IsShiny = CBool(tagValue)
loadedShiny = True
Case "attack1", "attack2", "attack3", "attack4" Case "attack1", "attack2", "attack3", "attack4"
If Not P3D.BattleSystem.Attack.ConvertStringToAttack(tagValue) Is Nothing Then If Not P3D.BattleSystem.Attack.ConvertStringToAttack(tagValue) Is Nothing Then
Attacks.Add(P3D.BattleSystem.Attack.ConvertStringToAttack(tagValue)) Attacks.Add(P3D.BattleSystem.Attack.ConvertStringToAttack(tagValue))
End If End If
loadedAttacks = True
Case "stats" Case "stats"
Dim Stats() As String = tagValue.Split(CChar(",")) Dim Stats() As String = tagValue.Split(CChar(","))
HP = CInt(Stats(0)).Clamp(0, 999) HP = CInt(Stats(0)).Clamp(0, 999)
@ -1660,6 +1684,7 @@ Public Class Pokemon
IVSpAttack = CInt(IVs(3)) IVSpAttack = CInt(IVs(3))
IVSpDefense = CInt(IVs(4)) IVSpDefense = CInt(IVs(4))
IVSpeed = CInt(IVs(5)) IVSpeed = CInt(IVs(5))
loadedIVs = True
Case "additionaldata" Case "additionaldata"
Me.AdditionalData = tagValue Me.AdditionalData = tagValue
Case "idvalue" Case "idvalue"
@ -1673,6 +1698,48 @@ Public Class Pokemon
CalculateStats() CalculateStats()
Dim pDumb As Pokemon = GetPokemonByID(Me.Number, Me.AdditionalData)
pDumb.Generate(Me.Level, True)
If loadedEXP = False Then
Me.Experience = pDumb.Experience
End If
If loadedAttacks = False Then
Me.Attacks = pDumb.Attacks
End If
If loadedIVs = False Then
IVHP = pDumb.IVHP
IVAttack = pDumb.IVAttack
IVDefense = pDumb.IVDefense
IVSpAttack = pDumb.IVSpAttack
IVSpDefense = pDumb.IVSpDefense
IVSpeed = pDumb.IVSpeed
End If
If loadedAbility = False Then
Me.Ability = pDumb.Ability
SetOriginalAbility()
Me.NormalAbility = Ability
End If
If loadedGender = False Then
Me.Gender = pDumb.Gender
End If
If loadedNature = False Then
Me.Nature = pDumb.Nature
End If
If loadedFriendship = False Then
Me.Friendship = pDumb.Friendship
End If
If loadedShiny = False Then
Me.IsShiny = pDumb.IsShiny
End If
If loadedHP = False Then If loadedHP = False Then
Me.HP = Me.MaxHP Me.HP = Me.MaxHP
Else Else