Fix critical roll damage.
This commit is contained in:
parent
b068004924
commit
a0251cbeee
1 changed files with 23 additions and 13 deletions
|
|
@ -669,13 +669,13 @@ class DiceThrowUseCase @Inject constructor(
|
|||
// retrieve some wording.
|
||||
val titleString = title(application, action)
|
||||
|
||||
val canMakeCriticalRoll =
|
||||
ability == Property.PHYSICAL_MELEE_ATTACK || ability == Property.PHYSICAL_RANGE_ATTACK || ability == Property.SPELL_ATTACK
|
||||
// check if this throw can be a critical success of failure.
|
||||
val canMakeCriticalRoll = when (ability) {
|
||||
Property.PHYSICAL_MELEE_ATTACK,
|
||||
Property.PHYSICAL_RANGE_ATTACK,
|
||||
Property.SPELL_ATTACK -> true
|
||||
|
||||
var criticalDiceMultiplier = 2
|
||||
if (ability == Property.PHYSICAL_MELEE_DAMAGE) {
|
||||
if (alterations.isSavageAttacks) criticalDiceMultiplier++
|
||||
if (alterations.isBrutalCritical) criticalDiceMultiplier++
|
||||
else -> false
|
||||
}
|
||||
|
||||
// create a list destined to contain all the values (rolled + bonus)
|
||||
|
|
@ -686,14 +686,25 @@ class DiceThrowUseCase @Inject constructor(
|
|||
val disadvantage = alterations[ability].disadvantage
|
||||
val fail = alterations[ability].fail
|
||||
|
||||
// compute the amount of main dice to throw.
|
||||
val amount = if (alterations.isCritical) {
|
||||
diceThrow?.amount?.times(2)?.let {
|
||||
if (ability == Property.PHYSICAL_MELEE_DAMAGE && alterations.isSavageAttacks)
|
||||
it.plus(1) else it
|
||||
}?.let {
|
||||
if (ability == Property.PHYSICAL_MELEE_DAMAGE && alterations.isBrutalCritical)
|
||||
it.plus(1) else it
|
||||
}
|
||||
} else {
|
||||
diceThrow?.amount
|
||||
} ?: 1
|
||||
// main roll
|
||||
val result = roll(
|
||||
amount = diceThrow?.amount ?: 1,
|
||||
amount = amount,
|
||||
faces = diceThrow?.faces ?: 20,
|
||||
advantage = advantage,
|
||||
disadvantage = disadvantage,
|
||||
fail = fail,
|
||||
critical = if (alterations.isCritical) criticalDiceMultiplier else 1,
|
||||
)
|
||||
allValue.add(result.value)
|
||||
|
||||
|
|
@ -701,7 +712,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
val diceAlterationBonus = alterations[ability]?.flatMap { status ->
|
||||
status.dices.map { dice ->
|
||||
val localRoll = roll(
|
||||
amount = dice.count,
|
||||
amount = if (alterations.isCritical) dice.count * 2 else dice.count,
|
||||
faces = dice.faces,
|
||||
advantage = dice.advantage,
|
||||
disadvantage = dice.disadvantage,
|
||||
|
|
@ -995,11 +1006,10 @@ class DiceThrowUseCase @Inject constructor(
|
|||
advantage: Boolean = false,
|
||||
disadvantage: Boolean = false,
|
||||
fail: Boolean = false,
|
||||
critical: Int = 1,
|
||||
): DiceRollResult {
|
||||
return when {
|
||||
advantage && !disadvantage -> {
|
||||
val roll = List(amount * critical) { random(faces, fail) to random(faces, fail) }
|
||||
val roll = List(amount) { random(faces, fail) to random(faces, fail) }
|
||||
DiceRollResult(
|
||||
label = roll.joinToString(" + ") { "${it.first}~${it.second}" },
|
||||
value = roll.sumOf { max(it.first, it.second) },
|
||||
|
|
@ -1007,7 +1017,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
}
|
||||
|
||||
disadvantage && !advantage -> {
|
||||
val roll = List(amount * critical) { random(faces, fail) to random(faces, fail) }
|
||||
val roll = List(amount) { random(faces, fail) to random(faces, fail) }
|
||||
DiceRollResult(
|
||||
label = roll.joinToString(" + ") { "${it.first}~${it.second}" },
|
||||
value = roll.sumOf { min(it.first, it.second) },
|
||||
|
|
@ -1015,7 +1025,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
}
|
||||
|
||||
else -> {
|
||||
val roll = List(amount * critical) { random(faces, fail) }
|
||||
val roll = List(amount) { random(faces, fail) }
|
||||
DiceRollResult(
|
||||
label = roll.toLabel(),
|
||||
value = roll.sum(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue