Change the behavior of the dice
This commit is contained in:
parent
bb0e10c1ad
commit
2c6fc19a2c
6 changed files with 61 additions and 35 deletions
|
|
@ -613,25 +613,25 @@ class DiceThrowUseCase @Inject constructor(
|
|||
)
|
||||
} ?: emptyList()
|
||||
|
||||
// compute the final roll result
|
||||
val rollResult = when (result.value) {
|
||||
1, 20 -> "${result.value}"
|
||||
else -> "${allValue.sum()}"
|
||||
}
|
||||
|
||||
// build the result.
|
||||
return DiceThrowResult(
|
||||
dice = RollDiceUio(
|
||||
isCriticalSuccess = result.value == 20,
|
||||
isCriticalFailure = result.value == 1,
|
||||
result = "${result.value}",
|
||||
result = rollResult,
|
||||
),
|
||||
card = ThrowsCardUio(
|
||||
title = abilityTitleString.uppercase(),
|
||||
highlight = abilityLabelString.uppercase(),
|
||||
dice = R.drawable.ic_d20_24,
|
||||
roll = allValue.toLabel(),
|
||||
result = "${
|
||||
when (result.value) {
|
||||
20 -> 20
|
||||
1 -> 1
|
||||
else -> allValue.sum()
|
||||
}
|
||||
}",
|
||||
result = rollResult,
|
||||
isCriticalSuccess = result.value == 20,
|
||||
isCriticalFailure = result.value == 1,
|
||||
details = listOf(
|
||||
|
|
@ -718,13 +718,20 @@ class DiceThrowUseCase @Inject constructor(
|
|||
)
|
||||
} ?: emptyList()
|
||||
|
||||
// compute the final roll result
|
||||
val rollResult = when {
|
||||
canMakeCriticalRoll && result.value == 20 -> "20"
|
||||
canMakeCriticalRoll && result.value == 1 -> "1"
|
||||
else -> "${allValue.sum()}"
|
||||
}
|
||||
|
||||
// build the result.
|
||||
return DiceThrowResult(
|
||||
dice = RollDiceUio(
|
||||
icon = diceThrow?.faces?.icon ?: R.drawable.ic_d20_24,
|
||||
isCriticalSuccess = canMakeCriticalRoll && result.value == 20,
|
||||
isCriticalFailure = canMakeCriticalRoll && result.value == 1,
|
||||
result = "${result.value}",
|
||||
result = rollResult,
|
||||
),
|
||||
card = ThrowsCardUio(
|
||||
title = titleString.uppercase(),
|
||||
|
|
@ -733,13 +740,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
isCriticalSuccess = canMakeCriticalRoll && result.value == 20,
|
||||
isCriticalFailure = canMakeCriticalRoll && result.value == 1,
|
||||
roll = allValue.toLabel(),
|
||||
result = "${
|
||||
when {
|
||||
canMakeCriticalRoll && result.value == 20 -> 20
|
||||
canMakeCriticalRoll && result.value == 1 -> 1
|
||||
else -> allValue.sum()
|
||||
}
|
||||
}",
|
||||
result = rollResult,
|
||||
details = listOf(
|
||||
ThrowsCardUio.Detail(
|
||||
title = action,
|
||||
|
|
@ -799,18 +800,21 @@ class DiceThrowUseCase @Inject constructor(
|
|||
// fetch and build the associated characteristic
|
||||
val relatedStatBonus = spell?.effect.statBonus(name = spellName)
|
||||
|
||||
// compute the final roll result
|
||||
val rollResult = "${allValue.sum()}"
|
||||
|
||||
// build the result.
|
||||
return DiceThrowResult(
|
||||
dice = RollDiceUio(
|
||||
icon = (spell?.effect?.faces ?: 4).icon,
|
||||
result = "${result.value}",
|
||||
result = rollResult,
|
||||
),
|
||||
card = ThrowsCardUio(
|
||||
title = titleString.uppercase(),
|
||||
highlight = spellName,
|
||||
dice = (spell?.effect?.faces ?: 4).icon,
|
||||
roll = allValue.toLabel(),
|
||||
result = "${allValue.sum()}",
|
||||
result = rollResult,
|
||||
details = listOf(
|
||||
ThrowsCardUio.Detail(
|
||||
title = spellName,
|
||||
|
|
@ -852,18 +856,21 @@ class DiceThrowUseCase @Inject constructor(
|
|||
// fetch and build the associated characteristic, proficiency or level
|
||||
val relatedStatBonus = skill?.effect.statBonus(name = skill?.name)
|
||||
|
||||
// compute the final roll result
|
||||
val rollResult = "${allValue.sum()}"
|
||||
|
||||
// build the result.
|
||||
return DiceThrowResult(
|
||||
dice = RollDiceUio(
|
||||
icon = (skill?.effect?.faces ?: 4).icon,
|
||||
result = "${result.value}",
|
||||
result = rollResult,
|
||||
),
|
||||
card = ThrowsCardUio(
|
||||
title = titleString.uppercase(),
|
||||
highlight = spellName,
|
||||
dice = (skill?.effect?.faces ?: 4).icon,
|
||||
roll = allValue.toLabel(),
|
||||
result = "${allValue.sum()}",
|
||||
result = rollResult,
|
||||
details = listOf(
|
||||
ThrowsCardUio.Detail(
|
||||
title = spellName,
|
||||
|
|
|
|||
|
|
@ -121,6 +121,6 @@ class AlterationParser @Inject constructor(
|
|||
private val TARGET = column("Cible")
|
||||
private val SOURCE = column("Source")
|
||||
private val COLUMNS
|
||||
get() = listOf(SOURCE, TARGET) + Property.values().map { column(it.key) }
|
||||
get() = listOf(SOURCE, TARGET) + Property.entries.map { column(it.key) }
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import androidx.compose.animation.AnimatedContent
|
|||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.ContentTransform
|
||||
import androidx.compose.animation.SizeTransform
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
|
|
@ -48,6 +49,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.composed
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
|
@ -58,6 +60,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
|
|
@ -251,7 +254,7 @@ private fun RollOverlayContent(
|
|||
modifier = Modifier
|
||||
.align(alignment = Alignment.Center)
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(bottom = 128.dp),
|
||||
.detailPaddingBottom(showDetail = showDetail, bottom = 128.dp),
|
||||
dice = dice,
|
||||
onDice = onDice,
|
||||
)
|
||||
|
|
@ -300,6 +303,20 @@ private fun RollOverlayContent(
|
|||
)
|
||||
}
|
||||
|
||||
private fun Modifier.detailPaddingBottom(
|
||||
showDetail: State<Boolean>,
|
||||
bottom: Dp = 128.dp,
|
||||
): Modifier = composed {
|
||||
val padding by animateDpAsState(
|
||||
targetValue = when (showDetail.value) {
|
||||
true -> bottom
|
||||
else -> 0.dp
|
||||
},
|
||||
label = "AnimationBottomPaddingDetail"
|
||||
)
|
||||
this.then(other = Modifier.padding(bottom = padding))
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AlterationDetailHandler(
|
||||
detail: State<AlterationDetailUio?>,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class RollOverlayViewModel @Inject constructor(
|
|||
private val _card = mutableStateOf<ThrowsCardUio?>(null)
|
||||
val card: State<ThrowsCardUio?> get() = _card
|
||||
|
||||
private val _showDetail = mutableStateOf(true)
|
||||
private val _showDetail = mutableStateOf(false)
|
||||
val showDetail: State<Boolean> get() = _showDetail
|
||||
|
||||
private val _alterationDetail = mutableStateOf<AlterationDetailUio?>(null)
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ fun ThrowsCard(
|
|||
)
|
||||
Text(
|
||||
modifier = Modifier.widthIn(min = resultWidth),
|
||||
style = MaterialTheme.typography.displayMedium,
|
||||
style = MaterialTheme.typography.displaySmall,
|
||||
textAlign = TextAlign.Center,
|
||||
color = when {
|
||||
throws.isCriticalSuccess -> MaterialTheme.colorScheme.primary
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class AlterationFactory @Inject constructor(
|
|||
is DiceThrow.PhysicalMeleeAttack -> {
|
||||
val action = actionRepository.find(
|
||||
character = diceThrow.character,
|
||||
action = diceThrow.weapon
|
||||
action = diceThrow.weapon,
|
||||
)
|
||||
listOf(Property.PHYSICAL_MELEE_ATTACK) + (action?.hit?.modifier ?: emptyList())
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ class AlterationFactory @Inject constructor(
|
|||
is DiceThrow.PhysicalMeleeDamage -> {
|
||||
val action = actionRepository.find(
|
||||
character = diceThrow.character,
|
||||
action = diceThrow.weapon
|
||||
action = diceThrow.weapon,
|
||||
)
|
||||
listOf(Property.PHYSICAL_MELEE_DAMAGE) + (action?.damage?.modifier ?: emptyList())
|
||||
}
|
||||
|
|
@ -83,17 +83,15 @@ class AlterationFactory @Inject constructor(
|
|||
is DiceThrow.PhysicalRangeAttack -> {
|
||||
val action = actionRepository.find(
|
||||
character = diceThrow.character,
|
||||
action = diceThrow.weapon
|
||||
action = diceThrow.weapon,
|
||||
)
|
||||
listOf(Property.PHYSICAL_RANGE_ATTACK) + (action?.hit?.modifier ?: emptyList())
|
||||
}
|
||||
|
||||
is DiceThrow.Object -> emptyList()
|
||||
|
||||
is DiceThrow.PhysicalRangeDamage -> {
|
||||
val action = actionRepository.find(
|
||||
character = diceThrow.character,
|
||||
action = diceThrow.weapon
|
||||
action = diceThrow.weapon,
|
||||
)
|
||||
listOf(Property.PHYSICAL_RANGE_DAMAGE) + (action?.damage?.modifier ?: emptyList())
|
||||
}
|
||||
|
|
@ -101,7 +99,7 @@ class AlterationFactory @Inject constructor(
|
|||
is DiceThrow.SpellAttack -> {
|
||||
val spell = spellRepository.findAssignedSpell(
|
||||
character = diceThrow.character,
|
||||
spell = diceThrow.spell
|
||||
spell = diceThrow.spell,
|
||||
)
|
||||
listOf(Property.SPELL_ATTACK) + (spell?.hit?.modifier ?: emptyList())
|
||||
}
|
||||
|
|
@ -109,7 +107,7 @@ class AlterationFactory @Inject constructor(
|
|||
is DiceThrow.SpellDamage -> {
|
||||
val spell = spellRepository.findAssignedSpell(
|
||||
character = diceThrow.character,
|
||||
spell = diceThrow.spell
|
||||
spell = diceThrow.spell,
|
||||
)
|
||||
listOf(Property.SPELL_DAMAGE) + (spell?.effect?.modifier ?: emptyList())
|
||||
}
|
||||
|
|
@ -117,16 +115,20 @@ class AlterationFactory @Inject constructor(
|
|||
is DiceThrow.SpellEffect -> {
|
||||
val spell = spellRepository.findAssignedSpell(
|
||||
character = diceThrow.character,
|
||||
spell = diceThrow.spell
|
||||
spell = diceThrow.spell,
|
||||
)
|
||||
spell?.effect?.modifier ?: emptyList()
|
||||
}
|
||||
|
||||
is DiceThrow.Skill -> {
|
||||
val skill =
|
||||
skillRepository.find(character = diceThrow.character, skill = diceThrow.skill)
|
||||
val skill = skillRepository.find(
|
||||
character = diceThrow.character,
|
||||
skill = diceThrow.skill,
|
||||
)
|
||||
listOf(Property.SKILL) + (skill?.effect?.modifier ?: emptyList())
|
||||
}
|
||||
|
||||
is DiceThrow.Object -> emptyList()
|
||||
}
|
||||
|
||||
return alterationRepository
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue