-18 - Dawnhold Dark Magic 0.16.0 Sahrab Android File

// 3️⃣ Converters ------------------------------------------------------------ class Converters ") @TypeConverter fun toList(value: String) = if (value.isEmpty()) emptyList() else value.split("

private fun synthesizeSpell(): SpellEntity require(canSynthesize()) val rune = currentComponents.first it?.type == ComponentType.RUNE !! val gesture = currentComponents.first it?.type == ComponentType.GESTURE !!

return SpellEntity( name = name, description = description, manaCost = mana, componentIds = comps.map it.id ) -18 - dawnhold Dark Magic 0.16.0 sahrab Android

@Entity(tableName = "components") data class ComponentEntity( @PrimaryKey val id: String, // e.g. "rune_ember" val name: String, val type: ComponentType, val rarity: Int, // 1..5 val iconRes: Int // @DrawableRes )

7.1 Repository Skeleton @Singleton class SpellRepository @Inject constructor( private val spellDao: SpellDao, private val componentDao: ComponentDao, private val api: SpellApi, @ApplicationContext private val ctx: Context ) { // Local flow val allSpells: Flow<List<SpellEntity>> = spellDao.observeAll() "rune_ember" val name: String, val type: ComponentType, val

val name = "$rune.name of $gesture.name" val mana = comps.sumOf it.rarity * when (it.type) ComponentType.RUNE -> 5 ComponentType.REAGENT -> 3 ComponentType.GESTURE -> 2

@Composable fun AltarSlot( slotIndex: Int, filledComponent: ComponentEntity?, onDrop: (ComponentEntity) -> Unit, onClear: () -> Unit ) val background = if (filledComponent == null) Color.Black.copy(alpha = 0.2f) else Color.Transparent | | Mana Cost = (Rarity × 10)

val description = comps.joinToString("\n") "- $it.name: $itLore[it.id] ?: "…""

| Rule | Explanation | |------|-------------| | Rarity Sum ≤ 10 | Prevent “over‑powered” spells. | | At least one RUNE | Guarantees a magical core. | | No duplicate component IDs | Each slot must be unique. | | Mana Cost = (Rarity × 10) + (type‑bonus) | Runes × 5, Reagents × 3, Gestures × 2. | | Name Generation | <Rune.name> + “ of ” + <Gesture.name> (fallback to generic). | | Description | Auto‑generated from component lore strings. |

// Insert locally + optional cloud suspend fun saveSpell(spell:

@Dao interface SpellDao @Query("SELECT * FROM spells ORDER BY createdAt DESC") fun observeAll(): Flow<List<SpellEntity>>