Lates fixes
This commit is contained in:
@@ -46,12 +46,14 @@ export class WarheroActorSheet extends ActorSheet {
|
||||
classSkills: this.actor.getClassSkills( ),
|
||||
languages: this.actor.getLanguages( ),
|
||||
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
|
||||
conditions: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getConditions()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
|
||||
powers: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getPowers())),
|
||||
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
slotEquipments: this.actor.buildEquipmentsSlot(),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
competency: this.actor.getCompetency(),
|
||||
race: duplicate(race),
|
||||
class: duplicate(this.actor.getClass()),
|
||||
moneys: duplicate(this.actor.getMoneys()),
|
||||
|
@@ -203,6 +203,12 @@ export class WarheroActor extends Actor {
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getConditions() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'condition') || []);
|
||||
WarheroUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.items.find(item => item.id == id);
|
||||
if (item) {
|
||||
@@ -365,6 +371,28 @@ export class WarheroActor extends Actor {
|
||||
this.update({ 'system.secondary.hp': hp })
|
||||
return Number(dmgRoll.total)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
updateCompetency(competency, obj) {
|
||||
for(let key in obj) {
|
||||
if (obj[key]) {
|
||||
competency[key] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
getCompetency() {
|
||||
let myRace = this.getRace()
|
||||
let myClass = this.getClass()
|
||||
let competency = { weapons: {}, armors: {}, shields: {}}
|
||||
if ( myRace.system && myClass.system) {
|
||||
this.updateCompetency(competency.weapons, myRace.system.weapons)
|
||||
this.updateCompetency(competency.armors, myRace.system.armors)
|
||||
this.updateCompetency(competency.shields, myRace.system.shields)
|
||||
this.updateCompetency(competency.weapons, myClass.system.weapons)
|
||||
this.updateCompetency(competency.armors, myClass.system.armors)
|
||||
this.updateCompetency(competency.shields, myClass.system.shields)
|
||||
}
|
||||
return competency
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAbility(abilKey) {
|
||||
@@ -549,7 +577,7 @@ export class WarheroActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
setLevel() {
|
||||
let xp = this.system.secondary.xp.value
|
||||
this.system.secondary.xp.level = Math.floor(xp/10)
|
||||
this.system.secondary.xp.level = 1 + Math.floor(xp/10)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
computeDRTotal() {
|
||||
|
@@ -519,12 +519,18 @@ export class WarheroUtility {
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
}
|
||||
rollData.roll = myRoll
|
||||
rollData.diceFormula = diceFormula
|
||||
rollData.diceResult = myRoll.terms[0].results[0].result
|
||||
rollData.isSuccess = false
|
||||
if (myRoll.total >= 12 || myRoll.terms[0].results[0].result == 12) {
|
||||
if (myRoll.total >= 12 || rollData.diceResult == 12) {
|
||||
rollData.isSuccess = true
|
||||
if (rollData.diceResult == 12) {
|
||||
rollData.isCriticalSuccess = true
|
||||
}
|
||||
}
|
||||
if (myRoll.terms[0].results[0].result == 1) {
|
||||
if (rollData.diceResult == 1) {
|
||||
rollData.isSuccess = false
|
||||
rollData.isCriticalFailure = true
|
||||
}
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-parry-result.html`, rollData)
|
||||
@@ -554,6 +560,8 @@ export class WarheroUtility {
|
||||
let myRoll = new Roll(rollData.weapon.damageFormula + "+" + rollData.bonusMalus).roll({ async: false })
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.roll = myRoll
|
||||
rollData.diceFormula = myRoll.formula
|
||||
rollData.diceResult = myRoll.terms[0].results[0].result
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
|
||||
@@ -571,7 +579,6 @@ export class WarheroUtility {
|
||||
diceFormula += "+" + rollData.mWeaponMalus
|
||||
}
|
||||
diceFormula += "+" + rollData.bonusMalus
|
||||
rollData.diceFormula = diceFormula
|
||||
|
||||
// Performs roll
|
||||
console.log("Roll formula", diceFormula)
|
||||
@@ -581,6 +588,14 @@ export class WarheroUtility {
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
}
|
||||
rollData.roll = myRoll
|
||||
rollData.diceFormula = diceFormula
|
||||
rollData.diceResult = myRoll.terms[0].results[0].result
|
||||
if (rollData.diceResult == 20) {
|
||||
rollData.isCriticalSuccess = true
|
||||
}
|
||||
if (rollData.diceResult == 1) {
|
||||
rollData.isCriticalFailure = true
|
||||
}
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
|
||||
|
Reference in New Issue
Block a user