mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-27 16:05:32 +00:00
Small fix related to special missions
- Now you can clear failed special missions. When a special mission fails, you will not get an item after clearing it. - Huge note: I have not tested this fix, but it should work... At least that's what my intuition is telling me! Jokes aside, this should work, but the home screen will not update. I should update this to make use of StateFlows and Flows to keep the home screen updated at all times.
This commit is contained in:
parent
2586190e5c
commit
8dc5bbbdde
@ -169,7 +169,7 @@ fun SpecialMissionsEntry(
|
|||||||
Card(
|
Card(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
shape = androidx.compose.material.MaterialTheme.shapes.small,
|
shape = androidx.compose.material.MaterialTheme.shapes.small,
|
||||||
onClick = if (specialMission.status == SpecialMission.Status.COMPLETED) {
|
onClick = if (specialMission.status == SpecialMission.Status.COMPLETED || specialMission.status == SpecialMission.Status.FAILED) {
|
||||||
onClickCard
|
onClickCard
|
||||||
} else {
|
} else {
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package com.github.nacabaro.vbhelper.screens.homeScreens
|
package com.github.nacabaro.vbhelper.screens.homeScreens
|
||||||
|
|
||||||
|
import com.github.cfogrady.vbnfc.vb.SpecialMission
|
||||||
import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
||||||
|
|
||||||
interface HomeScreenController {
|
interface HomeScreenController {
|
||||||
fun didAdventureMissionsFinish(onCompletion: (Boolean) -> Unit)
|
fun didAdventureMissionsFinish(onCompletion: (Boolean) -> Unit)
|
||||||
fun clearSpecialMission(missionId: Long, onCleared: (ItemDtos.PurchasedItem) -> Unit)
|
fun clearSpecialMission(missionId: Long, missionCompletion: SpecialMission.Status, onCleared: (ItemDtos.PurchasedItem?) -> Unit)
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@ package com.github.nacabaro.vbhelper.screens.homeScreens
|
|||||||
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import com.github.cfogrady.vbnfc.vb.SpecialMission
|
||||||
import com.github.nacabaro.vbhelper.di.VBHelper
|
import com.github.nacabaro.vbhelper.di.VBHelper
|
||||||
import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -30,37 +31,42 @@ class HomeScreenControllerImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSpecialMission(missionId: Long, onCleared: (ItemDtos.PurchasedItem) -> Unit) {
|
override fun clearSpecialMission(missionId: Long, missionCompletion: SpecialMission.Status, onCleared: (ItemDtos.PurchasedItem?) -> Unit) {
|
||||||
componentActivity.lifecycleScope.launch {
|
componentActivity.lifecycleScope.launch {
|
||||||
database
|
database
|
||||||
.specialMissionDao()
|
.specialMissionDao()
|
||||||
.clearSpecialMission(missionId)
|
.clearSpecialMission(missionId)
|
||||||
|
|
||||||
val randomItem = database
|
if (missionCompletion == SpecialMission.Status.COMPLETED) {
|
||||||
.itemDao()
|
val randomItem = database
|
||||||
.getAllItems()
|
.itemDao()
|
||||||
.random()
|
.getAllItems()
|
||||||
|
.random()
|
||||||
|
|
||||||
val randomItemAmount = (Random.nextFloat() * 5).roundToInt()
|
val randomItemAmount = (Random.nextFloat() * 5).roundToInt()
|
||||||
|
|
||||||
database
|
database
|
||||||
.itemDao()
|
.itemDao()
|
||||||
.purchaseItem(
|
.purchaseItem(
|
||||||
|
itemId = randomItem.id,
|
||||||
|
itemAmount = randomItemAmount
|
||||||
|
)
|
||||||
|
|
||||||
|
val purchasedItem = ItemDtos.PurchasedItem(
|
||||||
itemId = randomItem.id,
|
itemId = randomItem.id,
|
||||||
itemAmount = randomItemAmount
|
itemName = randomItem.name,
|
||||||
|
itemDescription = randomItem.description,
|
||||||
|
itemIcon = randomItem.itemIcon,
|
||||||
|
itemLength = randomItem.itemLength,
|
||||||
|
itemAmount = randomItemAmount,
|
||||||
|
itemType = randomItem.itemType
|
||||||
)
|
)
|
||||||
|
|
||||||
val purchasedItem = ItemDtos.PurchasedItem(
|
onCleared(purchasedItem)
|
||||||
itemId = randomItem.id,
|
} else {
|
||||||
itemName = randomItem.name,
|
onCleared(null)
|
||||||
itemDescription = randomItem.description,
|
}
|
||||||
itemIcon = randomItem.itemIcon,
|
|
||||||
itemLength = randomItem.itemLength,
|
|
||||||
itemAmount = randomItemAmount,
|
|
||||||
itemType = randomItem.itemType
|
|
||||||
)
|
|
||||||
|
|
||||||
onCleared(purchasedItem)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ fun VBDiMHomeScreen(
|
|||||||
homeScreenController: HomeScreenControllerImpl,
|
homeScreenController: HomeScreenControllerImpl,
|
||||||
transformationHistory: List<CharacterDtos.TransformationHistory>,
|
transformationHistory: List<CharacterDtos.TransformationHistory>,
|
||||||
contentPadding: PaddingValues,
|
contentPadding: PaddingValues,
|
||||||
onClickCollect: (ItemDtos.PurchasedItem) -> Unit
|
onClickCollect: (ItemDtos.PurchasedItem?) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -181,7 +181,7 @@ fun VBDiMHomeScreen(
|
|||||||
.padding(8.dp),
|
.padding(8.dp),
|
||||||
) {
|
) {
|
||||||
homeScreenController
|
homeScreenController
|
||||||
.clearSpecialMission(mission.id, onClickCollect)
|
.clearSpecialMission(mission.id, mission.status, onClickCollect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user