Add Object action in the character action sheet.
This commit is contained in:
parent
f9b3adfee0
commit
cd921ac16f
21 changed files with 416 additions and 10 deletions
|
|
@ -13,6 +13,7 @@ import com.pixelized.rplexicon.model.Throw
|
|||
import com.pixelized.rplexicon.repository.data.character.ActionRepository
|
||||
import com.pixelized.rplexicon.repository.data.character.AlterationRepository
|
||||
import com.pixelized.rplexicon.repository.data.character.CharacterSheetRepository
|
||||
import com.pixelized.rplexicon.repository.data.character.ObjectActionRepository
|
||||
import com.pixelized.rplexicon.repository.data.character.SkillRepository
|
||||
import com.pixelized.rplexicon.repository.data.character.SpellRepository
|
||||
import com.pixelized.rplexicon.ui.screens.rolls.composable.RollDiceUio
|
||||
|
|
@ -42,6 +43,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
private val application: Application,
|
||||
private val characterSheetRepository: CharacterSheetRepository,
|
||||
private val actionRepository: ActionRepository,
|
||||
private val objectRepository: ObjectActionRepository,
|
||||
private val spellRepository: SpellRepository,
|
||||
private val skillRepository: SkillRepository,
|
||||
private val alterationRepository: AlterationRepository,
|
||||
|
|
@ -393,6 +395,21 @@ class DiceThrowUseCase @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
is DiceThrow.Object -> {
|
||||
val action = objectRepository.find(
|
||||
character = diceThrow.character,
|
||||
item = diceThrow.item,
|
||||
)
|
||||
actionThrow(
|
||||
character = sheet,
|
||||
action = diceThrow.item,
|
||||
diceThrow = action?.effect,
|
||||
title = { getString(R.string.dice_roll_attack_hit_title, it) },
|
||||
alterations = emptyMap(),
|
||||
ability = null,
|
||||
)
|
||||
}
|
||||
|
||||
is DiceThrow.SpellAttack -> {
|
||||
val spell = spellRepository.find(
|
||||
character = diceThrow.character,
|
||||
|
|
@ -664,7 +681,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
diceThrow: Throw?,
|
||||
title: Context.(action: String) -> String,
|
||||
alterations: Map<Property, List<Alteration.Status>>,
|
||||
ability: Property,
|
||||
ability: Property?,
|
||||
): DiceThrowResult {
|
||||
// retrieve some wording.
|
||||
val titleString = title(application, action)
|
||||
|
|
@ -778,6 +795,17 @@ class DiceThrowUseCase @Inject constructor(
|
|||
}
|
||||
} ?: emptyList()
|
||||
|
||||
// check for flat dice bonus (ex: healing potion 2d4 + 2)
|
||||
val flatBonus = diceThrow?.flat?.takeIf { it > 0 }?.let {
|
||||
allValue.add(it)
|
||||
listOf(
|
||||
ThrowsCardUio.Detail(
|
||||
title = application.getString(R.string.dice_roll_bonus_detail, action),
|
||||
result = "$it",
|
||||
)
|
||||
)
|
||||
}?: emptyList()
|
||||
|
||||
// build the result.
|
||||
return DiceThrowResult(
|
||||
dice = RollDiceUio(
|
||||
|
|
@ -812,7 +840,7 @@ class DiceThrowUseCase @Inject constructor(
|
|||
),
|
||||
result = "${result.value}",
|
||||
),
|
||||
) + diceAlterationBonus + flatAlterationBonus + relatedStatBonus,
|
||||
) + diceAlterationBonus + flatAlterationBonus + relatedStatBonus + flatBonus,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue