mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-07-30 00:31:54 +00:00
Compare commits
5 Commits
81bfec5ac5
...
4b866aad8a
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b866aad8a | |||
| 33ad2728b8 | |||
|
|
05f04fdc49 | ||
|
|
07315fe11b | ||
|
|
2e72b543f6 |
@ -45,11 +45,12 @@ class HomeScreenControllerImpl(
|
|||||||
.clearSpecialMission(missionId)
|
.clearSpecialMission(missionId)
|
||||||
|
|
||||||
if (missionStatus.status == SpecialMission.Status.COMPLETED) {
|
if (missionStatus.status == SpecialMission.Status.COMPLETED) {
|
||||||
val randomItem = database
|
val allItems = database.itemDao().getAllItems().first()
|
||||||
.itemDao()
|
if (allItems.isEmpty()) {
|
||||||
.getAllItems()
|
onCleared(null, null)
|
||||||
.first()
|
return@launch
|
||||||
.random()
|
}
|
||||||
|
val randomItem = allItems.random()
|
||||||
|
|
||||||
val randomItemAmount = (Random.nextFloat() * 5).roundToInt()
|
val randomItemAmount = (Random.nextFloat() * 5).roundToInt()
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,7 @@ fun VBDiMHomeScreen(
|
|||||||
ItemDisplay(
|
ItemDisplay(
|
||||||
icon = R.drawable.baseline_swords_24,
|
icon = R.drawable.baseline_swords_24,
|
||||||
textValue = when {
|
textValue = when {
|
||||||
activeMon.totalBattlesLost == 0 -> "0.00 %"
|
activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost == 0 -> "0.00 %"
|
||||||
else -> {
|
else -> {
|
||||||
val battleWinPercentage =
|
val battleWinPercentage =
|
||||||
activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
|
activeMon.currentPhaseBattlesWon.toFloat() / (activeMon.currentPhaseBattlesWon + activeMon.currentPhaseBattlesLost).toFloat()
|
||||||
@ -150,7 +150,7 @@ fun VBDiMHomeScreen(
|
|||||||
Locale.getDefault(),
|
Locale.getDefault(),
|
||||||
"%.2f",
|
"%.2f",
|
||||||
battleWinPercentage * 100
|
battleWinPercentage * 100
|
||||||
) + " %" // Specify locale
|
) + " %"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
definition = stringResource(R.string.home_vbdim_current_phase_win),
|
definition = stringResource(R.string.home_vbdim_current_phase_win),
|
||||||
@ -193,9 +193,9 @@ fun VBDiMHomeScreen(
|
|||||||
onClickMission = { missionId ->
|
onClickMission = { missionId ->
|
||||||
selectedSpecialMissionId = missionId
|
selectedSpecialMissionId = missionId
|
||||||
},
|
},
|
||||||
onClickCollect = {
|
onClickCollect = { missionId ->
|
||||||
homeScreenController
|
homeScreenController
|
||||||
.clearSpecialMission(selectedSpecialMissionId, onClickCollect)
|
.clearSpecialMission(missionId, onClickCollect)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,14 +44,8 @@ fun ScanScreen(
|
|||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
LaunchedEffect(storageRepository) {
|
LaunchedEffect(characterId) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
/*
|
|
||||||
First check if there is a character sent through the navigation system
|
|
||||||
If there is not, that means we got here through the home screen nfc button
|
|
||||||
If we got here through the home screen, it does not hurt to check if there is
|
|
||||||
an active character.
|
|
||||||
*/
|
|
||||||
if (characterId != null && nfcCharacter == null) {
|
if (characterId != null && nfcCharacter == null) {
|
||||||
nfcCharacter = scanScreenController.characterToNfc(characterId)
|
nfcCharacter = scanScreenController.characterToNfc(characterId)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -231,7 +231,9 @@ class ScanScreenControllerImpl(
|
|||||||
val proto = VitalWearCharacterExporter(componentActivity, database).buildCharacterProto(characterId)
|
val proto = VitalWearCharacterExporter(componentActivity, database).buildCharacterProto(characterId)
|
||||||
val client = VitalWearHceReaderClient(isoDep)
|
val client = VitalWearHceReaderClient(isoDep)
|
||||||
client.sendCharacterToWatch(proto)
|
client.sendCharacterToWatch(proto)
|
||||||
Log.i("NFC_WRITE", "Character sent to VitalWear via HCE")
|
database.userCharacterDao().deleteCharacterById(characterId)
|
||||||
|
pendingExportCharacterId = null
|
||||||
|
Log.i("NFC_WRITE", "Character sent to VitalWear and deleted from app (id=$characterId)")
|
||||||
componentActivity.runOnUiThread {
|
componentActivity.runOnUiThread {
|
||||||
Toast.makeText(componentActivity, componentActivity.getString(R.string.scan_sent_character_success), Toast.LENGTH_SHORT).show()
|
Toast.makeText(componentActivity, componentActivity.getString(R.string.scan_sent_character_success), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user