mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-27 16:05:32 +00:00
Added basic stuff for compatibility with VB
This commit is contained in:
parent
f7b3b7256a
commit
9f5f806786
@ -42,4 +42,14 @@ interface CharacterDao {
|
||||
:transformationDate)
|
||||
""")
|
||||
fun insertTransformation(monId: Long, stage: Int, dimId: Long, transformationDate: Long)
|
||||
|
||||
@Query("""
|
||||
INSERT INTO VitalsHistory(characterId, date, vitalPoints)
|
||||
VALUES
|
||||
(:characterId,
|
||||
(:date),
|
||||
:vitalPoints)
|
||||
""")
|
||||
fun insertVitals(characterId: Long, date: Long, vitalPoints: Int)
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@ import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.SpecialMissions
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.TransformationHistory
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.VitalsHistory
|
||||
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
||||
|
||||
@Dao
|
||||
|
||||
@ -1,11 +1,19 @@
|
||||
package com.github.nacabaro.vbhelper.domain.device_data
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
import com.github.cfogrady.vbnfc.vb.SpecialMission
|
||||
|
||||
@Entity(
|
||||
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = UserCharacter::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["characterId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)
|
||||
]
|
||||
)
|
||||
data class SpecialMissions (
|
||||
@PrimaryKey(autoGenerate = true) var id: Long = 0,
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package com.github.nacabaro.vbhelper.domain.device_data
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = UserCharacter::class,
|
||||
parentColumns = ["characterId"],
|
||||
childColumns = ["id"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)
|
||||
]
|
||||
)
|
||||
data class VitalsHistory (
|
||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||
val characterId: Long,
|
||||
val date: Long,
|
||||
val vitalPoints: Int
|
||||
)
|
||||
@ -10,6 +10,7 @@ import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.SpecialMissions
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.UserCharacter
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData
|
||||
import com.github.nacabaro.vbhelper.domain.device_data.VitalsHistory
|
||||
import com.github.nacabaro.vbhelper.utils.DeviceType
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
@ -112,6 +113,9 @@ class FromNfcConverter (
|
||||
)
|
||||
}
|
||||
|
||||
val vitalsHistory = nfcCharacter.vitalHistory
|
||||
|
||||
|
||||
database
|
||||
.userCharacterDao()
|
||||
.insertVBCharacterData(extraCharacterData)
|
||||
@ -153,6 +157,27 @@ class FromNfcConverter (
|
||||
.insertBECharacterData(extraCharacterData)
|
||||
}
|
||||
|
||||
private fun addVitalsHistoryToDatabase(characterId: Long, nfcCharacter: NfcCharacter) {
|
||||
val vitalsHistoryWatch = nfcCharacter.vitalHistory
|
||||
vitalsHistoryWatch.map { item ->
|
||||
val date = GregorianCalendar(
|
||||
item.year.toInt(),
|
||||
item.month.toInt(),
|
||||
item.day.toInt()
|
||||
)
|
||||
.time
|
||||
.time
|
||||
|
||||
database
|
||||
.characterDao()
|
||||
.insertVitals(
|
||||
characterId,
|
||||
date,
|
||||
item.vitalsGained.toInt()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addTransformationHistoryToDatabase(characterId: Long, nfcCharacter: NfcCharacter, dimData: Card) {
|
||||
val transformationHistoryWatch = nfcCharacter.transformationHistory
|
||||
transformationHistoryWatch.map { item ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user