2016-09-07 18:50:38 +02:00
''' <summary>
''' Represents the player's inventory.
''' </summary>
Public Class PlayerInventory
Inherits List ( Of ItemContainer )
''' <summary>
''' A secure class to contain ItemID and Amount.
''' </summary>
Class ItemContainer
2023-05-29 15:33:57 +02:00
Private _itemID As String
2016-09-07 18:50:38 +02:00
Private _amount As Integer
2023-05-29 15:33:57 +02:00
Public Property ItemID ( ) As String
2016-09-07 18:50:38 +02:00
Get
Return Me . _itemID
End Get
2023-05-29 15:33:57 +02:00
Set ( value As String )
2016-09-07 18:50:38 +02:00
Me . _itemID = value
End Set
End Property
Public Property Amount ( ) As Integer
Get
Return Me . _amount
End Get
Set ( value As Integer )
Me . _amount = value
End Set
End Property
2023-05-29 15:33:57 +02:00
Public Sub New ( ByVal ItemID As String , ByVal Amount As Integer )
2016-09-07 18:50:38 +02:00
Me . ItemID = ItemID
Me . Amount = Amount
End Sub
End Class
''' <summary>
''' Returns a character that represents the item's pocket icon.
''' </summary>
Public Function GetItemPocketChar ( ByVal Item As Item ) As String
Select Case Item . ItemType
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . Standard
2021-08-22 16:47:26 +02:00
Return " € "
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . KeyItems
2021-08-22 16:47:26 +02:00
Return " № "
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . Machines
2021-08-22 16:47:26 +02:00
Return " ™ "
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . Mail
2021-08-22 16:47:26 +02:00
Return " ← "
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . Medicine
2021-08-22 16:47:26 +02:00
Return " ↑ "
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . Plants
2021-08-22 16:47:26 +02:00
Return " → "
2016-09-20 02:18:12 +02:00
Case Items . ItemTypes . Pokéballs
2021-08-22 16:47:26 +02:00
Return " ↓ "
2022-05-24 22:20:58 +02:00
Case Items . ItemTypes . BattleItems
Return " ↔ "
2016-09-07 18:50:38 +02:00
End Select
Return " "
End Function
''' <summary>
''' Adds items to the inventory.
''' </summary>
''' <param name="ID">The ID of the item.</param>
''' <param name="Amount">Amount of items to add.</param>
2023-05-29 15:33:57 +02:00
Public Sub AddItem ( ByVal ID As String , ByVal Amount As Integer )
2016-09-07 18:50:38 +02:00
For Each c As ItemContainer In Me
If c . ItemID = ID Then
c . Amount += Amount
Exit Sub
End If
Next
Me . Add ( New ItemContainer ( ID , Amount ) )
2024-02-09 17:51:09 +01:00
Dim item As Item = Item . GetItemByID ( ID )
If item . IsMail = True AndAlso item . IsGameModeItem = False Then
Dim hasAllMail = True
For m = 300 To 323
If Core . Player . Inventory . GetItemAmount ( m . ToString ) = 0 Then
hasAllMail = False
Exit For
End If
Next
If hasAllMail = True Then
GameJolt . Emblem . AchieveEmblem ( " mailman " )
End If
End If
2016-09-07 18:50:38 +02:00
End Sub
''' <summary>
''' Removes items from the inventory.
''' </summary>
''' <param name="ID">The ID of the item to remove.</param>
''' <param name="Amount">The amount of items to remove.</param>
2023-05-29 15:33:57 +02:00
Public Sub RemoveItem ( ByVal ID As String , ByVal Amount As Integer )
2016-09-07 18:50:38 +02:00
If Amount > 0 Then
For Each c As ItemContainer In Me
If c . ItemID = ID Then
If c . Amount - Amount <= 0 Then
Me . Remove ( c )
Exit Sub
Else
c . Amount -= Amount
End If
End If
Next
2023-01-30 19:45:36 +01:00
Else
For Each c As ItemContainer In Me
If c . ItemID = ID Then
Me . Remove ( c )
Exit Sub
End If
Next
2016-09-07 18:50:38 +02:00
End If
End Sub
''' <summary>
''' Removes all items of an ID from the inventory.
''' </summary>
''' <param name="ID">The ID of the item.</param>
2023-05-29 15:33:57 +02:00
Public Sub RemoveItem ( ByVal ID As String )
2016-09-07 18:50:38 +02:00
Dim Amount As Integer = Me . GetItemAmount ( ID )
If Amount > 0 Then
Me . RemoveItem ( ID , Amount )
End If
End Sub
''' <summary>
''' Returns the count of the item in the inventory.
''' </summary>
''' <param name="ID">The ID of the item to be counted.</param>
2023-05-29 15:33:57 +02:00
Public Function GetItemAmount ( ByVal ID As String ) As Integer
2016-09-07 18:50:38 +02:00
For Each c As ItemContainer In Me
If c . ItemID = ID Then
Return c . Amount
End If
Next
Return 0
End Function
''' <summary>
''' If the player has the Running Shoes in their inventory.
''' </summary>
Public ReadOnly Property HasRunningShoes ( ) As Boolean
Get
If Core . Player . SandBoxMode = True Or GameController . IS_DEBUG_ACTIVE = True Then
Return True
Else
2023-05-29 15:33:57 +02:00
If Me . GetItemAmount ( 78 . ToString ) > 0 Then
2016-09-07 18:50:38 +02:00
Return True
End If
End If
Return False
End Get
End Property
2018-01-21 20:38:05 +01:00
''' <summary>
''' If the player has the Mega Bracelet in their inventory.
''' </summary>
Public ReadOnly Property HasMegaBracelet ( ) As Boolean
Get
2023-05-29 15:33:57 +02:00
If Me . GetItemAmount ( 576 . ToString ) > 0 Then
2018-01-21 20:38:05 +01:00
Return True
End If
Return False
End Get
End Property
2016-09-07 18:50:38 +02:00
''' <summary>
''' Returns a message that displays the event of putting an item into the inventory.
''' </summary>
''' <param name="Item">The Item to store in the inventory.</param>
''' <param name="Amount">The amount.</param>
Public Function GetMessageReceive ( ByVal Item As Item , ByVal Amount As Integer ) As String
2023-05-29 15:33:57 +02:00
Dim Message As String
2023-08-10 10:31:57 +02:00
Dim SpaceAfterStart As String = " "
2016-09-07 18:50:38 +02:00
If Amount = 1 Then
2023-08-10 10:31:57 +02:00
If Localization . GetString ( " item_stored_in_pocket_single_start " , " <player.name> stored it in the~ " ) . Replace ( " <player.name> " , Core . Player . Name ) . EndsWith ( " ~ " ) = False Then
SpaceAfterStart = " "
End If
Else
If Localization . GetString ( " item_stored_in_pocket_multiple_start " , " <player.name> stored them~in the " ) . Replace ( " <player.name> " , Core . Player . Name ) . EndsWith ( " ~ " ) = False Then
SpaceAfterStart = " "
End If
End If
If Amount = 1 Then
Message = Localization . GetString ( " item_stored_in_pocket_single_start " , " <player.name> stored it in the~ " ) . Replace ( " <player.name> " , Core . Player . Name ) & SpaceAfterStart & Core . Player . Inventory . GetItemPocketChar ( Item ) & Localization . GetString ( " item_category_ " & Item . ItemType . ToString ( ) , Item . ItemType . ToString ( ) ) & " " & Localization . GetString ( " item_stored_in_pocket_single_end " , " pocket. " ) . Replace ( " <player.name> " , Core . Player . Name )
2016-09-07 18:50:38 +02:00
Else
2023-08-10 10:31:57 +02:00
Message = Localization . GetString ( " item_stored_in_pocket_multiple_start " , " <player.name> stored them~in the " ) . Replace ( " <player.name> " , Core . Player . Name ) & SpaceAfterStart & Core . Player . Inventory . GetItemPocketChar ( Item ) & Localization . GetString ( " item_category_ " & Item . ItemType . ToString ( ) , Item . ItemType . ToString ( ) ) & " " & Localization . GetString ( " item_stored_in_pocket_multiple_end " , " pocket. " ) . Replace ( " <player.name> " , Core . Player . Name )
2016-09-07 18:50:38 +02:00
End If
Return Message
End Function
End Class