Add Object / Spell alterations.

This commit is contained in:
Thomas Andres Gomez 2023-12-17 19:19:43 +01:00
parent 5db8e516ba
commit ae6581219b
4 changed files with 32 additions and 8 deletions

View file

@ -426,8 +426,8 @@ class DiceThrowUseCase @Inject constructor(
action = diceThrow.item,
diceThrow = action?.effect,
title = { getString(R.string.dice_roll_use_object, it) },
alterations = emptyList(),
ability = null,
alterations = alterations,
ability = Property.OBJECT_EFFECT,
)
}
@ -702,10 +702,10 @@ class DiceThrowUseCase @Inject constructor(
}
} else {
diceThrow?.amount
} ?: 1
}
// main roll
val result = roll(
amount = amount,
amount = amount ?: 1,
faces = diceThrow?.faces ?: 20,
advantage = advantage,
disadvantage = disadvantage,
@ -785,10 +785,16 @@ class DiceThrowUseCase @Inject constructor(
val spellName = spell?.spell?.name ?: ""
val titleString = application.getString(R.string.dice_roll_spell_cast, spellName)
val advantage = status[Property.SPELL_EFFECT].advantage
val disadvantage = status[Property.SPELL_EFFECT].disadvantage
// main roll
val result = roll(
amount = spell?.effect?.amount ?: 1,
faces = spell?.effect?.faces ?: 4,
advantage = advantage,
disadvantage = disadvantage,
fail = status[Property.SPELL_EFFECT].fail,
critical = status[Property.SPELL_EFFECT].critical,
)
// fetch and build a list of additionnal level effect.
@ -797,12 +803,18 @@ class DiceThrowUseCase @Inject constructor(
val localRoll = roll(
amount = spell.level.amount,
faces = spell.level.faces,
advantage = advantage,
disadvantage = disadvantage,
fail = status[Property.SPELL_EFFECT].fail,
critical = status[Property.SPELL_EFFECT].critical,
)
ThrowsCardUio.Detail(
title = application.getString(R.string.spell_level_chooser_label, "$it"),
throws = ThrowsCardUio.Throw(
dice = spell.level.faces.icon,
roll = "${spell.level.amount}d${spell.level.faces}",
advantage = advantage,
disadvantage = disadvantage,
result = localRoll.label,
),
result = "${localRoll.value}",
@ -836,6 +848,8 @@ class DiceThrowUseCase @Inject constructor(
throws = ThrowsCardUio.Throw(
dice = (spell?.effect?.faces ?: 4).icon,
roll = "${spell?.effect?.amount ?: 1}d${spell?.effect?.faces ?: 4}",
advantage = advantage,
disadvantage = disadvantage,
result = result.label,
),
result = "${result.value}",
@ -856,10 +870,16 @@ class DiceThrowUseCase @Inject constructor(
val spellName = skill?.name
val titleString = application.getString(R.string.dice_roll_spell_cast, spellName)
val advantage = status[Property.SKILL].advantage
val disadvantage = status[Property.SKILL].disadvantage
// main roll
val result = roll(
amount = skill?.effect?.amount ?: 1,
faces = skill?.effect?.faces ?: 4,
advantage = advantage,
disadvantage = disadvantage,
fail = status[Property.SKILL].fail,
critical = status[Property.SKILL].critical,
)
// fetch and build a list of dice roll base on alterations.
@ -892,6 +912,8 @@ class DiceThrowUseCase @Inject constructor(
throws = ThrowsCardUio.Throw(
dice = (skill?.effect?.faces ?: 4).icon,
roll = "${skill?.effect?.amount ?: 1}d${skill?.effect?.faces ?: 4}",
advantage = advantage,
disadvantage = disadvantage,
result = result.label,
),
result = "${result.value}",

View file

@ -50,4 +50,6 @@ enum class Property(val key: String) {
PHYSICAL_RANGE_DAMAGE("Dommage physique à distance"),
SPELL_ATTACK("Attaque sortilège"),
SPELL_DAMAGE("Dommage sortilège"),
SPELL_EFFECT("Effet des objects"),
OBJECT_EFFECT("Effet des sortilège")
}

View file

@ -225,8 +225,8 @@ private fun ThrowsRollDetail(
.align(alignment = Alignment.Bottom)
.padding(bottom = 2.dp),
tint = when {
it.advantage -> MaterialTheme.colorScheme.primary
it.disadvantage -> Color.Red
it.advantage && !it.disadvantage -> MaterialTheme.colorScheme.primary
it.disadvantage && !it.advantage -> Color.Red
else -> MaterialTheme.colorScheme.onSurface
},
painter = painterResource(id = it.dice),

View file

@ -117,7 +117,7 @@ class AlterationFactory @Inject constructor(
character = diceThrow.character,
spell = diceThrow.spell,
)
spell?.effect?.modifier ?: emptyList()
listOf(Property.SPELL_EFFECT) + (spell?.effect?.modifier ?: emptyList())
}
is DiceThrow.Skill -> {
@ -128,7 +128,7 @@ class AlterationFactory @Inject constructor(
listOf(Property.SKILL) + (skill?.effect?.modifier ?: emptyList())
}
is DiceThrow.Object -> emptyList()
is DiceThrow.Object -> listOf(Property.OBJECT_EFFECT)
}
return alterationRepository