Inventory List Checks

Blitz3D Forums/Blitz3D Programming/Inventory List Checks

Techlord(Posted 2007) [#1]
In my RPG I want to use a List Checking System to evaluate if a player possesses a specific item(s) needed to perforrm a specific action (ie: unlock a door). This checking is at the core of every action a player can perform.

Everything for the player is stored in a single inventory list to include attributes, skills, weapons, items, etc. This is the GIVE List. Every Game Control (Trigger/ Player Control / Gui Button) has a list of required item(s) needed to activate. This is the TAKE List.

Items in both Lists could be stored as Strings. The GIVE List item contains name & value. The TAKE List item contains logic condition {>, <, <>, <=, =>, =}, name & value.

When a player attempts to activate a control, items in the GIVE list are compared to the items TAKE list. First the items are checked to see if they exist, than compared using the logic condition. Each check results in a TRUE or FALSE. If all items checks = TRUE, the action is executed. If any item check = FALSE, the action is aborted.

The GIVE list can get pretty hefty in size requiring hundred of item checks. Thus, I' m looking for the most efficient means to store items (data structure) and evaluate the list (sort algorithm).


big10p(Posted 2007) [#2]
I take it you're using types for this? Should be quite straight forward, if so - assuming I'm understanding what you want, exactly. :)

Create a GIVE type and a TAKE type with the required fields, then have a linked list of GIVE/TAKE types in your main object type(s), as required.

For the logic condition checks of the TAKE type, have a field in the type that specifies the condition needed - 1 for =, 2 for <, 3 for > etc. Then you can apply the required condition test using a simple Select statement.


Techlord(Posted 2007) [#3]
@big10p: Thanks for the input. Ok, I used types. I've created one InventoryList List Type that mimics mySQL INVENTORY table. This is what I came up with: