Remove duplicated stage and attribute from UserCharacter

These fields are on the Character entity.
This commit is contained in:
Christopher O'Grady 2025-03-19 15:33:52 -04:00
parent e36a700d9f
commit da134247b1
5 changed files with 21 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import androidx.room.Insert
import androidx.room.OnConflictStrategy import androidx.room.OnConflictStrategy
import androidx.room.Query import androidx.room.Query
import androidx.room.Upsert 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.UserCharacter
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
import com.github.nacabaro.vbhelper.domain.device_data.TransformationHistory import com.github.nacabaro.vbhelper.domain.device_data.TransformationHistory
@ -116,4 +117,15 @@ interface UserCharacterDao {
@Query("UPDATE UserCharacter SET isActive = 1 WHERE id = :id") @Query("UPDATE UserCharacter SET isActive = 1 WHERE id = :id")
fun setActiveCharacter(id: Long) 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
} }

View File

@ -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 ( data class Character (
@PrimaryKey(autoGenerate = true) val id: Long = 0, @PrimaryKey(autoGenerate = true) val id: Long = 0,
val dimId: Long, val dimId: Long,

View File

@ -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 ( data class UserCharacter (
@PrimaryKey(autoGenerate = true) val id: Long = 0, @PrimaryKey(autoGenerate = true) val id: Long = 0,
var charId: Long, var charId: Long,
var stage: Int,
var attribute: NfcCharacter.Attribute,
var ageInDays: Int, var ageInDays: Int,
var nextAdventureMissionStage: Int, // next adventure mission stage on the character's dim var nextAdventureMissionStage: Int, // next adventure mission stage on the character's dim
var mood: Int, var mood: Int,

View File

@ -72,7 +72,7 @@ class AdventureScreenControllerImpl(
private suspend fun generateItem(characterId: Long): ItemDtos.PurchasedItem { private suspend fun generateItem(characterId: Long): ItemDtos.PurchasedItem {
val character = database val character = database
.userCharacterDao() .userCharacterDao()
.getCharacter(characterId) .getCharacterInfo(characterId)
val randomItem = database val randomItem = database
.itemDao() .itemDao()

View File

@ -167,8 +167,6 @@ class ScanScreenControllerImpl(
val characterData = UserCharacter( val characterData = UserCharacter(
charId = cardCharData.id, charId = cardCharData.id,
stage = nfcCharacter.stage.toInt(),
attribute = nfcCharacter.attribute,
ageInDays = nfcCharacter.ageInDays.toInt(), ageInDays = nfcCharacter.ageInDays.toInt(),
nextAdventureMissionStage = nfcCharacter.nextAdventureMissionStage.toInt(), nextAdventureMissionStage = nfcCharacter.nextAdventureMissionStage.toInt(),
mood = nfcCharacter.mood.toInt(), mood = nfcCharacter.mood.toInt(),