103 lines
4.6 KiB
Markdown
103 lines
4.6 KiB
Markdown
# Plan: Issue #91 - Cyberware/Bioware Tracking System
|
|
|
|
## Summary
|
|
|
|
Add a cyberware/bioware tracking system to the Shadowrun character sheet. This involves creating data model classes for augmentation entries (with name, grade, essence cost, and attribute effects), integrating essence tracking, applying attribute modifiers from installed ware, and building a UI panel for managing installed augmentations. The implementation follows the existing patterns established by the Lifestyle system for list-based character sub-models.
|
|
|
|
## Acceptance Criteria Checklist
|
|
|
|
1. [ ] Data model for cyberware/bioware entries with name, grade, essence cost, and effects
|
|
2. [ ] Installing ware automatically reduces essence
|
|
3. [ ] Attribute bonuses from ware are reflected in the character sheet
|
|
4. [ ] Removing ware restores essence
|
|
5. [ ] UI allows adding, viewing, and removing installed ware
|
|
6. [ ] Serialization/deserialization of ware data works correctly
|
|
|
|
## Implementation Steps
|
|
|
|
### Step 1: Create the Data Model
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/model/characterdata/Augmentation.kt`**
|
|
|
|
Create:
|
|
- `AugmentationType` enum: `Cyberware`, `Bioware`
|
|
- `AugmentationGrade` enum: `Standard`, `Alpha`, `Beta`, `Delta` with essence cost multipliers (1.0, 0.8, 0.7, 0.5)
|
|
- `AttributeEffect` data class: maps an `AttributeType` to a bonus `Int` value
|
|
- `Augmentation` data class with fields:
|
|
- `name: String`
|
|
- `type: AugmentationType`
|
|
- `grade: AugmentationGrade = AugmentationGrade.Standard`
|
|
- `baseEssenceCost: Float` (the base cost before grade multiplier)
|
|
- `effects: List<AttributeEffect> = emptyList()`
|
|
- `description: String = ""`
|
|
- Computed property `essenceCost: Float` = `baseEssenceCost * grade.essenceMultiplier`
|
|
|
|
All classes `@Serializable`.
|
|
|
|
### Step 2: Add Augmentations to ShadowrunCharacter
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/ShadowrunCharacter.kt`**
|
|
|
|
Add `val augmentations: List<Augmentation> = emptyList()` field.
|
|
|
|
### Step 3: Add Essence Calculation Logic
|
|
|
|
Add computed functions on `ShadowrunCharacter`:
|
|
- `totalEssenceLoss()`: sum of all augmentation essence costs
|
|
- `currentEssence()`: `characterData.essence - totalEssenceLoss()` (clamped to >= 0)
|
|
|
|
When adding/removing augmentations, the essence is automatically calculated from the base essence (6.0) minus total installed ware costs. The `characterData.essence` stays at the base value (6.0); the UI displays `currentEssence()`.
|
|
|
|
### Step 4: Create Augmentation Attribute Modifier
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/model/modifier/AugmentationModifier.kt`**
|
|
|
|
Create a `data class AugmentationModifier` implementing `AttributeModifier` that takes a list of `AttributeEffect` and applies them to `Attributes`. This integrates with the existing modifier system.
|
|
|
|
### Step 5: Add String Resources
|
|
|
|
**File: `sharedUI/src/commonMain/composeResources/values/strings.xml`**
|
|
|
|
Add strings for the augmentation UI (panel title, add/edit/remove labels, dialog fields, grade names, type names, empty state).
|
|
|
|
### Step 6: Add Test Tags
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/TestTags.kt`**
|
|
|
|
Add test tags for augmentation panel and dialog components.
|
|
|
|
### Step 7: Create AugmentationPanel UI
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/AugmentationPanel.kt`**
|
|
|
|
Follow the `LifestylePanel` pattern:
|
|
- Card with list of installed augmentations
|
|
- Each entry shows name, type, grade, essence cost, and effects
|
|
- Add, edit, and remove buttons
|
|
- Total essence cost display
|
|
- Edit dialog with all fields (name, type dropdown, grade dropdown, base essence cost input, effects list with attribute type dropdown + bonus input)
|
|
|
|
### Step 8: Integrate Panel into CharacterSheetPage
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/CharacterSheetPage.kt`**
|
|
|
|
Add `AugmentationPanel` to the Overview tab content, after LifestylePanel. Wire up `onAugmentationsChanged` callback to update `character.augmentations`. Display `currentEssence()` instead of raw `characterData.essence` where appropriate.
|
|
|
|
### Step 9: Update Defaults
|
|
|
|
**File: `sharedUI/src/commonMain/kotlin/org/shahondin1624/model/Defaults.kt`**
|
|
|
|
No changes needed since `augmentations` defaults to `emptyList()`.
|
|
|
|
### Step 10: Write Tests
|
|
|
|
**File: `sharedUI/src/commonTest/kotlin/org/shahondin1624/AugmentationTest.kt`**
|
|
|
|
Test:
|
|
- Augmentation essence cost calculation with different grades
|
|
- Adding augmentation reduces effective essence
|
|
- Removing augmentation restores effective essence
|
|
- Attribute effects are correctly modeled
|
|
- Serialization round-trip
|
|
- Essence cannot go below 0 constraint
|