Fix skill throw bonus.
This commit is contained in:
parent
bb1575ea84
commit
81b74cd03f
11 changed files with 178 additions and 25 deletions
|
|
@ -442,6 +442,8 @@ class DiceThrowUseCase @Inject constructor(
|
|||
skill = diceThrow.skill,
|
||||
)
|
||||
skillThrow(
|
||||
character = sheet,
|
||||
alterations = alterations,
|
||||
skill = skill,
|
||||
)
|
||||
}
|
||||
|
|
@ -908,6 +910,8 @@ class DiceThrowUseCase @Inject constructor(
|
|||
}
|
||||
|
||||
private fun skillThrow(
|
||||
character: CharacterSheet,
|
||||
alterations: Map<Property, List<Alteration.Status>>,
|
||||
skill: Skill?,
|
||||
): DiceThrowResult {
|
||||
// retrieve some wording.
|
||||
|
|
@ -924,6 +928,40 @@ class DiceThrowUseCase @Inject constructor(
|
|||
)
|
||||
allValue.add(result.value)
|
||||
|
||||
// fetch and build the associated characteristic
|
||||
val relatedStatBonus = skill?.effect?.modifier?.mapNotNull { property ->
|
||||
when (property) {
|
||||
Property.STRENGTH -> (character.strength + alterations[property].sum).modifier
|
||||
Property.DEXTERITY -> (character.dexterity + alterations[property].sum).modifier
|
||||
Property.CONSTITUTION -> (character.constitution + alterations[property].sum).modifier
|
||||
Property.INTELLIGENCE -> (character.intelligence + alterations[property].sum).modifier
|
||||
Property.WISDOM -> (character.wisdom + alterations[property].sum).modifier
|
||||
Property.CHARISMA -> (character.charisma + alterations[property].sum).modifier
|
||||
Property.PROFICIENCY -> character.proficiency
|
||||
else -> null
|
||||
}?.let { value ->
|
||||
val titleLabel = if (property == Property.PROFICIENCY) {
|
||||
application.getString(R.string.dice_roll_mastery_proficiency, skill)
|
||||
} else {
|
||||
val label = when (property) {
|
||||
Property.STRENGTH -> application.getString(R.string.character_sheet_stat_strength)
|
||||
Property.DEXTERITY -> application.getString(R.string.character_sheet_stat_dexterity)
|
||||
Property.CONSTITUTION -> application.getString(R.string.character_sheet_stat_constitution)
|
||||
Property.INTELLIGENCE -> application.getString(R.string.character_sheet_stat_intelligence)
|
||||
Property.WISDOM -> application.getString(R.string.character_sheet_stat_wisdom)
|
||||
Property.CHARISMA -> application.getString(R.string.character_sheet_stat_charisma)
|
||||
else -> ""
|
||||
}
|
||||
application.getString(R.string.dice_roll_bonus_detail, label)
|
||||
}
|
||||
allValue.add(value)
|
||||
ThrowsCardUio.Detail(
|
||||
title = titleLabel,
|
||||
result = "$value",
|
||||
)
|
||||
}
|
||||
} ?: emptyList()
|
||||
|
||||
// build the result.
|
||||
return DiceThrowResult(
|
||||
dice = RollDiceUio(
|
||||
|
|
@ -946,7 +984,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
),
|
||||
result = "${result.value}",
|
||||
),
|
||||
),
|
||||
) + relatedStatBonus,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue