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 duration: String,
 | 
			
		||||
    val description: String,
 | 
			
		||||
    val ritual: Boolean,
 | 
			
		||||
) {
 | 
			
		||||
    enum class School(val key: String) {
 | 
			
		||||
        ABJURATION("Abjuration"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,6 +38,7 @@ class SpellBookParser @Inject constructor() {
 | 
			
		|||
                    val requirement = row.parse(REQUIREMENT)
 | 
			
		||||
                    val duration = row.parse(DURATION)
 | 
			
		||||
                    val description = row.parse(DESCRIPTION)
 | 
			
		||||
                    val ritual = row.parse(RITUAL)?.toBoolean() ?: false
 | 
			
		||||
                    if (name != null
 | 
			
		||||
                        && level != null
 | 
			
		||||
                        && originalName != null
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +59,7 @@ class SpellBookParser @Inject constructor() {
 | 
			
		|||
                            requirement = requirement,
 | 
			
		||||
                            duration = duration,
 | 
			
		||||
                            description = description,
 | 
			
		||||
                            ritual = ritual,
 | 
			
		||||
                        )
 | 
			
		||||
                    } else {
 | 
			
		||||
                        null
 | 
			
		||||
| 
						 | 
				
			
			@ -85,6 +87,7 @@ class SpellBookParser @Inject constructor() {
 | 
			
		|||
        private const val RANGE = "Portée"
 | 
			
		||||
        private const val REQUIREMENT = "Composantes"
 | 
			
		||||
        private const val DURATION = "Durée"
 | 
			
		||||
        private const val RITUAL = "Rituel"
 | 
			
		||||
        private const val DESCRIPTION = "Description"
 | 
			
		||||
 | 
			
		||||
        private val COLUMNS
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +100,7 @@ class SpellBookParser @Inject constructor() {
 | 
			
		|||
                RANGE,
 | 
			
		||||
                REQUIREMENT,
 | 
			
		||||
                DURATION,
 | 
			
		||||
                RITUAL,
 | 
			
		||||
                DESCRIPTION,
 | 
			
		||||
            )
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,6 +47,7 @@ data class SpellUio(
 | 
			
		|||
    val hit: Dice?,
 | 
			
		||||
    val effect: Dice?,
 | 
			
		||||
    val changeWithLevel: Boolean,
 | 
			
		||||
    val ritual: Boolean,
 | 
			
		||||
) {
 | 
			
		||||
    class Dice(
 | 
			
		||||
        @DrawableRes val icon: Int,
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +66,9 @@ fun Spell(
 | 
			
		|||
    onCast: (String) -> Unit,
 | 
			
		||||
) {
 | 
			
		||||
    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),
 | 
			
		||||
        verticalAlignment = Alignment.CenterVertically,
 | 
			
		||||
    ) {
 | 
			
		||||
| 
						 | 
				
			
			@ -127,13 +130,33 @@ fun Spell(
 | 
			
		|||
                )
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Text(
 | 
			
		||||
                style = MaterialTheme.typography.labelMedium,
 | 
			
		||||
                fontStyle = FontStyle.Italic,
 | 
			
		||||
                overflow = TextOverflow.Ellipsis,
 | 
			
		||||
                maxLines = 1,
 | 
			
		||||
                text = spell.range,
 | 
			
		||||
            )
 | 
			
		||||
            Row(
 | 
			
		||||
                horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
 | 
			
		||||
            ) {
 | 
			
		||||
                if (spell.ritual) {
 | 
			
		||||
                    Text(
 | 
			
		||||
                        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 ->
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +228,8 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
 | 
			
		|||
                icon = R.drawable.ic_d10_24,
 | 
			
		||||
                label = "1d10",
 | 
			
		||||
            ),
 | 
			
		||||
            changeWithLevel = false
 | 
			
		||||
            changeWithLevel = false,
 | 
			
		||||
            ritual = false,
 | 
			
		||||
        ),
 | 
			
		||||
        SpellUio(
 | 
			
		||||
            icon = Spell.School.ENCHANTMENT.icon,
 | 
			
		||||
| 
						 | 
				
			
			@ -219,7 +243,8 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
 | 
			
		|||
                icon = R.drawable.ic_d10_24,
 | 
			
		||||
                label = "1d4",
 | 
			
		||||
            ),
 | 
			
		||||
            changeWithLevel = false
 | 
			
		||||
            changeWithLevel = false,
 | 
			
		||||
            ritual = false,
 | 
			
		||||
        ),
 | 
			
		||||
        SpellUio(
 | 
			
		||||
            icon = Spell.School.EVOCATION.icon,
 | 
			
		||||
| 
						 | 
				
			
			@ -234,6 +259,7 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
 | 
			
		|||
                label = "1d8+3",
 | 
			
		||||
            ),
 | 
			
		||||
            changeWithLevel = true,
 | 
			
		||||
            ritual = true,
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +35,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
 | 
			
		|||
                        icon = R.drawable.ic_d10_24,
 | 
			
		||||
                        label = "1d10",
 | 
			
		||||
                    ),
 | 
			
		||||
                    changeWithLevel = false
 | 
			
		||||
                    changeWithLevel = false,
 | 
			
		||||
                    ritual = true,
 | 
			
		||||
                ),
 | 
			
		||||
                SpellUio(
 | 
			
		||||
                    icon = Spell.School.ENCHANTMENT.icon,
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +50,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
 | 
			
		|||
                        icon = R.drawable.ic_d10_24,
 | 
			
		||||
                        label = "1d4",
 | 
			
		||||
                    ),
 | 
			
		||||
                    changeWithLevel = false
 | 
			
		||||
                    changeWithLevel = false,
 | 
			
		||||
                    ritual = false,
 | 
			
		||||
                ),
 | 
			
		||||
            ),
 | 
			
		||||
            SpellHeaderUio(
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +71,7 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
 | 
			
		|||
                        label = "1d8+3",
 | 
			
		||||
                    ),
 | 
			
		||||
                    changeWithLevel = true,
 | 
			
		||||
                    ritual = false,
 | 
			
		||||
                ),
 | 
			
		||||
            ),
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,6 +52,7 @@ class SpellUioFactory @Inject constructor() {
 | 
			
		|||
            hit = hit,
 | 
			
		||||
            effect = effect,
 | 
			
		||||
            changeWithLevel = assignedSpell.level != null,
 | 
			
		||||
            ritual = assignedSpell.spell.ritual,
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,6 +58,7 @@ class SpellDetailUio(
 | 
			
		|||
    val requirement: String,
 | 
			
		||||
    val duration: String,
 | 
			
		||||
    val description: String,
 | 
			
		||||
    val ritual: Boolean,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
| 
						 | 
				
			
			@ -146,11 +147,19 @@ private fun SpellDetailContent(
 | 
			
		|||
                        horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
 | 
			
		||||
                    ) {
 | 
			
		||||
                        Text(
 | 
			
		||||
                            modifier = Modifier.alignByBaseline(),
 | 
			
		||||
                            style = MaterialTheme.typography.bodyMedium,
 | 
			
		||||
                            fontWeight = FontWeight.Bold,
 | 
			
		||||
                            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(
 | 
			
		||||
                            modifier = Modifier.alignByBaseline(),
 | 
			
		||||
                            style = MaterialTheme.typography.bodyMedium,
 | 
			
		||||
                            text = stringResource(id = detail.school),
 | 
			
		||||
                        )
 | 
			
		||||
| 
						 | 
				
			
			@ -261,6 +270,7 @@ private fun SpellDetailPreview() {
 | 
			
		|||
                            requirement = "V, S",
 | 
			
		||||
                            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.",
 | 
			
		||||
                            ritual = true,
 | 
			
		||||
                        )
 | 
			
		||||
                    )
 | 
			
		||||
                },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,6 +41,7 @@ class SpellDetailViewModel @Inject constructor(
 | 
			
		|||
                requirement = it.spell.requirement,
 | 
			
		||||
                duration = it.spell.duration,
 | 
			
		||||
                description = it.spell.description,
 | 
			
		||||
                ritual = it.spell.ritual,
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -144,6 +144,7 @@
 | 
			
		|||
    <string name="spell_detail_range">Portée</string>
 | 
			
		||||
    <string name="spell_detail_components">Composantes</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_level_chooser_label">Sort de niveau %1$s</string>
 | 
			
		||||
    <string name="spell_level_chooser_available">Disponible : </string>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -144,6 +144,7 @@
 | 
			
		|||
    <string name="spell_detail_range">Range</string>
 | 
			
		||||
    <string name="spell_detail_components">Components</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_level_chooser_label">Spell level %1$s</string>
 | 
			
		||||
    <string name="spell_level_chooser_available">Available: </string>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue