forked from MagicBane/Server
83 lines
2.9 KiB
Markdown
83 lines
2.9 KiB
Markdown
# Warehouse Handler Documentation
|
|||
|
|
|
||
|
|
## Overview
|
||
|
|
This document describes the database relationships and interactions for the `dbWarehouseHandler` class. The warehouse handler manages storage systems and inventory management for characters in the Magicbane emulator system.
|
||
|
|
|
||
|
|
## Handler Class
|
||
|
|
**File:** `src/engine/db/handlers/dbWarehouseHandler.java`
|
||
|
|
**Class:** `dbWarehouseHandler`
|
||
|
|
**Extends:** `dbHandlerBase`
|
||
|
|
|
||
|
|
## Database Tables
|
||
|
|
|
||
|
|
### Main Table(s)
|
||
|
|
- **Table Name:** `obj_warehouse`
|
||
|
|
- **Description:** Core warehouse information including storage capacity and location
|
||
|
|
- **Columns:**
|
||
|
|
- UID (Primary Key)
|
||
|
|
- name
|
||
|
|
- description
|
||
|
|
- characterID
|
||
|
|
- storageCapacity
|
||
|
|
- currentStorage
|
||
|
|
- locationX
|
||
|
|
- locationY
|
||
|
|
- locationZ
|
||
|
|
- isPublic
|
||
|
|
|
||
|
|
### Related Tables
|
||
|
|
|
||
|
|
| Table Name | Description | Relationship |
|
||
|
|
|------------|-------------|--------------|
|
||
|
|
| `obj_warehouse_item` | Tracks items stored in warehouses | WarehouseID → obj_warehouse.UID, ItemID → obj_item.UID |
|
||
|
|
| `obj_character_warehouse` | Links characters to their warehouse access | CharacterID → obj_character.UID, WarehouseID → obj_warehouse.UID |
|
||
|
|
|
||
|
|
## Key Queries
|
||
|
|
|
||
|
|
### Get Warehouse by ID
|
||
|
|
```sql
|
||
|
|
SELECT * FROM `obj_warehouse` WHERE `UID`=?
|
||
|
|
```
|
||
|
|
**File:** `dbWarehouseHandler.java`, Line ~60
|
||
|
|
|
||
|
|
### Get Character's Warehouses
|
||
|
|
```sql
|
||
|
|
SELECT w.* FROM `obj_warehouse` w
|
||
|
|
INNER JOIN `obj_character_warehouse` cw ON w.`UID` = cw.`WarehouseID`
|
||
|
|
WHERE cw.`CharacterID`=?
|
||
|
|
```
|
||
|
|
**File:** `dbWarehouseHandler.java`, Line ~85
|
||
|
|
|
||
|
|
### Get Warehouse Items
|
||
|
|
```sql
|
||
|
|
SELECT i.*, wi.quantity
|
||
|
|
FROM `obj_item` i
|
||
|
|
INNER JOIN `obj_warehouse_item` wi ON i.`UID` = wi.`ItemID`
|
||
|
|
WHERE wi.`WarehouseID`=?
|
||
|
|
```
|
||
|
|
**File:** `dbWarehouseHandler.java`, Line ~120
|
||
|
|
|
||
|
|
## Relationships
|
||
|
|
|
||
|
|
1. **Warehouse to Items:** Many-to-many through `obj_warehouse_item` table
|
||
|
|
2. **Warehouse to Characters:** Many-to-many through `obj_character_warehouse` table
|
||
|
|
3. **Warehouse to Storage Capacity:** Tracks current and maximum storage limits
|
||
|
|
|
||
|
|
## Java Field to Database Column Mappings
|
||
|
|
|
||
|
|
| Java Field | Database Column | Notes |
|
||
|
|
|------------|-----------------|-------|
|
||
|
|
| `name` | `obj_warehouse.name` | Warehouse name |
|
||
|
|
| `description` | `obj_warehouse.description` | Description of the warehouse |
|
||
|
|
| `characterID` | `obj_warehouse.characterID` | Character who owns this warehouse |
|
||
|
|
| `storageCapacity` | `obj_warehouse.storageCapacity` | Maximum storage capacity |
|
||
|
|
| `currentStorage` | `obj_warehouse.currentStorage` | Current amount of stored items |
|
||
|
|
| `locationX` | `obj_warehouse.locationX` | X coordinate of warehouse location |
|
||
|
|
| `locationY` | `obj_warehouse.locationY` | Y coordinate of warehouse location |
|
||
|
|
| `locationZ` | `obj_warehouse.locationZ` | Z coordinate of warehouse location |
|
||
|
|
| `isPublic` | `obj_warehouse.isPublic` | Whether the warehouse is publicly accessible |
|
||
|
|
|
||
|
|
## Notes
|
||
|
|
- Warehouses provide extended storage for character inventories
|
||
|
|
- Multiple characters can access shared warehouses
|
||
|
|
- The system tracks both storage capacity and current usage
|