-
Notifications
You must be signed in to change notification settings - Fork 0
Inventory System
A reusable inventory system built with Python and Object-Oriented Programming.
The goal of this project is to create an inventory system that can eventually be used in different types of games instead of being designed for only one specific game.
I want to build an inventory system that can handle common game inventory features while keeping the system separate from the game itself.
The inventory should eventually be able to manage:
- Items
- Quantities
- Inventory capacity
- Item stacking
- Item categories
- Weight
- Value
- Searching
- Sorting
- Saving and loading
After the inventory system is complete, I plan to demonstrate it by connecting it to a game.
The first version focuses only on the basic inventory system.
Current features:
-
Inventoryclass - Inventory capacity
- Add items
- Remove items
- Check for items
- Display inventory
- Count items
- Clear inventory
- Full inventory handling
- Missing item handling
The inventory currently uses regular Python strings as items.
Example:
Inventory:
- Sword
- Potion
- Dungeon Key
Capacity: 3/10
The project currently uses one main class:
Inventory
│
├── capacity
├── items
│
├── add_item()
├── remove_item()
├── display_inventory()
├── check_item()
├── clear_inventory()
└── count_items()
The goal is to gradually expand this structure as the inventory becomes more advanced.
Allow multiple copies of the same item to be represented as a quantity.
Instead of:
Potion
Potion
Potion
the inventory could display:
Potion x3
Create rules for how many copies of an item can occupy one inventory slot.
For example:
Potion
Maximum Stack: 10
Add categories such as:
- Weapons
- Armor
- Consumables
- Quest Items
- Materials
- Tools
- Miscellaneous
Give items different weights and calculate the total inventory weight.
Give items values and calculate the total value of everything in the inventory.
Allow the inventory to search for items or display only certain categories.
Allow items to be sorted by:
- Name
- Quantity
- Value
- Weight
- Category
Eventually, the inventory will be able to save its data to a JSON file and load it again later.
Once the basic inventory system is working, I want to introduce more OOP concepts.
A future version could have:
Item
├── Weapon
├── Armor
├── Consumable
└── QuestItem
This would allow me to practice:
- Inheritance
- Encapsulation
- Polymorphism
- Composition
- Multiple classes working together
After the inventory system is finished, I want to create a small game to demonstrate it.
The game will not contain a completely separate inventory system.
Instead:
Demo Game
↓
Universal Inventory System
The game will use the inventory system for things such as:
- Collecting items
- Viewing the inventory
- Using items
- Managing quantities
- Finding items
- Possibly equipping items
The purpose of the demo is to show that the inventory can be reused in a real game.
This project is helping me practice:
- Python classes
- Objects
__init__()self- Methods
- Lists
- Dictionaries
- Conditional statements
- Loops
- Searching
- Data structures
- JSON
- Object-Oriented Programming
- Designing reusable systems
Version 1
Basic Inventory
↓
Version 2
Quantities & Stacking
↓
Version 3
Categories, Weight & Value
↓
Version 4
Searching & Sorting
↓
Version 5
JSON Save/Load
↓
Version 6
Advanced OOP
↓
Version 7
Demo Game
The main goal is to build the inventory system independently first and only connect it to a game once the system is working reliably.
Pet Simulator Game