Add support of melee/range physical attack for "Bow mastery"
This commit is contained in:
		
							parent
							
								
									bdc3b19989
								
							
						
					
					
						commit
						418224a482
					
				
					 7 changed files with 44 additions and 60 deletions
				
			
		| 
						 | 
				
			
			@ -15,7 +15,7 @@ class ConvertCharacterSheetIntoDisplayableFactory @Inject constructor() {
 | 
			
		|||
        return CharacterSheetUio(
 | 
			
		||||
            armorClass = LabelPointUio(
 | 
			
		||||
                label = R.string.character_sheet_title_ca,
 | 
			
		||||
                value = "${sheet.armorClass}",
 | 
			
		||||
                value = sheet.armorClass,
 | 
			
		||||
                max = null,
 | 
			
		||||
            ),
 | 
			
		||||
            speed = LabelPointUio(
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ class ConvertCharacterSheetIntoDisplayableFactory @Inject constructor() {
 | 
			
		|||
            ),
 | 
			
		||||
            hitPoint = LabelPointUio(
 | 
			
		||||
                label = R.string.character_sheet_title_hp,
 | 
			
		||||
                value = "${sheet.hitPoint}",
 | 
			
		||||
                value = sheet.hitPoint,
 | 
			
		||||
                max = "/ ${sheet.maxHitPoint}",
 | 
			
		||||
            ),
 | 
			
		||||
            initiative = LabelPointUio(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,12 @@
 | 
			
		|||
package com.pixelized.rplexicon.facotry.model
 | 
			
		||||
 | 
			
		||||
import android.util.Log
 | 
			
		||||
import com.google.api.services.sheets.v4.model.ValueRange
 | 
			
		||||
import com.pixelized.rplexicon.facotry.model.roll.DiceParser
 | 
			
		||||
import com.pixelized.rplexicon.facotry.model.roll.ModifierParser
 | 
			
		||||
import com.pixelized.rplexicon.model.Action
 | 
			
		||||
import com.pixelized.rplexicon.model.CharacterSheet
 | 
			
		||||
import com.pixelized.rplexicon.model.Property
 | 
			
		||||
import com.pixelized.rplexicon.utilitary.exceptions.IncompatibleSheetStructure
 | 
			
		||||
import com.pixelized.rplexicon.utilitary.extentions.checkSheetStructure
 | 
			
		||||
import com.pixelized.rplexicon.utilitary.extentions.sheet
 | 
			
		||||
| 
						 | 
				
			
			@ -58,12 +60,11 @@ class ActionParser @Inject constructor(
 | 
			
		|||
        return actions
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun parseType(value: String?): Action.Type? {
 | 
			
		||||
        return when (value) {
 | 
			
		||||
            Action.Type.ATTACK.key -> Action.Type.ATTACK
 | 
			
		||||
            Action.Type.SPELL.key -> Action.Type.SPELL
 | 
			
		||||
            else -> null
 | 
			
		||||
        }
 | 
			
		||||
    private fun parseType(value: String?): Action.Type? = try {
 | 
			
		||||
        Action.Type.values().firstOrNull { it.key == value }
 | 
			
		||||
    } catch (exception: Exception) {
 | 
			
		||||
        Log.e("ActionParser", exception.message, exception)
 | 
			
		||||
        null
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun parseThrows(value: String?): Action.Throw? {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,46 +1,14 @@
 | 
			
		|||
package com.pixelized.rplexicon.facotry.model.alteration
 | 
			
		||||
 | 
			
		||||
import android.util.Log
 | 
			
		||||
import com.pixelized.rplexicon.model.Property
 | 
			
		||||
import javax.inject.Inject
 | 
			
		||||
 | 
			
		||||
class PropertyParser @Inject constructor() {
 | 
			
		||||
    fun parseProperty(property: String): Property? = when (property) {
 | 
			
		||||
        Property.PROFICIENCY.key -> Property.PROFICIENCY
 | 
			
		||||
        Property.HIT_POINT.key -> Property.HIT_POINT
 | 
			
		||||
        Property.ARMOR_CLASS.key -> Property.ARMOR_CLASS
 | 
			
		||||
        Property.INITIATIVE.key -> Property.INITIATIVE
 | 
			
		||||
        Property.STRENGTH.key -> Property.STRENGTH
 | 
			
		||||
        Property.DEXTERITY.key -> Property.DEXTERITY
 | 
			
		||||
        Property.CONSTITUTION.key -> Property.CONSTITUTION
 | 
			
		||||
        Property.INTELLIGENCE.key -> Property.INTELLIGENCE
 | 
			
		||||
        Property.WISDOM.key -> Property.WISDOM
 | 
			
		||||
        Property.CHARISMA.key -> Property.CHARISMA
 | 
			
		||||
        Property.STRENGTH_SAVING_THROW.key -> Property.STRENGTH_SAVING_THROW
 | 
			
		||||
        Property.DEXTERITY_SAVING_THROW.key -> Property.DEXTERITY_SAVING_THROW
 | 
			
		||||
        Property.CONSTITUTION_SAVING_THROW.key -> Property.CONSTITUTION_SAVING_THROW
 | 
			
		||||
        Property.INTELLIGENCE_SAVING_THROW.key -> Property.INTELLIGENCE_SAVING_THROW
 | 
			
		||||
        Property.WISDOM_SAVING_THROW.key -> Property.WISDOM_SAVING_THROW
 | 
			
		||||
        Property.CHARISMA_SAVING_THROW.key -> Property.CHARISMA_SAVING_THROW
 | 
			
		||||
        Property.ACROBATICS.key -> Property.ACROBATICS
 | 
			
		||||
        Property.ANIMAL_HANDLING.key -> Property.ANIMAL_HANDLING
 | 
			
		||||
        Property.ARCANA.key -> Property.ARCANA
 | 
			
		||||
        Property.ATHLETICS.key -> Property.ATHLETICS
 | 
			
		||||
        Property.DECEPTION.key -> Property.DECEPTION
 | 
			
		||||
        Property.HISTORY.key -> Property.HISTORY
 | 
			
		||||
        Property.INSIGHT.key -> Property.INSIGHT
 | 
			
		||||
        Property.INTIMIDATION.key -> Property.INTIMIDATION
 | 
			
		||||
        Property.INVESTIGATION.key -> Property.INVESTIGATION
 | 
			
		||||
        Property.MEDICINE.key -> Property.MEDICINE
 | 
			
		||||
        Property.NATURE.key -> Property.NATURE
 | 
			
		||||
        Property.PERCEPTION.key -> Property.PERCEPTION
 | 
			
		||||
        Property.PERFORMANCE.key -> Property.PERFORMANCE
 | 
			
		||||
        Property.PERSUASION.key -> Property.PERSUASION
 | 
			
		||||
        Property.RELIGION.key -> Property.RELIGION
 | 
			
		||||
        Property.SLEIGHT_OF_HAND.key -> Property.SLEIGHT_OF_HAND
 | 
			
		||||
        Property.STEALTH.key -> Property.STEALTH
 | 
			
		||||
        Property.SURVIVAL.key -> Property.SURVIVAL
 | 
			
		||||
        Property.ATTACK_ROLL.key -> Property.ATTACK_ROLL
 | 
			
		||||
        Property.ATTACK_DAMAGE_ROLL.key -> Property.ATTACK_DAMAGE_ROLL
 | 
			
		||||
        else -> null
 | 
			
		||||
    fun parseProperty(property: String): Property? = try {
 | 
			
		||||
        Property.values().firstOrNull { it.key == property }
 | 
			
		||||
    } catch (exception: Exception) {
 | 
			
		||||
        Log.e("PropertyParser", exception.message, exception)
 | 
			
		||||
        null
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import javax.inject.Inject
 | 
			
		|||
class FlatValueParser @Inject constructor() {
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        private val FLAT_REGEX = Regex("(?<!d|\\d)(\\d+)(?!d)")
 | 
			
		||||
        private val FLAT_REGEX = Regex("(?<!d|\\d)(-?\\d+)(?!d)")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun findAll(title: String, value: String): List<Roll.Bonus> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,8 @@ data class Action(
 | 
			
		|||
    val damage: Throw?,
 | 
			
		||||
) {
 | 
			
		||||
    enum class Type(val key: String) {
 | 
			
		||||
        ATTACK("Attaque"),
 | 
			
		||||
        PHYSICAL_MELEE_ATTACK(Property.PHYSICAL_MELEE_ATTACK.key),
 | 
			
		||||
        PHYSICAL_RANGE_ATTACK(Property.PHYSICAL_RANGE_ATTACK.key),
 | 
			
		||||
        SPELL("Sortilège"),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,6 +35,8 @@ enum class Property(val key: String) {
 | 
			
		|||
    SLEIGHT_OF_HAND("Escamotage"),
 | 
			
		||||
    STEALTH("Discrétion"),
 | 
			
		||||
    SURVIVAL("Survie"),
 | 
			
		||||
    ATTACK_ROLL("Attaque"),
 | 
			
		||||
    ATTACK_DAMAGE_ROLL("Dommage"),
 | 
			
		||||
    PHYSICAL_MELEE_ATTACK("Attaque physique corps à corps"),
 | 
			
		||||
    PHYSICAL_MELEE_DAMAGE("Dommage physique corps à corps"),
 | 
			
		||||
    PHYSICAL_RANGE_ATTACK("Attaque physique à distance"),
 | 
			
		||||
    PHYSICAL_RANGE_DAMAGE("Dommage physique à distance"),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -538,16 +538,28 @@ class CharacterSheetViewModel @Inject constructor(
 | 
			
		|||
            action?.title,
 | 
			
		||||
        )
 | 
			
		||||
        // get the alteration for roll and a given player
 | 
			
		||||
        val alterations = if (action?.type == Action.Type.ATTACK) {
 | 
			
		||||
            alterationRepository.getStatus(
 | 
			
		||||
                character = model.name,
 | 
			
		||||
                property = when (throws === action.hit) {
 | 
			
		||||
                    true -> Property.ATTACK_ROLL
 | 
			
		||||
                    else -> Property.ATTACK_DAMAGE_ROLL
 | 
			
		||||
                },
 | 
			
		||||
            )
 | 
			
		||||
        } else {
 | 
			
		||||
            emptyList()
 | 
			
		||||
        val alterations = when (action?.type) {
 | 
			
		||||
            Action.Type.PHYSICAL_MELEE_ATTACK -> {
 | 
			
		||||
                alterationRepository.getStatus(
 | 
			
		||||
                    character = model.name,
 | 
			
		||||
                    property = when (throws === action.hit) {
 | 
			
		||||
                        true -> Property.PHYSICAL_MELEE_ATTACK
 | 
			
		||||
                        else -> Property.PHYSICAL_MELEE_DAMAGE
 | 
			
		||||
                    },
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
            Action.Type.PHYSICAL_RANGE_ATTACK -> {
 | 
			
		||||
                alterationRepository.getStatus(
 | 
			
		||||
                    character = model.name,
 | 
			
		||||
                    property = when (throws === action.hit) {
 | 
			
		||||
                        true -> Property.PHYSICAL_RANGE_ATTACK
 | 
			
		||||
                        else -> Property.PHYSICAL_RANGE_DAMAGE
 | 
			
		||||
                    },
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
            else -> {
 | 
			
		||||
                emptyList()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        // check if any alteration give us advantage or disadvantage
 | 
			
		||||
        val advantage = alterations.any { it.advantage }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue