Gestion/assistance aventure/eclat

This commit is contained in:
2022-06-05 15:54:17 +02:00
parent 8a4efaad9a
commit c7a1133334
14 changed files with 280 additions and 61 deletions

View File

@ -46,18 +46,18 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
getWeapons() {
return this.data.items.filter(item => item.type == "arme" )
return this.data.items.filter(item => item.type == "arme")
}
/* -------------------------------------------- */
getArmors() {
return this.data.items.filter(item => item.type == "protection" )
return this.data.items.filter(item => item.type == "protection")
}
/* -------------------------------------------- */
getSkills() {
let comp = []
for( let item of this.data.items) {
for (let item of this.data.items) {
item = duplicate(item)
if ( item.type == "competence") {
if (item.type == "competence") {
item.data.attribut1total = item.data.niveau + (this.data.data.attributs[item.data.attribut1]?.value || 0)
item.data.attribut2total = item.data.niveau + (this.data.data.attributs[item.data.attribut2]?.value || 0)
item.data.attribut3total = item.data.niveau + (this.data.data.attributs[item.data.attribut3]?.value || 0)
@ -69,12 +69,17 @@ export class MournbladeActor extends Actor {
item.data.attribut1label = this.data.data.attributs[item.data.attribut1]?.label || ""
item.data.attribut2label = this.data.data.attributs[item.data.attribut2]?.label || ""
item.data.attribut3label = this.data.data.attributs[item.data.attribut3]?.label || ""
comp.push( item )
}
comp.push(item)
}
}
return comp
}
/* -------------------------------------------- */
getAlignement() {
return (this.data.data.balance.loi > this.data.data.balance.chaos) ? "loyal" : "chaotique"
}
/* -------------------------------------------- */
prepareBaseData() {
}
@ -119,7 +124,7 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
editItemField(itemId, itemType, itemField, dataType, value) {
let item= this.data.items.find(item => item.id == itemId)
let item = this.data.items.find(item => item.id == itemId)
if (item) {
console.log("Item ", item, itemField, dataType, value)
if (dataType.toLowerCase() == "number") {
@ -128,10 +133,39 @@ export class MournbladeActor extends Actor {
value = String(value)
}
let update = { _id: item.id, [`data.${itemField}`]: value };
this.updateEmbeddedDocuments( "Item", [update])
this.updateEmbeddedDocuments("Item", [update])
}
}
/* -------------------------------------------- */
getBonneAventure() {
return this.data.data.bonneaventure.actuelle
}
/* -------------------------------------------- */
changeBonneAventure(value) {
let newBA = this.data.data.bonneaventure.actuelle
newBA += value
this.update({ 'data.bonneaventure.actuelle': newBA })
}
/* -------------------------------------------- */
getEclat() {
return this.data.data.eclat.value
}
/* -------------------------------------------- */
changeEclat(value) {
let newE = this.data.data.eclat.value
newE += value
this.update({ 'data.eclat.value': newE })
}
/* -------------------------------------------- */
canEclatDoubleD20( ) {
return ( this.getAlignement() == "loyal" && this.data.data.eclat.value> 0)
}
/* -------------------------------------------- */
compareName(a, b) {
if (a.name < b.name) {
@ -198,13 +232,17 @@ export class MournbladeActor extends Actor {
rollData.actorImg = this.img
rollData.actorId = this.id
rollData.img = this.img
rollData.canEclatDoubleD20 = this.canEclatDoubleD20()
rollData.doubleD20 = false
if (attrKey) {
rollData.attrKey = attrKey
rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + this.data.data.attributs[attrKey].labelnorm + ".webp"
rollData.attr = duplicate(this.data.data.attributs[attrKey])
}
if (compId) {
rollData.competence = duplicate(this.data.items.get(compId) || {})
rollData.actionImg = rollData.competence.img
}
return rollData
}