Add inspiration support in the game master screen.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-08-21 15:44:25 +02:00
parent 70148c9987
commit abdb39abc2
5 changed files with 52 additions and 16 deletions

View file

@ -34,6 +34,7 @@ data class AttributesSummaryUio(
val dc: SummaryRowUio,
val initiative: SummaryRowUio,
val speed: SummaryRowUio,
val inspiration: SummaryRowUio,
)
@Composable
@ -74,6 +75,9 @@ fun AttributesSummary(
SummaryRow(
row = attributes.speed,
)
SummaryRow(
row = attributes.inspiration,
)
}
}
Text(

View file

@ -54,7 +54,7 @@ data class SummaryCellUio(
@Stable
data class Proficiency(
val label: String,
val label: String?,
val multiplier: Int,
) : Mode()
@ -93,7 +93,7 @@ fun maxLabel(
@Stable
fun proficiency(
label: String,
label: String?,
multiplier: Int,
): SummaryCellUio {
return SummaryCellUio(
@ -226,25 +226,28 @@ private fun SummaryProficiency(
.padding(start = 4.dp)
.then(other = modifier),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
MasteryCircle(
size = MaterialTheme.lexicon.dimens.summary.mastery,
multiplier = value.multiplier,
)
AnimatedContent(
modifier = Modifier.weight(weight = 1f),
targetState = value.label,
label = "SummaryMaxLabelAnimation",
transitionSpec = animationSpec(),
) {
Text(
text = it,
style = style,
color = color,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
maxLines = 1
)
if (value.label != null) {
AnimatedContent(
modifier = Modifier.weight(weight = 1f),
targetState = value.label,
label = "SummaryMaxLabelAnimation",
transitionSpec = animationSpec(),
) {
Text(
text = it,
style = style,
color = color,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
maxLines = 1
)
}
}
}
}

View file

@ -157,6 +157,18 @@ private fun SummaryRowPreview() {
)
}
)
SummaryRow(
row = remember {
SummaryRowUio(
label = R.string.character_sheet_proficiency_perception,
c1 = mutableStateOf(proficiency(null, 1)),
c2 = mutableStateOf(proficiency(null, 0)),
c3 = mutableStateOf(proficiency(null, 1)),
c4 = mutableStateOf(proficiency(null, 0)),
c5 = mutableStateOf(proficiency(null, 0)),
)
}
)
SummaryRow(
row = remember {
SummaryRowUio(

View file

@ -8,6 +8,7 @@ import com.pixelized.rplexicon.R
import com.pixelized.rplexicon.ui.screens.summary.composable.AttributesSummaryUio
import com.pixelized.rplexicon.ui.screens.summary.composable.common.SummaryRowUio
import com.pixelized.rplexicon.ui.screens.summary.composable.common.label
import com.pixelized.rplexicon.ui.screens.summary.composable.common.proficiency
@Composable
@Stable
@ -54,6 +55,14 @@ fun rememberAttributesSummary(): AttributesSummaryUio {
c4 = mutableStateOf(label(label = "10m")),
c5 = mutableStateOf(label(label = "10m")),
),
inspiration = SummaryRowUio(
label = R.string.character_sheet_title_inspiration,
c1 = mutableStateOf(proficiency(label = null, multiplier = 0)),
c2 = mutableStateOf(proficiency(label = null, multiplier = 1)),
c3 = mutableStateOf(proficiency(label = null, multiplier = 1)),
c4 = mutableStateOf(proficiency(label = null, multiplier = 1)),
c5 = mutableStateOf(proficiency(label = null, multiplier = 1)),
)
)
}
}

View file

@ -76,6 +76,7 @@ class SummaryFactory @Inject constructor(
dc = SummaryRowUio(label = R.string.character_sheet_title_dc),
initiative = SummaryRowUio(label = R.string.character_sheet_title_initiative),
speed = SummaryRowUio(label = R.string.character_sheet_title_speed),
inspiration = SummaryRowUio(label = R.string.character_sheet_title_inspiration),
)
val characteristics = CharacteristicsSummaryUio(
strength = SummaryRowUio(label = R.string.character_sheet_stat_strength),
@ -217,12 +218,17 @@ class SummaryFactory @Inject constructor(
val speed = label(
label = "${max(sheet.speed + status[Property.SPEED].sum, 0)}m",
)
val inspiration = proficiency(
label = null,
multiplier = fire?.skills?.get(INSPIRATION) ?: 0
)
withContext(Dispatchers.Main) {
attributes.hp.get(sheet)?.value = hitPoint
attributes.ac.get(sheet)?.value = armorClass
attributes.dc.get(sheet)?.value = dC
attributes.initiative.get(sheet)?.value = initiative
attributes.speed.get(sheet)?.value = speed
attributes.inspiration.get(sheet)?.value = inspiration
}
}
withContext(Dispatchers.Main) {
@ -757,6 +763,8 @@ class SummaryFactory @Inject constructor(
private const val ENTER_ANIMATION_INITIAL_DELAY = 250L
private const val ENTER_ANIMATION_DELAY = 100L
private const val INSPIRATION = "Inspiration"
private const val PRONE = "À terre"
private const val GRAPPLED = "Agrippé"
private const val DEAFENED = "Assourdi"