Melee fight

This commit is contained in:
2022-08-14 10:10:26 +02:00
parent ab755aac22
commit e73931d032
10 changed files with 360 additions and 197 deletions

View File

@ -325,6 +325,25 @@ export class CrucibleActor extends Actor {
}
/* -------------------------------------------- */
async rollArmor( rollData) {
let armor = this.getEquippedArmor()
if (armor) {
}
return { armor: "none"}
}
/* -------------------------------------------- */
async incDecHP( formula ) {
let dmgRoll = new Roll(formula).roll( {async: false})
await CrucibleUtility.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
let hp = duplicate(this.data.data.secondary.hp)
hp.value = Number(hp.value) + Number(dmgRoll.total)
this.update( {'data.secondary.hp': hp })
return Number(dmgRoll.total)
}
/* -------------------------------------------- */
getAbility(abilKey) {
return this.data.data.abilities[abilKey];
@ -590,20 +609,71 @@ export class CrucibleActor extends Actor {
let rollData = this.getCommonRollData()
rollData.mode = "shield"
rollData.shield = shield
rollData.useshield = true
rollData.img = shield.img
this.startRoll(rollData)
}
}
/* -------------------------------------------- */
rollArmorDie() {
async rollArmorDie(rollData = undefined) {
let armor = this.getEquippedArmor()
if (armor) {
armor = duplicate(armor)
let reduce = 0
let multiply = 1
let disadvantage = false
let advantage = false
let messages = ["Armor applied"]
if (rollData) {
if (CrucibleUtility.isArmorLight(armor) && CrucibleUtility.isWeaponPenetrating(rollData.attackRollData.weapon) ) {
return { armorIgnored: true, nbSuccess: 0, messages: ["Armor ignored : Penetrating weapons ignore Light Armors."] }
}
if (CrucibleUtility.isWeaponPenetrating(rollData.attackRollData.weapon) ) {
messages.push("Armor reduced by 1 (Penetrating weapon)")
reduce = 1
}
if (CrucibleUtility.isWeaponLight(rollData.attackRollData.weapon) ) {
messages.push("Armor with advantage (Light weapon)")
advantage = true
}
if (CrucibleUtility.isWeaponHeavy(rollData.attackRollData.weapon) ) {
messages.push("Armor with disadvantage (Heavy weapon)")
disadvantage = true
}
if (CrucibleUtility.isWeaponHack(rollData.attackRollData.weapon) ) {
messages.push("Armor reduced by 1 (Hack weapon)")
reduce = 1
}
if (CrucibleUtility.isWeaponUndamaging(rollData.attackRollData.weapon) ) {
messages.push("Armor multiplied by 2 (Undamaging weapon)")
multiply = 2
}
}
let diceColor = armor.data.absorprionroll
let rollTable = CrucibleUtility.getRollTableFromDiceColor( diceColor)
let armorResult = await CrucibleUtility.getRollTableFromDiceColor( diceColor, false )
let armorValue = (Number(armorResult.data.text) - reduce) * multiply
if ( advantage || disadvantage) {
let armorResult2 = await CrucibleUtility.getRollTableFromDiceColor( diceColor, false )
let armorValue2 = (Number(armorResult2.data.text) - reduce) * multiply
if ( advantage) {
armorValue = (armorValue2 > armorValue) ? armorValue2 : armorValue
messages.push(`Armor advantage - Roll 1 = ${armorValue} - Roll 2 = ${armorValue2}`)
}
if ( disadvantage) {
armorValue = (armorValue2 < armorValue) ? armorValue2 : armorValue
messages.push(`Armor disadvantage - Roll 1 = ${armorValue} - Roll 2 = ${armorValue2}`)
}
}
armorResult.armorValue = armorValue
if ( !rollData) {
ChatMessage.create( { content: "Armor result : " + armorValue } )
}
messages.push( "Armor result : " + armorValue)
return { armorIgnored: false, nbSuccess: armorValue, messages: messages }
}
return { armorIgnored: true, nbSuccess: 0, messages: ["No armor equipped."] }
}
/* -------------------------------------------- */