Add icons and background
This commit is contained in:
@ -154,6 +154,8 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
let autoresult = HawkmoonAutomation.processAutomations("on-drop", item, this.actor)
|
||||
if ( autoresult.isValid ) {
|
||||
super._onDropItem(event, dragData)
|
||||
} else {
|
||||
ui.notifications.warn( autoresult.warningMessage)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,12 +228,18 @@ export class HawkmoonActor extends Actor {
|
||||
return {isValid: false}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkCompetenceLevel(compName, minLevel) {
|
||||
checkAttributOrCompetenceLevel(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) }
|
||||
} else {
|
||||
for (let attrKey in this.system.attributs) {
|
||||
if ( this.system.attributs[attrKey].label.toLowerCase() == compName.toLowerCase() && this.system.attributs[attrKey].value >= minLevel ) {
|
||||
return {isValid: true, item: duplicate(this.system.attributs[attrKey]) }
|
||||
}
|
||||
}
|
||||
}
|
||||
return {isValid: false, warningMessage: `Prérequis insuffisant : la compétence ${compName} doit être de niveau ${minLevel} au minimum`}
|
||||
return {isValid: false, warningMessage: `Prérequis insuffisant : la compétence/attribut ${compName} doit être de niveau ${minLevel} au minimum`}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
addCompetenceBonus(compName, bonus, baCost) {
|
||||
|
@ -31,13 +31,22 @@ export class HawkmoonAutomation {
|
||||
if ( !relevantAutomations || relevantAutomations.length == 0) {
|
||||
return {isValid: true}
|
||||
}
|
||||
|
||||
|
||||
let validTab = []
|
||||
for(let auto of relevantAutomations) {
|
||||
if ( event == "on-drop") {
|
||||
return actor.checkCompetenceLevel( auto.competence, auto.minLevel)
|
||||
if ( event == "on-drop") {
|
||||
validTab.push( actor.checkAttributOrCompetenceLevel( auto.competence, auto.minLevel) )
|
||||
}
|
||||
}
|
||||
return {isValid: false}
|
||||
|
||||
// Post process validation array
|
||||
for (let ret of validTab) {
|
||||
if ( !ret.isValid) {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
return {isValid: true}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user