Manage weapons
This commit is contained in:
parent
17e8fb4aa6
commit
8f9ecff285
@ -107,7 +107,20 @@ export class Avd12Actor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rebuildBonus() {
|
||||
for (let bonusKey in this.system.bonus) {
|
||||
let bonus = this.system.bonus[bonusKey]
|
||||
for (let content in bonus) {
|
||||
let dataPath = bonusKey + "." + content
|
||||
//console.log("Parsing", bonusKey, content, dataPath)
|
||||
let availableTraits = this.items.filter(t => t.type == "trait" && t.system.computebonus && t.system.bonusdata == dataPath)
|
||||
for (let trait of availableTraits) {
|
||||
bonus[content] += Number(trait.system.bonusvalue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
prepareDerivedData() {
|
||||
|
||||
@ -118,6 +131,7 @@ export class Avd12Actor extends Actor {
|
||||
|
||||
this.rebuildSkills()
|
||||
this.rebuildMitigations()
|
||||
this.rebuildBonus()
|
||||
}
|
||||
|
||||
super.prepareDerivedData();
|
||||
@ -146,10 +160,23 @@ export class Avd12Actor extends Actor {
|
||||
return comp;
|
||||
}
|
||||
getEquippedWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon' && item.system.equipped) || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon' && item.system.equipped) || [])
|
||||
comp.forEach(item => {
|
||||
this.prepareWeapon(item)
|
||||
})
|
||||
Avd12Utility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || [])
|
||||
comp.forEach(item => {
|
||||
this.prepareWeapon(item)
|
||||
})
|
||||
Avd12Utility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getArmors() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'armor') || []);
|
||||
@ -199,29 +226,29 @@ export class Avd12Actor extends Actor {
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
addDamages( damage) {
|
||||
addDamages(damage, bonusDamage) {
|
||||
//console.log(damage)
|
||||
if (damage.damagetype != "none" && damage.dice) {
|
||||
damage.normal = damage.dice + '+' + damage.bonus
|
||||
damage.critical = damage.dice + '+' + Number(damage.bonus)*2
|
||||
let fullBonus = Number(bonusDamage) + Number(damage.bonus)
|
||||
damage.normal = damage.dice + '+' + fullBonus
|
||||
damage.critical = damage.dice + '+' + Number(fullBonus) * 2
|
||||
let parser = damage.dice.match(/(\d+)(d\d+)/)
|
||||
let nbDice = 2
|
||||
if (parser && parser[1]) {
|
||||
nbDice = Number(parser[1]) * 2
|
||||
}
|
||||
damage.brutal = nbDice + parser[2] + "+" + Number(damage.bonus)*2
|
||||
damage.brutal = nbDice + parser[2] + "+" + Number(fullBonus) * 2
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || [])
|
||||
comp.forEach(item => {
|
||||
this.addDamages(item.system.damages.primary)
|
||||
this.addDamages(item.system.damages.secondary)
|
||||
this.addDamages(item.system.damages.tertiary)
|
||||
})
|
||||
Avd12Utility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
prepareWeapon(weapon) {
|
||||
weapon.attackBonus = this.system.bonus.weapon.attack + this.system.bonus[weapon.system.weapontype].attack
|
||||
let bonusDamage = this.system.bonus.weapon.damage + this.system.bonus[weapon.system.weapontype].damage
|
||||
this.addDamages(weapon.system.damages.primary, bonusDamage)
|
||||
bonusDamage = this.system.bonus.weapon.damage + this.system.bonus[weapon.system.weapontype].crits
|
||||
this.addDamages(weapon.system.damages.secondary, bonusDamage)
|
||||
bonusDamage = this.system.bonus.weapon.damage + this.system.bonus[weapon.system.weapontype].brutals
|
||||
this.addDamages(weapon.system.damages.tertiary + bonusDamage)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
@ -683,6 +710,7 @@ export class Avd12Actor extends Actor {
|
||||
let weapon = this.items.get(weaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
this.prepareWeapon(weapon)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.modifier = this.system.bonus[weapon.system.weapontype]
|
||||
rollData.mode = "weapon"
|
||||
@ -698,7 +726,7 @@ export class Avd12Actor extends Actor {
|
||||
let weapon = this.items.get(weaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
this.addDamages(weapon.system.damages.primary)
|
||||
this.prepareWeapon(weapon)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.damageFormula = weapon.system.damages.primary[damageType]
|
||||
rollData.mode = "weapon-damage"
|
||||
|
@ -536,6 +536,9 @@ export class Avd12Utility {
|
||||
if (rollData.skill && rollData.skill.good) {
|
||||
diceFormula += "+1d4"
|
||||
}
|
||||
if (rollData.weapon ) {
|
||||
diceFormula += "+" + rollData.weapon.attackBonus
|
||||
}
|
||||
rollData.diceFormula = diceFormula
|
||||
|
||||
// Performs roll
|
||||
|
@ -64,7 +64,7 @@
|
||||
],
|
||||
"title": "AnyVenture D12 RPG",
|
||||
"url": "https://www.uberwald.me/gitea/public/fvtt-avd12",
|
||||
"version": "10.0.17",
|
||||
"download": "https://www.uberwald.me/gitea/public/fvtt-avd12/archive/fvtt-avd12-v10.0.17.zip",
|
||||
"version": "10.0.18",
|
||||
"download": "https://www.uberwald.me/gitea/public/fvtt-avd12/archive/fvtt-avd12-v10.0.18.zip",
|
||||
"background": "systems/fvtt-avd12/images/ui/avd12_welcome_page.webp"
|
||||
}
|
@ -212,7 +212,7 @@
|
||||
<label class="short-label">Brutal</label>
|
||||
</span>
|
||||
</li>
|
||||
{{#each weapons as |weapon key|}}
|
||||
{{#each equippedWeapons as |weapon key|}}
|
||||
<li class="item flexrow list-item list-item-shadow" data-item-id="{{weapon._id}}">
|
||||
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
|
||||
src="{{weapon.img}}" /></a>
|
||||
|
@ -15,6 +15,13 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if weapon}}
|
||||
<div class="flexrow">
|
||||
<span class="roll-dialog-label">Weapon Attack Bonus : </span>
|
||||
<span class="roll-dialog-label">{{weapon.attackBonus}}</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if spell}}
|
||||
<div class="flexrow">
|
||||
<span class="roll-dialog-label">Spell : </span>
|
||||
|
Reference in New Issue
Block a user