-18 - Dawnhold Dark Magic 0.16.0 Sahrab Android Apr 2026
@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
// 2️⃣ Spell -------------------------------------------------------------- @Entity(tableName = "spells") data class SpellEntity( @PrimaryKey val spellId: String = UUID.randomUUID().toString(), val name: String, val description: String, val manaCost: Int, val componentIds: List<String>, // stored via TypeConverter val createdAt: Long = System.currentTimeMillis() )
@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 )
private fun canSynthesize(): Boolean val comps = currentComponents.filterNotNull() if (comps.size != 3) return false if (comps.distinctBy it.id .size != 3) return false if (comps.none it.type == ComponentType.RUNE ) return false if (comps.sumOf it.rarity > 10) return false return true -18 - dawnhold Dark Magic 0.16.0 sahrab Android
// Insert locally + optional cloud suspend fun saveSpell(spell:
@Dao interface SpellDao @Query("SELECT * FROM spells ORDER BY createdAt DESC") fun observeAll(): Flow<List<SpellEntity>>
// 3️⃣ Converters ------------------------------------------------------------ class Converters ") @Composable fun AltarSlot( slotIndex: Int
@Delete suspend fun delete(spell: SpellEntity)
@Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertAll(components: List<ComponentEntity>)
@Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insert(spell: SpellEntity) onDrop: (ComponentEntity) ->
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
Implementation (inside SpellCraftViewModel ):
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()