package com.craigvg.lichun_android.ui.screens.character import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.CheckCircle import androidx.compose.material.icons.filled.Diamond import androidx.compose.material.icons.filled.Lock import androidx.compose.material.icons.filled.Star import androidx.compose.material.icons.filled.Work import androidx.compose.material.icons.filled.WorkspacePremium import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.craigvg.lichun_android.ui.theme.AppColors import com.craigvg.lichun_android.ui.theme.AppSpacing import com.craigvg.lichun_android.ui.theme.AppTypography import com.craigvg.lichun_android.viewmodel.GameStateViewModel /** * Prestige screen (Wave 2) — surfaces the player's current prestige and the * compounding family (generational) prestige, plus what prestige unlocks: * senior/top job tiers and prestige-gated shop items. Each threshold is shown as * a milestone: unlocked once current prestige meets it, otherwise locked with * the gap remaining. * * Thresholds mirror the server: jobs (senior 100 / top 300) and shop items * (100 / 250 / 500). */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun PrestigeScreen( gameStateViewModel: GameStateViewModel = hiltViewModel(), onBack: () -> Unit = {} ) { val prestige by gameStateViewModel.prestige.collectAsStateWithLifecycle() val familyPrestige by gameStateViewModel.familyPrestige.collectAsStateWithLifecycle() Scaffold( topBar = { TopAppBar( title = { Text("Prestige", style = AppTypography.headline) }, navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, "Back", tint = AppColors.primaryText) } }, colors = TopAppBarDefaults.topAppBarColors(containerColor = AppColors.surfaceElevated) ) }, containerColor = AppColors.background ) { padding -> Column( modifier = Modifier .fillMaxSize() .padding(padding) .verticalScroll(rememberScrollState()) .padding(horizontal = AppSpacing.md) ) { Spacer(Modifier.height(AppSpacing.md)) PrestigeHeader(prestige = prestige, familyPrestige = familyPrestige) Spacer(Modifier.height(AppSpacing.lg)) Text("Career Tiers", style = AppTypography.headline, color = AppColors.primaryText) Spacer(Modifier.height(AppSpacing.sm)) MilestoneRow(Icons.Default.Work, "Senior roles", "Unlock senior-level jobs", 100, prestige) Spacer(Modifier.height(AppSpacing.sm)) MilestoneRow(Icons.Default.WorkspacePremium, "Top-tier roles", "Unlock the most prestigious jobs", 300, prestige) Spacer(Modifier.height(AppSpacing.lg)) Text("Prestige Shop", style = AppTypography.headline, color = AppColors.primaryText) Spacer(Modifier.height(AppSpacing.sm)) MilestoneRow(Icons.Default.Diamond, "Tier 1 items", "Exclusive items unlock", 100, prestige) Spacer(Modifier.height(AppSpacing.sm)) MilestoneRow(Icons.Default.Diamond, "Tier 2 items", "Premium prestige items", 250, prestige) Spacer(Modifier.height(AppSpacing.sm)) MilestoneRow(Icons.Default.Diamond, "Tier 3 items", "The rarest items in the game", 500, prestige) Spacer(Modifier.height(AppSpacing.lg)) Text( "Family prestige compounds across generations and survives each new life. " + "Personal prestige resets, so keep building your legacy.", style = AppTypography.caption, color = AppColors.secondaryText ) Spacer(Modifier.height(AppSpacing.xl)) } } } @Composable private fun PrestigeHeader(prestige: Int, familyPrestige: Double) { Card( modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(AppSpacing.cornerRadius), colors = CardDefaults.cardColors(containerColor = AppColors.surfaceElevated) ) { Row( modifier = Modifier .fillMaxWidth() .padding(AppSpacing.md), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically ) { PrestigeStat("$prestige", "Prestige", AppColors.prestige) Box( modifier = Modifier .width(1.dp) .height(48.dp) .background(AppColors.disabledText.copy(alpha = 0.3f)) ) PrestigeStat("${familyPrestige.toInt()}", "Family Prestige", AppColors.secondary) } } } @Composable private fun PrestigeStat(value: String, label: String, color: Color) { Column(horizontalAlignment = Alignment.CenterHorizontally) { Box( modifier = Modifier .size(48.dp) .background(color.copy(alpha = 0.18f), CircleShape), contentAlignment = Alignment.Center ) { Icon(Icons.Default.Star, null, tint = color, modifier = Modifier.size(24.dp)) } Spacer(Modifier.height(AppSpacing.xs)) Text(value, style = AppTypography.title2, color = AppColors.primaryText) Text(label, style = AppTypography.caption, color = AppColors.secondaryText) } } @Composable private fun MilestoneRow( icon: ImageVector, title: String, subtitle: String, threshold: Int, currentPrestige: Int ) { val unlocked = currentPrestige >= threshold val fraction = (currentPrestige.toFloat() / threshold.toFloat()).coerceIn(0f, 1f) Card( modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(AppSpacing.cornerRadius), colors = CardDefaults.cardColors( containerColor = if (unlocked) AppColors.success.copy(alpha = 0.1f) else AppColors.surfaceElevated ), elevation = CardDefaults.cardElevation(defaultElevation = 1.dp) ) { Column(modifier = Modifier.padding(AppSpacing.md)) { Row(verticalAlignment = Alignment.CenterVertically) { Box( modifier = Modifier .size(44.dp) .background( (if (unlocked) AppColors.success else AppColors.prestige).copy(alpha = 0.15f), CircleShape ), contentAlignment = Alignment.Center ) { Icon( if (unlocked) Icons.Default.CheckCircle else icon, null, tint = if (unlocked) AppColors.success else AppColors.prestige, modifier = Modifier.size(20.dp) ) } Spacer(Modifier.width(AppSpacing.sm)) Column(modifier = Modifier.weight(1f)) { Text(title, style = AppTypography.bodyBold, color = AppColors.primaryText) Text(subtitle, style = AppTypography.caption, color = AppColors.secondaryText) } if (!unlocked) { Icon(Icons.Default.Lock, null, tint = AppColors.disabledText, modifier = Modifier.size(18.dp)) } } if (!unlocked) { Spacer(Modifier.height(AppSpacing.sm)) Box( modifier = Modifier .fillMaxWidth() .height(6.dp) .clip(RoundedCornerShape(3.dp)) .background(AppColors.prestige.copy(alpha = 0.2f)) ) { Box( modifier = Modifier .fillMaxWidth(fraction) .fillMaxHeight() .clip(RoundedCornerShape(3.dp)) .background(AppColors.prestige) ) } Spacer(Modifier.height(AppSpacing.xxs)) Text( "$currentPrestige / $threshold prestige (${(threshold - currentPrestige).coerceAtLeast(0)} to go)", style = AppTypography.caption, color = AppColors.secondaryText ) } } } }