forked from foundryvtt/dnd5e
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b167aa
commit 19158ac
Showing
4 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
export class PlayerActorSheetDND extends ActorSheet { | ||
|
||
constructor (object, options) { | ||
let actor = super(object, options); | ||
// console.warn("CharacterSheet | constructor | actor"); | ||
// console.log(actor.token); | ||
return actor; | ||
} | ||
|
||
get template() { | ||
return `systems/empire-des-cerisiers/templates/actors/character-sheet.hbs`; | ||
} | ||
|
||
static get defaultOptions() { | ||
return foundry.utils.mergeObject(super.defaultOptions, { | ||
classes: ["sheet", "character", "player"], | ||
template: `systems/empire-des-cerisiers/templates/actors/character-sheet.hbs`, | ||
width: 1200, | ||
height: 700, | ||
// tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }], | ||
// dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], | ||
dragDrop: [ | ||
{ dropSelector: "#droppable-journaux"} | ||
], | ||
}); | ||
} | ||
|
||
async getData(options = {}) { | ||
const sheetData = await super.getData(options); | ||
const system = sheetData.data.system; | ||
|
||
sheetData.data.isGM = game.user.isGM; | ||
|
||
return sheetData; | ||
} | ||
|
||
async activateListeners (html) { | ||
super.activateListeners(html); | ||
|
||
html.find(".clear-journaEntries*").on("click", this._clearJournalEntries.bind(this)); | ||
} | ||
|
||
async _clearJournalEntries (event) { | ||
event.preventDefault(); | ||
if (!game.user.isGM) return; | ||
this.actor.update({ "system.journalEntries": [] }); | ||
} | ||
|
||
async _onDrop (event) { | ||
/* { | ||
"type":"JournalEntryPage", | ||
"uuid":"JournalEntry.X9RVyhaeWkjKiRbs.JournalEntryPage.is8OXOwy5stuQGPl", | ||
"anchor":{"name":"0.\nInventaire"} | ||
} */ | ||
try { | ||
let data = JSON.parse(event.dataTransfer?.getData("text/plain")); | ||
if (data.type === "JournalEntryPage") { | ||
if (!game.user.isGM) return; | ||
let name = data.anchor.name.split('\n').pop(); | ||
let newLink = { | ||
"name": name, | ||
"uuid": data.uuid, | ||
"id": data.uuid.split('.').pop(), | ||
"type": data.type | ||
} | ||
|
||
let je = this.actor.system?.journalEntries || []; | ||
this.actor.update({ "system.journalEntries": [...je, newLink] }); | ||
|
||
return; | ||
} | ||
} catch (error) {} | ||
return super._onDrop(event); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters