With compendiums + talent management
This commit is contained in:
@@ -109,11 +109,6 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
let compId = li.data("item-id")
|
||||
this.actor.rollCompetence(attrKey, compId)
|
||||
})
|
||||
html.find('.roll-rune').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
let runeId = li.data("item-id")
|
||||
this.actor.rollRune(runeId)
|
||||
})
|
||||
html.find('.roll-arme-offensif').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
let armeId = li.data("item-id")
|
||||
|
@@ -236,6 +236,17 @@ export class HawkmoonActor extends Actor {
|
||||
return {isValid: false, warningMessage: `Prérequis insuffisant : la compétence ${compName} doit être de niveau ${minLevel} au minimum`}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
addCompetenceBonus(compName, bonus, baCost) {
|
||||
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
||||
if ( comp) {
|
||||
comp = duplicate(comp)
|
||||
comp.system.bonus = bonus
|
||||
comp.system.baCost = baCost
|
||||
return {isValid: true, item: comp }
|
||||
}
|
||||
return {isValid: false, warningMessage: `Compétence ${compName} non trouvée`}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkIfCompetence( compName ) {
|
||||
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
||||
if ( comp) {
|
||||
@@ -247,7 +258,10 @@ export class HawkmoonActor extends Actor {
|
||||
getBonneAventure() {
|
||||
return this.system.bonneaventure.actuelle
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
checkBonneAventure(cost) {
|
||||
return (this.system.bonneaventure.actuelle >= cost)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
changeBonneAventure(value) {
|
||||
let newBA = this.system.bonneaventure.actuelle
|
||||
@@ -375,9 +389,12 @@ export class HawkmoonActor extends Actor {
|
||||
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)
|
||||
if (auto.eventtype === "prepare-roll") {
|
||||
if (auto.competence.toLowerCase() == competence.name.toLowerCase() ) {
|
||||
talent = duplicate(talent)
|
||||
talent.system.bonus = auto.bonus
|
||||
talent.system.baCost = auto.baCost
|
||||
talents.push( talent )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,19 +33,8 @@ export class HawkmoonAutomation {
|
||||
}
|
||||
|
||||
for(let auto of relevantAutomations) {
|
||||
console.log(" Script", auto.script)
|
||||
try {
|
||||
let result = eval(auto.script)
|
||||
if (result.isValid) {
|
||||
return { isValid: result.isValid, item: duplicate(result) }
|
||||
} else {
|
||||
if (result.warningMessage) {
|
||||
ui.notifications.warn(result.warningMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(error) {
|
||||
ui.notifications.error("Erreur lors du processing de l'automation : " + error)
|
||||
if ( event == "on-drop") {
|
||||
return actor.checkCompetenceLevel( auto.competence, auto.minLevel)
|
||||
}
|
||||
}
|
||||
return {isValid: false}
|
||||
|
@@ -185,7 +185,7 @@ export class HawkmoonItemSheet extends ItemSheet {
|
||||
|
||||
html.find('#add-automation').click(ev => {
|
||||
let autom = duplicate(this.object.system.automations)
|
||||
autom.push( { eventtype: "on-drop", name: "Automatisation 1", script: "", id: randomID(16) })
|
||||
autom.push( { eventtype: "on-drop", name: "Automatisation 1", competence: "", minLevel: 0, id: randomID(16) })
|
||||
this.object.update( { 'system.automations': autom })
|
||||
})
|
||||
html.find('.delete-automation').click(ev => {
|
||||
@@ -196,9 +196,8 @@ export class HawkmoonItemSheet extends ItemSheet {
|
||||
this.object.update( { 'system.automations': autom })
|
||||
})
|
||||
html.find('.automation-edit-field').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".automation-item")
|
||||
let index = li.data("automation-index")
|
||||
let field = li.data("automation-field")
|
||||
let index = $(ev.currentTarget).data("automation-index")
|
||||
let field = $(ev.currentTarget).data("automation-field")
|
||||
let auto = duplicate(this.object.system.automations)
|
||||
auto[index][field] = ev.currentTarget.value
|
||||
auto[index].id = auto[index].id || randomID(16)
|
||||
|
@@ -317,10 +317,18 @@ export class HawkmoonUtility {
|
||||
|
||||
if ( rollData.selectedTalents && rollData.selectedTalents.length > 0) {
|
||||
for (let id of rollData.selectedTalents) {
|
||||
let talent = actor.items.find(t => t.id == id)
|
||||
let bonus = talent.system.automations.find( a => a.eventtype == "roll-bonus")
|
||||
if (bonus) {
|
||||
rollData.diceFormula += `+${bonus.value}`
|
||||
let talent = rollData.talents.find(t => t._id == id)
|
||||
let bonusOK = true
|
||||
if ( talent.system.baCost ) {
|
||||
bonusOK = actor.checkBonneAventure( talent.system.baCost)
|
||||
if ( bonusOK ) {
|
||||
actor.changeBonneAventure( -talent.system.baCost )
|
||||
} else {
|
||||
ui.notifications.warn("Vous n'avez pas assez de points de Bonne Aventure !")
|
||||
}
|
||||
}
|
||||
if (bonusOK) {
|
||||
rollData.diceFormula += `+${talent.system.bonus}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user