mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-27 16:05:32 +00:00
Remove duplicated stage and attribute from UserCharacter
These fields are on the Character entity.
This commit is contained in:
parent
e36a700d9f
commit
da134247b1
@ -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
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user