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,
|
critical: Boolean = false,
|
||||||
): DiceRollResult {
|
): DiceRollResult {
|
||||||
val result = when {
|
val result = when {
|
||||||
advantage && !disadvantage && !emphasis -> {
|
advantage && !disadvantage -> {
|
||||||
val roll = List(amount) {
|
val roll = List(amount) {
|
||||||
val first = random(faces = faces, fail = fail, critical = critical)
|
val first = random(faces = faces, fail = fail, critical = critical)
|
||||||
val second = 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 roll = List(amount) {
|
||||||
val first = random(faces = faces, fail = fail, critical = critical)
|
val first = random(faces = faces, fail = fail, critical = critical)
|
||||||
val second = 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 ->
|
throws = detail.throws?.let { dice ->
|
||||||
ThrowsCardUio.Throw(
|
ThrowsCardUio.Throw(
|
||||||
dice = dice.dice.icon,
|
dice = dice.dice.icon,
|
||||||
advantage = dice.advantage == true,
|
type = when {
|
||||||
disadvantage = dice.disadvantage == true,
|
dice.advantage == true && dice.disadvantage != true -> ThrowsCardUio.Throw.Type.ADVANTAGE
|
||||||
emphasis = dice.emphasis == true,
|
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,
|
roll = dice.roll,
|
||||||
result = dice.result,
|
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 androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.pixelized.rplexicon.R
|
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.ui.theme.LexiconTheme
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan
|
import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.ddBorder
|
import com.pixelized.rplexicon.utilitary.extentions.ddBorder
|
||||||
|
|
@ -75,12 +76,18 @@ data class ThrowsCardUio(
|
||||||
@Stable
|
@Stable
|
||||||
data class Throw(
|
data class Throw(
|
||||||
@DrawableRes val dice: Int, // the throw dice icon
|
@DrawableRes val dice: Int, // the throw dice icon
|
||||||
val advantage: Boolean = false, // highlight if advantage
|
val type: Type = Type.NORMAL, // highlight
|
||||||
val disadvantage: Boolean = false, // highlight if disadvantage
|
|
||||||
val emphasis: Boolean = false, // highlight if emphasis
|
|
||||||
val roll: String, // the roll (1d20, 2d20)
|
val roll: String, // the roll (1d20, 2d20)
|
||||||
val result: String, // the result
|
val result: String, // the result
|
||||||
)
|
) {
|
||||||
|
@Stable
|
||||||
|
enum class Type {
|
||||||
|
ADVANTAGE,
|
||||||
|
DISADVANTAGE,
|
||||||
|
EMPHASIS,
|
||||||
|
NORMAL,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -206,14 +213,12 @@ private fun ThrowsRollDetail(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||||
) {
|
) {
|
||||||
detail.title.let {
|
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.alignByBaseline(),
|
modifier = Modifier.alignByBaseline(),
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
text = it,
|
text = detail.title,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
detail.throws?.let {
|
detail.throws?.let {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.alignByBaseline(),
|
modifier = Modifier.alignByBaseline(),
|
||||||
|
|
@ -227,11 +232,11 @@ private fun ThrowsRollDetail(
|
||||||
.size(16.dp)
|
.size(16.dp)
|
||||||
.align(alignment = Alignment.Bottom)
|
.align(alignment = Alignment.Bottom)
|
||||||
.padding(bottom = 2.dp),
|
.padding(bottom = 2.dp),
|
||||||
tint = when {
|
tint = when (it.type) {
|
||||||
it.advantage && !it.disadvantage && !it.emphasis -> MaterialTheme.lexicon.colorScheme.throwsColor.advantage
|
Type.ADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.advantage
|
||||||
!it.advantage && it.disadvantage && !it.emphasis -> MaterialTheme.lexicon.colorScheme.throwsColor.disadvantage
|
Type.DISADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.disadvantage
|
||||||
!it.advantage && !it.disadvantage && it.emphasis -> MaterialTheme.lexicon.colorScheme.throwsColor.emphasis
|
Type.EMPHASIS -> MaterialTheme.lexicon.colorScheme.throwsColor.emphasis
|
||||||
else -> MaterialTheme.colorScheme.onSurface
|
Type.NORMAL -> MaterialTheme.colorScheme.onSurface
|
||||||
},
|
},
|
||||||
painter = painterResource(id = it.dice),
|
painter = painterResource(id = it.dice),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
|
|
@ -326,8 +331,8 @@ private class RollToastPreviewProvider : PreviewParameterProvider<ThrowsCardUio>
|
||||||
title = "Hit Check \"Advantage\"",
|
title = "Hit Check \"Advantage\"",
|
||||||
throws = ThrowsCardUio.Throw(
|
throws = ThrowsCardUio.Throw(
|
||||||
dice = R.drawable.ic_d20_24,
|
dice = R.drawable.ic_d20_24,
|
||||||
|
type = Type.ADVANTAGE,
|
||||||
roll = "1d20",
|
roll = "1d20",
|
||||||
advantage = true,
|
|
||||||
result = "20 ~ 5",
|
result = "20 ~ 5",
|
||||||
),
|
),
|
||||||
result = "20",
|
result = "20",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue