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