Add support for primary and secondary class.
This commit is contained in:
parent
3b075a05e4
commit
b14e836d80
10 changed files with 46 additions and 14 deletions
|
|
@ -20,6 +20,7 @@ import com.pixelized.rplexicon.data.repository.character.SpellRepository
|
||||||
import com.pixelized.rplexicon.ui.screens.rolls.composable.RollDiceUio
|
import com.pixelized.rplexicon.ui.screens.rolls.composable.RollDiceUio
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.icon
|
import com.pixelized.rplexicon.utilitary.extentions.icon
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.advantage
|
import com.pixelized.rplexicon.utilitary.extentions.local.advantage
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.local.base
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.critical
|
import com.pixelized.rplexicon.utilitary.extentions.local.critical
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.disadvantage
|
import com.pixelized.rplexicon.utilitary.extentions.local.disadvantage
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.emphasis
|
import com.pixelized.rplexicon.utilitary.extentions.local.emphasis
|
||||||
|
|
@ -27,6 +28,8 @@ import com.pixelized.rplexicon.utilitary.extentions.local.fail
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.isBrutalCritical
|
import com.pixelized.rplexicon.utilitary.extentions.local.isBrutalCritical
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.isCritical
|
import com.pixelized.rplexicon.utilitary.extentions.local.isCritical
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.isSavageAttacks
|
import com.pixelized.rplexicon.utilitary.extentions.local.isSavageAttacks
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.local.primary
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.local.secondary
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.sum
|
import com.pixelized.rplexicon.utilitary.extentions.local.sum
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.local.toStatus
|
import com.pixelized.rplexicon.utilitary.extentions.local.toStatus
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.masteryMultiplier
|
import com.pixelized.rplexicon.utilitary.extentions.masteryMultiplier
|
||||||
|
|
@ -979,7 +982,9 @@ class DiceThrowUseCase @Inject constructor(
|
||||||
Property.WISDOM -> (character.wisdom + this@ThrowScope.status[this].sum).modifier
|
Property.WISDOM -> (character.wisdom + this@ThrowScope.status[this].sum).modifier
|
||||||
Property.CHARISMA -> (character.charisma + this@ThrowScope.status[this].sum).modifier
|
Property.CHARISMA -> (character.charisma + this@ThrowScope.status[this].sum).modifier
|
||||||
Property.PROFICIENCY -> character.proficiency
|
Property.PROFICIENCY -> character.proficiency
|
||||||
Property.LEVEL -> character.level
|
Property.LEVEL -> character.level.base
|
||||||
|
Property.LEVEL_PC -> character.level.primary
|
||||||
|
Property.LEVEL_SC -> character.level.secondary
|
||||||
else -> null
|
else -> null
|
||||||
}?.let { value ->
|
}?.let { value ->
|
||||||
val titleLabel = if (this == Property.PROFICIENCY) {
|
val titleLabel = if (this == Property.PROFICIENCY) {
|
||||||
|
|
@ -993,6 +998,8 @@ class DiceThrowUseCase @Inject constructor(
|
||||||
Property.WISDOM -> context.getString(R.string.character_sheet_stat_wisdom)
|
Property.WISDOM -> context.getString(R.string.character_sheet_stat_wisdom)
|
||||||
Property.CHARISMA -> context.getString(R.string.character_sheet_stat_charisma)
|
Property.CHARISMA -> context.getString(R.string.character_sheet_stat_charisma)
|
||||||
Property.LEVEL -> context.getString(R.string.character_sheet_stat_level)
|
Property.LEVEL -> context.getString(R.string.character_sheet_stat_level)
|
||||||
|
Property.LEVEL_PC -> context.getString(R.string.character_sheet_stat_level_pc)
|
||||||
|
Property.LEVEL_SC -> context.getString(R.string.character_sheet_stat_level_sc)
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
context.getString(R.string.dice_roll_bonus_detail, label)
|
context.getString(R.string.dice_roll_bonus_detail, label)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ data class CharacterSheet(
|
||||||
val name: String,
|
val name: String,
|
||||||
val race: String?,
|
val race: String?,
|
||||||
val proficiency: Int, // Bonus de maîtrise
|
val proficiency: Int, // Bonus de maîtrise
|
||||||
val level: Int, // Niveau
|
val level: List<Int>, // Niveau
|
||||||
val characterClass: List<Class>, // Classe
|
val characterClass: List<Class>, // Classe
|
||||||
val hitPoint: Int, // Point de vie MAX
|
val hitPoint: Int, // Point de vie MAX
|
||||||
val spell1: Int?, // level 1 spell slot
|
val spell1: Int?, // level 1 spell slot
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.pixelized.rplexicon.data.model
|
||||||
enum class Property(val key: String) {
|
enum class Property(val key: String) {
|
||||||
PROFICIENCY("Maîtrise"),
|
PROFICIENCY("Maîtrise"),
|
||||||
LEVEL("Niveau"),
|
LEVEL("Niveau"),
|
||||||
|
LEVEL_PC("NiveauPC"),
|
||||||
|
LEVEL_SC("NiveauCS"),
|
||||||
HIT_POINT("Point de vie"),
|
HIT_POINT("Point de vie"),
|
||||||
ARMOR_CLASS("Classe d'armure"),
|
ARMOR_CLASS("Classe d'armure"),
|
||||||
SPEED("Vitesse"),
|
SPEED("Vitesse"),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
class PropertyParser @Inject constructor() {
|
class PropertyParser @Inject constructor() {
|
||||||
fun parseProperty(property: String): Property? = try {
|
fun parseProperty(property: String): Property? = try {
|
||||||
Property.values().firstOrNull { it.key == property }
|
Property.entries.firstOrNull { it.key == property }
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.e("PropertyParser", exception.message, exception)
|
Log.e("PropertyParser", exception.message, exception)
|
||||||
null
|
null
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class CharacterSheetParser @Inject constructor(
|
||||||
name = name,
|
name = name,
|
||||||
race = item.parse(column = RACE),
|
race = item.parse(column = RACE),
|
||||||
proficiency = item.parseInt(column = MASTERY) ?: 2,
|
proficiency = item.parseInt(column = MASTERY) ?: 2,
|
||||||
level = item.parseInt(column = LEVEL) ?: 2,
|
level = item.parseList(column = LEVEL).mapNotNull { it.toIntOrNull() },
|
||||||
characterClass = classParser.parse(value = item.parse(column = CLASS)),
|
characterClass = classParser.parse(value = item.parse(column = CLASS)),
|
||||||
hitPoint = item.parseInt(column = MAX_HIT_POINT) ?: 1,
|
hitPoint = item.parseInt(column = MAX_HIT_POINT) ?: 1,
|
||||||
spell1 = item.parseInt(column = SPELL_LEVEL_1),
|
spell1 = item.parseInt(column = SPELL_LEVEL_1),
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,24 @@ class ModifierParser @Inject constructor(
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private val MODIFIER_REGEX = Regex(
|
private val MODIFIER_REGEX = Regex(
|
||||||
pattern = Property.PROFICIENCY.key +
|
pattern = listOf(
|
||||||
"|${Property.LEVEL.key}" +
|
Property.PROFICIENCY,
|
||||||
"|${Property.STRENGTH.key}" +
|
Property.LEVEL_PC,
|
||||||
"|${Property.DEXTERITY.key}" +
|
Property.LEVEL_SC,
|
||||||
"|${Property.CONSTITUTION.key}" +
|
Property.LEVEL,
|
||||||
"|${Property.INTELLIGENCE.key}" +
|
Property.STRENGTH,
|
||||||
"|${Property.WISDOM.key}" +
|
Property.DEXTERITY,
|
||||||
"|${Property.CHARISMA.key}",
|
Property.CONSTITUTION,
|
||||||
|
Property.INTELLIGENCE,
|
||||||
|
Property.WISDOM,
|
||||||
|
Property.CHARISMA
|
||||||
|
).joinToString(
|
||||||
|
prefix = "(",
|
||||||
|
postfix = ")",
|
||||||
|
separator = "|"
|
||||||
|
) {
|
||||||
|
"\\b${it.key}\\b"
|
||||||
|
},
|
||||||
option = RegexOption.IGNORE_CASE
|
option = RegexOption.IGNORE_CASE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ import com.pixelized.rplexicon.data.network.CharacterSheetFire
|
||||||
import com.pixelized.rplexicon.data.repository.character.DescriptionRepository
|
import com.pixelized.rplexicon.data.repository.character.DescriptionRepository
|
||||||
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SkillItemUio
|
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SkillItemUio
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.icon
|
import com.pixelized.rplexicon.utilitary.extentions.icon
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.local.base
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.local.primary
|
||||||
|
import com.pixelized.rplexicon.utilitary.extentions.local.secondary
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.modifier
|
import com.pixelized.rplexicon.utilitary.extentions.modifier
|
||||||
import com.pixelized.rplexicon.utilitary.extentions.toLabel
|
import com.pixelized.rplexicon.utilitary.extentions.toLabel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -24,7 +27,9 @@ class SkillFactoryUioFactory @Inject constructor(
|
||||||
val description = descriptionRepository.find(name = skill.name)
|
val description = descriptionRepository.find(name = skill.name)
|
||||||
val effectModifier = skill.effect?.modifier?.sumOf {
|
val effectModifier = skill.effect?.modifier?.sumOf {
|
||||||
when (it) {
|
when (it) {
|
||||||
Property.LEVEL -> character?.level ?: 0
|
Property.LEVEL -> character?.level?.base ?: 0
|
||||||
|
Property.LEVEL_PC -> character?.level?.primary ?: 0
|
||||||
|
Property.LEVEL_SC -> character?.level?.secondary ?: 0
|
||||||
Property.PROFICIENCY -> character?.proficiency ?: 0
|
Property.PROFICIENCY -> character?.proficiency ?: 0
|
||||||
Property.STRENGTH -> character?.strength?.modifier ?: 0
|
Property.STRENGTH -> character?.strength?.modifier ?: 0
|
||||||
Property.DEXTERITY -> character?.dexterity?.modifier ?: 0
|
Property.DEXTERITY -> character?.dexterity?.modifier ?: 0
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,8 @@ fun CharacterSheet.firstSpellSlot(): Int? {
|
||||||
this.spell9 != null -> 9
|
this.spell9 != null -> 9
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val List<Int>.base: Int get() = sum()
|
||||||
|
val List<Int>.primary: Int get() = getOrNull(0) ?: 0
|
||||||
|
val List<Int>.secondary: Int get() = getOrNull(1) ?: 0
|
||||||
|
|
@ -139,6 +139,8 @@
|
||||||
<string name="character_sheet_title_spell_slot_8">Sort de niveau 8</string>
|
<string name="character_sheet_title_spell_slot_8">Sort de niveau 8</string>
|
||||||
<string name="character_sheet_title_spell_slot_9">Sort de niveau 9</string>
|
<string name="character_sheet_title_spell_slot_9">Sort de niveau 9</string>
|
||||||
<string name="character_sheet_stat_level">Niveau</string>
|
<string name="character_sheet_stat_level">Niveau</string>
|
||||||
|
<string name="character_sheet_stat_level_pc">Niveau de classe primaire</string>
|
||||||
|
<string name="character_sheet_stat_level_sc">Niveau de sous classe</string>
|
||||||
<string name="character_sheet_stat_strength">Force</string>
|
<string name="character_sheet_stat_strength">Force</string>
|
||||||
<string name="character_sheet_stat_strength_short">FOR</string>
|
<string name="character_sheet_stat_strength_short">FOR</string>
|
||||||
<string name="character_sheet_stat_dexterity">Dextérité</string>
|
<string name="character_sheet_stat_dexterity">Dextérité</string>
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,8 @@
|
||||||
<string name="character_sheet_title_spell_slot_8">Spell slot 8</string>
|
<string name="character_sheet_title_spell_slot_8">Spell slot 8</string>
|
||||||
<string name="character_sheet_title_spell_slot_9">Spell slot 9</string>
|
<string name="character_sheet_title_spell_slot_9">Spell slot 9</string>
|
||||||
<string name="character_sheet_stat_level">Level</string>
|
<string name="character_sheet_stat_level">Level</string>
|
||||||
|
<string name="character_sheet_stat_level_pc">Primary class level</string>
|
||||||
|
<string name="character_sheet_stat_level_sc">Secondary class level</string>
|
||||||
<string name="character_sheet_stat_strength">Strength</string>
|
<string name="character_sheet_stat_strength">Strength</string>
|
||||||
<string name="character_sheet_stat_strength_short">STR</string>
|
<string name="character_sheet_stat_strength_short">STR</string>
|
||||||
<string name="character_sheet_stat_dexterity">Dexterity</string>
|
<string name="character_sheet_stat_dexterity">Dexterity</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue