Ajout zone libre, macros et tirage de carte

This commit is contained in:
2023-02-26 15:38:44 +01:00
parent b2a9d8cb75
commit cb8e70c6c1
13 changed files with 78 additions and 34 deletions

View File

@ -5,24 +5,29 @@ import { MaleficesUtility } from "./malefices-utility.js";
export class MaleficesCharacterSummary extends Application {
/* -------------------------------------------- */
static displayPCSummary(){
game.system.malefices.charSummary.render(true)
static displayPCSummary() {
if (game.user.isGM) {
game.system.malefices.charSummary.render(true)
} else {
ui.notifications.info("Commande /tirage réservée au MJ !")
}
}
/* -------------------------------------------- */
updatePCSummary(){
if ( this.rendered) {
updatePCSummary() {
if (this.rendered) {
this.render(true)
}
}
/* -------------------------------------------- */
static createSummaryPos() {
return { top: 200, left: 200 };
}
/* -------------------------------------------- */
static ready() {
if ( !game.user.isGM ) { // Uniquement si GM
if (!game.user.isGM) { // Uniquement si GM
return
}
let charSummary = new MaleficesCharacterSummary()
@ -51,14 +56,14 @@ export class MaleficesCharacterSummary extends Application {
getData() {
let formData = super.getData();
formData.pcs = game.actors.filter( ac => ac.type == "personnage" && ac.hasPlayerOwner )
formData.pcs = game.actors.filter(ac => ac.type == "personnage" && ac.hasPlayerOwner)
formData.npcs = []
let newList = []
let toUpdate = false
for( let actorId of this.settings.npcList ) {
let toUpdate = false
for (let actorId of this.settings.npcList) {
let actor = game.actors.get(actorId)
if (actor) {
formData.npcs.push( actor )
formData.npcs.push(actor)
newList.push(actorId)
} else {
toUpdate = true
@ -66,7 +71,7 @@ export class MaleficesCharacterSummary extends Application {
}
formData.config = game.system.malefices.config
if ( toUpdate ) {
if (toUpdate) {
this.settings.npcList = newList
//console.log("Going to update ...", this.settings)
game.settings.set("world", "character-summary-data", this.settings)
@ -79,21 +84,21 @@ export class MaleficesCharacterSummary extends Application {
updateNPC() {
game.settings.set("world", "character-summary-data", game.system.malefices.charSummary.settings)
game.system.malefices.charSummary.close()
setTimeout( function() { game.system.malefices.charSummary.render(true)}, 500)
setTimeout(function () { game.system.malefices.charSummary.render(true) }, 500)
}
/* -------------------------------------------- */
async _onDrop(event) {
//console.log("Dragged data are : ", dragData)
let data = event.dataTransfer.getData('text/plain')
let dataItem = JSON.parse( data)
let dataItem = JSON.parse(data)
let actor = fromUuidSync(dataItem.uuid)
if (actor) {
game.system.malefices.charSummary.settings.npcList.push( actor.id )
game.system.malefices.charSummary.settings.npcList.push(actor.id)
game.system.malefices.charSummary.updateNPC()
} else {
ui.notifications.warn( "Pas d'acteur trouvé" )
ui.notifications.warn("Pas d'acteur trouvé")
}
}
@ -124,6 +129,6 @@ export class MaleficesCharacterSummary extends Application {
game.system.malefices.charSummary.updateNPC()
})
}
}
}