TABLE OF CONTENTS
- 1. Items/Items
- 1.1. Items/Items.Inventory_Container
- 1.2. Items/Items.Items_Durability
- 1.3. Items/Items.Values_Range
- 1.4. Items/Items.Inventory_Data
- 1.5. Items/Items.Object_Data
- 1.6. Items/Items.Default_Item_Durability
- 1.7. Items/Items.Empty_Item
- 1.8. Items/Items.Empty_Object
- 1.9. Items/Items.Find_Item
- 1.10. Items/Items.Find_Proto_Item
- 1.11. Items/Items.Get_Item_Chance_To_Damage
- 1.12. Items/Items.Get_Item_Damage
- 1.13. Items/Items.Get_Item_Name
- 1.14. Items/Items.Is_Tool
Items/Items [ Packages ]
FUNCTION
Provice code for manipulate items
SOURCE
package Items is
Items/Items.Inventory_Container [ Types ]
FUNCTION
Used to store inventory data
SOURCE
package Inventory_Container is new Formal_Vectors (Index_Type => Positive, Element_Type => Inventory_Data);
Items/Items.Items_Durability [ Types ]
FUNCTION
Used to mark items durability
SOURCE
subtype Items_Durability is Natural range 0 .. 101;
Items/Items.Values_Range [ Types ]
FUNCTION
Used to set amount of additional data for items
SOURCE
subtype Values_Range is Positive range 1 .. 5;
HISTORY
7.4 - Added
Items/Items.Inventory_Data [ Records ]
FUNCTION
Data structure for item in inventory
SOURCE
type Inventory_Data is record Proto_Index: Natural; Amount: Positive := 1; Name: Tiny_String.Bounded_String; Durability: Items_Durability; Price: Natural := 0; end record;
PARAMETERS
Proto_Index - Index of prototype Amount - Amount of item Name - Name of item if different than default Durability - Current durability of item Price - Price for which item was bought
Items/Items.Object_Data [ Records ]
FUNCTION
Data structure for objects prototypes
SOURCE
type Object_Data is record Name: Tiny_String.Bounded_String; Weight: Positive := 1; I_Type: Tiny_String.Bounded_String; Price: Natural := 0; Value: Integer_Array (Values_Range); Show_Type: Tiny_String.Bounded_String; Description: Short_String.Bounded_String; Reputation: Reputation_Range; end record;
PARAMETERS
Name - Name of item Weight - Weight of item I_Type - Type of item Price - Price of item in bases Value - Additional item data (damage for ammo, etc) Show_Type - Displayed type of item (can be group of items, renamed type, etc) Description - Description of item Reputation - Minimal reputation in base needed to buy that module
Items/Items.Default_Item_Durability [ Constants ]
[ Top ] [ Items ] [ Constants ]
FUNCTION
Default value for items durability
SOURCE
Default_Item_Durability: constant Items_Durability := 100;
Items/Items.Empty_Item [ Constants ]
[ Top ] [ Items ] [ Constants ]
FUNCTION
Default, empty item for inventory
SOURCE
Empty_Item: constant Inventory_Data := (others => <>);
Items/Items.Empty_Object [ Constants ]
[ Top ] [ Items ] [ Constants ]
FUNCTION
Default, empty object prototype
SOURCE
Empty_Object: constant Object_Data := (others => <>);
Items/Items.Find_Item [ Subprograms ]
[ Top ] [ Items ] [ Subprograms ]
FUNCTION
Find item in ship cargo or character inventory
SOURCE
function Find_Item (Inventory: Inventory_Container.Vector; Proto_Index: Natural := 0; Item_Type: Tiny_String.Bounded_String := Tiny_String.Null_Bounded_String; Durability: Items_Durability := Items_Durability'Last; Quality: Positive := 100) return Natural with Post => Find_Item'Result <= Inventory_Container.Last_Index(Container => Inventory);
PARAMETERS
Inventory - Inventory in which item will be looking for Proto_Index - Prototype index of item. Can be empty if ItemType is set Item_Type - Type of item to search. Can be empty if ProtoIndex is set Durability - Durability of item to search. Can be empty Quality - Quality of item to search. Can be empty
RESULT
Iventory index of item or 0 if item was not found
Items/Items.Find_Proto_Item [ Subprograms ]
[ Top ] [ Items ] [ Subprograms ]
FUNCTION
Search for prototype index of selected item
SOURCE
function Find_Proto_Item (Item_Type: Tiny_String.Bounded_String) return Natural with Pre => Tiny_String.Length(Source => Item_Type) > 0;
PARAMETERS
Item_Type - Item type of item which map index is looking for
RESULT
Prototype index of the item or 0 if index can't be found
Items/Items.Get_Item_Chance_To_Damage [ Subprograms ]
[ Top ] [ Items ] [ Subprograms ]
FUNCTION
Get item chance to damage info
SOURCE
function Get_Item_Chance_To_Damage(Item_Data: Natural) return String with Post => Get_Item_Chance_To_Damage'Result'Length > 0;
PARAMETERS
Item_Data - Numeric chance to damage for selected item
RESULT
String with chance to damage level description
Items/Items.Get_Item_Damage [ Subprograms ]
[ Top ] [ Items ] [ Subprograms ]
FUNCTION
Get description of item damage
SOURCE
function Get_Item_Damage (Item_Durability: Items_Durability; To_Lower, With_Colors: Boolean := False) return String with Post => Get_Item_Damage'Result'Length > 0;
PARAMETERS
Item_Durability - Numeric value of current durability of the item To_Lower - If true, convert description to lower cases. Default is false With_Colors - If true, add colors' tags to the description. Default value is false
RESULT
Description of item damage level
Items/Items.Get_Item_Name [ Subprograms ]
[ Top ] [ Items ] [ Subprograms ]
FUNCTION
Get name of item in ship cargo or character inventory Item - Item to get it name Damage_Info - If true, include description of the item damage in name. Default is true. To_Lower - If true, convert damage info to lower case. Default is true.
SOURCE
function Get_Item_Name (Item: Inventory_Data; Damage_Info, To_Lower: Boolean := True) return String with Post => Get_Item_Name'Result'Length > 0;
RESULT
Name of item with additional damage level info
Items/Items.Is_Tool [ Subprograms ]
[ Top ] [ Items ] [ Subprograms ]
FUNCTION
Check if the selected items type is tool
SOURCE
function Is_Tool(Item_Type: Tiny_String.Bounded_String) return Boolean;
PARAMETERS
Item_Type - The type of items to check
RESULT
True if the Item_Type is tool, otherwise False