-18 - Dawnhold Dark Magic 0.16.0 Sahrab Android -
@Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insert(spell: SpellEntity)
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
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 -18 - dawnhold Dark Magic 0.16.0 sahrab Android
// 3️⃣ Converters ------------------------------------------------------------ class Converters ") @TypeConverter fun toList(value: String) = if (value.isEmpty()) emptyList() else value.split("
@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 ) @Insert(onConflict = OnConflictStrategy
@Dao interface SpellDao @Query("SELECT * FROM spells ORDER BY createdAt DESC") fun observeAll(): Flow<List<SpellEntity>>
Box( modifier = Modifier .size(96.dp) .clip(CircleShape) .background(background) .border(2.dp, Color.Magenta, CircleShape) .pointerInput(Unit) detectDragGestures( onDragStart = /* ignore */ , onDragEnd = /* ignore */ , onDragCancel = /* ignore */ , onDrag = change, _ -> // Accept only if dragged composable carries a ComponentEntity tag val comp = change.consumeAllChanges().metadata?.get<ComponentEntity>() comp?.let onDrop(it) ) ) if (filledComponent != null) Icon(painterResource(filledComponent.iconRes), contentDescription = filledComponent.name) IconButton(onClick = onClear, modifier = Modifier.align(Alignment.TopEnd)) Icon(Icons.Default.Close, tint = Color.White) else Icon(Icons.Default.Add, tint = Color.White.copy(alpha = 0.5f)) 5 ComponentType.REAGENT ->
// 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() )