P3D-Legacy/P3D/Pokemon/Items/MedicineItem.vb

251 lines
9.8 KiB
VB.net
Raw Normal View History

2016-09-19 03:26:44 +02:00
Namespace Items
2016-09-07 18:50:38 +02:00
''' <summary>
''' Represents a Medicine Item.
''' </summary>
Public MustInherit Class MedicineItem
2016-09-07 18:50:38 +02:00
Inherits Item
2016-09-20 02:18:12 +02:00
Public Overrides ReadOnly Property ItemType As ItemTypes = ItemTypes.Medicine
2016-09-07 18:50:38 +02:00
''' <summary>
''' Tries to heal a Pokémon from the player's party. If this succeeds, the method returns True.
''' </summary>
''' <param name="PokeIndex">The index of the Pokémon in the player's party.</param>
''' <param name="HP">The HP that should be healed.</param>
Public Function HealPokemon(ByVal PokeIndex As Integer, ByVal HP As Integer) As Boolean
If PokeIndex < 0 Or PokeIndex > 5 Then
Throw New ArgumentOutOfRangeException("PokeIndex", PokeIndex, "The index for a Pokémon in a player's party can only be between 0 and 5.")
End If
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If HP < 0 Then
HP = CInt(Pokemon.MaxHP / (100 / (HP * (-1))))
End If
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & "~is fainted!", {})
2016-09-07 18:50:38 +02:00
Return False
Else
If Pokemon.HP = Pokemon.MaxHP Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " has full~HP already.", {})
2016-09-07 18:50:38 +02:00
Return False
Else
Dim diff As Integer = Pokemon.MaxHP - Pokemon.HP
diff = CInt(MathHelper.Clamp(diff, 1, HP))
Pokemon.Heal(HP)
Screen.TextBox.reDelay = 0.0F
Dim t As String = "Restored " & Pokemon.GetDisplayName() & "'s~HP by " & diff & "."
2016-09-07 18:50:38 +02:00
t &= RemoveItem()
SoundManager.PlaySound("Use_Item", False)
Screen.TextBox.Show(t, {})
2016-09-07 18:50:38 +02:00
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
End If
End If
End Function
''' <summary>
''' Tries to cure a Pokémon from Poison.
''' </summary>
''' <param name="PokeIndex">The index of a Pokémon in the player's party.</param>
Public Function CurePoison(ByVal PokeIndex As Integer) As Boolean
If PokeIndex < 0 Or PokeIndex > 5 Then
Throw New ArgumentOutOfRangeException("PokeIndex", PokeIndex, "The index for a Pokémon in a player's party can only be between 0 and 5.")
End If
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & "~is fainted!", {})
Return False
ElseIf Pokemon.Status = P3D.Pokemon.StatusProblems.Poison Or Pokemon.Status = P3D.Pokemon.StatusProblems.BadPoison Then
Pokemon.Status = P3D.Pokemon.StatusProblems.None
2016-09-07 18:50:38 +02:00
Screen.TextBox.reDelay = 0.0F
2016-09-07 18:50:38 +02:00
Dim t As String = "Cures the poison of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
PlayerStatistics.Track("[17]Medicine Items used", 1)
SoundManager.PlaySound("Use_Item", False)
Screen.TextBox.Show(t, {})
2016-09-07 18:50:38 +02:00
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not poisoned.", {})
2016-09-07 18:50:38 +02:00
Return False
End If
End Function
''' <summary>
''' Tries to wake a Pokémon up from Sleep.
''' </summary>
''' <param name="PokeIndex">The index of a Pokémon in the player's party.</param>
Public Function WakeUp(ByVal PokeIndex As Integer) As Boolean
If PokeIndex < 0 Or PokeIndex > 5 Then
Throw New ArgumentOutOfRangeException("PokeIndex", PokeIndex, "The index for a Pokémon in a player's party can only be between 0 and 5.")
End If
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & "~is fainted!", {})
Return False
ElseIf Pokemon.Status = P3D.Pokemon.StatusProblems.Sleep Then
Pokemon.Status = P3D.Pokemon.StatusProblems.None
2016-09-07 18:50:38 +02:00
Screen.TextBox.reDelay = 0.0F
2016-09-07 18:50:38 +02:00
Dim t As String = "Cures the sleep of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("Use_Item", False)
Screen.TextBox.Show(t, {})
2016-09-07 18:50:38 +02:00
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not asleep.", {})
2016-09-07 18:50:38 +02:00
Return False
End If
End Function
''' <summary>
''' Tries to heal a Pokémon from Burn.
''' </summary>
''' <param name="PokeIndex">The index of a Pokémon in the player's party.</param>
Public Function HealBurn(ByVal PokeIndex As Integer) As Boolean
If PokeIndex < 0 Or PokeIndex > 5 Then
Throw New ArgumentOutOfRangeException("PokeIndex", PokeIndex, "The index for a Pokémon in a player's party can only be between 0 and 5.")
End If
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & "~is fainted!", {})
Return False
ElseIf Pokemon.Status = P3D.Pokemon.StatusProblems.Burn Then
Pokemon.Status = P3D.Pokemon.StatusProblems.None
2016-09-07 18:50:38 +02:00
Screen.TextBox.reDelay = 0.0F
2016-09-07 18:50:38 +02:00
Dim t As String = "Cures the burn of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("Use_Item", False)
Screen.TextBox.Show(t, {})
2016-09-07 18:50:38 +02:00
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not burned.", {})
2016-09-07 18:50:38 +02:00
Return False
End If
End Function
''' <summary>
''' Tries to heal a Pokémon from Ice.
''' </summary>
''' <param name="PokeIndex">The index of a Pokémon in the player's party.</param>
Public Function HealIce(ByVal PokeIndex As Integer) As Boolean
If PokeIndex < 0 Or PokeIndex > 5 Then
Throw New ArgumentOutOfRangeException("PokeIndex", PokeIndex, "The index for a Pokémon in a player's party can only be between 0 and 5.")
End If
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & "~is fainted!", {})
Return False
ElseIf Pokemon.Status = P3D.Pokemon.StatusProblems.Freeze Then
Pokemon.Status = P3D.Pokemon.StatusProblems.None
2016-09-07 18:50:38 +02:00
Core.Player.Inventory.RemoveItem(Me.ID, 1)
Screen.TextBox.reDelay = 0.0F
2016-09-07 18:50:38 +02:00
Dim t As String = "Cures the ice of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("Use_Item", False)
Screen.TextBox.Show(t, {})
2016-09-07 18:50:38 +02:00
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not frozen.", {})
2016-09-07 18:50:38 +02:00
Return False
End If
End Function
''' <summary>
''' Tries to heal a Pokémon from Paralysis.
''' </summary>
''' <param name="PokeIndex">The index of a Pokémon in the player's party.</param>
Public Function HealParalyze(ByVal PokeIndex As Integer) As Boolean
If PokeIndex < 0 Or PokeIndex > 5 Then
Throw New ArgumentOutOfRangeException("PokeIndex", PokeIndex, "The index for a Pokémon in a player's party can only be between 0 and 5.")
End If
Dim Pokemon As Pokemon = Core.Player.Pokemons(PokeIndex)
If Pokemon.Status = P3D.Pokemon.StatusProblems.Fainted Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & "~is fainted!", {})
Return False
ElseIf Pokemon.Status = P3D.Pokemon.StatusProblems.Paralyzed Then
Pokemon.Status = P3D.Pokemon.StatusProblems.None
2016-09-07 18:50:38 +02:00
Core.Player.Inventory.RemoveItem(Me.ID, 1)
Screen.TextBox.reDelay = 0.0F
2016-09-07 18:50:38 +02:00
Dim t As String = "Cures the paralysis~of " & Pokemon.GetDisplayName() & "."
2016-09-07 18:50:38 +02:00
t &= RemoveItem()
SoundManager.PlaySound("Use_Item", False)
Screen.TextBox.Show(t, {})
2016-09-07 18:50:38 +02:00
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not~paralyzed.", {})
2016-09-07 18:50:38 +02:00
Return False
End If
End Function
End Class
2016-09-19 03:26:44 +02:00
End Namespace