Fixed Transform, made PvP data exchange methods somewhat more robust. Added data catching for PvP in debug mode.

This commit is contained in:
CaptainSegis 2017-09-20 02:17:09 -05:00
parent f35af71a36
commit 2068159522
9 changed files with 212 additions and 46 deletions

View File

@ -149,6 +149,7 @@
<Compile Include="Battle\BattleSystemV2\PokemonProfile.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\CameraQueryObject.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\ChoosePokemonQueryObject.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\AfterFaintQueryObject.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\DelayQueryObject.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\DisplayLevelUpQueryObject.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\EndBattleQueryObject.vb" />
@ -1691,7 +1692,6 @@
<Compile Include="Screens\MapPreview\MapPreviewCamera.vb" />
<Compile Include="Screens\MapPreview\MapPreviewScreen.vb" />
<Compile Include="Screens\MapScreen.vb" />
<Compile Include="Screens\NewGameScreen.vb" />
<Compile Include="Screens\NewMenuScreen.vb" />
<Compile Include="Screens\NewTrainerScreen.vb" />
<Compile Include="Screens\OptionScreen.vb" />

View File

@ -4164,7 +4164,10 @@
p.IsShiny = op.IsShiny
p.Attacks.Clear()
p.Attacks.AddRange(op.Attacks.ToArray())
For i = 0 To op.Attacks.Count - 1
p.Attacks.Add(Attack.GetAttackByID(op.Attacks(i).ID))
p.Attacks(i).CurrentPP = 5
Next
p.Ability = Ability.GetAbilityByID(op.Ability.ID)
@ -4447,7 +4450,8 @@
BattleScreen.BattleQuery.AddRange({cq1, cq2})
StartRound(BattleScreen)
BattleScreen.ClearMenuTime = True
BattleScreen.ClearMainMenuTime = True
BattleScreen.ClearMoveMenuTime = True
Case 1 'Own round
EndTurnOwn(BattleScreen)
Case 2 'Opp round

View File

@ -561,9 +561,9 @@
Private Sub UpdateMainMenu(ByRef BattleScreen As BattleScreen)
If BattleScreen.ClearMenuTime = True Then
If BattleScreen.ClearMainMenuTime = True Then
_mainMenuItemList.Clear()
BattleScreen.ClearMenuTime = False
BattleScreen.ClearMainMenuTime = False
End If
If _mainMenuItemList.Count = 0 Then
@ -816,6 +816,11 @@
End Sub
Private Sub UpdateMoveMenu(ByVal BattleScreen As BattleScreen)
If BattleScreen.ClearMoveMenuTime = True Then
_moveMenuItemList.Clear()
BattleScreen.ClearMoveMenuTime = False
End If
If _moveMenuChoseMove = True Then
_moveMenuAlpha -= 15
If _moveMenuAlpha <= 0 Then

View File

