Création de tâches dans la fenêtre de jets
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Fix: affichage des points de tâche
|
- Fix: affichage des points de tâche
|
||||||
- Fix: affichage des ajustements cohérent
|
- Fix: affichage des ajustements cohérent
|
||||||
- L'ouverture depuis les caractéristiques permet plusieurs types de jets
|
- L'ouverture depuis les caractéristiques permet plusieurs types de jets
|
||||||
|
- On peut créer ou modifier les tâches dans la fenêtre de jets de tâches
|
||||||
- attaque/défense
|
- attaque/défense
|
||||||
- les maladresses sont affichées dans le résultat du jet
|
- les maladresses sont affichées dans le résultat du jet
|
||||||
- le message au défenseur s'affiche correctement
|
- le message au défenseur s'affiche correctement
|
||||||
|
|||||||
@@ -761,7 +761,10 @@ select,
|
|||||||
.system-foundryvtt-reve-de-dragon .window-header {
|
.system-foundryvtt-reve-de-dragon .window-header {
|
||||||
background: rgba(0, 0, 0, 0.75);
|
background: rgba(0, 0, 0, 0.75);
|
||||||
}
|
}
|
||||||
.system-foundryvtt-reve-de-dragon .application .window-content,
|
.system-foundryvtt-reve-de-dragon .application .window-content {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.2rem;
|
||||||
|
}
|
||||||
.system-foundryvtt-reve-de-dragon .window-app.sheet .window-content {
|
.system-foundryvtt-reve-de-dragon .window-app.sheet .window-content {
|
||||||
margin: 0.2rem;
|
margin: 0.2rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
@@ -12,7 +12,10 @@
|
|||||||
background: rgba(0,0,0,0.75);
|
background: rgba(0,0,0,0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
.application .window-content,
|
.application .window-content {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.2rem;
|
||||||
|
}
|
||||||
.window-app.sheet .window-content {
|
.window-app.sheet .window-content {
|
||||||
margin: 0.2rem;
|
margin: 0.2rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async createEmptyTache() {
|
async createEmptyTache() {
|
||||||
await this.actor.createItem('tache', 'Nouvelle tache');
|
await this.actor.createItem(ITEM_TYPES.tache, 'Nouvelle tache')
|
||||||
}
|
}
|
||||||
|
|
||||||
_getActionCombat(event) {
|
_getActionCombat(event) {
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||||||
constructor(rollData, rollOptions) {
|
constructor(rollData, rollOptions) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
this.hooks = []
|
||||||
this.rollData = RollDialog.$prepareRollData(rollData)
|
this.rollData = RollDialog.$prepareRollData(rollData)
|
||||||
this.rollOptions = {
|
this.rollOptions = {
|
||||||
callbacks: [
|
callbacks: [
|
||||||
@@ -328,8 +329,23 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||||||
}
|
}
|
||||||
this.chatRollResult = new ChatRollResult()
|
this.chatRollResult = new ChatRollResult()
|
||||||
this.selectType()
|
this.selectType()
|
||||||
|
this.registerHooks(rollData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerHooks(rollData) {
|
||||||
|
ROLL_PARTS.filter(p => p.isValid(rollData))
|
||||||
|
.forEach(p => p.getHooks(this).forEach(h => {
|
||||||
|
const hook = h.hook;
|
||||||
|
const id = Hooks.on(hook, h.fn)
|
||||||
|
this.hooks.push({ hook, id })
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
unregisterHooks() {
|
||||||
|
this.hooks.forEach(h => Hooks.off(h.hook, h.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
selectType() {
|
selectType() {
|
||||||
const selectedType = this.getSelectedType();
|
const selectedType = this.getSelectedType();
|
||||||
this.rollData.type.label = selectedType.title(this.rollData)
|
this.rollData.type.label = selectedType.title(this.rollData)
|
||||||
@@ -445,6 +461,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||||||
if (this.rollOptions.onClose) {
|
if (this.rollOptions.onClose) {
|
||||||
this.rollOptions.onClose()
|
this.rollOptions.onClose()
|
||||||
}
|
}
|
||||||
|
this.unregisterHooks()
|
||||||
return await super.close(options)
|
return await super.close(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ export class RollPartTache extends RollPartSelect {
|
|||||||
loadRefs(rollData) {
|
loadRefs(rollData) {
|
||||||
const refs = this.getRefs(rollData)
|
const refs = this.getRefs(rollData)
|
||||||
const selected = this.getSelected(rollData)
|
const selected = this.getSelected(rollData)
|
||||||
|
refs.forced = selected.forced
|
||||||
refs.all = rollData.active.actor.itemTypes[ITEM_TYPES.tache]
|
refs.all = rollData.active.actor.itemTypes[ITEM_TYPES.tache]
|
||||||
.filter(tache => !selected.forced || tache.id == selected.key)
|
.filter(tache => !selected.forced || tache.id == selected.key)
|
||||||
.filter(tache => tache.system.points_de_tache_courant < tache.system.points_de_tache)
|
.filter(tache => tache.system.points_de_tache_courant < tache.system.points_de_tache)
|
||||||
.map(tache => RollPartTache.$extractTache(tache, rollData.active.actor))
|
.map(tache => RollPartTache.$extractTache(tache, rollData.active.actor))
|
||||||
|
|
||||||
refs.taches = refs.all
|
refs.taches = refs.all
|
||||||
if (refs.taches.length > 0) {
|
if (refs.taches.length > 0) {
|
||||||
this.$selectTache(rollData)
|
this.$selectTache(rollData)
|
||||||
@@ -46,6 +48,8 @@ export class RollPartTache extends RollPartSelect {
|
|||||||
|
|
||||||
async _onRender(rollDialog, context, options) {
|
async _onRender(rollDialog, context, options) {
|
||||||
const selectTache = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-tache"]`)
|
const selectTache = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-tache"]`)
|
||||||
|
const buttonCreate = rollDialog.element.querySelector(`roll-section[name="${this.code}"] button[name="create-tache"]`)
|
||||||
|
const buttonEdit = rollDialog.element.querySelector(`roll-section[name="${this.code}"] button[name="edit-tache"]`)
|
||||||
|
|
||||||
selectTache.addEventListener("change", e => {
|
selectTache.addEventListener("change", e => {
|
||||||
const selectOptions = e.currentTarget.options
|
const selectOptions = e.currentTarget.options
|
||||||
@@ -53,16 +57,45 @@ export class RollPartTache extends RollPartSelect {
|
|||||||
this.$selectTache(rollDialog.rollData, selectOptions[index]?.value)
|
this.$selectTache(rollDialog.rollData, selectOptions[index]?.value)
|
||||||
rollDialog.render()
|
rollDialog.render()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
buttonCreate?.addEventListener(
|
||||||
|
"click", async e => {
|
||||||
|
e.preventDefault()
|
||||||
|
await rollDialog.rollData.active.actor.createItem(ITEM_TYPES.tache, 'Nouvelle tache')
|
||||||
|
})
|
||||||
|
|
||||||
|
buttonEdit?.addEventListener(
|
||||||
|
"click", e => {
|
||||||
|
e.preventDefault()
|
||||||
|
const current = this.getCurrent(rollDialog.rollData)
|
||||||
|
current.tache?.sheet.render(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getHooks(rollDialog) {
|
||||||
|
return [
|
||||||
|
{ hook: "createItem", fn: (item, options, id) => this.onCreateUpdateItem(rollDialog, item, options, id) },
|
||||||
|
{ hook: "updateItem", fn: (item, options, id) => this.onCreateUpdateItem(rollDialog, item, options, id) }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreateUpdateItem(rollDialog, item, options, id) {
|
||||||
|
if (item.type == ITEM_TYPES.tache && item.parent?.id == rollDialog.rollData.active.actor.id) {
|
||||||
|
this.loadRefs(rollDialog.rollData)
|
||||||
|
rollDialog.render()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impactOtherPart(part, rollData) {
|
impactOtherPart(part, rollData) {
|
||||||
if (this.visible(rollData)) {
|
if (this.visible(rollData)) {
|
||||||
const current = this.getCurrent(rollData)
|
const current = this.getCurrent(rollData)
|
||||||
|
if (current.tache) {
|
||||||
switch (part.code) {
|
switch (part.code) {
|
||||||
case PART_CARAC: return part.filterCaracs(rollData, [current?.tache.system.carac])
|
case PART_CARAC: return part.filterCaracs(rollData, [current?.tache.system.carac])
|
||||||
case PART_COMP: return part.filterComps(rollData, [current.comp?.name])
|
case PART_COMP: return part.filterComps(rollData, [current.comp?.name])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,4 +110,5 @@ export class RollPart {
|
|||||||
|
|
||||||
async _onRender(rollDialog, context, options) { }
|
async _onRender(rollDialog, context, options) { }
|
||||||
|
|
||||||
|
getHooks() { return [] }
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ export class RollTypeTache extends RollType {
|
|||||||
title(rollData) {
|
title(rollData) {
|
||||||
const current = rollData.current[PART_TACHE]
|
const current = rollData.current[PART_TACHE]
|
||||||
const tache = current?.tache
|
const tache = current?.tache
|
||||||
return `travaille à sa tâche: ${tache.name ?? ''}`
|
return tache ? `travaille à sa tâche: ${tache.name}` : `n'a pas de tâches à travailler`
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelect(rollData) {
|
onSelect(rollData) {
|
||||||
|
|||||||
@@ -7,7 +7,14 @@
|
|||||||
{{selectOptions refs.taches selected=current.key valueAttr="key" labelAttr="label"}}
|
{{selectOptions refs.taches selected=current.key valueAttr="key" labelAttr="label"}}
|
||||||
</select>
|
</select>
|
||||||
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
|
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
|
||||||
|
{{#unless refs.forced}}
|
||||||
|
<button name="create-tache" data-tooltip="Créer une nouvelle tâche"><i class="fa-solid fa-circle-plus"></i></button>
|
||||||
|
{{#if refs.taches.length}}
|
||||||
|
<button name="edit-tache" data-tooltip="Modifier la tâche"><i class="fa-solid fa-edit"></i></button>
|
||||||
|
{{/if}}
|
||||||
|
{{/unless}}
|
||||||
</subline>
|
</subline>
|
||||||
|
{{#if refs.taches.length}}
|
||||||
<subline>
|
<subline>
|
||||||
Points de tâche: {{current.tache.system.points_de_tache_courant}} /
|
Points de tâche: {{current.tache.system.points_de_tache_courant}} /
|
||||||
{{#if current.tache.system.cacher_points_de_tache}}
|
{{#if current.tache.system.cacher_points_de_tache}}
|
||||||
@@ -25,4 +32,5 @@
|
|||||||
{{#if current.tache.system.periodicite}}
|
{{#if current.tache.system.periodicite}}
|
||||||
<subline>Périodicité: {{current.tache.system.periodicite}}</subline>
|
<subline>Périodicité: {{current.tache.system.periodicite}}</subline>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
</roll-part-detail>
|
</roll-part-detail>
|
||||||
|
|||||||
Reference in New Issue
Block a user