Add alteration management for skill

This commit is contained in:
Thomas Andres Gomez 2023-10-10 09:13:00 +02:00
parent a0251cbeee
commit 2b040afd5c
3 changed files with 39 additions and 2 deletions

View file

@ -939,6 +939,42 @@ class DiceThrowUseCase @Inject constructor(
) )
allValue.add(result.value) allValue.add(result.value)
// fetch and build a list of dice roll base on alterations.
val diceAlterationBonus = alterations[Property.SKILL]?.flatMap { status ->
status.dices.map { dice ->
val localRoll = roll(
amount = if (alterations.isCritical) dice.count * 2 else dice.count,
faces = dice.faces,
advantage = dice.advantage,
disadvantage = dice.disadvantage,
fail = dice.fail
)
allValue.add(localRoll.value)
ThrowsCardUio.Detail(
title = dice.title,
throws = ThrowsCardUio.Throw(
dice = dice.faces.icon,
advantage = dice.advantage,
disadvantage = dice.disadvantage,
roll = "${dice.count}d${dice.faces}",
result = localRoll.label,
),
result = "${localRoll.value}",
)
}
} ?: emptyList()
// fetch and build a list of flat bonus
val flatAlterationBonus = alterations[Property.SKILL]?.flatMap { status ->
status.bonus.map { bonus ->
allValue.add(bonus.value)
ThrowsCardUio.Detail(
title = bonus.title,
result = "${bonus.value}",
)
}
} ?: emptyList()
// fetch and build the associated characteristic // fetch and build the associated characteristic
val relatedStatBonus = skill?.effect?.modifier?.mapNotNull { property -> val relatedStatBonus = skill?.effect?.modifier?.mapNotNull { property ->
when (property) { when (property) {
@ -995,7 +1031,7 @@ class DiceThrowUseCase @Inject constructor(
), ),
result = "${result.value}", result = "${result.value}",
), ),
) + relatedStatBonus, ) + diceAlterationBonus + flatAlterationBonus + relatedStatBonus,
) )
) )
} }

View file

@ -41,6 +41,7 @@ enum class Property(val key: String) {
SLEIGHT_OF_HAND("Escamotage"), SLEIGHT_OF_HAND("Escamotage"),
STEALTH("Discrétion"), STEALTH("Discrétion"),
SURVIVAL("Survie"), SURVIVAL("Survie"),
SKILL("Capacité"),
PHYSICAL_MELEE_ATTACK("Attaque physique corps à corps"), PHYSICAL_MELEE_ATTACK("Attaque physique corps à corps"),
PHYSICAL_MELEE_DAMAGE("Dommage physique corps à corps"), PHYSICAL_MELEE_DAMAGE("Dommage physique corps à corps"),
PHYSICAL_RANGE_ATTACK("Attaque physique à distance"), PHYSICAL_RANGE_ATTACK("Attaque physique à distance"),

View file

@ -100,7 +100,7 @@ class AlterationFactory @Inject constructor(
is DiceThrow.Skill -> { is DiceThrow.Skill -> {
val skill = skillRepository.find(diceThrow.character, skill = diceThrow.skill) val skill = skillRepository.find(diceThrow.character, skill = diceThrow.skill)
skill?.effect?.modifier ?: emptyList() listOf(Property.SKILL) + (skill?.effect?.modifier ?: emptyList())
} }
} }