mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-10-01 15:41:36 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dc5bbbdde | ||
|
|
2586190e5c |
@@ -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 {
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
+2
-1
@@ -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)
|
||||||
}
|
}
|
||||||
+26
-20
@@ -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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.7.3"
|
agp = "8.12.2"
|
||||||
datastore = "1.1.2"
|
datastore = "1.1.2"
|
||||||
kotlin = "2.0.0"
|
kotlin = "2.0.0"
|
||||||
coreKtx = "1.15.0"
|
coreKtx = "1.15.0"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#Tue Dec 24 10:55:57 UTC 2024
|
#Tue Dec 24 10:55:57 UTC 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
Reference in New Issue
Block a user