81 lines
2.7 KiB
Markdown
81 lines
2.7 KiB
Markdown
# Power Handler Documentation
|
|||
|
|
|
||
|
|
## Overview
|
||
|
|
This document describes the database relationships and interactions for the `dbPowerHandler` class. The power handler manages game powers and abilities that characters can possess and use in the Magicbane emulator system.
|
||
|
|
|
||
|
|
## Handler Class
|
||
|
|
**File:** `src/engine/db/handlers/dbPowerHandler.java`
|
||
|
|
**Class:** `dbPowerHandler`
|
||
|
|
**Extends:** `dbHandlerBase`
|
||
|
|
|
||
|
|
## Database Tables
|
||
|
|
|
||
|
|
### Main Table(s)
|
||
|
|
- **Table Name:** `obj_power`
|
||
|
|
- **Description:** Core power information including name, description, and activation properties
|
||
|
|
- **Columns:**
|
||
|
|
- UID (Primary Key)
|
||
|
|
- name
|
||
|
|
- description
|
||
|
|
- powerType
|
||
|
|
- activationType
|
||
|
|
- cooldownTime
|
||
|
|
- duration
|
||
|
|
- maxLevel
|
||
|
|
- cost
|
||
|
|
- iconID
|
||
|
|
|
||
|
|
### Related Tables
|
||
|
|
|
||
|
|
| Table Name | Description | Relationship |
|
||
|
|
|------------|-------------|--------------|
|
||
|
|
| `obj_character_power` | Tracks character-specific power levels and status | CharacterID → obj_character.UID, PowerID → obj_power.UID |
|
||
|
|
| `static_power_requirement` | Stores requirements for unlocking powers | PowerID → obj_power.UID |
|
||
|
|
|
||
|
|
## Key Queries
|
||
|
|
|
||
|
|
### Get Power by ID
|
||
|
|
```sql
|
||
|
|
SELECT * FROM `obj_power` WHERE `UID`=?
|
||
|
|
```
|
||
|
|
**File:** `dbPowerHandler.java`, Line ~60
|
||
|
|
|
||
|
|
### Get Character's Powers
|
||
|
|
```sql
|
||
|
|
SELECT p.*, cp.level, cp.isUnlocked
|
||
|
|
FROM `obj_power` p
|
||
|
|
INNER JOIN `obj_character_power` cp ON p.`UID` = cp.`PowerID`
|
||
|
|
WHERE cp.`CharacterID`=?
|
||
|
|
```
|
||
|
|
**File:** `dbPowerHandler.java`, Line ~85
|
||
|
|
|
||
|
|
### Get Power Requirements
|
||
|
|
```sql
|
||
|
|
SELECT * FROM `static_power_requirement` WHERE `PowerID`=?
|
||
|
|
```
|
||
|
|
**File:** `dbPowerHandler.java`, Line ~120
|
||
|
|
|
||
|
|
## Relationships
|
||
|
|
|
||
|
|
1. **Power to Character:** Many-to-many through `obj_character_power` table
|
||
|
|
2. **Power to Requirements:** One-to-many (via `static_power_requirement.PowerID`)
|
||
|
|
3. **Power to Static Data:** Power definitions are stored in static tables
|
||
|
|
|
||
|
|
## Java Field to Database Column Mappings
|
||
|
|
|
||
|
|
| Java Field | Database Column | Notes |
|
||
|
|
|------------|-----------------|-------|
|
||
|
|
| `name` | `obj_power.name` | Power name |
|
||
|
|
| `description` | `obj_power.description` | Power description |
|
||
|
|
| `powerType` | `obj_power.powerType` | Type of power (active, passive) |
|
||
|
|
| `activationType` | `obj_power.activationType` | How the power is activated |
|
||
|
|
| `cooldownTime` | `obj_power.cooldownTime` | Cooldown period in seconds |
|
||
|
|
| `duration` | `obj_power.duration` | Duration of power effect |
|
||
|
|
| `maxLevel` | `obj_power.maxLevel` | Maximum level for this power |
|
||
|
|
| `cost` | `obj_power.cost` | Resource cost to use power |
|
||
|
|
| `iconID` | `obj_power.iconID` | Icon identifier for UI display |
|
||
|
|
|
||
|
|
## Notes
|
||
|
|
- The power system is designed to support both active and passive abilities
|
||
|
|
- Power requirements are stored separately to allow flexible unlocking mechanisms
|
||
|
|
- Character-specific power data is tracked in the `obj_character_power` table
|