Add DC saving throw in the character sheets.

This commit is contained in:
Thomas Andres Gomez 2023-09-28 17:01:07 +02:00
parent 1b5dfe8552
commit c5874fcc8c
8 changed files with 28 additions and 7 deletions

View file

@ -17,6 +17,7 @@ data class CharacterSheet(
val spell7: Counter?, val spell7: Counter?,
val spell8: Counter?, val spell8: Counter?,
val spell9: Counter?, val spell9: Counter?,
val dC: Int?,
val criticalModifier: Int, // Critical Dice Multiplier val criticalModifier: Int, // Critical Dice Multiplier
val armorClass: Int, // Classe d'armure val armorClass: Int, // Classe d'armure
val speed: Int, // Vitesse val speed: Int, // Vitesse

View file

@ -80,6 +80,7 @@ class CharacterSheetParser @Inject constructor(
spell9 = counterParser.parseCounter( spell9 = counterParser.parseCounter(
value = item.parseString(SPELL_LEVEL_9) value = item.parseString(SPELL_LEVEL_9)
), ),
dC = item.parseInt(DD_SAVE_THROW),
criticalModifier = item.parseInt(CRITICAL_MODIFIER) ?: 2, criticalModifier = item.parseInt(CRITICAL_MODIFIER) ?: 2,
armorClass = item.parseInt(ARMOR_CLASS) ?: 10, armorClass = item.parseInt(ARMOR_CLASS) ?: 10,
speed = item.parseInt(SPEED) ?: 10, speed = item.parseInt(SPEED) ?: 10,
@ -140,6 +141,7 @@ class CharacterSheetParser @Inject constructor(
private const val SPELL_LEVEL_7 = "Sort de niveau 7" private const val SPELL_LEVEL_7 = "Sort de niveau 7"
private const val SPELL_LEVEL_8 = "Sort de niveau 8" private const val SPELL_LEVEL_8 = "Sort de niveau 8"
private const val SPELL_LEVEL_9 = "Sort de niveau 9" private const val SPELL_LEVEL_9 = "Sort de niveau 9"
private const val DD_SAVE_THROW = "DD sauvergarde des sorts"
private const val CRITICAL_MODIFIER = "Dé de critique" private const val CRITICAL_MODIFIER = "Dé de critique"
private const val ARMOR_CLASS = "Classe d'armure" private const val ARMOR_CLASS = "Classe d'armure"
private const val SPEED = "Vitesse" private const val SPEED = "Vitesse"
@ -192,6 +194,7 @@ class CharacterSheetParser @Inject constructor(
SPELL_LEVEL_7, SPELL_LEVEL_7,
SPELL_LEVEL_8, SPELL_LEVEL_8,
SPELL_LEVEL_9, SPELL_LEVEL_9,
DD_SAVE_THROW,
CRITICAL_MODIFIER, CRITICAL_MODIFIER,
ARMOR_CLASS, ARMOR_CLASS,
SPEED, SPEED,

View file

@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable import androidx.compose.runtime.Stable
@ -27,6 +28,7 @@ data class CharacterSheetHeaderUio(
val armorClass: LabelPointUio, val armorClass: LabelPointUio,
val hitPoint: LabelPointUio, val hitPoint: LabelPointUio,
val speed: LabelPointUio, val speed: LabelPointUio,
val dC: LabelPointUio?,
) )
@OptIn(ExperimentalFoundationApi::class) @OptIn(ExperimentalFoundationApi::class)
@ -55,7 +57,8 @@ fun CharacterSheetHeader(
) { ) {
header.value?.armorClass?.let { LabelPoint(label = it) } header.value?.armorClass?.let { LabelPoint(label = it) }
header.value?.hitPoint?.let { LabelPoint(label = it) } header.value?.hitPoint?.let { LabelPoint(label = it) }
header.value?.speed?.let { LabelPoint(label = it) } header.value?.dC?.let { LabelPoint(label = it) }
header.value?.speed?.let { LabelPoint(label = it,) }
} }
IndicatorStep( IndicatorStep(

View file

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -16,6 +15,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.pixelized.rplexicon.R import com.pixelized.rplexicon.R
@ -31,18 +31,19 @@ class LabelPointUio(
@Composable @Composable
fun LabelPoint( fun LabelPoint(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
titleStyle: TextStyle = MaterialTheme.typography.labelSmall, labelStyle: TextStyle = MaterialTheme.typography.labelSmall,
valueStyle: TextStyle = MaterialTheme.typography.headlineMedium, valueStyle: TextStyle = MaterialTheme.typography.headlineMedium,
labelStyle: TextStyle = MaterialTheme.typography.titleMedium, maxStyle: TextStyle = MaterialTheme.typography.titleMedium,
label: LabelPointUio, label: LabelPointUio,
) { ) {
Column( Column(
verticalArrangement = Arrangement.spacedBy(4.dp), modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
label.label?.let { label.label?.let {
Text( Text(
style = titleStyle, style = labelStyle,
fontWeight = FontWeight.Light,
text = stringResource(id = it) text = stringResource(id = it)
) )
} }
@ -52,12 +53,13 @@ fun LabelPoint(
Text( Text(
modifier = Modifier.alignByBaseline(), modifier = Modifier.alignByBaseline(),
style = valueStyle, style = valueStyle,
fontWeight = FontWeight.Bold,
text = label.value ?: "0" text = label.value ?: "0"
) )
label.max?.let { label.max?.let {
Text( Text(
modifier = Modifier.alignByBaseline(), modifier = Modifier.alignByBaseline(),
style = labelStyle, style = maxStyle,
text = it, text = it,
) )
} }

View file

@ -27,6 +27,10 @@ fun rememberCharacterHeaderStatePreview() = remember {
value = "30", value = "30",
max = "m", max = "m",
), ),
dC = LabelPointUio(
label = R.string.character_sheet_title_dc,
value = "13",
),
) )
) )
} }

View file

@ -36,6 +36,12 @@ class CharacterSheetHeaderUioFactory @Inject constructor() {
value = model.hitPoint, value = model.hitPoint,
max = "/ ${model.maxHitPoint}", max = "/ ${model.maxHitPoint}",
), ),
dC = model.dC?.let {
LabelPointUio(
label = R.string.character_sheet_title_dc,
value = "$it",
)
}
) )
} }
} }

View file

@ -74,6 +74,7 @@
<string name="character_sheet_title">Feuille de personnage</string> <string name="character_sheet_title">Feuille de personnage</string>
<string name="character_sheet_title_hp">Point de vie</string> <string name="character_sheet_title_hp">Point de vie</string>
<string name="character_sheet_title_ca">CA</string> <string name="character_sheet_title_ca">CA</string>
<string name="character_sheet_title_dc">DD</string>
<string name="character_sheet_title_speed">Vitesse</string> <string name="character_sheet_title_speed">Vitesse</string>
<string name="character_sheet_title_initiative">Initiative</string> <string name="character_sheet_title_initiative">Initiative</string>
<string name="character_sheet_title_saving_throws">Jet de sauvegarde</string> <string name="character_sheet_title_saving_throws">Jet de sauvegarde</string>

View file

@ -74,6 +74,7 @@
<string name="character_sheet_title">Character sheet</string> <string name="character_sheet_title">Character sheet</string>
<string name="character_sheet_title_hp">HP</string> <string name="character_sheet_title_hp">HP</string>
<string name="character_sheet_title_ca">CA</string> <string name="character_sheet_title_ca">CA</string>
<string name="character_sheet_title_dc">DC</string>
<string name="character_sheet_title_speed">Speed</string> <string name="character_sheet_title_speed">Speed</string>
<string name="character_sheet_title_initiative">Initiative</string> <string name="character_sheet_title_initiative">Initiative</string>
<string name="character_sheet_title_saving_throws">Saving Throws</string> <string name="character_sheet_title_saving_throws">Saving Throws</string>