Fix #72 : effect OK for dmr roll

This commit is contained in:
sladecraven 2022-09-28 20:04:04 +02:00
parent e1d6b1aaff
commit fb69f24fce
5 changed files with 47 additions and 9 deletions

View File

@ -7,7 +7,7 @@ const coverBonusTable = { "nocover": 0, "lightcover": 2, "heavycover": 4, "entre
const statThreatLevel = ["agi", "str", "phy", "com", "def", "per"]
const __subkey2title = {
"melee-dmg": "Melee Damage", "melee-atk": "Melee Attack", "ranged-atk": "Ranged Attack",
"ranged-dmg": "Ranged Damage", "defence": "Defence", "dmg-res": "Damare Resistance"
"ranged-dmg": "Ranged Damage", "defence": "Defence", "dmg-res": "Damage Resistance", "power-dmg": "Power Damage"
}
const __statBuild = [
{ modules: ["vehiclehull"], field: "hr", itemfield: "hr" },
@ -373,7 +373,7 @@ export class PegasusActor extends Actor {
}
}
if (ppp != this.system.ppp.spentPPP) {
this.update({ 'system.ppp.spentPPP': ppp })
//this.update({ 'system.ppp.spentPPP': ppp })
}
}
/* -------------------------------------------- */
@ -385,7 +385,7 @@ export class PegasusActor extends Actor {
}
}
if (sizeBonus != this.system.biodata.sizebonus) {
setTimeout(500, this.update( {'system.biodata.sizebonus': sizeBonus}) )
//this.update( {'system.biodata.sizebonus': sizeBonus})
}
}
@ -1684,6 +1684,7 @@ export class PegasusActor extends Actor {
rollData.diceList = PegasusUtility.getDiceList()
rollData.noBonusDice = this.checkNoBonusDice()
rollData.dicePool = []
rollData.subKey = subKey
if (subKey == "melee-dmg" || subKey == "ranged-dmg" || subKey == "power-dmg") {
rollData.isDamage = true
@ -1743,6 +1744,7 @@ export class PegasusActor extends Actor {
}
}
this.processSizeBonus(rollData)
this.addEffects(rollData, isInit, isPower, subKey == "power-dmg")
this.addArmorsShields(rollData, statKey, useShield)
this.addWeapons(rollData, statKey, useShield)
@ -1752,6 +1754,33 @@ export class PegasusActor extends Actor {
return rollData
}
/* -------------------------------------------- */
processSizeBonus( rollData) {
if ( rollData.defenderTokenId) {
let diffSize = rollData.defenderSize - this.system.biodata.sizenum+this.system.biodata.sizebonus
if( rollData.subKey == "melee-atk" || rollData.subKey == "ranged-atk") {
if ( diffSize > 0) {
rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: diffSize })
}
}
if( rollData.subKey == "dmg-res" ) {
if ( diffSize < 0) {
rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: Math.abs(diffSize) })
}
}
if( rollData.subKey == "defence" ) {
if ( diffSize > 0) {
rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: Math.abs(diffSize) })
}
}
if( rollData.subKey == "melee-dmg" || rollData.subKey == "ranged-dmg") {
if ( diffSize < 0) {
rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: diffSize })
}
}
}
}
/* -------------------------------------------- */
getLevelRemainingList() {
let options = []

View File

@ -65,6 +65,9 @@ export class PegasusUtility {
Handlebars.registerHelper('sub', function (a, b) {
return parseInt(a) - parseInt(b);
})
Handlebars.registerHelper('getDice', function (a) {
return PegasusUtility.getDiceFromLevel(a)
})
}
@ -988,11 +991,11 @@ export class PegasusUtility {
static updateWithTarget(rollData) {
let target = PegasusUtility.getTarget()
if (target) {
console.log("TARGET ", target)
let defenderActor = target.actor
rollData.defenderTokenId = target.id
rollData.defenderSize = Number(defenderActor.system.biodata.sizenum) + Number(defenderActor.system.biodata.sizebonus)
//rollData.attackerId = this.id
console.log("DEFENDER", defenderActor)
console.log("Target/DEFENDER", defenderActor)
defenderActor.addHindrancesList(rollData.effectsList)
}
}

View File

@ -613,6 +613,9 @@ ul, li {
flex-grow: 2;
margin-left: 4px;
}
.select-stat {
max-width: 5rem;
}
.status-header-label {
margin-left: 2px;
}

View File

@ -5,12 +5,15 @@
<span class="stat-label stat-margin" name="{{key}}">
<h4 class="stat-text-white stat-margin"><a class="roll-stat stat-margin" data-stat-key="{{key}}">{{stat.abbrev}}</a></h4>
</span>
<select class="status-small-label color-class-common" type="text" name="system.statistics.{{key}}.value" value="{{stat.value}}"
<select class="status-small-label color-class-common select-stat" type="text" name="system.statistics.{{key}}.value" value="{{stat.value}}"
data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
{{#select (add stat.value stat.bonuseffect)}}
{{#select stat.value}}
{{{@root.optionsDiceList}}}
{{/select}}
</select>
<span class="stat-label stat-margin" name="{{key}}">
<h4 class="stat-text-white stat-margin">{{getDice (add stat.value stat.bonuseffect)}}</h4>
</span>
<input type="text" class="input-numeric-short padd-right status-small-label color-class-common" name="system.statistics.{{key}}.mod" value="{{stat.mod}}"
data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}} />
</li>

View File

@ -17,13 +17,13 @@
</li>
{{else}}
{{#if (eq effect.effect.data.stataffected "powerroll")}}
{{#if (eq effect.effect.system.stataffected "powerroll")}}
<li class="flex-group-left">
<label class="attribute-value checkbox"><input type="checkbox" class="effect-clicked" id="effect-{{idx}}" data-effect-idx="{{idx}}" {{checked effect.applied}}/></label>
<label class="generic-label">{{effect.label}} ({{effect.value}})</label>
</li>
{{/if}}
{{#if (eq effect.effect.data.stataffected "powerdmgroll")}}
{{#if (eq effect.effect.system.stataffected "powerdmgroll")}}
<li class="flex-group-left">
<label class="attribute-value checkbox"><input type="checkbox" class="effect-clicked" id="effect-{{idx}}" data-effect-idx="{{idx}}" {{checked effect.applied}}/></label>
<label class="generic-label">{{effect.label}} ({{effect.value}})</label>