Properly implemented after faint switch by using query objects. Fixed small bug related to offline saves.
This commit is contained in:
parent
2068159522
commit
326916231a
|
@ -4416,8 +4416,7 @@
|
|||
BattleScreen.OwnFaint = True
|
||||
If BattleScreen.IsRemoteBattle AndAlso BattleScreen.IsHost Then
|
||||
Logger.Debug("[Battle]: The host's pokemon faints")
|
||||
Core.ServersManager.ServerConnection.SendPackage(New Servers.Package(Servers.Package.PackageTypes.BattleHostData,
|
||||
Core.ServersManager.ID, Servers.Package.ProtocolTypes.TCP, {BattleScreen.PartnerNetworkID.ToString(), "-HostFainted-"}.ToList()))
|
||||
BattleScreen.BattleQuery.Add(New AfterFaintQueryObject(True))
|
||||
End If
|
||||
SwitchOutOwn(BattleScreen, -1, -1)
|
||||
End If
|
||||
|
@ -4426,8 +4425,7 @@
|
|||
BattleScreen.OppFaint = True
|
||||
If BattleScreen.IsRemoteBattle AndAlso BattleScreen.IsHost Then
|
||||
Logger.Debug("[Battle]: The client's pokemon faints")
|
||||
Core.ServersManager.ServerConnection.SendPackage(New Servers.Package(Servers.Package.PackageTypes.BattleHostData,
|
||||
Core.ServersManager.ID, Servers.Package.ProtocolTypes.TCP, {BattleScreen.PartnerNetworkID.ToString(), "-ClientFainted-"}.ToList()))
|
||||
BattleScreen.BattleQuery.Add(New AfterFaintQueryObject(False))
|
||||
End If
|
||||
If BattleScreen.IsTrainerBattle = True Then
|
||||
If BattleScreen.Trainer.HasBattlePokemon() = True Then
|
||||
|
@ -6610,8 +6608,8 @@
|
|||
End Enum
|
||||
|
||||
Public Sub EndBattle(ByVal reason As EndBattleReasons, ByVal BattleScreen As BattleScreen, ByVal AddPVP As Boolean)
|
||||
BattleSystem.BattleScreen.OwnFaint = False
|
||||
BattleSystem.BattleScreen.OppFaint = False
|
||||
BattleScreen.OwnFaint = False
|
||||
BattleScreen.OppFaint = False
|
||||
IsAfterFaint = False
|
||||
If AddPVP = True Then
|
||||
Select Case reason
|
||||
|
|
|
@ -944,7 +944,7 @@
|
|||
Else
|
||||
If TempBattleScreen.OwnPokemonIndex <> PokeIndex Then
|
||||
If TempBattleScreen.IsRemoteBattle = True And TempBattleScreen.IsHost = False Then
|
||||
BattleScreen.OppFaint = False
|
||||
TempBattleScreen.OppFaint = False
|
||||
TempBattleScreen.OwnStatistics.Switches += 1
|
||||
TempBattleScreen.BattleQuery.Clear()
|
||||
TempBattleScreen.BattleQuery.Add(TempBattleScreen.FocusBattle())
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
Inherits Screen
|
||||
|
||||
'Used for after fainting switching
|
||||
Public Shared OwnFaint As Boolean = False
|
||||
Public Shared OppFaint As Boolean = False
|
||||
Public OwnFaint As Boolean = False
|
||||
Public OppFaint As Boolean = False
|
||||
|
||||
'Used for lead picking in PvP Battles
|
||||
Public Shared OwnLeadIndex As Integer = 0
|
||||
|
@ -118,9 +118,6 @@
|
|||
Me.IsTrainerBattle = False
|
||||
Me.MouseVisible = False
|
||||
Me.PVPGameJoltID = ""
|
||||
|
||||
OppFaint = False
|
||||
OwnFaint = False
|
||||
End Sub
|
||||
|
||||
Public Sub New(ByVal Trainer As Trainer, ByVal OverworldScreen As Screen, ByVal defaultMapType As Integer)
|
||||
|
@ -130,9 +127,6 @@
|
|||
Me.IsTrainerBattle = True
|
||||
Me.MouseVisible = False
|
||||
Me.PVPGameJoltID = ""
|
||||
|
||||
OppFaint = False
|
||||
OwnFaint = False
|
||||
End Sub
|
||||
|
||||
#Region "Initialize"
|
||||
|
@ -1307,8 +1301,6 @@ nextIndex:
|
|||
Battle.Won = True
|
||||
EndBattle(False)
|
||||
PVPLobbyScreen.BattleSuccessful = False
|
||||
OwnFaint = False
|
||||
OppFaint = False
|
||||
Return False
|
||||
End If
|
||||
Else
|
||||
|
@ -1318,8 +1310,6 @@ nextIndex:
|
|||
Battle.Won = False
|
||||
EndBattle(False)
|
||||
PVPLobbyScreen.BattleSuccessful = False
|
||||
OwnFaint = False
|
||||
OppFaint = False
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
|
@ -1435,15 +1425,6 @@ nextIndex:
|
|||
s = s.PreScreen
|
||||
End While
|
||||
If s.Identification = Identifications.BattleScreen Then
|
||||
If data = "-HostFainted-" Then
|
||||
Logger.Debug("[Battle]: The host's pokemon faints")
|
||||
OppFaint = True
|
||||
Exit Sub
|
||||
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\")
|
||||
|
@ -1452,7 +1433,6 @@ nextIndex:
|
|||
IO.File.WriteAllText(GameController.GamePath & "\PvP Log\HostData.dat", shownData)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
While cData.Length > 0
|
||||
If cData(0).ToString() = "|" AndAlso tempData(tempData.Length - 1).ToString() = "}" Then
|
||||
|
@ -1519,13 +1499,14 @@ nextIndex:
|
|||
s = s.PreScreen
|
||||
End While
|
||||
|
||||
CType(s, BattleScreen).BattleMenu.Visible = False
|
||||
Dim BV2Screen As BattleScreen = CType(s, BattleScreen)
|
||||
BV2Screen.BattleMenu.Visible = False
|
||||
|
||||
'prevents multi turn action to take place in an after fainting switching turn
|
||||
If Not (OppFaint And CType(s, BattleScreen).IsRemoteBattle) Then
|
||||
CType(s, BattleScreen).Battle.StartMultiTurnAction(CType(s, BattleScreen))
|
||||
If Not (BV2Screen.OppFaint And BV2Screen.IsRemoteBattle) Then
|
||||
BV2Screen.Battle.StartMultiTurnAction(BV2Screen)
|
||||
Else
|
||||
CType(s, BattleScreen).BattleMenu.Visible = True
|
||||
BV2Screen.BattleMenu.Visible = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
|
|
@ -4,39 +4,49 @@
|
|||
|
||||
Inherits QueryObject
|
||||
|
||||
Private _delay As Integer = 0
|
||||
Private _isHost As Boolean
|
||||
Private _ready As Boolean = False
|
||||
|
||||
Public Sub New(ByVal Delay As Integer)
|
||||
MyBase.New(QueryTypes.Delay)
|
||||
|
||||
Me._delay = Delay
|
||||
Public Sub New(ByVal IsHost As Boolean)
|
||||
MyBase.New(QueryTypes.AfterFaint)
|
||||
_isHost = IsHost
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Update(BV2Screen As BattleScreen)
|
||||
If Me._delay > 0 Then
|
||||
Me._delay -= 1
|
||||
If BV2Screen.IsHost Then
|
||||
If _isHost Then
|
||||
BV2Screen.OwnFaint = True
|
||||
Else
|
||||
BV2Screen.OppFaint = True
|
||||
End If
|
||||
Else
|
||||
If _isHost Then
|
||||
Logger.Debug("[Battle]: The host's pokemon faints")
|
||||
BV2Screen.OppFaint = True
|
||||
Else
|
||||
Logger.Debug("[Battle]: The client's pokemon faints")
|
||||
BV2Screen.OwnFaint = True
|
||||
End If
|
||||
End If
|
||||
Me._ready = True
|
||||
End Sub
|
||||
|
||||
Public Overrides ReadOnly Property IsReady As Boolean
|
||||
Get
|
||||
If Me._delay = 0 Then
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
Return _ready
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides Function NeedForPVPData() As Boolean
|
||||
Return True
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Shared Shadows Function FromString(input As String) As QueryObject
|
||||
Return New DelayQueryObject(CInt(input))
|
||||
Return New AfterFaintQueryObject(CBool(input))
|
||||
End Function
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return "{DELAY|" & Me._delay.ToString() & "}"
|
||||
Return "{FAINT|" & Me._isHost.ToString() & "}"
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
DisplayLevelUp
|
||||
PlaySound
|
||||
MoveAnimation
|
||||
AfterFaint
|
||||
End Enum
|
||||
|
||||
Public QueryType As QueryTypes = QueryTypes.CameraMovement
|
||||
|
@ -88,6 +89,8 @@
|
|||
Return ToggleMenuQueryObject.FromString(Data)
|
||||
Case "TRIGGERNEWROUNDPVP"
|
||||
Return TriggerNewRoundPVPQueryObject.FromString(Data)
|
||||
Case "FAINT"
|
||||
Return AfterFaintQueryObject.FromString(Data)
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
Logger.Debug("QueryObject.vb: Wrong data received, could not convert to [" & Type & "] query object. Return Nothing.")
|
||||
|
|
|
@ -628,8 +628,6 @@
|
|||
MusicManager.PlayMusic("lobby", False)
|
||||
Core.Player.Pokemons.Clear()
|
||||
Core.Player.Pokemons.AddRange(TempOriginalTeam.ToArray())
|
||||
BattleSystem.BattleScreen.OwnFaint = False
|
||||
BattleSystem.BattleScreen.OppFaint = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
@ -682,8 +680,6 @@
|
|||
Else
|
||||
PlayerStatistics.Track("PVP Losses", 1)
|
||||
End If
|
||||
BattleSystem.BattleScreen.OwnFaint = False
|
||||
BattleSystem.BattleScreen.OppFaint = False
|
||||
End Sub
|
||||
|
||||
Private Sub DrawBattleResults()
|
||||
|
|
|
@ -257,10 +257,9 @@
|
|||
Core.ServersManager.ServerConnection.Disconnect()
|
||||
End If
|
||||
Chat.ClearChat()
|
||||
If Core.Player.loadedSave = True And Me.canCreateAutosave = True Then
|
||||
'Core.Player.SaveGame(True)
|
||||
Core.Player.SaveGame(False)
|
||||
End If
|
||||
'If Core.Player.loadedSave = True And Me.canCreateAutosave = True Then
|
||||
' Core.Player.SaveGame(False)
|
||||
'End If
|
||||
ScriptStorage.Clear()
|
||||
Core.SetScreen(New PressStartScreen())
|
||||
Core.Player.loadedSave = False
|
||||
|
|
Loading…
Reference in New Issue