Change the priority of the Emphasis throw (lesser than advantage/disadvantage)
This commit is contained in:
parent
dc12434689
commit
091e76bbf0
3 changed files with 31 additions and 23 deletions
|
|
@ -1066,7 +1066,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
critical: Boolean = false,
|
||||
): DiceRollResult {
|
||||
val result = when {
|
||||
advantage && !disadvantage && !emphasis -> {
|
||||
advantage && !disadvantage -> {
|
||||
val roll = List(amount) {
|
||||
val first = random(faces = faces, fail = fail, critical = critical)
|
||||
val second = random(faces = faces, fail = fail, critical = critical)
|
||||
|
|
@ -1078,7 +1078,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
!advantage && disadvantage && !emphasis -> {
|
||||
!advantage && disadvantage -> {
|
||||
val roll = List(amount) {
|
||||
val first = random(faces = faces, fail = fail, critical = critical)
|
||||
val second = random(faces = faces, fail = fail, critical = critical)
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@ class ThrowCardFactory @Inject constructor() {
|
|||
throws = detail.throws?.let { dice ->
|
||||
ThrowsCardUio.Throw(
|
||||
dice = dice.dice.icon,
|
||||
advantage = dice.advantage == true,
|
||||
disadvantage = dice.disadvantage == true,
|
||||
emphasis = dice.emphasis == true,
|
||||
type = when {
|
||||
dice.advantage == true && dice.disadvantage != true -> ThrowsCardUio.Throw.Type.ADVANTAGE
|
||||
dice.advantage != true && dice.disadvantage == true -> ThrowsCardUio.Throw.Type.DISADVANTAGE
|
||||
dice.emphasis == true -> ThrowsCardUio.Throw.Type.EMPHASIS
|
||||
else -> ThrowsCardUio.Throw.Type.NORMAL
|
||||
},
|
||||
roll = dice.roll,
|
||||
result = dice.result,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
|||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.rolls.composable.ThrowsCardUio.Throw.Type
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan
|
||||
import com.pixelized.rplexicon.utilitary.extentions.ddBorder
|
||||
|
|
@ -75,12 +76,18 @@ data class ThrowsCardUio(
|
|||
@Stable
|
||||
data class Throw(
|
||||
@DrawableRes val dice: Int, // the throw dice icon
|
||||
val advantage: Boolean = false, // highlight if advantage
|
||||
val disadvantage: Boolean = false, // highlight if disadvantage
|
||||
val emphasis: Boolean = false, // highlight if emphasis
|
||||
val type: Type = Type.NORMAL, // highlight
|
||||
val roll: String, // the roll (1d20, 2d20)
|
||||
val result: String, // the result
|
||||
)
|
||||
) {
|
||||
@Stable
|
||||
enum class Type {
|
||||
ADVANTAGE,
|
||||
DISADVANTAGE,
|
||||
EMPHASIS,
|
||||
NORMAL,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
@ -206,14 +213,12 @@ private fun ThrowsRollDetail(
|
|||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||
) {
|
||||
detail.title.let {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
text = it,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
text = detail.title,
|
||||
)
|
||||
detail.throws?.let {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
|
|
@ -227,11 +232,11 @@ private fun ThrowsRollDetail(
|
|||
.size(16.dp)
|
||||
.align(alignment = Alignment.Bottom)
|
||||
.padding(bottom = 2.dp),
|
||||
tint = when {
|
||||
it.advantage && !it.disadvantage && !it.emphasis -> MaterialTheme.lexicon.colorScheme.throwsColor.advantage
|
||||
!it.advantage && it.disadvantage && !it.emphasis -> MaterialTheme.lexicon.colorScheme.throwsColor.disadvantage
|
||||
!it.advantage && !it.disadvantage && it.emphasis -> MaterialTheme.lexicon.colorScheme.throwsColor.emphasis
|
||||
else -> MaterialTheme.colorScheme.onSurface
|
||||
tint = when (it.type) {
|
||||
Type.ADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.advantage
|
||||
Type.DISADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.disadvantage
|
||||
Type.EMPHASIS -> MaterialTheme.lexicon.colorScheme.throwsColor.emphasis
|
||||
Type.NORMAL -> MaterialTheme.colorScheme.onSurface
|
||||
},
|
||||
painter = painterResource(id = it.dice),
|
||||
contentDescription = null,
|
||||
|
|
@ -326,8 +331,8 @@ private class RollToastPreviewProvider : PreviewParameterProvider<ThrowsCardUio>
|
|||
title = "Hit Check \"Advantage\"",
|
||||
throws = ThrowsCardUio.Throw(
|
||||
dice = R.drawable.ic_d20_24,
|
||||
type = Type.ADVANTAGE,
|
||||
roll = "1d20",
|
||||
advantage = true,
|
||||
result = "20 ~ 5",
|
||||
),
|
||||
result = "20",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue