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}",