Add support for primary and secondary class.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-05-30 14:41:30 +02:00
parent 3b075a05e4
commit b14e836d80
10 changed files with 46 additions and 14 deletions

View file

@ -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.utilitary.extentions.icon
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.disadvantage
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.isCritical
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.toStatus
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.CHARISMA -> (character.charisma + this@ThrowScope.status[this].sum).modifier
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
}?.let { value ->
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.CHARISMA -> context.getString(R.string.character_sheet_stat_charisma)
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 -> ""
}
context.getString(R.string.dice_roll_bonus_detail, label)

View file

@ -7,7 +7,7 @@ data class CharacterSheet(
val name: String,
val race: String?,
val proficiency: Int, // Bonus de maîtrise
val level: Int, // Niveau
val level: List<Int>, // Niveau
val characterClass: List<Class>, // Classe
val hitPoint: Int, // Point de vie MAX
val spell1: Int?, // level 1 spell slot

View file

@ -3,6 +3,8 @@ package com.pixelized.rplexicon.data.model
enum class Property(val key: String) {
PROFICIENCY("Maîtrise"),
LEVEL("Niveau"),
LEVEL_PC("NiveauPC"),
LEVEL_SC("NiveauCS"),
HIT_POINT("Point de vie"),
ARMOR_CLASS("Classe d'armure"),
SPEED("Vitesse"),

View file

@ -6,7 +6,7 @@ import javax.inject.Inject
class PropertyParser @Inject constructor() {
fun parseProperty(property: String): Property? = try {
Property.values().firstOrNull { it.key == property }
Property.entries.firstOrNull { it.key == property }
} catch (exception: Exception) {
Log.e("PropertyParser", exception.message, exception)
null

View file

@ -36,7 +36,7 @@ class CharacterSheetParser @Inject constructor(
name = name,
race = item.parse(column = RACE),
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)),
hitPoint = item.parseInt(column = MAX_HIT_POINT) ?: 1,
spell1 = item.parseInt(column = SPELL_LEVEL_1),

View file

@ -9,14 +9,24 @@ class ModifierParser @Inject constructor(
) {
companion object {
private val MODIFIER_REGEX = Regex(
pattern = Property.PROFICIENCY.key +
"|${Property.LEVEL.key}" +
"|${Property.STRENGTH.key}" +
"|${Property.DEXTERITY.key}" +
"|${Property.CONSTITUTION.key}" +
"|${Property.INTELLIGENCE.key}" +
"|${Property.WISDOM.key}" +
"|${Property.CHARISMA.key}",
pattern = listOf(
Property.PROFICIENCY,
Property.LEVEL_PC,
Property.LEVEL_SC,
Property.LEVEL,
Property.STRENGTH,
Property.DEXTERITY,
Property.CONSTITUTION,
Property.INTELLIGENCE,
Property.WISDOM,
Property.CHARISMA
).joinToString(
prefix = "(",
postfix = ")",
separator = "|"
) {
"\\b${it.key}\\b"
},
option = RegexOption.IGNORE_CASE
)
}

View file

@ -7,6 +7,9 @@ import com.pixelized.rplexicon.data.network.CharacterSheetFire
import com.pixelized.rplexicon.data.repository.character.DescriptionRepository
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SkillItemUio
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.toLabel
import javax.inject.Inject
@ -24,7 +27,9 @@ class SkillFactoryUioFactory @Inject constructor(
val description = descriptionRepository.find(name = skill.name)
val effectModifier = skill.effect?.modifier?.sumOf {
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.STRENGTH -> character?.strength?.modifier ?: 0
Property.DEXTERITY -> character?.dexterity?.modifier ?: 0

View file

@ -44,4 +44,8 @@ fun CharacterSheet.firstSpellSlot(): Int? {
this.spell9 != null -> 9
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

View file

@ -139,6 +139,8 @@
<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_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_short">FOR</string>
<string name="character_sheet_stat_dexterity">Dextérité</string>

View file

@ -145,6 +145,8 @@
<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_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_short">STR</string>
<string name="character_sheet_stat_dexterity">Dexterity</string>