Namespace Items
'''
''' Represents a Medicine Item.
'''
Public MustInherit Class MedicineItem
Inherits Item
Public Overrides ReadOnly Property ItemType As ItemTypes = ItemTypes.Medicine
'''
''' Tries to heal a Pokémon from the player's party. If this succeeds, the method returns True.
'''
''' The index of the Pokémon in the player's party.
''' The HP that should be healed.
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!", {})
Return False
Else
If Pokemon.HP = Pokemon.MaxHP Then
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " has full~HP already.", {})
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 & "."
t &= RemoveItem()
SoundManager.PlaySound("single_heal", False)
Screen.TextBox.Show(t, {})
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
End If
End If
End Function
'''
''' Tries to cure a Pokémon from Poison.
'''
''' The index of a Pokémon in the player's party.
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
Screen.TextBox.reDelay = 0.0F
Dim t As String = "Cures the poison of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
PlayerStatistics.Track("[17]Medicine Items used", 1)
SoundManager.PlaySound("single_heal", False)
Screen.TextBox.Show(t, {})
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not poisoned.", {})
Return False
End If
End Function
'''
''' Tries to wake a Pokémon up from Sleep.
'''
''' The index of a Pokémon in the player's party.
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
Screen.TextBox.reDelay = 0.0F
Dim t As String = "Cures the sleep of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("single_heal", False)
Screen.TextBox.Show(t, {})
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not asleep.", {})
Return False
End If
End Function
'''
''' Tries to heal a Pokémon from Burn.
'''
''' The index of a Pokémon in the player's party.
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
Screen.TextBox.reDelay = 0.0F
Dim t As String = "Cures the burn of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("single_heal", False)
Screen.TextBox.Show(t, {})
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not burned.", {})
Return False
End If
End Function
'''
''' Tries to heal a Pokémon from Ice.
'''
''' The index of a Pokémon in the player's party.
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
Core.Player.Inventory.RemoveItem(Me.ID, 1)
Screen.TextBox.reDelay = 0.0F
Dim t As String = "Cures the ice of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("single_heal", False)
Screen.TextBox.Show(t, {})
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not frozen.", {})
Return False
End If
End Function
'''
''' Tries to heal a Pokémon from Paralysis.
'''
''' The index of a Pokémon in the player's party.
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
Core.Player.Inventory.RemoveItem(Me.ID, 1)
Screen.TextBox.reDelay = 0.0F
Dim t As String = "Cures the paralysis~of " & Pokemon.GetDisplayName() & "."
t &= RemoveItem()
SoundManager.PlaySound("single_heal", False)
Screen.TextBox.Show(t, {})
PlayerStatistics.Track("[17]Medicine Items used", 1)
Return True
Else
Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(Pokemon.GetDisplayName() & " is not~paralyzed.", {})
Return False
End If
End Function
End Class
End Namespace