mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-27 16:05:32 +00:00
Quite a few things
- Renamed a few objects to avoid legality issues - Added a few accompanying tables to support the VB/VH - While we speak about tables, added an auxiliary table to track card adventure progress - Extracted NFC character generation and extraction to different classes, should result in a cleaner ScanScreenController
This commit is contained in:
parent
f7a4039d66
commit
d847f600f1
@ -0,0 +1,16 @@
|
|||||||
|
package com.github.nacabaro.vbhelper.daos
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.OnConflictStrategy
|
||||||
|
import androidx.room.Query
|
||||||
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface CardDao {
|
||||||
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
|
suspend fun insertNewDim(card: Card): Long
|
||||||
|
|
||||||
|
@Query("SELECT * FROM Card WHERE cardId = :id")
|
||||||
|
fun getDimById(id: Int): Card?
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.nacabaro.vbhelper.daos
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Upsert
|
||||||
|
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface CardProgressDao {
|
||||||
|
@Upsert
|
||||||
|
fun updateDimProgress(vararg cardProgresses: CardProgress)
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"SELECT currentStage FROM CardProgress WHERE cardId = :cardId"
|
||||||
|
)
|
||||||
|
fun getCardProgress(cardId: Int): Int
|
||||||
|
}
|
||||||
@ -18,21 +18,20 @@ interface CharacterDao {
|
|||||||
@Insert
|
@Insert
|
||||||
suspend fun insertSprite(vararg sprite: Sprite)
|
suspend fun insertSprite(vararg sprite: Sprite)
|
||||||
|
|
||||||
@Query("SELECT * FROM Sprite")
|
|
||||||
suspend fun getAllSprites(): List<Sprite>
|
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
d.cardId as cardId,
|
d.cardId as cardId,
|
||||||
c.monIndex as charId
|
c.monIndex as charId,
|
||||||
|
c.stage as stage,
|
||||||
|
c.attribute as attribute
|
||||||
FROM Character c
|
FROM Character c
|
||||||
JOIN UserCharacter uc ON c.id = uc.charId
|
JOIN UserCharacter uc ON c.id = uc.charId
|
||||||
JOIN Card d ON c.dimId = d.id
|
JOIN Card d ON c.dimId = d.id
|
||||||
WHERE uc.id = :charId
|
WHERE uc.id = :charId
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
suspend fun getCharacterInfo(charId: Long): CharacterDtos.DiMInfo
|
suspend fun getCharacterInfo(charId: Long): CharacterDtos.CardCharacterInfo
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
INSERT INTO TransformationHistory(monId, stageId, transformationDate)
|
INSERT INTO TransformationHistory(monId, stageId, transformationDate)
|
||||||
@ -44,12 +43,12 @@ interface CharacterDao {
|
|||||||
fun insertTransformation(monId: Long, stage: Int, dimId: Long, transformationDate: Long)
|
fun insertTransformation(monId: Long, stage: Int, dimId: Long, transformationDate: Long)
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
INSERT INTO VitalsHistory(characterId, date, vitalPoints)
|
INSERT INTO VitalsHistory(charId, date, vitalPoints)
|
||||||
VALUES
|
VALUES
|
||||||
(:characterId,
|
(:charId,
|
||||||
(:date),
|
(:date),
|
||||||
:vitalPoints)
|
:vitalPoints)
|
||||||
""")
|
""")
|
||||||
fun insertVitals(characterId: Long, date: Long, vitalPoints: Int)
|
fun insertVitals(charId: Long, date: Long, vitalPoints: Int)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,32 +0,0 @@
|
|||||||
package com.github.nacabaro.vbhelper.daos
|
|
||||||
|
|
||||||
import androidx.room.Dao
|
|
||||||
import androidx.room.Insert
|
|
||||||
import androidx.room.OnConflictStrategy
|
|
||||||
import androidx.room.Query
|
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
|
||||||
|
|
||||||
@Dao
|
|
||||||
interface DiMDao {
|
|
||||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
|
||||||
suspend fun insertNewDim(card: Card): Long
|
|
||||||
|
|
||||||
@Query("SELECT * FROM Card WHERE cardId = :id")
|
|
||||||
fun getDimById(id: Int): Card?
|
|
||||||
|
|
||||||
@Query(
|
|
||||||
"""
|
|
||||||
UPDATE Card
|
|
||||||
SET currentStage = :currentStage
|
|
||||||
WHERE cardId = :id
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
fun updateCurrentStage(id: Int, currentStage: Int)
|
|
||||||
|
|
||||||
@Query("""
|
|
||||||
SELECT currentStage
|
|
||||||
FROM Card
|
|
||||||
WHERE cardId = :id
|
|
||||||
""")
|
|
||||||
fun getCurrentStage(id: Int): Int
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
package com.github.nacabaro.vbhelper.daos
|
|
||||||
|
|
||||||
import androidx.room.Dao
|
|
||||||
import androidx.room.Upsert
|
|
||||||
import com.github.nacabaro.vbhelper.domain.DimProgress
|
|
||||||
|
|
||||||
@Dao
|
|
||||||
interface DiMProgressDao {
|
|
||||||
@Upsert
|
|
||||||
suspend fun updateDimProgress(vararg dimProgress: DimProgress)
|
|
||||||
}
|
|
||||||
@ -5,12 +5,14 @@ import androidx.room.RoomDatabase
|
|||||||
import com.github.nacabaro.vbhelper.daos.AdventureDao
|
import com.github.nacabaro.vbhelper.daos.AdventureDao
|
||||||
import com.github.nacabaro.vbhelper.daos.CharacterDao
|
import com.github.nacabaro.vbhelper.daos.CharacterDao
|
||||||
import com.github.nacabaro.vbhelper.daos.DexDao
|
import com.github.nacabaro.vbhelper.daos.DexDao
|
||||||
import com.github.nacabaro.vbhelper.daos.DiMDao
|
import com.github.nacabaro.vbhelper.daos.CardDao
|
||||||
|
import com.github.nacabaro.vbhelper.daos.CardProgressDao
|
||||||
import com.github.nacabaro.vbhelper.daos.ItemDao
|
import com.github.nacabaro.vbhelper.daos.ItemDao
|
||||||
import com.github.nacabaro.vbhelper.daos.SpriteDao
|
import com.github.nacabaro.vbhelper.daos.SpriteDao
|
||||||
import com.github.nacabaro.vbhelper.daos.UserCharacterDao
|
import com.github.nacabaro.vbhelper.daos.UserCharacterDao
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Character
|
import com.github.nacabaro.vbhelper.domain.characters.Character
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
|
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Adventure
|
import com.github.nacabaro.vbhelper.domain.characters.Adventure
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Dex
|
import com.github.nacabaro.vbhelper.domain.characters.Dex
|
||||||
@ -19,12 +21,14 @@ 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.TransformationHistory
|
||||||
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.VBCharacterData
|
import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData
|
||||||
|
import com.github.nacabaro.vbhelper.domain.device_data.VitalsHistory
|
||||||
import com.github.nacabaro.vbhelper.domain.items.Items
|
import com.github.nacabaro.vbhelper.domain.items.Items
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 1,
|
version = 1,
|
||||||
entities = [
|
entities = [
|
||||||
Card::class,
|
Card::class,
|
||||||
|
CardProgress::class,
|
||||||
Character::class,
|
Character::class,
|
||||||
Sprite::class,
|
Sprite::class,
|
||||||
UserCharacter::class,
|
UserCharacter::class,
|
||||||
@ -32,13 +36,15 @@ import com.github.nacabaro.vbhelper.domain.items.Items
|
|||||||
VBCharacterData::class,
|
VBCharacterData::class,
|
||||||
SpecialMissions::class,
|
SpecialMissions::class,
|
||||||
TransformationHistory::class,
|
TransformationHistory::class,
|
||||||
|
VitalsHistory::class,
|
||||||
Dex::class,
|
Dex::class,
|
||||||
Items::class,
|
Items::class,
|
||||||
Adventure::class
|
Adventure::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
abstract fun dimDao(): DiMDao
|
abstract fun cardDao(): CardDao
|
||||||
|
abstract fun cardProgressDao(): CardProgressDao
|
||||||
abstract fun characterDao(): CharacterDao
|
abstract fun characterDao(): CharacterDao
|
||||||
abstract fun userCharacterDao(): UserCharacterDao
|
abstract fun userCharacterDao(): UserCharacterDao
|
||||||
abstract fun dexDao(): DexDao
|
abstract fun dexDao(): DexDao
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
package com.github.nacabaro.vbhelper.domain
|
|
||||||
|
|
||||||
import androidx.room.Entity
|
|
||||||
import androidx.room.ForeignKey
|
|
||||||
import androidx.room.PrimaryKey
|
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
|
||||||
|
|
||||||
@Entity(
|
|
||||||
foreignKeys = [
|
|
||||||
ForeignKey(
|
|
||||||
entity = User::class,
|
|
||||||
parentColumns = ["id"],
|
|
||||||
childColumns = ["userId"],
|
|
||||||
onDelete = ForeignKey.CASCADE
|
|
||||||
),
|
|
||||||
ForeignKey(
|
|
||||||
entity = Card::class,
|
|
||||||
parentColumns = ["id"],
|
|
||||||
childColumns = ["dimId"],
|
|
||||||
onDelete = ForeignKey.CASCADE
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
data class DimProgress(
|
|
||||||
@PrimaryKey val dimId: Int,
|
|
||||||
@PrimaryKey val userId: Int,
|
|
||||||
val currentStage: Int,
|
|
||||||
val unlocked: Boolean
|
|
||||||
)
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.github.nacabaro.vbhelper.domain.characters
|
package com.github.nacabaro.vbhelper.domain.card
|
||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
@ -13,6 +13,5 @@ data class Card(
|
|||||||
val logoHeight: Int,
|
val logoHeight: Int,
|
||||||
val name: String,
|
val name: String,
|
||||||
val stageCount: Int,
|
val stageCount: Int,
|
||||||
val currentStage: Int,
|
|
||||||
val isBEm: Boolean
|
val isBEm: Boolean
|
||||||
)
|
)
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.github.nacabaro.vbhelper.domain.card
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
foreignKeys = [
|
||||||
|
ForeignKey(
|
||||||
|
entity = Card::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["cardId"],
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
data class CardProgress(
|
||||||
|
@PrimaryKey val cardId: Int,
|
||||||
|
val currentStage: Int,
|
||||||
|
val unlocked: Boolean
|
||||||
|
)
|
||||||
@ -4,6 +4,7 @@ import androidx.room.Entity
|
|||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
import com.github.cfogrady.vbnfc.data.NfcCharacter
|
import com.github.cfogrady.vbnfc.data.NfcCharacter
|
||||||
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
|
|
||||||
@Entity(
|
@Entity(
|
||||||
foreignKeys = [
|
foreignKeys = [
|
||||||
@ -23,7 +24,7 @@ import com.github.cfogrady.vbnfc.data.NfcCharacter
|
|||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Character represents a character on a DIM card. There should only be one of these per dimId
|
* Character represents a character on a card. There should only be one of these per dimId
|
||||||
* and monIndex.
|
* and monIndex.
|
||||||
* TODO: Customs will mean this should be unique per cardName and monIndex
|
* TODO: Customs will mean this should be unique per cardName and monIndex
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -8,15 +8,15 @@ import androidx.room.PrimaryKey
|
|||||||
foreignKeys = [
|
foreignKeys = [
|
||||||
ForeignKey(
|
ForeignKey(
|
||||||
entity = UserCharacter::class,
|
entity = UserCharacter::class,
|
||||||
parentColumns = ["characterId"],
|
parentColumns = ["id"],
|
||||||
childColumns = ["id"],
|
childColumns = ["charId"],
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
data class VitalsHistory (
|
data class VitalsHistory (
|
||||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||||
val characterId: Long,
|
val charId: Long,
|
||||||
val date: Long,
|
val date: Long,
|
||||||
val vitalPoints: Int
|
val vitalPoints: Int
|
||||||
)
|
)
|
||||||
@ -11,7 +11,6 @@ object CharacterDtos {
|
|||||||
var stage: Int,
|
var stage: Int,
|
||||||
var attribute: NfcCharacter.Attribute,
|
var attribute: NfcCharacter.Attribute,
|
||||||
var ageInDays: Int,
|
var ageInDays: Int,
|
||||||
var nextAdventureMissionStage: Int, // next adventure mission stage on the character's dim
|
|
||||||
var mood: Int,
|
var mood: Int,
|
||||||
var vitalPoints: Int,
|
var vitalPoints: Int,
|
||||||
var transformationCountdown: Int,
|
var transformationCountdown: Int,
|
||||||
@ -35,9 +34,11 @@ object CharacterDtos {
|
|||||||
val isInAdventure: Boolean
|
val isInAdventure: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
data class DiMInfo(
|
data class CardCharacterInfo(
|
||||||
val cardId: Int,
|
val cardId: Int,
|
||||||
val charId: Int
|
val charId: Int,
|
||||||
|
val stage: Int,
|
||||||
|
val attribute: NfcCharacter.Attribute
|
||||||
)
|
)
|
||||||
|
|
||||||
data class TransformationHistory(
|
data class TransformationHistory(
|
||||||
@ -63,7 +64,6 @@ object CharacterDtos {
|
|||||||
var stage: Int,
|
var stage: Int,
|
||||||
var attribute: NfcCharacter.Attribute,
|
var attribute: NfcCharacter.Attribute,
|
||||||
var ageInDays: Int,
|
var ageInDays: Int,
|
||||||
var nextAdventureMissionStage: Int, // next adventure mission stage on the character's dim
|
|
||||||
var mood: Int,
|
var mood: Int,
|
||||||
var vitalPoints: Int,
|
var vitalPoints: Int,
|
||||||
var transformationCountdown: Int,
|
var transformationCountdown: Int,
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import com.github.nacabaro.vbhelper.utils.BitmapData
|
|||||||
import com.github.nacabaro.vbhelper.components.DexDiMEntry
|
import com.github.nacabaro.vbhelper.components.DexDiMEntry
|
||||||
import com.github.nacabaro.vbhelper.components.TopBanner
|
import com.github.nacabaro.vbhelper.components.TopBanner
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.di.VBHelper
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
|
||||||
import com.github.nacabaro.vbhelper.dtos.CardDtos
|
import com.github.nacabaro.vbhelper.dtos.CardDtos
|
||||||
import com.github.nacabaro.vbhelper.navigation.NavigationItems
|
import com.github.nacabaro.vbhelper.navigation.NavigationItems
|
||||||
import com.github.nacabaro.vbhelper.source.DexRepository
|
import com.github.nacabaro.vbhelper.source.DexRepository
|
||||||
|
|||||||
@ -283,6 +283,7 @@ fun ScanScreenPreview() {
|
|||||||
override fun onClickCheckCard(secrets: Secrets, nfcCharacter: NfcCharacter, onComplete: () -> Unit) {}
|
override fun onClickCheckCard(secrets: Secrets, nfcCharacter: NfcCharacter, onComplete: () -> Unit) {}
|
||||||
override fun onClickWrite(secrets: Secrets, nfcCharacter: NfcCharacter, onComplete: () -> Unit) {}
|
override fun onClickWrite(secrets: Secrets, nfcCharacter: NfcCharacter, onComplete: () -> Unit) {}
|
||||||
override fun cancelRead() {}
|
override fun cancelRead() {}
|
||||||
|
override fun characterFromNfc(nfcCharacter: NfcCharacter): String { return "" }
|
||||||
override suspend fun characterToNfc(characterId: Long): NfcCharacter? { return null }
|
override suspend fun characterToNfc(characterId: Long): NfcCharacter? { return null }
|
||||||
},
|
},
|
||||||
characterId = null
|
characterId = null
|
||||||
|
|||||||
@ -16,5 +16,6 @@ interface ScanScreenController {
|
|||||||
fun registerActivityLifecycleListener(key: String, activityLifecycleListener: ActivityLifecycleListener)
|
fun registerActivityLifecycleListener(key: String, activityLifecycleListener: ActivityLifecycleListener)
|
||||||
fun unregisterActivityLifecycleListener(key: String)
|
fun unregisterActivityLifecycleListener(key: String)
|
||||||
|
|
||||||
|
fun characterFromNfc(nfcCharacter: NfcCharacter): String
|
||||||
suspend fun characterToNfc(characterId: Long): NfcCharacter?
|
suspend fun characterToNfc(characterId: Long): NfcCharacter?
|
||||||
}
|
}
|
||||||
@ -11,22 +11,17 @@ import android.widget.Toast
|
|||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.github.cfogrady.vbnfc.TagCommunicator
|
import com.github.cfogrady.vbnfc.TagCommunicator
|
||||||
import com.github.cfogrady.vbnfc.be.BENfcCharacter
|
|
||||||
import com.github.cfogrady.vbnfc.data.NfcCharacter
|
import com.github.cfogrady.vbnfc.data.NfcCharacter
|
||||||
import com.github.cfogrady.vbnfc.vb.VBNfcCharacter
|
|
||||||
import com.github.nacabaro.vbhelper.ActivityLifecycleListener
|
import com.github.nacabaro.vbhelper.ActivityLifecycleListener
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.screens.scanScreen.converters.FromNfcConverter
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.BECharacterData
|
import com.github.nacabaro.vbhelper.screens.scanScreen.converters.ToNfcConverter
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.UserCharacter
|
|
||||||
import com.github.nacabaro.vbhelper.source.getCryptographicTransformerMap
|
import com.github.nacabaro.vbhelper.source.getCryptographicTransformerMap
|
||||||
import com.github.nacabaro.vbhelper.source.isMissingSecrets
|
import com.github.nacabaro.vbhelper.source.isMissingSecrets
|
||||||
import com.github.nacabaro.vbhelper.source.proto.Secrets
|
import com.github.nacabaro.vbhelper.source.proto.Secrets
|
||||||
import com.github.nacabaro.vbhelper.utils.DeviceType
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.GregorianCalendar
|
|
||||||
|
|
||||||
class ScanScreenControllerImpl(
|
class ScanScreenControllerImpl(
|
||||||
override val secretsFlow: Flow<Secrets>,
|
override val secretsFlow: Flow<Secrets>,
|
||||||
@ -49,7 +44,7 @@ class ScanScreenControllerImpl(
|
|||||||
override fun onClickRead(secrets: Secrets, onComplete: ()->Unit) {
|
override fun onClickRead(secrets: Secrets, onComplete: ()->Unit) {
|
||||||
handleTag(secrets) { tagCommunicator ->
|
handleTag(secrets) { tagCommunicator ->
|
||||||
val character = tagCommunicator.receiveCharacter()
|
val character = tagCommunicator.receiveCharacter()
|
||||||
val resultMessage = addCharacterScannedIntoDatabase(character)
|
val resultMessage = characterFromNfc(character)
|
||||||
onComplete.invoke()
|
onComplete.invoke()
|
||||||
resultMessage
|
resultMessage
|
||||||
}
|
}
|
||||||
@ -151,6 +146,11 @@ class ScanScreenControllerImpl(
|
|||||||
componentActivity.startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS))
|
componentActivity.startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Todo: Move all of this to a separate class
|
||||||
|
// Todo: Test the new mess
|
||||||
|
// Todo: Remove this
|
||||||
|
|
||||||
private fun addCharacterScannedIntoDatabase(nfcCharacter: NfcCharacter): String {
|
private fun addCharacterScannedIntoDatabase(nfcCharacter: NfcCharacter): String {
|
||||||
val application = componentActivity.applicationContext as VBHelper
|
val application = componentActivity.applicationContext as VBHelper
|
||||||
val storageRepository = application.container.db
|
val storageRepository = application.container.db
|
||||||
@ -168,7 +168,6 @@ class ScanScreenControllerImpl(
|
|||||||
val characterData = UserCharacter(
|
val characterData = UserCharacter(
|
||||||
charId = cardCharData.id,
|
charId = cardCharData.id,
|
||||||
ageInDays = nfcCharacter.ageInDays.toInt(),
|
ageInDays = nfcCharacter.ageInDays.toInt(),
|
||||||
nextAdventureMissionStage = nfcCharacter.nextAdventureMissionStage.toInt(),
|
|
||||||
mood = nfcCharacter.mood.toInt(),
|
mood = nfcCharacter.mood.toInt(),
|
||||||
vitalPoints = nfcCharacter.vitalPoints.toInt(),
|
vitalPoints = nfcCharacter.vitalPoints.toInt(),
|
||||||
transformationCountdown = nfcCharacter.transformationCountdownInMinutes.toInt(),
|
transformationCountdown = nfcCharacter.transformationCountdownInMinutes.toInt(),
|
||||||
@ -247,5 +246,19 @@ class ScanScreenControllerImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "Done reading character!"
|
return "Done reading character!"
|
||||||
|
}*/
|
||||||
|
|
||||||
|
override fun characterFromNfc(nfcCharacter: NfcCharacter): String {
|
||||||
|
val nfcConverter = FromNfcConverter(
|
||||||
|
componentActivity = componentActivity
|
||||||
|
)
|
||||||
|
return nfcConverter.addCharacter(nfcCharacter)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun characterToNfc(characterId: Long): NfcCharacter {
|
||||||
|
val nfcGenerator = ToNfcConverter(
|
||||||
|
componentActivity = componentActivity
|
||||||
|
)
|
||||||
|
return nfcGenerator.characterToNfc(characterId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,12 +5,12 @@ import com.github.cfogrady.vbnfc.be.BENfcCharacter
|
|||||||
import com.github.cfogrady.vbnfc.data.NfcCharacter
|
import com.github.cfogrady.vbnfc.data.NfcCharacter
|
||||||
import com.github.cfogrady.vbnfc.vb.VBNfcCharacter
|
import com.github.cfogrady.vbnfc.vb.VBNfcCharacter
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.di.VBHelper
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
|
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
||||||
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.SpecialMissions
|
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.UserCharacter
|
||||||
import com.github.nacabaro.vbhelper.domain.device_data.VBCharacterData
|
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 com.github.nacabaro.vbhelper.utils.DeviceType
|
||||||
import java.util.GregorianCalendar
|
import java.util.GregorianCalendar
|
||||||
|
|
||||||
@ -20,29 +20,24 @@ class FromNfcConverter (
|
|||||||
private val application = componentActivity.applicationContext as VBHelper
|
private val application = componentActivity.applicationContext as VBHelper
|
||||||
private val database = application.container.db
|
private val database = application.container.db
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun addCharacter(nfcCharacter: NfcCharacter): String {
|
fun addCharacter(nfcCharacter: NfcCharacter): String {
|
||||||
val dimData = database
|
val cardData = database
|
||||||
.dimDao()
|
.cardDao()
|
||||||
.getDimById(nfcCharacter.dimId.toInt())
|
.getDimById(nfcCharacter.dimId.toInt())
|
||||||
|
|
||||||
if (dimData == null)
|
if (cardData == null)
|
||||||
return "Card not found"
|
return "Card not found"
|
||||||
|
|
||||||
val cardCharData = database
|
val cardCharData = database
|
||||||
.characterDao()
|
.characterDao()
|
||||||
.getCharacterByMonIndex(nfcCharacter.charIndex.toInt(), dimData.id)
|
.getCharacterByMonIndex(nfcCharacter.charIndex.toInt(), cardData.id)
|
||||||
|
|
||||||
database
|
updateCardProgress(nfcCharacter, cardData)
|
||||||
.dimDao()
|
|
||||||
.updateCurrentStage(
|
|
||||||
id = nfcCharacter.dimId.toInt(),
|
|
||||||
currentStage = nfcCharacter.nextAdventureMissionStage.toInt()
|
|
||||||
)
|
|
||||||
|
|
||||||
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(),
|
||||||
mood = nfcCharacter.mood.toInt(),
|
mood = nfcCharacter.mood.toInt(),
|
||||||
vitalPoints = nfcCharacter.vitalPoints.toInt(),
|
vitalPoints = nfcCharacter.vitalPoints.toInt(),
|
||||||
@ -62,6 +57,8 @@ class FromNfcConverter (
|
|||||||
isActive = true
|
isActive = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
updateCardProgress(cardData, nfcCharacter)
|
||||||
|
|
||||||
database
|
database
|
||||||
.userCharacterDao()
|
.userCharacterDao()
|
||||||
.clearActiveCharacter()
|
.clearActiveCharacter()
|
||||||
@ -85,20 +82,73 @@ class FromNfcConverter (
|
|||||||
addTransformationHistoryToDatabase(
|
addTransformationHistoryToDatabase(
|
||||||
characterId = characterId,
|
characterId = characterId,
|
||||||
nfcCharacter = nfcCharacter,
|
nfcCharacter = nfcCharacter,
|
||||||
dimData = dimData
|
dimData = cardData
|
||||||
)
|
)
|
||||||
|
|
||||||
return "Done reading character!"
|
return "Done reading character!"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addVbCharacterToDatabase(characterId: Long, nfcCharacter: VBNfcCharacter) {
|
|
||||||
|
|
||||||
|
private fun updateCardProgress(
|
||||||
|
nfcCharacter: NfcCharacter,
|
||||||
|
cardData: Card
|
||||||
|
) {
|
||||||
|
val currentCardProgress = CardProgress(
|
||||||
|
cardId = cardData.cardId,
|
||||||
|
currentStage = nfcCharacter.nextAdventureMissionStage.toInt(),
|
||||||
|
unlocked = nfcCharacter.nextAdventureMissionStage.toInt() > cardData.stageCount
|
||||||
|
)
|
||||||
|
|
||||||
|
database
|
||||||
|
.cardProgressDao()
|
||||||
|
.updateDimProgress(currentCardProgress)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun updateCardProgress(
|
||||||
|
cardData: Card,
|
||||||
|
nfcCharacter: NfcCharacter,
|
||||||
|
) {
|
||||||
|
val cardProgress = CardProgress(
|
||||||
|
cardId = cardData.cardId,
|
||||||
|
currentStage = nfcCharacter.nextAdventureMissionStage.toInt(),
|
||||||
|
unlocked = nfcCharacter.nextAdventureMissionStage.toInt() > cardData.stageCount
|
||||||
|
)
|
||||||
|
|
||||||
|
database
|
||||||
|
.cardProgressDao()
|
||||||
|
.updateDimProgress(cardProgress)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun addVbCharacterToDatabase(
|
||||||
|
characterId: Long,
|
||||||
|
nfcCharacter: VBNfcCharacter
|
||||||
|
) {
|
||||||
val extraCharacterData = VBCharacterData(
|
val extraCharacterData = VBCharacterData(
|
||||||
id = characterId,
|
id = characterId,
|
||||||
generation = nfcCharacter.generation.toInt(),
|
generation = nfcCharacter.generation.toInt(),
|
||||||
totalTrophies = nfcCharacter.totalTrophies.toInt()
|
totalTrophies = nfcCharacter.totalTrophies.toInt()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
database
|
||||||
|
.userCharacterDao()
|
||||||
|
.insertVBCharacterData(extraCharacterData)
|
||||||
|
|
||||||
|
addSpecialMissionsToDatabase(nfcCharacter, characterId)
|
||||||
|
|
||||||
|
addVitalsHistoryToDatabase(characterId, nfcCharacter)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun addSpecialMissionsToDatabase(
|
||||||
|
nfcCharacter: VBNfcCharacter,
|
||||||
|
characterId: Long
|
||||||
|
) {
|
||||||
val specialMissionsWatch = nfcCharacter.specialMissions
|
val specialMissionsWatch = nfcCharacter.specialMissions
|
||||||
val specialMissionsDb = specialMissionsWatch.map { item ->
|
val specialMissionsDb = specialMissionsWatch.map { item ->
|
||||||
SpecialMissions(
|
SpecialMissions(
|
||||||
@ -113,19 +163,17 @@ class FromNfcConverter (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val vitalsHistory = nfcCharacter.vitalHistory
|
|
||||||
|
|
||||||
|
|
||||||
database
|
|
||||||
.userCharacterDao()
|
|
||||||
.insertVBCharacterData(extraCharacterData)
|
|
||||||
|
|
||||||
database
|
database
|
||||||
.userCharacterDao()
|
.userCharacterDao()
|
||||||
.insertSpecialMissions(*specialMissionsDb.toTypedArray())
|
.insertSpecialMissions(*specialMissionsDb.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addBeCharacterToDatabase(characterId: Long, nfcCharacter: BENfcCharacter) {
|
|
||||||
|
|
||||||
|
private fun addBeCharacterToDatabase(
|
||||||
|
characterId: Long,
|
||||||
|
nfcCharacter: BENfcCharacter
|
||||||
|
) {
|
||||||
val extraCharacterData = BECharacterData(
|
val extraCharacterData = BECharacterData(
|
||||||
id = characterId,
|
id = characterId,
|
||||||
trainingHp = nfcCharacter.trainingHp.toInt(),
|
trainingHp = nfcCharacter.trainingHp.toInt(),
|
||||||
@ -157,7 +205,12 @@ class FromNfcConverter (
|
|||||||
.insertBECharacterData(extraCharacterData)
|
.insertBECharacterData(extraCharacterData)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addVitalsHistoryToDatabase(characterId: Long, nfcCharacter: NfcCharacter) {
|
|
||||||
|
|
||||||
|
private fun addVitalsHistoryToDatabase(
|
||||||
|
characterId: Long,
|
||||||
|
nfcCharacter: NfcCharacter
|
||||||
|
) {
|
||||||
val vitalsHistoryWatch = nfcCharacter.vitalHistory
|
val vitalsHistoryWatch = nfcCharacter.vitalHistory
|
||||||
vitalsHistoryWatch.map { item ->
|
vitalsHistoryWatch.map { item ->
|
||||||
val date = GregorianCalendar(
|
val date = GregorianCalendar(
|
||||||
@ -178,7 +231,12 @@ class FromNfcConverter (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addTransformationHistoryToDatabase(characterId: Long, nfcCharacter: NfcCharacter, dimData: Card) {
|
|
||||||
|
private fun addTransformationHistoryToDatabase(
|
||||||
|
characterId: Long,
|
||||||
|
nfcCharacter: NfcCharacter,
|
||||||
|
dimData: Card
|
||||||
|
) {
|
||||||
val transformationHistoryWatch = nfcCharacter.transformationHistory
|
val transformationHistoryWatch = nfcCharacter.transformationHistory
|
||||||
transformationHistoryWatch.map { item ->
|
transformationHistoryWatch.map { item ->
|
||||||
if (item.toCharIndex.toInt() != 255) {
|
if (item.toCharIndex.toInt() != 255) {
|
||||||
|
|||||||
@ -20,7 +20,11 @@ class ToNfcConverter(
|
|||||||
private val application: VBHelper = componentActivity.applicationContext as VBHelper
|
private val application: VBHelper = componentActivity.applicationContext as VBHelper
|
||||||
private val database: AppDatabase = application.container.db
|
private val database: AppDatabase = application.container.db
|
||||||
|
|
||||||
suspend fun characterToNfc(characterId: Long): NfcCharacter {
|
|
||||||
|
|
||||||
|
suspend fun characterToNfc(
|
||||||
|
characterId: Long
|
||||||
|
): NfcCharacter {
|
||||||
val app = componentActivity.applicationContext as VBHelper
|
val app = componentActivity.applicationContext as VBHelper
|
||||||
val database = app.container.db
|
val database = app.container.db
|
||||||
|
|
||||||
@ -32,7 +36,9 @@ class ToNfcConverter(
|
|||||||
.characterDao()
|
.characterDao()
|
||||||
.getCharacterInfo(userCharacter.charId)
|
.getCharacterInfo(userCharacter.charId)
|
||||||
|
|
||||||
val currentCardStage = database.dimDao().getCurrentStage(characterInfo.cardId)
|
val currentCardStage = database
|
||||||
|
.cardProgressDao()
|
||||||
|
.getCardProgress(characterInfo.cardId)
|
||||||
|
|
||||||
return if (userCharacter.characterType == DeviceType.BEDevice)
|
return if (userCharacter.characterType == DeviceType.BEDevice)
|
||||||
nfcToBENfc(characterId, characterInfo, currentCardStage, userCharacter)
|
nfcToBENfc(characterId, characterInfo, currentCardStage, userCharacter)
|
||||||
@ -40,9 +46,11 @@ class ToNfcConverter(
|
|||||||
nfcToVBNfc(characterId, characterInfo, currentCardStage, userCharacter)
|
nfcToVBNfc(characterId, characterInfo, currentCardStage, userCharacter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private suspend fun nfcToVBNfc(
|
private suspend fun nfcToVBNfc(
|
||||||
characterId: Long,
|
characterId: Long,
|
||||||
characterInfo: CharacterDtos.DiMInfo,
|
characterInfo: CharacterDtos.CardCharacterInfo,
|
||||||
currentCardStage: Int,
|
currentCardStage: Int,
|
||||||
userCharacter: UserCharacter
|
userCharacter: UserCharacter
|
||||||
): VBNfcCharacter {
|
): VBNfcCharacter {
|
||||||
@ -50,29 +58,15 @@ class ToNfcConverter(
|
|||||||
.userCharacterDao()
|
.userCharacterDao()
|
||||||
.getVbData(characterId)
|
.getVbData(characterId)
|
||||||
|
|
||||||
val specialMissions = database
|
|
||||||
.userCharacterDao()
|
|
||||||
.getSpecialMissions(characterId)
|
|
||||||
|
|
||||||
val paddedTransformationArray = generateTransformationHistory(characterId)
|
val paddedTransformationArray = generateTransformationHistory(characterId)
|
||||||
|
|
||||||
val watchSpecialMissions = specialMissions.map {
|
val watchSpecialMissions = generateSpecialMissionsArray(characterId)
|
||||||
SpecialMission(
|
|
||||||
goal = it.goal.toUShort(),
|
|
||||||
id = it.watchId.toUShort(),
|
|
||||||
progress = it.progress.toUShort(),
|
|
||||||
status = it.status,
|
|
||||||
timeElapsedInMinutes = it.timeElapsedInMinutes.toUShort(),
|
|
||||||
timeLimitInMinutes = it.timeLimitInMinutes.toUShort(),
|
|
||||||
type = it.missionType
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val nfcData = VBNfcCharacter(
|
val nfcData = VBNfcCharacter(
|
||||||
dimId = characterInfo.cardId.toUShort(),
|
dimId = characterInfo.cardId.toUShort(),
|
||||||
charIndex = characterInfo.charId.toUShort(),
|
charIndex = characterInfo.charId.toUShort(),
|
||||||
stage = userCharacter.stage.toByte(),
|
stage = characterInfo.stage.toByte(),
|
||||||
attribute = userCharacter.attribute,
|
attribute = characterInfo.attribute,
|
||||||
ageInDays = userCharacter.ageInDays.toByte(),
|
ageInDays = userCharacter.ageInDays.toByte(),
|
||||||
nextAdventureMissionStage = currentCardStage.toByte(),
|
nextAdventureMissionStage = currentCardStage.toByte(),
|
||||||
mood = userCharacter.mood.toByte(),
|
mood = userCharacter.mood.toByte(),
|
||||||
@ -100,9 +94,35 @@ class ToNfcConverter(
|
|||||||
return nfcData
|
return nfcData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private suspend fun generateSpecialMissionsArray(
|
||||||
|
characterId: Long
|
||||||
|
): List<SpecialMission> {
|
||||||
|
val specialMissions = database
|
||||||
|
.userCharacterDao()
|
||||||
|
.getSpecialMissions(characterId)
|
||||||
|
|
||||||
|
val watchSpecialMissions = specialMissions.map {
|
||||||
|
SpecialMission(
|
||||||
|
goal = it.goal.toUShort(),
|
||||||
|
id = it.watchId.toUShort(),
|
||||||
|
progress = it.progress.toUShort(),
|
||||||
|
status = it.status,
|
||||||
|
timeElapsedInMinutes = it.timeElapsedInMinutes.toUShort(),
|
||||||
|
timeLimitInMinutes = it.timeLimitInMinutes.toUShort(),
|
||||||
|
type = it.missionType
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return watchSpecialMissions
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private suspend fun nfcToBENfc(
|
private suspend fun nfcToBENfc(
|
||||||
characterId: Long,
|
characterId: Long,
|
||||||
characterInfo: CharacterDtos.DiMInfo,
|
characterInfo: CharacterDtos.CardCharacterInfo,
|
||||||
currentCardStage: Int,
|
currentCardStage: Int,
|
||||||
userCharacter: UserCharacter
|
userCharacter: UserCharacter
|
||||||
): BENfcCharacter {
|
): BENfcCharacter {
|
||||||
@ -115,8 +135,8 @@ class ToNfcConverter(
|
|||||||
val nfcData = BENfcCharacter(
|
val nfcData = BENfcCharacter(
|
||||||
dimId = characterInfo.cardId.toUShort(),
|
dimId = characterInfo.cardId.toUShort(),
|
||||||
charIndex = characterInfo.charId.toUShort(),
|
charIndex = characterInfo.charId.toUShort(),
|
||||||
stage = userCharacter.stage.toByte(),
|
stage = characterInfo.stage.toByte(),
|
||||||
attribute = userCharacter.attribute,
|
attribute = characterInfo.attribute,
|
||||||
ageInDays = userCharacter.ageInDays.toByte(),
|
ageInDays = userCharacter.ageInDays.toByte(),
|
||||||
nextAdventureMissionStage = currentCardStage.toByte(),
|
nextAdventureMissionStage = currentCardStage.toByte(),
|
||||||
mood = userCharacter.mood.toByte(),
|
mood = userCharacter.mood.toByte(),
|
||||||
@ -163,9 +183,10 @@ class ToNfcConverter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return nfcData
|
return nfcData
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private suspend fun generateTransformationHistory(
|
private suspend fun generateTransformationHistory(
|
||||||
characterId: Long
|
characterId: Long
|
||||||
): Array<NfcCharacter.Transformation> {
|
): Array<NfcCharacter.Transformation> {
|
||||||
@ -196,6 +217,8 @@ class ToNfcConverter(
|
|||||||
return paddedTransformationArray
|
return paddedTransformationArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun padTransformationArray(
|
private fun padTransformationArray(
|
||||||
transformationArray: Array<NfcCharacter.Transformation>
|
transformationArray: Array<NfcCharacter.Transformation>
|
||||||
): Array<NfcCharacter.Transformation> {
|
): Array<NfcCharacter.Transformation> {
|
||||||
|
|||||||
@ -16,7 +16,8 @@ import com.github.cfogrady.vbnfc.data.NfcCharacter
|
|||||||
import com.github.nacabaro.vbhelper.database.AppDatabase
|
import com.github.nacabaro.vbhelper.database.AppDatabase
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.di.VBHelper
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
import com.github.nacabaro.vbhelper.domain.characters.Sprite
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
import com.github.nacabaro.vbhelper.domain.card.Card
|
||||||
|
import com.github.nacabaro.vbhelper.domain.card.CardProgress
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Character
|
import com.github.nacabaro.vbhelper.domain.characters.Character
|
||||||
import com.github.nacabaro.vbhelper.source.ApkSecretsImporter
|
import com.github.nacabaro.vbhelper.source.ApkSecretsImporter
|
||||||
import com.github.nacabaro.vbhelper.source.SecretsImporter
|
import com.github.nacabaro.vbhelper.source.SecretsImporter
|
||||||
@ -121,17 +122,28 @@ class SettingsScreenControllerImpl(
|
|||||||
logo = card.spriteData.sprites[0].pixelData,
|
logo = card.spriteData.sprites[0].pixelData,
|
||||||
name = card.spriteData.text, // TODO Make user write card name
|
name = card.spriteData.text, // TODO Make user write card name
|
||||||
stageCount = card.adventureLevels.levels.size,
|
stageCount = card.adventureLevels.levels.size,
|
||||||
currentStage = 0,
|
|
||||||
logoHeight = card.spriteData.sprites[0].height,
|
logoHeight = card.spriteData.sprites[0].height,
|
||||||
logoWidth = card.spriteData.sprites[0].width,
|
logoWidth = card.spriteData.sprites[0].width,
|
||||||
isBEm = card is BemCard
|
isBEm = card is BemCard
|
||||||
)
|
)
|
||||||
|
|
||||||
val dimId = database
|
val dimId = database
|
||||||
.dimDao()
|
.cardDao()
|
||||||
.insertNewDim(cardModel)
|
.insertNewDim(cardModel)
|
||||||
|
|
||||||
val characters = card.characterStats.characterEntries
|
val cardProgress = CardProgress(
|
||||||
|
cardId = cardModel.cardId,
|
||||||
|
currentStage = 0,
|
||||||
|
unlocked = false
|
||||||
|
)
|
||||||
|
|
||||||
|
database
|
||||||
|
.cardProgressDao()
|
||||||
|
.updateDimProgress(cardProgress)
|
||||||
|
|
||||||
|
val characters = card
|
||||||
|
.characterStats
|
||||||
|
.characterEntries
|
||||||
|
|
||||||
var spriteCounter = when (card is BemCard) {
|
var spriteCounter = when (card is BemCard) {
|
||||||
true -> 54
|
true -> 54
|
||||||
@ -141,7 +153,7 @@ class SettingsScreenControllerImpl(
|
|||||||
val domainCharacters = mutableListOf<Character>()
|
val domainCharacters = mutableListOf<Character>()
|
||||||
|
|
||||||
for (index in 0 until characters.size) {
|
for (index in 0 until characters.size) {
|
||||||
var domainSprite: Sprite? = null;
|
var domainSprite: Sprite?
|
||||||
|
|
||||||
if (index < 2 && card is DimCard) {
|
if (index < 2 && card is DimCard) {
|
||||||
domainSprite = Sprite(
|
domainSprite = Sprite(
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.github.nacabaro.vbhelper.source
|
package com.github.nacabaro.vbhelper.source
|
||||||
|
|
||||||
import com.github.nacabaro.vbhelper.database.AppDatabase
|
import com.github.nacabaro.vbhelper.database.AppDatabase
|
||||||
import com.github.nacabaro.vbhelper.domain.characters.Card
|
|
||||||
import com.github.nacabaro.vbhelper.dtos.CardDtos
|
import com.github.nacabaro.vbhelper.dtos.CardDtos
|
||||||
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
import com.github.nacabaro.vbhelper.dtos.CharacterDtos
|
||||||
|
|
||||||
|
|||||||
@ -19,14 +19,10 @@ class StorageRepository (
|
|||||||
return db.userCharacterDao().getBeData(id)
|
return db.userCharacterDao().getBeData(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTransformationHistory(characterId: Long): List<CharacterDtos.TransformationHistory>? {
|
suspend fun getTransformationHistory(characterId: Long): List<CharacterDtos.TransformationHistory>? {
|
||||||
return db.userCharacterDao().getTransformationHistory(characterId)
|
return db.userCharacterDao().getTransformationHistory(characterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCharacterData(id: Long): CharacterDtos.DiMInfo {
|
|
||||||
return db.characterDao().getCharacterInfo(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun getActiveCharacter(): CharacterDtos.CharacterWithSprites? {
|
suspend fun getActiveCharacter(): CharacterDtos.CharacterWithSprites? {
|
||||||
return db.userCharacterDao().getActiveCharacter()
|
return db.userCharacterDao().getActiveCharacter()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user