mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-01-27 16:05:32 +00:00
More things
- Active characters display different - Adventure missions award credits (same as special missions) - Clicking on about will open the github page - Corrected from arean to arena - Removed rename from the settings (it was not used)
This commit is contained in:
parent
6be167bbed
commit
489e27b038
@ -15,7 +15,7 @@ android {
|
|||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "Alpha 0.6.1"
|
versionName = "Alpha 0.6.2"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,13 +9,11 @@ import androidx.compose.foundation.lazy.items
|
|||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.produceState
|
import androidx.compose.runtime.produceState
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -30,7 +28,6 @@ import com.github.nacabaro.vbhelper.navigation.NavigationItems
|
|||||||
import com.github.nacabaro.vbhelper.source.StorageRepository
|
import com.github.nacabaro.vbhelper.source.StorageRepository
|
||||||
import com.github.nacabaro.vbhelper.utils.BitmapData
|
import com.github.nacabaro.vbhelper.utils.BitmapData
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -46,6 +43,9 @@ fun AdventureScreen(
|
|||||||
var obtainedItem by remember {
|
var obtainedItem by remember {
|
||||||
mutableStateOf<ItemDtos.PurchasedItem?>(null)
|
mutableStateOf<ItemDtos.PurchasedItem?>(null)
|
||||||
}
|
}
|
||||||
|
var obtainedCurrency by remember {
|
||||||
|
mutableStateOf(0)
|
||||||
|
}
|
||||||
|
|
||||||
val currentTime by produceState(initialValue = Instant.now().epochSecond) {
|
val currentTime by produceState(initialValue = Instant.now().epochSecond) {
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -94,8 +94,9 @@ fun AdventureScreen(
|
|||||||
onClick = {
|
onClick = {
|
||||||
if (it.finishesAdventure < currentTime) {
|
if (it.finishesAdventure < currentTime) {
|
||||||
storageScreenController
|
storageScreenController
|
||||||
.getItemFromAdventure(it.id) { adventureResult ->
|
.getItemFromAdventure(it.id) { adventureResult, generatedCurrency ->
|
||||||
obtainedItem = adventureResult
|
obtainedItem = adventureResult
|
||||||
|
obtainedCurrency = generatedCurrency
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cancelAdventureDialog = it
|
cancelAdventureDialog = it
|
||||||
@ -110,6 +111,7 @@ fun AdventureScreen(
|
|||||||
if (obtainedItem != null) {
|
if (obtainedItem != null) {
|
||||||
ObtainedItemDialog(
|
ObtainedItemDialog(
|
||||||
obtainedItem = obtainedItem!!,
|
obtainedItem = obtainedItem!!,
|
||||||
|
obtainedCurrency = obtainedCurrency,
|
||||||
onClickDismiss = {
|
onClickDismiss = {
|
||||||
obtainedItem = null
|
obtainedItem = null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,6 @@ import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
|||||||
|
|
||||||
interface AdventureScreenController {
|
interface AdventureScreenController {
|
||||||
fun sendCharacterToAdventure(characterId: Long, timeInMinutes: Long)
|
fun sendCharacterToAdventure(characterId: Long, timeInMinutes: Long)
|
||||||
fun getItemFromAdventure(characterId: Long, onResult: (ItemDtos.PurchasedItem) -> Unit)
|
fun getItemFromAdventure(characterId: Long, onResult: (ItemDtos.PurchasedItem, Int) -> Unit)
|
||||||
fun cancelAdventure(characterId: Long, onResult: () -> Unit)
|
fun cancelAdventure(characterId: Long, onResult: () -> Unit)
|
||||||
}
|
}
|
||||||
@ -38,19 +38,29 @@ class AdventureScreenControllerImpl(
|
|||||||
|
|
||||||
override fun getItemFromAdventure(
|
override fun getItemFromAdventure(
|
||||||
characterId: Long,
|
characterId: Long,
|
||||||
onResult: (ItemDtos.PurchasedItem) -> Unit
|
onResult: (ItemDtos.PurchasedItem, Int) -> Unit
|
||||||
) {
|
) {
|
||||||
componentActivity.lifecycleScope.launch(Dispatchers.IO) {
|
componentActivity.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
database
|
database
|
||||||
.adventureDao()
|
.adventureDao()
|
||||||
.deleteAdventure(characterId)
|
.deleteAdventure(characterId)
|
||||||
|
|
||||||
|
val generatedCurrency = generateRandomCurrency()
|
||||||
|
|
||||||
val generatedItem = generateItem(characterId)
|
val generatedItem = generateItem(characterId)
|
||||||
|
|
||||||
onResult(generatedItem)
|
onResult(generatedItem, generatedCurrency)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun generateRandomCurrency(): Int {
|
||||||
|
val currentValue = application.container.currencyRepository.currencyValue.first()
|
||||||
|
val random = (2..6).random() * 1000
|
||||||
|
application.container.currencyRepository.setCurrencyValue(currentValue + random)
|
||||||
|
|
||||||
|
return random
|
||||||
|
}
|
||||||
|
|
||||||
override fun cancelAdventure(characterId: Long, onResult: () -> Unit) {
|
override fun cancelAdventure(characterId: Long, onResult: () -> Unit) {
|
||||||
componentActivity.lifecycleScope.launch(Dispatchers.IO) {
|
componentActivity.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
database
|
database
|
||||||
|
|||||||
@ -55,6 +55,7 @@ fun HomeScreen(
|
|||||||
var adventureMissionsFinished by rememberSaveable { mutableStateOf(false) }
|
var adventureMissionsFinished by rememberSaveable { mutableStateOf(false) }
|
||||||
var betaWarning by rememberSaveable { mutableStateOf(true) }
|
var betaWarning by rememberSaveable { mutableStateOf(true) }
|
||||||
var collectedItem by remember { mutableStateOf<ItemDtos.PurchasedItem?>(null) }
|
var collectedItem by remember { mutableStateOf<ItemDtos.PurchasedItem?>(null) }
|
||||||
|
var collectedCurrency by remember { mutableStateOf<Int?>(null) }
|
||||||
|
|
||||||
LaunchedEffect(storageRepository, activeMon, collectedItem) {
|
LaunchedEffect(storageRepository, activeMon, collectedItem) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
@ -123,8 +124,9 @@ fun HomeScreen(
|
|||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
specialMissions = vbSpecialMissions.value,
|
specialMissions = vbSpecialMissions.value,
|
||||||
homeScreenController = homeScreenController,
|
homeScreenController = homeScreenController,
|
||||||
onClickCollect = { item ->
|
onClickCollect = { item, currency ->
|
||||||
collectedItem = item
|
collectedItem = item
|
||||||
|
collectedCurrency = currency
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -134,8 +136,10 @@ fun HomeScreen(
|
|||||||
if (collectedItem != null) {
|
if (collectedItem != null) {
|
||||||
ObtainedItemDialog(
|
ObtainedItemDialog(
|
||||||
obtainedItem = collectedItem!!,
|
obtainedItem = collectedItem!!,
|
||||||
|
obtainedCurrency = collectedCurrency!!,
|
||||||
onClickDismiss = {
|
onClickDismiss = {
|
||||||
collectedItem = null
|
collectedItem = null
|
||||||
|
collectedCurrency = null
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,5 @@ 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, missionCompletion: SpecialMission.Status, onCleared: (ItemDtos.PurchasedItem?) -> Unit)
|
fun clearSpecialMission(missionId: Long, missionCompletion: SpecialMission.Status, onCleared: (ItemDtos.PurchasedItem?, Int?) -> Unit)
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ class HomeScreenControllerImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSpecialMission(missionId: Long, missionCompletion: SpecialMission.Status, onCleared: (ItemDtos.PurchasedItem?) -> Unit) {
|
override fun clearSpecialMission(missionId: Long, missionCompletion: SpecialMission.Status, onCleared: (ItemDtos.PurchasedItem?, Int?) -> Unit) {
|
||||||
componentActivity.lifecycleScope.launch {
|
componentActivity.lifecycleScope.launch {
|
||||||
database
|
database
|
||||||
.specialMissionDao()
|
.specialMissionDao()
|
||||||
@ -65,9 +65,13 @@ class HomeScreenControllerImpl(
|
|||||||
itemType = randomItem.itemType
|
itemType = randomItem.itemType
|
||||||
)
|
)
|
||||||
|
|
||||||
onCleared(purchasedItem)
|
val randomAmount = (2..6).random() * 1000
|
||||||
|
val currentCurrency = application.container.currencyRepository.currencyValue.first()
|
||||||
|
application.container.currencyRepository.setCurrencyValue(currentCurrency + randomAmount)
|
||||||
|
|
||||||
|
onCleared(purchasedItem, randomAmount)
|
||||||
} else {
|
} else {
|
||||||
onCleared(null)
|
onCleared(null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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?, Int?) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.github.nacabaro.vbhelper.dtos.ItemDtos
|
|||||||
@Composable
|
@Composable
|
||||||
fun ObtainedItemDialog(
|
fun ObtainedItemDialog(
|
||||||
obtainedItem: ItemDtos.PurchasedItem,
|
obtainedItem: ItemDtos.PurchasedItem,
|
||||||
|
obtainedCurrency: Int,
|
||||||
onClickDismiss: () -> Unit
|
onClickDismiss: () -> Unit
|
||||||
) {
|
) {
|
||||||
Dialog(
|
Dialog(
|
||||||
@ -84,7 +85,16 @@ fun ObtainedItemDialog(
|
|||||||
text = "You have obtained ${obtainedItem.itemAmount} of this item",
|
text = "You have obtained ${obtainedItem.itemAmount} of this item",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(5.dp)
|
.padding(top = 4.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
text = "You also got $obtainedCurrency credits",
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 4.dp)
|
||||||
)
|
)
|
||||||
Button(
|
Button(
|
||||||
onClick = onClickDismiss,
|
onClick = onClickDismiss,
|
||||||
|
|||||||
@ -12,7 +12,8 @@ import androidx.compose.foundation.lazy.grid.GridCells
|
|||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
import androidx.compose.foundation.lazy.grid.items
|
import androidx.compose.foundation.lazy.grid.items
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.material3.CardColors
|
import androidx.compose.material3.CardDefaults
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -99,7 +100,15 @@ fun StorageScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cardColors = CardColors
|
cardColors = if (index.active) {
|
||||||
|
CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHighest
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user