M app/src/main/java/com/github/nacabaro/vbhelper/daos/UserCharacterDao.kt => app/src/main/java/com/github/nacabaro/vbhelper/daos/UserCharacterDao.kt +12 -0
@@ 5,6 5,7 @@ import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Upsert
+import com.github.nacabaro.vbhelper.domain.characters.Character
import com.github.nacabaro.vbhelper.domain.device_data.UserCharacter
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
import com.github.nacabaro.vbhelper.domain.device_data.TransformationHistory
@@ 116,4 117,15 @@ interface UserCharacterDao {
@Query("UPDATE UserCharacter SET isActive = 1 WHERE id = :id")
fun setActiveCharacter(id: Long)
+
+ @Query(
+ """
+ SELECT c.*
+ FROM Character c
+ join UserCharacter uc on c.id = uc.charId
+ where uc.id = :charId
+ LIMIT 1
+ """
+ )
+ suspend fun getCharacterInfo(charId: Long): Character
}=
\ No newline at end of file
M app/src/main/java/com/github/nacabaro/vbhelper/domain/characters/Character.kt => app/src/main/java/com/github/nacabaro/vbhelper/domain/characters/Character.kt +5 -0
@@ 14,6 14,11 @@ import androidx.room.ForeignKey
)
]
)
+/*
+ * Character represents a character on a DIM card. There should only be one of these per dimId
+ * and monIndex.
+ * TODO: Customs will mean this should be unique per cardName and monIndex
+ */
data class Character (
@PrimaryKey(autoGenerate = true) val id: Long = 0,
val dimId: Long,
M app/src/main/java/com/github/nacabaro/vbhelper/domain/device_data/UserCharacter.kt => app/src/main/java/com/github/nacabaro/vbhelper/domain/device_data/UserCharacter.kt +3 -2
@@ 17,11 17,12 @@ import com.github.nacabaro.vbhelper.domain.characters.Character
)
]
)
+/**
+ * UserCharacter represents and instance of a character. The charId should map to a Character
+ */
data class UserCharacter (
@PrimaryKey(autoGenerate = true) val id: Long = 0,
var charId: Long,
- var stage: Int,
- var attribute: NfcCharacter.Attribute,
var ageInDays: Int,
var nextAdventureMissionStage: Int, // next adventure mission stage on the character's dim
var mood: Int,
M app/src/main/java/com/github/nacabaro/vbhelper/screens/adventureScreen/AdventureScreenControllerImpl.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/adventureScreen/AdventureScreenControllerImpl.kt +1 -1
@@ 72,7 72,7 @@ class AdventureScreenControllerImpl(
private suspend fun generateItem(characterId: Long): ItemDtos.PurchasedItem {
val character = database
.userCharacterDao()
- .getCharacter(characterId)
+ .getCharacterInfo(characterId)
val randomItem = database
.itemDao()
M app/src/main/java/com/github/nacabaro/vbhelper/screens/scanScreen/ScanScreenControllerImpl.kt => app/src/main/java/com/github/nacabaro/vbhelper/screens/scanScreen/ScanScreenControllerImpl.kt +0 -2
@@ 167,8 167,6 @@ class ScanScreenControllerImpl(
val characterData = UserCharacter(
charId = cardCharData.id,
- stage = nfcCharacter.stage.toInt(),
- attribute = nfcCharacter.attribute,
ageInDays = nfcCharacter.ageInDays.toInt(),
nextAdventureMissionStage = nfcCharacter.nextAdventureMissionStage.toInt(),
mood = nfcCharacter.mood.toInt(),