-
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
2925d99
commit 64a6611
Showing
10 changed files
with
291 additions
and
315 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,106 @@ | ||
import EFSCharacterExtraSheet from "./efs-character-extra-sheet.js"; | ||
|
||
export default class EFSBaseActorSheet extends ActorSheet { | ||
heroic = false; | ||
|
||
activateListeners(html) { | ||
super.activateListeners(html) | ||
|
||
html.find(".clickable.approach").click(this._approachClicked.bind(this)); | ||
html.find(".clickable#extra").click(this._showExtra.bind(this)); | ||
html.find(".dp").change(this._dpClick.bind(this)) | ||
|
||
html.find(".edit-item").click(this._onEditItem.bind(this)) | ||
html.find(".delete-item").click(this._onDeleteItem.bind(this)) | ||
html.find(".add-item").click(this._onAddItem.bind(this)) | ||
html.find(".item").click(this._onClickItem.bind(this)) | ||
} | ||
|
||
|
||
async _onClickItem(event) { | ||
event.preventDefault(); | ||
const itemId = event.target.dataset.id; | ||
const item = this.actor.getEmbeddedDocument("Item", itemId); | ||
|
||
let r = await new Roll(`1d`+item._system.dice).evaluate({async: true}); | ||
let message = "<b>"+game.i18n.localize("EFS.Message.ItemUsed").replace("{item}", item.name)+"</b>" | ||
|
||
await r.toMessage({ | ||
flavor: message, | ||
speaker: ChatMessage.getSpeaker({actor: this.actor}) | ||
}); | ||
} | ||
|
||
_onEditItem(event) { | ||
event.preventDefault(); | ||
|
||
const item = this.actor.getEmbeddedDocument("Item", event.target.dataset.id); | ||
if (!item) { | ||
return; | ||
} | ||
item.sheet.render(true); | ||
} | ||
|
||
async _onDeleteItem(event) { | ||
event.preventDefault(); | ||
const itemId = event.target.dataset.id; | ||
const item = this.actor.getEmbeddedDocument("Item", itemId); | ||
|
||
new Dialog({ | ||
title: game.i18n.localize("EFS.Dialog.ActionConfirm"), | ||
content: game.i18n.localize("EFS.Dialog.ConfirmDeletion")+"<b>"+item.name+"</b>?", | ||
buttons: { | ||
yes: { | ||
label: game.i18n.localize("EFS.Dialog.Yes"), | ||
callback: () => {this.actor.deleteEmbeddedDocuments("Item", [event.target.dataset.id])}, | ||
}, | ||
no: { | ||
label: game.i18n.localize("EFS.Dialog.No"), | ||
callback: () => {} | ||
} | ||
} | ||
}).render(true); | ||
} | ||
|
||
async _onAddItem(event) { | ||
event.preventDefault(); | ||
const items = await this.actor.createEmbeddedDocuments("Item", [{name:game.i18n.localize("EFS.Item.DefaultName"), type:"item"}]) | ||
await items[0].sheet.render(true); | ||
} | ||
|
||
async _showExtra(event) { | ||
new EFSCharacterExtraSheet(this.actor).render(true); | ||
} | ||
|
||
|
||
async _dpClick(event) { | ||
let set = event.target.checked; | ||
let dp = !set ? +event.target.dataset.num : +event.target.dataset.num+1; | ||
|
||
await this.actor.update({"system.dp.value": this.actor.system.dp.max - dp}) | ||
} | ||
|
||
async _approachClicked(event) { | ||
event.preventDefault(); | ||
|
||
const diceSteps = ["6", "8", "10", "12", "20"]; | ||
|
||
const id = event.currentTarget.id; | ||
let diceSize = this.actor._system.approaches[id]; | ||
if (this.heroic) { | ||
diceSize = diceSteps[diceSteps.indexOf(diceSize) + 1] | ||
} | ||
let r = await new Roll("1d" + diceSize).evaluate({async: true}); | ||
|
||
let heroMessage = game.i18n.localize("EFS.Message.Uses") + " <b>" + game.i18n.localize("EFS.Approaches." + id.charAt(0).toUpperCase() + id.slice(1)) + "</b> " + game.i18n.localize("EFS.Approaches.Singular").toLowerCase() | ||
if (this.heroic) { | ||
heroMessage = game.i18n.localize("EFS.Message.InHeroicMoment") + "<br/>" + heroMessage; | ||
} | ||
|
||
await r.toMessage({ | ||
flavor: heroMessage, | ||
speaker: ChatMessage.getSpeaker({actor: this.actor}) | ||
}); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.