@ -15,7 +15,8 @@
#Region "BattleValues"
Public IsChoiced As Boolean = False
Public ClearMenuTime As Boolean = False
Public ClearMainMenuTime As Boolean = False
Public ClearMoveMenuTime As Boolean = False
Public Shared CanCatch As Boolean = True
Public Shared CanRun As Boolean = True
Public Shared CanBlackout As Boolean = True
@ -854,7 +855,8 @@ nextIndex:
ClientWaitForData = False
ReceivedPokemonData = False
BattleMenu.Reset()
ClearMenuTime = True
ClearMainMenuTime = True
ClearMoveMenuTime = True
BattleMenu.Update(Me)
End If
End If
@ -1346,8 +1348,15 @@ nextIndex:
Public Shared Sub ReceiveHostEndRoundData(ByVal data As String)
Dim newQueries As New List(Of String)
Dim tempData As String = ""
Dim cData As String = data
Dim cData As String = data
If GameController.IS_DEBUG_ACTIVE Then
If Directory.Exists(GameController.GamePath & "\PvP Log\") = False Then
Directory.CreateDirectory(GameController.GamePath & "\PvP Log\")
End If
Dim shownData As String = data.Replace("}{", "}" & vbNewLine & "{").Replace("}|{", "}|" & vbNewLine & vbNewLine & "{")
IO.File.WriteAllText(GameController.GamePath & "\PvP Log\HostEndRoundData.dat", shownData)
End If
'Converts the single string received as data into a list of string
While cData.Length > 0
If cData(0).ToString() = "|" AndAlso tempData(tempData.Length - 1).ToString() = "}" Then
@ -1430,11 +1439,18 @@ nextIndex:
Logger.Debug("[Battle]: The host's pokemon faints")
OppFaint = True
Exit Sub
End If
If data = "-ClientFainted-" Then
ElseIf data = "-ClientFainted-" Then
Logger.Debug("[Battle]: The client's pokemon faints")
OwnFaint = True
Exit Sub
Else
If GameController.IS_DEBUG_ACTIVE Then
If Directory.Exists(GameController.GamePath & "\PvP Log\") = False Then
Directory.CreateDirectory(GameController.GamePath & "\PvP Log\")
End If
Dim shownData As String = data.Replace("}{", "}" & vbNewLine & "{").Replace("}|{", "}|" & vbNewLine & vbNewLine & "{")
IO.File.WriteAllText(GameController.GamePath & "\PvP Log\HostData.dat", shownData)
End If
End If
End If
@ -1456,7 +1472,10 @@ nextIndex:
If s.Identification = Identifications.BattleScreen Then
CType(s, BattleScreen).BattleQuery.Clear()
For Each q As String In newQueries
CType(s, BattleScreen).BattleQuery.Add(QueryObject.FromString(q))
Dim Query As QueryObject = QueryObject.FromString(q)
If Query IsNot Nothing Then
CType(s, BattleScreen).BattleQuery.Add(Query)
End If
Next
For i = 0 To 99
CType(s, BattleScreen).InsertCasualCameramove()
@ -1487,6 +1506,14 @@ nextIndex:
Logger.Debug("[Battle]: Received Client data")
ReceivedInput = data
If GameController.IS_DEBUG_ACTIVE Then
If Directory.Exists(GameController.GamePath & "\PvP Log\") = False Then
Directory.CreateDirectory(GameController.GamePath & "\PvP Log\")
End If
Dim shownData As String = data.Replace("}{", "}" & vbNewLine & "{").Replace("}|{", "}|" & vbNewLine & vbNewLine & "{")
IO.File.WriteAllText(GameController.GamePath & "\PvP Log\ClientCommand.dat", shownData)
End If
Dim s As Screen = Core.CurrentScreen
While Not s.PreScreen Is Nothing And s.Identification <> Identifications.BattleScreen
s = s.PreScreen
@ -1532,6 +1559,13 @@ nextIndex:
End If
d &= p.GetSaveData()
Next
If GameController.IS_DEBUG_ACTIVE Then
If Directory.Exists(GameController.GamePath & "\PvP Log\") = False Then
Directory.CreateDirectory(GameController.GamePath & "\PvP Log\")
End If
Dim shownData As String = d.Replace("}{", "}" & vbNewLine & "{").Replace("}|{", "}|" & vbNewLine & vbNewLine & "{")
IO.File.WriteAllText(GameController.GamePath & "\PvP Log\SentEndRoundData.dat", shownData)
End If
Logger.Debug("[Battle]: Sent End Round data")
Core.ServersManager.ServerConnection.SendPackage(New Servers.Package(Servers.Package.PackageTypes.BattlePokemonData, Core.ServersManager.ID, Servers.Package.ProtocolTypes.TCP, {PartnerNetworkID.ToString(), d}.ToList()))
End Sub
@ -1558,6 +1592,13 @@ nextIndex:
Me.TempPVPBattleQuery.Clear()
Logger.Debug("[Battle]: Sent Host Query")
If GameController.IS_DEBUG_ACTIVE Then
If Directory.Exists(GameController.GamePath & "\PvP Log\") = False Then
Directory.CreateDirectory(GameController.GamePath & "\PvP Log\")
End If
Dim shownData As String = d.Replace("}{", "}" & vbNewLine & "{").Replace("}|{", "}|" & vbNewLine & vbNewLine & "{")
IO.File.WriteAllText(GameController.GamePath & "\PvP Log\SentHostQuery.dat", shownData)
End If
Core.ServersManager.ServerConnection.SendPackage(New Servers.Package(Servers.Package.PackageTypes.BattleHostData, Core.ServersManager.ID, Servers.Package.ProtocolTypes.TCP, {PartnerNetworkID.ToString(), d}.ToList()))
SentHostData = True
End Sub

View File

@ -0,0 +1,44 @@
Namespace BattleSystem
Public Class AfterFaintQueryObject
Inherits QueryObject
Private _delay As Integer = 0
Public Sub New(ByVal Delay As Integer)
MyBase.New(QueryTypes.Delay)
Me._delay = Delay
End Sub
Public Overrides Sub Update(BV2Screen As BattleScreen)
If Me._delay > 0 Then
Me._delay -= 1
End If
End Sub
Public Overrides ReadOnly Property IsReady As Boolean
Get
If Me._delay = 0 Then
Return True
End If
Return False
End Get
End Property
Public Overrides Function NeedForPVPData() As Boolean
Return True
End Function
Public Shared Shadows Function FromString(input As String) As QueryObject
Return New DelayQueryObject(CInt(input))
End Function
Public Overrides Function ToString() As String
Return "{DELAY|" & Me._delay.ToString() & "}"
End Function
End Class
End Namespace

View File

@ -64,30 +64,37 @@
Dim Type As String = input.Remove(input.IndexOf("|"))
Dim Data As String = input.Remove(0, input.IndexOf("|") + 1)
Select Case Type
Case "CAMERA"
Return CameraQueryObject.FromString(Data)
Case "DELAY"
Return DelayQueryObject.FromString(Data)
Case "ENDBATTLE"
Return EndBattleQueryObject.FromString(Data)
Case "MATHHP"
Return MathHPQueryObject.FromString(Data)
Case "MUSIC"
Return PlayMusicQueryObject.FromString(Data)
Case "SOUND"
Return PlaySoundQueryObject.FromString(Data)
Case "FADE"
Return ScreenFadeQueryObject.FromString(Data)
Case "TEXT"
Return TextQueryObject.FromString(Data)
Case "TOGGLEENTITY"
Return ToggleEntityQueryObject.FromString(Data)
Case "TOGGLEMENU"
Return ToggleMenuQueryObject.FromString(Data)
Case "TRIGGERNEWROUNDPVP"
Return TriggerNewRoundPVPQueryObject.FromString(Data)
End Select
Try
Select Case Type
Case "CAMERA"
Return CameraQueryObject.FromString(Data)
Case "DELAY"
Return DelayQueryObject.FromString(Data)
Case "ENDBATTLE"
Return EndBattleQueryObject.FromString(Data)
Case "MATHHP"
Return MathHPQueryObject.FromString(Data)
Case "MUSIC"
Return PlayMusicQueryObject.FromString(Data)
Case "SOUND"
Return PlaySoundQueryObject.FromString(Data)
Case "FADE"
Return ScreenFadeQueryObject.FromString(Data)
Case "TEXT"
Return TextQueryObject.FromString(Data)
Case "TOGGLEENTITY"
Return ToggleEntityQueryObject.FromString(Data)
Case "TOGGLEMENU"
Return ToggleMenuQueryObject.FromString(Data)
Case "TRIGGERNEWROUNDPVP"
Return TriggerNewRoundPVPQueryObject.FromString(Data)
End Select
Catch ex As Exception
Logger.Debug("QueryObject.vb: Wrong data received, could not convert to [" & Type & "] query object. Return Nothing.")
Logger.Debug(input)
Return Nothing
End Try
End If
Return Nothing
End Function

View File

@ -536,10 +536,10 @@ Namespace GameJolt
Next
If exists(ID_BERRIES) = False Then
_berries = NewGameScreen.GetBerryData()
_berries = GetBerryData()
End If
If exists(ID_OPTIONS) = False Then
_options = NewGameScreen.GetOptionsData()
_options = GetOptionsData()
End If
If exists(ID_PLAYER) = False Then
_player = GetPlayerData()
@ -623,7 +623,7 @@ Namespace GameJolt
_berries = data.Replace("\""", """")
Else
_berries = NewGameScreen.GetBerryData()
_berries = GetBerryData()
End If
_downloadedFlags(ID_BERRIES) = True
@ -713,7 +713,7 @@ Namespace GameJolt
_options = data.Replace("\""", """")
Else
_options = NewGameScreen.GetOptionsData()
_options = GetOptionsData()
End If
_downloadedFlags(ID_OPTIONS) = True
@ -963,13 +963,13 @@ Namespace GameJolt
Gender = "0"
_apricorns = ""
_berries = NewGameScreen.GetBerryData()
_berries = GetBerryData()
_box = ""
_daycare = ""
_itemData = ""
_items = ""
_NPC = ""
_options = NewGameScreen.GetOptionsData()
_options = GetOptionsData()
_party = ""
_player = GetPlayerData()
_pokedex = ""
@ -980,6 +980,44 @@ Namespace GameJolt
_statistics = ""
End Sub
Public Shared Function GetOptionsData() As String
Dim s As String = "FOV|50" & vbNewLine &
"TextSpeed|2" & vbNewLine &
"MouseSpeed|12"
Return s
End Function
Public Shared Function GetBerryData() As String
Dim s As String = "{route29.dat|13,0,5|6|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route29.dat|14,0,5|6|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route29.dat|15,0,5|6|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{azalea.dat|9,0,3|0|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{azalea.dat|9,0,4|1|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{azalea.dat|9,0,5|0|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route30.dat|7,0,41|10|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route30.dat|14,0,5|2|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route30.dat|15,0,5|6|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route30.dat|16,0,5|2|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{routes\route35.dat|0,0,4|7|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{routes\route35.dat|1,0,4|8|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route36.dat|37,0,7|0|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route36.dat|38,0,7|4|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route36.dat|39,0,7|3|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route39.dat|8,0,2|9|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route39.dat|8,0,3|6|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route38.dat|13,0,12|16|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route38.dat|14,0,12|23|1|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{route38.dat|15,0,12|16|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{routes\route43.dat|13,0,45|23|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{routes\route43.dat|13,0,46|24|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{routes\route43.dat|13,0,47|25|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{safarizone\main.dat|3,0,11|5|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{safarizone\main.dat|4,0,11|0|2|0|2012,9,21,4,0,0|1}" & vbNewLine &
"{safarizone\main.dat|5,0,11|6|3|0|2012,9,21,4,0,0|1}"
Return s
End Function
End Class
Public Class StaffProfile
@ -993,6 +1031,7 @@ Namespace GameJolt
Staff.Add(New StaffProfile("33742", "Prince", "princevade", {StaffArea.GlobalAdmin, StaffArea.GTSAdmin, StaffArea.GTSDaily, StaffArea.MailManagement}))
Staff.Add(New StaffProfile("1", "GameJolt", "cros", {}))
Staff.Add(New StaffProfile("35947", "", "", {StaffArea.GTSDaily}))
Staff.Add(New StaffProfile("541732", "The Captain", "", {StaffArea.GTSDaily}))
End Sub
Public Enum StaffArea

View File

@ -102,7 +102,10 @@
p.IsShiny = op.IsShiny
p.Attacks.Clear()
p.Attacks.AddRange(op.Attacks.ToArray())
For i = 0 To op.Attacks.Count - 1
p.Attacks.Add(GetAttackByID(op.Attacks(i).ID))
p.Attacks(i).CurrentPP = 5
Next
p.Ability = Ability.GetAbilityByID(op.Ability.ID)

View File

@ -1237,10 +1237,18 @@ Public Class Pokemon
For Each Tag As String In Data
If Tag.Contains("{") = True And Tag.Contains("[") = True Then
Dim TagName As String = Tag.Remove(0, 2)
TagName = TagName.Remove(TagName.IndexOf(""""))
Try
TagName = TagName.Remove(TagName.IndexOf(""""))
Catch ex As Exception
Logger.Debug("Pokemon.vb, GetPokemonByData: Wrong Pokemon data, symbol "" was missing")
End Try
Dim TagContent As String = Tag.Remove(0, Tag.IndexOf("[") + 1)
TagContent = TagContent.Remove(TagContent.IndexOf("]"))
Try
TagContent = TagContent.Remove(TagContent.IndexOf("]"))
Catch ex As Exception
Logger.Debug("Pokemon.vb, GetPokemonByData: Wrong Pokemon data, symbol ] was missing")
End Try
If Tags.ContainsKey(TagName) = False Then
Tags.Add(TagName, TagContent)
@ -1514,10 +1522,20 @@ Public Class Pokemon
For Each Tag As String In Data
If Tag.Contains("{") = True And Tag.Contains("[") = True Then
Dim TagName As String = Tag.Remove(0, 2)
TagName = TagName.Remove(TagName.IndexOf(""""))
Try
TagName = TagName.Remove(TagName.IndexOf(""""))
Catch ex As Exception
Logger.Debug("Pokemon.vb, LoadData: Wrong Pokemon data, symbol "" was missing")
End Try
Dim TagContent As String = Tag.Remove(0, Tag.IndexOf("[") + 1)
TagContent = TagContent.Remove(TagContent.IndexOf("]"))
Try
TagContent = TagContent.Remove(TagContent.IndexOf("]"))
Catch ex As Exception
Logger.Debug("Pokemon.vb, LoadData: Wrong Pokemon data, symbol ] was missing")
End Try
If Tags.ContainsKey(TagName) = False Then
Tags.Add(TagName, TagContent)
@ -1530,6 +1548,8 @@ Public Class Pokemon
Dim tagValue As String = Tags.Values(i)
Select Case tagName.ToLower()
Case "originalnumber"
Me.OriginalNumber = CInt(tagValue)
Case "experience"
Me.Experience = CInt(tagValue)
Case "gender"
@ -1750,6 +1770,7 @@ Public Class Pokemon
End If
Dim Data As String = "{""Pokemon""[" & Me.Number & "]}" &
"{""OriginalNumber""[" & Me.OriginalNumber & "]}" &
"{""Experience""[" & Me.Experience & "]}" &
"{""Gender""[" & SaveGender & "]}" &
"{""EggSteps""[" & Me.EggSteps & "]}" &
@ -2190,6 +2211,8 @@ Public Class Pokemon
If DoHP = True Then
If Me.Number = 292 Then
Return 1
ElseIf OriginalNumber <> -1 AndAlso OriginalNumber <> Number Then 'when transformed
Return CInt(Math.Floor((((IVStat + (2 * GetPokemonByID(OriginalNumber).BaseHP) + (EVStat / 4) + 100) * calcLevel) / 100) + 10))
Else
Return CInt(Math.Floor((((IVStat + (2 * baseStat) + (EVStat / 4) + 100) * calcLevel) / 100) + 10))
End If