Simplify the UI for the warlock.
This commit is contained in:
parent
60c11e6192
commit
73428d4341
4 changed files with 87 additions and 27 deletions
|
|
@ -52,7 +52,8 @@ class SpellBookUseCase @Inject constructor(
|
||||||
val spellList = entry.value.map {
|
val spellList = entry.value.map {
|
||||||
factory.toSpellUio(
|
factory.toSpellUio(
|
||||||
assignedSpell = it,
|
assignedSpell = it,
|
||||||
characterSheet = character
|
characterSheet = character,
|
||||||
|
warlockSpellLevel = firstSpellSlot,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
header to spellList
|
header to spellList
|
||||||
|
|
@ -77,7 +78,8 @@ class SpellBookUseCase @Inject constructor(
|
||||||
val spellList = entry.value.map {
|
val spellList = entry.value.map {
|
||||||
factory.toSpellUio(
|
factory.toSpellUio(
|
||||||
assignedSpell = it,
|
assignedSpell = it,
|
||||||
characterSheet = character
|
characterSheet = character,
|
||||||
|
warlockSpellLevel = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
header to spellList
|
header to spellList
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ data class SpellUio(
|
||||||
val hit: Dice?,
|
val hit: Dice?,
|
||||||
val effect: Dice?,
|
val effect: Dice?,
|
||||||
val changeWithLevel: Boolean,
|
val changeWithLevel: Boolean,
|
||||||
|
val isWarlock: Boolean,
|
||||||
val ritual: Boolean,
|
val ritual: Boolean,
|
||||||
) {
|
) {
|
||||||
class Dice(
|
class Dice(
|
||||||
|
|
@ -180,7 +181,8 @@ fun Spell(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
spell.effect?.let { dice ->
|
spell.effect?.let { dice ->
|
||||||
if (spell.changeWithLevel) {
|
when {
|
||||||
|
spell.changeWithLevel && spell.isWarlock.not() -> {
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
modifier = Modifier.padding(end = 8.dp),
|
modifier = Modifier.padding(end = 8.dp),
|
||||||
border = BorderStroke(
|
border = BorderStroke(
|
||||||
|
|
@ -193,7 +195,15 @@ fun Spell(
|
||||||
text = stringResource(id = R.string.character_sheet_action_spell_cast),
|
text = stringResource(id = R.string.character_sheet_action_spell_cast),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
spell.changeWithLevel && spell.isWarlock -> {
|
||||||
|
DiceButton(
|
||||||
|
icon = dice.icon,
|
||||||
|
text = dice.label,
|
||||||
|
onClick = { onCast(spell.name) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
DiceButton(
|
DiceButton(
|
||||||
icon = dice.icon,
|
icon = dice.icon,
|
||||||
text = dice.label,
|
text = dice.label,
|
||||||
|
|
@ -204,6 +214,7 @@ fun Spell(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -244,6 +255,7 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||||
label = "1d10",
|
label = "1d10",
|
||||||
),
|
),
|
||||||
changeWithLevel = false,
|
changeWithLevel = false,
|
||||||
|
isWarlock = false,
|
||||||
ritual = false,
|
ritual = false,
|
||||||
),
|
),
|
||||||
SpellUio(
|
SpellUio(
|
||||||
|
|
@ -260,6 +272,7 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||||
label = "1d4",
|
label = "1d4",
|
||||||
),
|
),
|
||||||
changeWithLevel = false,
|
changeWithLevel = false,
|
||||||
|
isWarlock = false,
|
||||||
ritual = false,
|
ritual = false,
|
||||||
),
|
),
|
||||||
SpellUio(
|
SpellUio(
|
||||||
|
|
@ -276,6 +289,24 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||||
label = "1d8+3",
|
label = "1d8+3",
|
||||||
),
|
),
|
||||||
changeWithLevel = true,
|
changeWithLevel = true,
|
||||||
|
isWarlock = false,
|
||||||
|
ritual = true,
|
||||||
|
),
|
||||||
|
SpellUio(
|
||||||
|
icon = null,
|
||||||
|
school = Spell.School.EVOCATION,
|
||||||
|
name = "Soins",
|
||||||
|
translated = "Cure Wounds",
|
||||||
|
castingTime = "1 action",
|
||||||
|
range = "contact",
|
||||||
|
duration = "instantanée",
|
||||||
|
hit = null,
|
||||||
|
effect = SpellUio.Dice(
|
||||||
|
icon = R.drawable.ic_d8_24,
|
||||||
|
label = "1d8+3",
|
||||||
|
),
|
||||||
|
changeWithLevel = true,
|
||||||
|
isWarlock = true,
|
||||||
ritual = true,
|
ritual = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
||||||
label = "1d10",
|
label = "1d10",
|
||||||
),
|
),
|
||||||
changeWithLevel = false,
|
changeWithLevel = false,
|
||||||
|
isWarlock = false,
|
||||||
ritual = true,
|
ritual = true,
|
||||||
),
|
),
|
||||||
SpellUio(
|
SpellUio(
|
||||||
|
|
@ -55,6 +56,7 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
||||||
label = "1d4",
|
label = "1d4",
|
||||||
),
|
),
|
||||||
changeWithLevel = false,
|
changeWithLevel = false,
|
||||||
|
isWarlock = false,
|
||||||
ritual = false,
|
ritual = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -76,6 +78,7 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
||||||
label = "1d8+3",
|
label = "1d8+3",
|
||||||
),
|
),
|
||||||
changeWithLevel = true,
|
changeWithLevel = true,
|
||||||
|
isWarlock = false,
|
||||||
ritual = false,
|
ritual = false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,24 @@
|
||||||
package com.pixelized.rplexicon.ui.screens.character.factory
|
package com.pixelized.rplexicon.ui.screens.character.factory
|
||||||
|
|
||||||
import androidx.core.net.toUri
|
import androidx.compose.animation.core.spring
|
||||||
import com.pixelized.rplexicon.data.model.AssignedSpell
|
import com.pixelized.rplexicon.data.model.AssignedSpell
|
||||||
import com.pixelized.rplexicon.data.model.CharacterSheet
|
import com.pixelized.rplexicon.data.model.CharacterSheet
|
||||||
import com.pixelized.rplexicon.data.model.Property
|
import com.pixelized.rplexicon.data.model.Property
|
||||||
import com.pixelized.rplexicon.data.repository.character.DescriptionRepository
|
import com.pixelized.rplexicon.data.repository.character.DescriptionRepository
|
||||||
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SpellUio
|
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SpellUio
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.icon
|
import com.pixelized.rplexicon.utilitary.extentions.icon
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.icon
|
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.modifier
|
import com.pixelized.rplexicon.utilitary.extentions.modifier
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.uri
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SpellUioFactory @Inject constructor(
|
class SpellUioFactory @Inject constructor(
|
||||||
private val descriptionRepository: DescriptionRepository,
|
private val descriptionRepository: DescriptionRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun toSpellUio(assignedSpell: AssignedSpell, characterSheet: CharacterSheet): SpellUio {
|
fun toSpellUio(
|
||||||
|
assignedSpell: AssignedSpell,
|
||||||
|
characterSheet: CharacterSheet,
|
||||||
|
warlockSpellLevel: Int?,
|
||||||
|
): SpellUio {
|
||||||
val hit = assignedSpell.hit?.let { dice ->
|
val hit = assignedSpell.hit?.let { dice ->
|
||||||
val modifier = dice.modifier.sumOf {
|
val modifier = dice.modifier.sumOf {
|
||||||
when (it) {
|
when (it) {
|
||||||
|
|
@ -44,11 +46,32 @@ class SpellUioFactory @Inject constructor(
|
||||||
Property.CHARISMA -> characterSheet.charisma.modifier
|
Property.CHARISMA -> characterSheet.charisma.modifier
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
}
|
} + dice.flat
|
||||||
|
|
||||||
|
val level = assignedSpell.level
|
||||||
|
val delta = warlockSpellLevel?.minus(assignedSpell.spell.level) ?: 0
|
||||||
|
if (warlockSpellLevel == null || level == null || delta <= 0) {
|
||||||
|
// default case of non warlock character of the spell don't scale
|
||||||
SpellUio.Dice(
|
SpellUio.Dice(
|
||||||
icon = dice.faces.icon,
|
icon = dice.faces.icon,
|
||||||
label = "${dice.amount}d${dice.faces}${if (modifier > 0) "+$modifier" else ""}",
|
label = "${dice.amount}d${dice.faces}${if (modifier > 0) "+$modifier" else ""}",
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
// warlock character, upscale the spell to warlock spell level
|
||||||
|
if (dice.faces == level.faces) {
|
||||||
|
val upscaleModifier = modifier + level.flat * delta
|
||||||
|
SpellUio.Dice(
|
||||||
|
icon = dice.faces.icon,
|
||||||
|
label = "${dice.amount + level.amount * delta}d${dice.faces}${if (upscaleModifier > 0) "+$upscaleModifier" else ""}",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
SpellUio.Dice(
|
||||||
|
icon = dice.faces.icon,
|
||||||
|
label = "${dice.amount}d${dice.faces}${modifier.takeIf { it > 0 }?.let { "+$it" } ?: ""} + " +
|
||||||
|
"${level.amount}d${level.faces * delta}${(level.flat * delta).takeIf { it > 0 }?.let { "+$it" } ?: ""}",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SpellUio(
|
return SpellUio(
|
||||||
icon = assignedSpell.spell.icon,
|
icon = assignedSpell.spell.icon,
|
||||||
|
|
@ -61,6 +84,7 @@ class SpellUioFactory @Inject constructor(
|
||||||
hit = hit,
|
hit = hit,
|
||||||
effect = effect,
|
effect = effect,
|
||||||
changeWithLevel = assignedSpell.level != null,
|
changeWithLevel = assignedSpell.level != null,
|
||||||
|
isWarlock = warlockSpellLevel != null,
|
||||||
ritual = assignedSpell.spell.ritual,
|
ritual = assignedSpell.spell.ritual,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue