Add ritual display in spell item & detail.
This commit is contained in:
parent
d25246f452
commit
1b5dfe8552
9 changed files with 60 additions and 12 deletions
|
|
@ -10,6 +10,7 @@ data class Spell(
|
||||||
val requirement: String,
|
val requirement: String,
|
||||||
val duration: String,
|
val duration: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
|
val ritual: Boolean,
|
||||||
) {
|
) {
|
||||||
enum class School(val key: String) {
|
enum class School(val key: String) {
|
||||||
ABJURATION("Abjuration"),
|
ABJURATION("Abjuration"),
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ class SpellBookParser @Inject constructor() {
|
||||||
val requirement = row.parse(REQUIREMENT)
|
val requirement = row.parse(REQUIREMENT)
|
||||||
val duration = row.parse(DURATION)
|
val duration = row.parse(DURATION)
|
||||||
val description = row.parse(DESCRIPTION)
|
val description = row.parse(DESCRIPTION)
|
||||||
|
val ritual = row.parse(RITUAL)?.toBoolean() ?: false
|
||||||
if (name != null
|
if (name != null
|
||||||
&& level != null
|
&& level != null
|
||||||
&& originalName != null
|
&& originalName != null
|
||||||
|
|
@ -58,6 +59,7 @@ class SpellBookParser @Inject constructor() {
|
||||||
requirement = requirement,
|
requirement = requirement,
|
||||||
duration = duration,
|
duration = duration,
|
||||||
description = description,
|
description = description,
|
||||||
|
ritual = ritual,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
|
@ -85,6 +87,7 @@ class SpellBookParser @Inject constructor() {
|
||||||
private const val RANGE = "Portée"
|
private const val RANGE = "Portée"
|
||||||
private const val REQUIREMENT = "Composantes"
|
private const val REQUIREMENT = "Composantes"
|
||||||
private const val DURATION = "Durée"
|
private const val DURATION = "Durée"
|
||||||
|
private const val RITUAL = "Rituel"
|
||||||
private const val DESCRIPTION = "Description"
|
private const val DESCRIPTION = "Description"
|
||||||
|
|
||||||
private val COLUMNS
|
private val COLUMNS
|
||||||
|
|
@ -97,6 +100,7 @@ class SpellBookParser @Inject constructor() {
|
||||||
RANGE,
|
RANGE,
|
||||||
REQUIREMENT,
|
REQUIREMENT,
|
||||||
DURATION,
|
DURATION,
|
||||||
|
RITUAL,
|
||||||
DESCRIPTION,
|
DESCRIPTION,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ data class SpellUio(
|
||||||
val hit: Dice?,
|
val hit: Dice?,
|
||||||
val effect: Dice?,
|
val effect: Dice?,
|
||||||
val changeWithLevel: Boolean,
|
val changeWithLevel: Boolean,
|
||||||
|
val ritual: Boolean,
|
||||||
) {
|
) {
|
||||||
class Dice(
|
class Dice(
|
||||||
@DrawableRes val icon: Int,
|
@DrawableRes val icon: Int,
|
||||||
|
|
@ -65,7 +66,9 @@ fun Spell(
|
||||||
onCast: (String) -> Unit,
|
onCast: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.clickable { onClick(spell.name) }.then(other = modifier),
|
modifier = Modifier
|
||||||
|
.clickable { onClick(spell.name) }
|
||||||
|
.then(other = modifier),
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
|
@ -127,13 +130,33 @@ fun Spell(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Row(
|
||||||
style = MaterialTheme.typography.labelMedium,
|
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||||
fontStyle = FontStyle.Italic,
|
) {
|
||||||
overflow = TextOverflow.Ellipsis,
|
if (spell.ritual) {
|
||||||
maxLines = 1,
|
Text(
|
||||||
text = spell.range,
|
style = MaterialTheme.typography.labelMedium,
|
||||||
)
|
fontStyle = FontStyle.Italic,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
text = stringResource(id = R.string.spell_detail_ritual),
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
style = MaterialTheme.typography.labelMedium,
|
||||||
|
fontStyle = FontStyle.Italic,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
text = "-",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
style = MaterialTheme.typography.labelMedium,
|
||||||
|
fontStyle = FontStyle.Italic,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
text = spell.range,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spell.hit?.let { dice ->
|
spell.hit?.let { dice ->
|
||||||
|
|
@ -205,7 +228,8 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||||
icon = R.drawable.ic_d10_24,
|
icon = R.drawable.ic_d10_24,
|
||||||
label = "1d10",
|
label = "1d10",
|
||||||
),
|
),
|
||||||
changeWithLevel = false
|
changeWithLevel = false,
|
||||||
|
ritual = false,
|
||||||
),
|
),
|
||||||
SpellUio(
|
SpellUio(
|
||||||
icon = Spell.School.ENCHANTMENT.icon,
|
icon = Spell.School.ENCHANTMENT.icon,
|
||||||
|
|
@ -219,7 +243,8 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||||
icon = R.drawable.ic_d10_24,
|
icon = R.drawable.ic_d10_24,
|
||||||
label = "1d4",
|
label = "1d4",
|
||||||
),
|
),
|
||||||
changeWithLevel = false
|
changeWithLevel = false,
|
||||||
|
ritual = false,
|
||||||
),
|
),
|
||||||
SpellUio(
|
SpellUio(
|
||||||
icon = Spell.School.EVOCATION.icon,
|
icon = Spell.School.EVOCATION.icon,
|
||||||
|
|
@ -234,6 +259,7 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||||
label = "1d8+3",
|
label = "1d8+3",
|
||||||
),
|
),
|
||||||
changeWithLevel = true,
|
changeWithLevel = true,
|
||||||
|
ritual = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
||||||
icon = R.drawable.ic_d10_24,
|
icon = R.drawable.ic_d10_24,
|
||||||
label = "1d10",
|
label = "1d10",
|
||||||
),
|
),
|
||||||
changeWithLevel = false
|
changeWithLevel = false,
|
||||||
|
ritual = true,
|
||||||
),
|
),
|
||||||
SpellUio(
|
SpellUio(
|
||||||
icon = Spell.School.ENCHANTMENT.icon,
|
icon = Spell.School.ENCHANTMENT.icon,
|
||||||
|
|
@ -49,7 +50,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
||||||
icon = R.drawable.ic_d10_24,
|
icon = R.drawable.ic_d10_24,
|
||||||
label = "1d4",
|
label = "1d4",
|
||||||
),
|
),
|
||||||
changeWithLevel = false
|
changeWithLevel = false,
|
||||||
|
ritual = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpellHeaderUio(
|
SpellHeaderUio(
|
||||||
|
|
@ -69,6 +71,7 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
||||||
label = "1d8+3",
|
label = "1d8+3",
|
||||||
),
|
),
|
||||||
changeWithLevel = true,
|
changeWithLevel = true,
|
||||||
|
ritual = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ class SpellUioFactory @Inject constructor() {
|
||||||
hit = hit,
|
hit = hit,
|
||||||
effect = effect,
|
effect = effect,
|
||||||
changeWithLevel = assignedSpell.level != null,
|
changeWithLevel = assignedSpell.level != null,
|
||||||
|
ritual = assignedSpell.spell.ritual,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ class SpellDetailUio(
|
||||||
val requirement: String,
|
val requirement: String,
|
||||||
val duration: String,
|
val duration: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
|
val ritual: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -146,11 +147,19 @@ private fun SpellDetailContent(
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.alignByBaseline(),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
text = stringResource(id = R.string.spell_detail_school),
|
text = stringResource(id = R.string.spell_detail_school),
|
||||||
)
|
)
|
||||||
|
if (detail.ritual) {
|
||||||
|
Text(
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
text = stringResource(id = R.string.spell_detail_ritual),
|
||||||
|
)
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.alignByBaseline(),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
text = stringResource(id = detail.school),
|
text = stringResource(id = detail.school),
|
||||||
)
|
)
|
||||||
|
|
@ -261,6 +270,7 @@ private fun SpellDetailPreview() {
|
||||||
requirement = "V, S",
|
requirement = "V, S",
|
||||||
duration = "instantanée",
|
duration = "instantanée",
|
||||||
description = "La créature que vous touchez récupère un nombre de points de vie égal à 1d8 + votre modificateur de caractéristique d'incantation. Ce sort n'a aucun effet sur les morts-vivants et les créatures artificielles.\nÀ plus haut niveau. Si vous lancez ce sort en utilisant un emplacement de niveau 2 ou supérieur, les soins augmentent de 1d8 par niveau au-delà du niveau 1.",
|
description = "La créature que vous touchez récupère un nombre de points de vie égal à 1d8 + votre modificateur de caractéristique d'incantation. Ce sort n'a aucun effet sur les morts-vivants et les créatures artificielles.\nÀ plus haut niveau. Si vous lancez ce sort en utilisant un emplacement de niveau 2 ou supérieur, les soins augmentent de 1d8 par niveau au-delà du niveau 1.",
|
||||||
|
ritual = true,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ class SpellDetailViewModel @Inject constructor(
|
||||||
requirement = it.spell.requirement,
|
requirement = it.spell.requirement,
|
||||||
duration = it.spell.duration,
|
duration = it.spell.duration,
|
||||||
description = it.spell.description,
|
description = it.spell.description,
|
||||||
|
ritual = it.spell.ritual,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@
|
||||||
<string name="spell_detail_range">Portée</string>
|
<string name="spell_detail_range">Portée</string>
|
||||||
<string name="spell_detail_components">Composantes</string>
|
<string name="spell_detail_components">Composantes</string>
|
||||||
<string name="spell_detail_duration">Durée</string>
|
<string name="spell_detail_duration">Durée</string>
|
||||||
|
<string name="spell_detail_ritual">Rituel</string>
|
||||||
<string name="spell_detail_description">Description</string>
|
<string name="spell_detail_description">Description</string>
|
||||||
<string name="spell_level_chooser_label">Sort de niveau %1$s</string>
|
<string name="spell_level_chooser_label">Sort de niveau %1$s</string>
|
||||||
<string name="spell_level_chooser_available">Disponible : </string>
|
<string name="spell_level_chooser_available">Disponible : </string>
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@
|
||||||
<string name="spell_detail_range">Range</string>
|
<string name="spell_detail_range">Range</string>
|
||||||
<string name="spell_detail_components">Components</string>
|
<string name="spell_detail_components">Components</string>
|
||||||
<string name="spell_detail_duration">Duration</string>
|
<string name="spell_detail_duration">Duration</string>
|
||||||
|
<string name="spell_detail_ritual">Ritual</string>
|
||||||
<string name="spell_detail_description">Description</string>
|
<string name="spell_detail_description">Description</string>
|
||||||
<string name="spell_level_chooser_label">Spell level %1$s</string>
|
<string name="spell_level_chooser_label">Spell level %1$s</string>
|
||||||
<string name="spell_level_chooser_available">Available: </string>
|
<string name="spell_level_chooser_available">Available: </string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue