Talents automation + management

This commit is contained in:
2022-10-28 21:44:49 +02:00
parent e4d7ff4ca3
commit 6551a93791
14 changed files with 453 additions and 89 deletions

View File

@@ -98,7 +98,7 @@ export class HawkmoonActor extends Actor {
return this.items.find(item => item.type == "profil")
}
getTalents() {
return this.items.find(item => item.type == "talent")
return this.items.filter(item => item.type == "talent")
}
/* -------------------------------------------- */
getSkills() {
@@ -219,6 +219,30 @@ export class HawkmoonActor extends Actor {
}
}
/* -------------------------------------------- */
checkAttribut(attribut, minLevel) {
let attr = this.system.attributs.find( at => at.labelnorm == attribut.toLowerCase() )
if (attr && attr.value >= minLevel) {
return {isValid: true, attr: duplicate(attr) }
}
return {isValid: false}
}
/* -------------------------------------------- */
checkCompetenceLevel(compName, minLevel) {
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase() && i.system.niveau >= minLevel)
if ( comp) {
return {isValid: true, item: duplicate(comp) }
}
return {isValid: false, warningMessage: `Prérequis insuffisant : la compétence ${compName} doit être de niveau ${minLevel} au minimum`}
}
/* -------------------------------------------- */
checkIfCompetence( compName ) {
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
if ( comp) {
return {isValid: true, item: comp}
}
return {isValid: false }
}
/* -------------------------------------------- */
getBonneAventure() {
return this.system.bonneaventure.actuelle
@@ -344,6 +368,24 @@ export class HawkmoonActor extends Actor {
return bestArme
}
/* -------------------------------------------- */
searchRelevantTalents(competence) {
let talents = []
for( let talent of this.items) {
if (talent.type == "talent" && talent.system.isautomated && talent.system.automations.length > 0) {
for (let auto of talent.system.automations) {
if (auto.eventtype === "associated-competence") {
if (auto.script.toLowerCase() == competence.name.toLowerCase() ) {
talents.push( talent)
}
}
}
}
}
return talents
}
/* -------------------------------------------- */
getCommonRollData(attrKey = undefined, compId = undefined, compName = undefined) {
let rollData = HawkmoonUtility.getBasicRollData()
@@ -366,7 +408,8 @@ export class HawkmoonActor extends Actor {
if (compId) {
rollData.competence = duplicate(this.items.get(compId) || {})
rollData.maitrises = rollData.competence.system.predilections.filter(p => p.maitrise )
rollData.actionImg = rollData.competence?.img
rollData.actionImg = rollData.competence?.img
rollData.talents = this.searchRelevantTalents( rollData.competence)
}
if (compName) {
rollData.competence = duplicate(this.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {})