mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-05 20:34:15 +02:00
Removed damage dialogs
This commit is contained in:
parent
cb2116ffef
commit
5240186984
10 changed files with 4 additions and 771 deletions
|
|
@ -712,12 +712,6 @@
|
||||||
"ReactionRoll": {
|
"ReactionRoll": {
|
||||||
"title": "Reaction Roll: {trait}"
|
"title": "Reaction Roll: {trait}"
|
||||||
},
|
},
|
||||||
"RerollDialog": {
|
|
||||||
"title": "Reroll",
|
|
||||||
"damageTitle": "Reroll Damage",
|
|
||||||
"deselectDiceNotification": "Deselect one of the selected dice first",
|
|
||||||
"acceptCurrentRolls": "Accept Current Rolls"
|
|
||||||
},
|
|
||||||
"ResourceDice": {
|
"ResourceDice": {
|
||||||
"title": "{name} Resource",
|
"title": "{name} Resource",
|
||||||
"rerollDice": "Reroll Dice"
|
"rerollDice": "Reroll Dice"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ export { default as ImageSelectDialog } from './imageSelectDialog.mjs';
|
||||||
export { default as ItemTransferDialog } from './itemTransfer.mjs';
|
export { default as ItemTransferDialog } from './itemTransfer.mjs';
|
||||||
export { default as MulticlassChoiceDialog } from './multiclassChoiceDialog.mjs';
|
export { default as MulticlassChoiceDialog } from './multiclassChoiceDialog.mjs';
|
||||||
export { default as OwnershipSelection } from './ownershipSelection.mjs';
|
export { default as OwnershipSelection } from './ownershipSelection.mjs';
|
||||||
export { default as RerollDamageDialog } from './rerollDamageDialog.mjs';
|
|
||||||
export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs';
|
export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs';
|
||||||
export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
|
export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
|
||||||
export { default as TagTeamDialog } from './tagTeamDialog.mjs';
|
export { default as TagTeamDialog } from './tagTeamDialog.mjs';
|
||||||
|
|
|
||||||
|
|
@ -1,280 +0,0 @@
|
||||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
|
||||||
|
|
||||||
export default class RerollDamageDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|
||||||
constructor(message, options = {}) {
|
|
||||||
super(options);
|
|
||||||
|
|
||||||
this.message = message;
|
|
||||||
this.damage = Object.keys(message.system.damage).reduce((acc, typeKey) => {
|
|
||||||
const type = message.system.damage[typeKey];
|
|
||||||
acc[typeKey] = Object.keys(type.parts).reduce((acc, partKey) => {
|
|
||||||
const part = type.parts[partKey];
|
|
||||||
acc[partKey] = Object.keys(part.dice).reduce((acc, diceKey) => {
|
|
||||||
const dice = part.dice[diceKey];
|
|
||||||
const activeResults = dice.results.filter(x => x.active);
|
|
||||||
acc[diceKey] = {
|
|
||||||
dice: dice.dice,
|
|
||||||
selectedResults: activeResults.length,
|
|
||||||
maxSelected: activeResults.length,
|
|
||||||
results: activeResults.map(x => ({ ...x, selected: true }))
|
|
||||||
};
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
|
||||||
id: 'reroll-dialog',
|
|
||||||
classes: ['daggerheart', 'dialog', 'dh-style', 'views', 'reroll-dialog'],
|
|
||||||
window: {
|
|
||||||
icon: 'fa-solid fa-dice'
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
toggleResult: RerollDamageDialog.#toggleResult,
|
|
||||||
selectRoll: RerollDamageDialog.#selectRoll,
|
|
||||||
doReroll: RerollDamageDialog.#doReroll,
|
|
||||||
save: RerollDamageDialog.#save
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @override */
|
|
||||||
static PARTS = {
|
|
||||||
main: {
|
|
||||||
id: 'main',
|
|
||||||
template: 'systems/daggerheart/templates/dialogs/rerollDialog/damage/main.hbs'
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
id: 'footer',
|
|
||||||
template: 'systems/daggerheart/templates/dialogs/rerollDialog/footer.hbs'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
get title() {
|
|
||||||
return game.i18n.localize('DAGGERHEART.APPLICATIONS.RerollDialog.damageTitle');
|
|
||||||
}
|
|
||||||
|
|
||||||
_attachPartListeners(partId, htmlElement, options) {
|
|
||||||
super._attachPartListeners(partId, htmlElement, options);
|
|
||||||
|
|
||||||
htmlElement.querySelectorAll('.to-reroll-input').forEach(element => {
|
|
||||||
element.addEventListener('change', this.toggleDice.bind(this));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
|
||||||
const context = await super._prepareContext(_options);
|
|
||||||
context.damage = this.damage;
|
|
||||||
context.disabledReroll = !this.getRerollDice().length;
|
|
||||||
context.saveDisabled = !this.isSelectionDone();
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #save() {
|
|
||||||
const update = {
|
|
||||||
'system.damage': Object.keys(this.damage).reduce((acc, typeKey) => {
|
|
||||||
const type = this.damage[typeKey];
|
|
||||||
let typeTotal = 0;
|
|
||||||
const messageType = this.message.system.damage[typeKey];
|
|
||||||
const parts = Object.keys(type).map(partKey => {
|
|
||||||
const part = type[partKey];
|
|
||||||
const messagePart = messageType.parts[partKey];
|
|
||||||
let partTotal = messagePart.modifierTotal;
|
|
||||||
const dice = Object.keys(part).map(diceKey => {
|
|
||||||
const dice = part[diceKey];
|
|
||||||
const total = dice.results.reduce((acc, result) => {
|
|
||||||
if (result.active) acc += result.result;
|
|
||||||
return acc;
|
|
||||||
}, 0);
|
|
||||||
partTotal += total;
|
|
||||||
const messageDice = messagePart.dice[diceKey];
|
|
||||||
return {
|
|
||||||
...messageDice,
|
|
||||||
total: total,
|
|
||||||
results: dice.results.map(x => ({
|
|
||||||
...x,
|
|
||||||
hasRerolls: dice.results.length > 1
|
|
||||||
}))
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
typeTotal += partTotal;
|
|
||||||
return {
|
|
||||||
...messagePart,
|
|
||||||
total: partTotal,
|
|
||||||
dice: dice
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
acc[typeKey] = {
|
|
||||||
...messageType,
|
|
||||||
total: typeTotal,
|
|
||||||
parts: parts
|
|
||||||
};
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {})
|
|
||||||
};
|
|
||||||
|
|
||||||
await this.message.update(update);
|
|
||||||
await this.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
getRerollDice() {
|
|
||||||
const rerollDice = [];
|
|
||||||
Object.keys(this.damage).forEach(typeKey => {
|
|
||||||
const type = this.damage[typeKey];
|
|
||||||
Object.keys(type).forEach(partKey => {
|
|
||||||
const part = type[partKey];
|
|
||||||
Object.keys(part).forEach(diceKey => {
|
|
||||||
const dice = part[diceKey];
|
|
||||||
Object.keys(dice.results).forEach(resultKey => {
|
|
||||||
const result = dice.results[resultKey];
|
|
||||||
if (result.toReroll) {
|
|
||||||
rerollDice.push({
|
|
||||||
...result,
|
|
||||||
dice: dice.dice,
|
|
||||||
type: typeKey,
|
|
||||||
part: partKey,
|
|
||||||
dice: diceKey,
|
|
||||||
result: resultKey
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return rerollDice;
|
|
||||||
}
|
|
||||||
|
|
||||||
isSelectionDone() {
|
|
||||||
const diceFinishedData = [];
|
|
||||||
Object.keys(this.damage).forEach(typeKey => {
|
|
||||||
const type = this.damage[typeKey];
|
|
||||||
Object.keys(type).forEach(partKey => {
|
|
||||||
const part = type[partKey];
|
|
||||||
Object.keys(part).forEach(diceKey => {
|
|
||||||
const dice = part[diceKey];
|
|
||||||
const selected = dice.results.reduce((acc, result) => acc + (result.active ? 1 : 0), 0);
|
|
||||||
diceFinishedData.push(selected === dice.maxSelected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return diceFinishedData.every(x => x);
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleDice(event) {
|
|
||||||
const target = event.target;
|
|
||||||
const { type, part, dice } = target.dataset;
|
|
||||||
const toggleDice = this.damage[type][part][dice];
|
|
||||||
|
|
||||||
const existingDiceRerolls = this.getRerollDice().filter(
|
|
||||||
x => x.type === type && x.part === part && x.dice === dice
|
|
||||||
);
|
|
||||||
|
|
||||||
const allRerolled = existingDiceRerolls.length === toggleDice.results.filter(x => x.active).length;
|
|
||||||
|
|
||||||
toggleDice.toReroll = !allRerolled;
|
|
||||||
toggleDice.results.forEach(result => {
|
|
||||||
if (result.active) {
|
|
||||||
result.toReroll = !allRerolled;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static #toggleResult(event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
const target = event.target.closest('.to-reroll-result');
|
|
||||||
const { type, part, dice, result } = target.dataset;
|
|
||||||
const toggleDice = this.damage[type][part][dice];
|
|
||||||
const toggleResult = toggleDice.results[result];
|
|
||||||
toggleResult.toReroll = !toggleResult.toReroll;
|
|
||||||
|
|
||||||
const existingDiceRerolls = this.getRerollDice().filter(
|
|
||||||
x => x.type === type && x.part === part && x.dice === dice
|
|
||||||
);
|
|
||||||
|
|
||||||
const allToReroll = existingDiceRerolls.length === toggleDice.results.filter(x => x.active).length;
|
|
||||||
toggleDice.toReroll = allToReroll;
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #selectRoll(_, button) {
|
|
||||||
const { type, part, dice, result } = button.dataset;
|
|
||||||
|
|
||||||
const diceVal = this.damage[type][part][dice];
|
|
||||||
const diceResult = diceVal.results[result];
|
|
||||||
if (!diceResult.active && diceVal.results.filter(x => x.active).length === diceVal.maxSelected) {
|
|
||||||
return ui.notifications.warn(
|
|
||||||
game.i18n.localize('DAGGERHEART.APPLICATIONS.RerollDialog.deselectDiceNotification')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diceResult.active) {
|
|
||||||
diceVal.toReroll = false;
|
|
||||||
diceResult.toReroll = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
diceVal.selectedResults += diceResult.active ? -1 : 1;
|
|
||||||
diceResult.active = !diceResult.active;
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #doReroll() {
|
|
||||||
const toReroll = this.getRerollDice().map(x => {
|
|
||||||
const { type, part, dice, result } = x;
|
|
||||||
const diceData = this.damage[type][part][dice].results[result];
|
|
||||||
return {
|
|
||||||
...diceData,
|
|
||||||
dice: this.damage[type][part][dice].dice,
|
|
||||||
typeKey: type,
|
|
||||||
partKey: part,
|
|
||||||
diceKey: dice,
|
|
||||||
resultsIndex: result
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const roll = await new Roll(toReroll.map(x => `1${x.dice}`).join(' + ')).evaluate();
|
|
||||||
|
|
||||||
if (game.modules.get('dice-so-nice')?.active) {
|
|
||||||
const diceSoNiceRoll = {
|
|
||||||
_evaluated: true,
|
|
||||||
dice: roll.dice,
|
|
||||||
options: { appearance: {} }
|
|
||||||
};
|
|
||||||
|
|
||||||
await game.dice3d.showForRoll(diceSoNiceRoll, game.user, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
toReroll.forEach((data, index) => {
|
|
||||||
const { typeKey, partKey, diceKey, resultsIndex } = data;
|
|
||||||
const rerolledDice = roll.dice[index];
|
|
||||||
|
|
||||||
const dice = this.damage[typeKey][partKey][diceKey];
|
|
||||||
dice.toReroll = false;
|
|
||||||
dice.results[resultsIndex].active = false;
|
|
||||||
dice.results[resultsIndex].discarded = true;
|
|
||||||
dice.results[resultsIndex].toReroll = false;
|
|
||||||
dice.results.splice(dice.results.length, 0, {
|
|
||||||
...rerolledDice.results[0],
|
|
||||||
toReroll: false,
|
|
||||||
selected: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,279 +0,0 @@
|
||||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
|
||||||
|
|
||||||
export default class RerollDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|
||||||
constructor(message, options = {}) {
|
|
||||||
super(options);
|
|
||||||
|
|
||||||
this.message = message;
|
|
||||||
this.damage = Object.keys(message.system.damage).reduce((acc, typeKey) => {
|
|
||||||
const type = message.system.damage[typeKey];
|
|
||||||
acc[typeKey] = Object.keys(type.parts).reduce((acc, partKey) => {
|
|
||||||
const part = type.parts[partKey];
|
|
||||||
acc[partKey] = Object.keys(part.dice).reduce((acc, diceKey) => {
|
|
||||||
const dice = part.dice[diceKey];
|
|
||||||
const activeResults = dice.results.filter(x => x.active);
|
|
||||||
acc[diceKey] = {
|
|
||||||
dice: dice.dice,
|
|
||||||
selectedResults: activeResults.length,
|
|
||||||
maxSelected: activeResults.length,
|
|
||||||
results: activeResults.map(x => ({ ...x, selected: true }))
|
|
||||||
};
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
|
||||||
id: 'reroll-dialog',
|
|
||||||
classes: ['daggerheart', 'dialog', 'dh-style', 'views', 'reroll-dialog'],
|
|
||||||
window: {
|
|
||||||
icon: 'fa-solid fa-dice'
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
toggleResult: RerollDialog.#toggleResult,
|
|
||||||
selectRoll: RerollDialog.#selectRoll,
|
|
||||||
doReroll: RerollDialog.#doReroll,
|
|
||||||
save: RerollDialog.#save
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @override */
|
|
||||||
static PARTS = {
|
|
||||||
main: {
|
|
||||||
id: 'main',
|
|
||||||
template: 'systems/daggerheart/templates/dialogs/rerollDialog/main.hbs'
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
id: 'footer',
|
|
||||||
template: 'systems/daggerheart/templates/dialogs/rerollDialog/footer.hbs'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
get title() {
|
|
||||||
return game.i18n.localize('DAGGERHEART.APPLICATIONS.RerollDialog.title');
|
|
||||||
}
|
|
||||||
|
|
||||||
_attachPartListeners(partId, htmlElement, options) {
|
|
||||||
super._attachPartListeners(partId, htmlElement, options);
|
|
||||||
|
|
||||||
htmlElement.querySelectorAll('.to-reroll-input').forEach(element => {
|
|
||||||
element.addEventListener('change', this.toggleDice.bind(this));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
|
||||||
const context = await super._prepareContext(_options);
|
|
||||||
context.damage = this.damage;
|
|
||||||
context.disabledReroll = !this.getRerollDice().length;
|
|
||||||
context.saveDisabled = !this.isSelectionDone();
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #save() {
|
|
||||||
const update = {
|
|
||||||
'system.damage': Object.keys(this.damage).reduce((acc, typeKey) => {
|
|
||||||
const type = this.damage[typeKey];
|
|
||||||
let typeTotal = 0;
|
|
||||||
const messageType = this.message.system.damage[typeKey];
|
|
||||||
const parts = Object.keys(type).map(partKey => {
|
|
||||||
const part = type[partKey];
|
|
||||||
const messagePart = messageType.parts[partKey];
|
|
||||||
let partTotal = messagePart.modifierTotal;
|
|
||||||
const dice = Object.keys(part).map(diceKey => {
|
|
||||||
const dice = part[diceKey];
|
|
||||||
const total = dice.results.reduce((acc, result) => {
|
|
||||||
if (result.active) acc += result.result;
|
|
||||||
return acc;
|
|
||||||
}, 0);
|
|
||||||
partTotal += total;
|
|
||||||
const messageDice = messagePart.dice[diceKey];
|
|
||||||
return {
|
|
||||||
...messageDice,
|
|
||||||
total: total,
|
|
||||||
results: dice.results.map(x => ({
|
|
||||||
...x,
|
|
||||||
hasRerolls: dice.results.length > 1
|
|
||||||
}))
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
typeTotal += partTotal;
|
|
||||||
return {
|
|
||||||
...messagePart,
|
|
||||||
total: partTotal,
|
|
||||||
dice: dice
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
acc[typeKey] = {
|
|
||||||
...messageType,
|
|
||||||
total: typeTotal,
|
|
||||||
parts: parts
|
|
||||||
};
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {})
|
|
||||||
};
|
|
||||||
await this.message.update(update);
|
|
||||||
await this.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
getRerollDice() {
|
|
||||||
const rerollDice = [];
|
|
||||||
Object.keys(this.damage).forEach(typeKey => {
|
|
||||||
const type = this.damage[typeKey];
|
|
||||||
Object.keys(type).forEach(partKey => {
|
|
||||||
const part = type[partKey];
|
|
||||||
Object.keys(part).forEach(diceKey => {
|
|
||||||
const dice = part[diceKey];
|
|
||||||
Object.keys(dice.results).forEach(resultKey => {
|
|
||||||
const result = dice.results[resultKey];
|
|
||||||
if (result.toReroll) {
|
|
||||||
rerollDice.push({
|
|
||||||
...result,
|
|
||||||
dice: dice.dice,
|
|
||||||
type: typeKey,
|
|
||||||
part: partKey,
|
|
||||||
dice: diceKey,
|
|
||||||
result: resultKey
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return rerollDice;
|
|
||||||
}
|
|
||||||
|
|
||||||
isSelectionDone() {
|
|
||||||
const diceFinishedData = [];
|
|
||||||
Object.keys(this.damage).forEach(typeKey => {
|
|
||||||
const type = this.damage[typeKey];
|
|
||||||
Object.keys(type).forEach(partKey => {
|
|
||||||
const part = type[partKey];
|
|
||||||
Object.keys(part).forEach(diceKey => {
|
|
||||||
const dice = part[diceKey];
|
|
||||||
const selected = dice.results.reduce((acc, result) => acc + (result.active ? 1 : 0), 0);
|
|
||||||
diceFinishedData.push(selected === dice.maxSelected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return diceFinishedData.every(x => x);
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleDice(event) {
|
|
||||||
const target = event.target;
|
|
||||||
const { type, part, dice } = target.dataset;
|
|
||||||
const toggleDice = this.damage[type][part][dice];
|
|
||||||
|
|
||||||
const existingDiceRerolls = this.getRerollDice().filter(
|
|
||||||
x => x.type === type && x.part === part && x.dice === dice
|
|
||||||
);
|
|
||||||
|
|
||||||
const allRerolled = existingDiceRerolls.length === toggleDice.results.filter(x => x.active).length;
|
|
||||||
|
|
||||||
toggleDice.toReroll = !allRerolled;
|
|
||||||
toggleDice.results.forEach(result => {
|
|
||||||
if (result.active) {
|
|
||||||
result.toReroll = !allRerolled;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static #toggleResult(event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
const target = event.target.closest('.to-reroll-result');
|
|
||||||
const { type, part, dice, result } = target.dataset;
|
|
||||||
const toggleDice = this.damage[type][part][dice];
|
|
||||||
const toggleResult = toggleDice.results[result];
|
|
||||||
toggleResult.toReroll = !toggleResult.toReroll;
|
|
||||||
|
|
||||||
const existingDiceRerolls = this.getRerollDice().filter(
|
|
||||||
x => x.type === type && x.part === part && x.dice === dice
|
|
||||||
);
|
|
||||||
|
|
||||||
const allToReroll = existingDiceRerolls.length === toggleDice.results.length;
|
|
||||||
toggleDice.toReroll = allToReroll;
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #selectRoll(_, button) {
|
|
||||||
const { type, part, dice, result } = button.dataset;
|
|
||||||
|
|
||||||
const diceVal = this.damage[type][part][dice];
|
|
||||||
const diceResult = diceVal.results[result];
|
|
||||||
if (!diceResult.active && diceVal.results.filter(x => x.active).length === diceVal.maxSelected) {
|
|
||||||
return ui.notifications.warn(
|
|
||||||
game.i18n.localize('DAGGERHEART.APPLICATIONS.RerollDialog.deselectDiceNotification')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diceResult.active) {
|
|
||||||
diceVal.toReroll = false;
|
|
||||||
diceResult.toReroll = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
diceVal.selectedResults += diceResult.active ? -1 : 1;
|
|
||||||
diceResult.active = !diceResult.active;
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #doReroll() {
|
|
||||||
const toReroll = this.getRerollDice().map(x => {
|
|
||||||
const { type, part, dice, result } = x;
|
|
||||||
const diceData = this.damage[type][part][dice].results[result];
|
|
||||||
return {
|
|
||||||
...diceData,
|
|
||||||
dice: this.damage[type][part][dice].dice,
|
|
||||||
typeKey: type,
|
|
||||||
partKey: part,
|
|
||||||
diceKey: dice,
|
|
||||||
resultsIndex: result
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const roll = await new Roll(toReroll.map(x => `1${x.dice}`).join(' + ')).evaluate();
|
|
||||||
|
|
||||||
if (game.modules.get('dice-so-nice')?.active) {
|
|
||||||
const diceSoNiceRoll = {
|
|
||||||
_evaluated: true,
|
|
||||||
dice: roll.dice,
|
|
||||||
options: { appearance: {} }
|
|
||||||
};
|
|
||||||
|
|
||||||
await game.dice3d.showForRoll(diceSoNiceRoll, game.user, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
toReroll.forEach((data, index) => {
|
|
||||||
const { typeKey, partKey, diceKey, resultsIndex } = data;
|
|
||||||
const rerolledDice = roll.dice[index];
|
|
||||||
|
|
||||||
const dice = this.damage[typeKey][partKey][diceKey];
|
|
||||||
dice.toReroll = false;
|
|
||||||
dice.results[resultsIndex].active = false;
|
|
||||||
dice.results[resultsIndex].discarded = true;
|
|
||||||
dice.results[resultsIndex].toReroll = false;
|
|
||||||
dice.results.splice(dice.results.length, 0, {
|
|
||||||
...rerolledDice.results[0],
|
|
||||||
toReroll: false,
|
|
||||||
selected: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -113,7 +113,6 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
callback: async li => {
|
callback: async li => {
|
||||||
const message = game.messages.get(li.dataset.messageId);
|
const message = game.messages.get(li.dataset.messageId);
|
||||||
const reroll = await message.rolls[0].reroll({ liveRoll: true });
|
const reroll = await message.rolls[0].reroll({ liveRoll: true });
|
||||||
|
|
||||||
message.update({ rolls: [reroll] });
|
message.update({ rolls: [reroll] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -129,9 +128,10 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
},
|
},
|
||||||
callback: async li => {
|
callback: async li => {
|
||||||
const message = game.messages.get(li.dataset.messageId);
|
const message = game.messages.get(li.dataset.messageId);
|
||||||
const reroll = await message.rolls[0].reroll();
|
const damageRoll = new game.system.api.dice.DamageRoll(message.system.damage.hitPoints.roll);
|
||||||
message.update({ rolls: [reroll] });
|
await message.system.action.workflow.get('damage')?.execute(message.system, message.id, true);
|
||||||
// new game.system.api.applications.dialogs.RerollDamageDialog(message).render({ force: true });
|
// message.update({ rolls: [reroll] });
|
||||||
|
console.log('test');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
@import './multiclass-choice/sheet.less';
|
@import './multiclass-choice/sheet.less';
|
||||||
|
|
||||||
@import './reroll-dialog/sheet.less';
|
|
||||||
|
|
||||||
@import './tag-team-dialog/initialization.less';
|
@import './tag-team-dialog/initialization.less';
|
||||||
@import './tag-team-dialog/sheet.less';
|
@import './tag-team-dialog/sheet.less';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,125 +0,0 @@
|
||||||
.daggerheart.dialog.dh-style.views.reroll-dialog {
|
|
||||||
.window-content {
|
|
||||||
max-width: 648px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reroll-outer-container {
|
|
||||||
h2 {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dices-container {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dice-outer-container {
|
|
||||||
width: 300px;
|
|
||||||
|
|
||||||
legend {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4px;
|
|
||||||
|
|
||||||
i {
|
|
||||||
margin-right: 4px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.dice-container {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
|
|
||||||
|
|
||||||
.result-container {
|
|
||||||
position: relative;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 1.375rem;
|
|
||||||
opacity: 0.8;
|
|
||||||
|
|
||||||
&.selected {
|
|
||||||
opacity: 1;
|
|
||||||
border: 1px solid;
|
|
||||||
border-radius: 6px;
|
|
||||||
border-color: light-dark(@dark-blue, @golden);
|
|
||||||
filter: drop-shadow(0 0 3px @golden);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: ' ';
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: -1;
|
|
||||||
mask: var(--svg-die) no-repeat center;
|
|
||||||
mask-size: contain;
|
|
||||||
background: linear-gradient(139.01deg, #efe6d8 3.51%, #372e1f 96.49%);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.d4:before {
|
|
||||||
--svg-die: url(../assets/icons/dice/default/d4.svg);
|
|
||||||
}
|
|
||||||
&.d6:before {
|
|
||||||
--svg-die: url(../assets/icons/dice/default/d6.svg);
|
|
||||||
}
|
|
||||||
&.d8:before {
|
|
||||||
--svg-die: url(../assets/icons/dice/default/d8.svg);
|
|
||||||
}
|
|
||||||
&.d10:before {
|
|
||||||
--svg-die: url(../assets/icons/dice/default/d10.svg);
|
|
||||||
}
|
|
||||||
&.d12:before {
|
|
||||||
--svg-die: url('../assets/icons/dice/default/d12.svg');
|
|
||||||
}
|
|
||||||
&.d20:before {
|
|
||||||
--svg-die: url(../assets/icons/dice/default/d20.svg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.to-reroll-result {
|
|
||||||
position: absolute;
|
|
||||||
bottom: -7px;
|
|
||||||
gap: 2px;
|
|
||||||
border: 1px solid;
|
|
||||||
border-radius: 6px;
|
|
||||||
background-image: url(../assets/parchments/dh-parchment-dark.png);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 2px 6px;
|
|
||||||
|
|
||||||
input {
|
|
||||||
margin: 0;
|
|
||||||
height: 12px;
|
|
||||||
line-height: 0px;
|
|
||||||
position: relative;
|
|
||||||
top: 1px;
|
|
||||||
|
|
||||||
&:before,
|
|
||||||
&:after {
|
|
||||||
line-height: 12px;
|
|
||||||
font-size: var(--font-size-12);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i {
|
|
||||||
font-size: var(--font-size-10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
margin-top: 8px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<div class="reroll-outer-container">
|
|
||||||
{{#each damage}}
|
|
||||||
<h2>{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' @key '.name')}}</h2>
|
|
||||||
{{#each this}}
|
|
||||||
<div class="dices-container">
|
|
||||||
{{#each this}}
|
|
||||||
<fieldset class="dice-outer-container">
|
|
||||||
<legend>
|
|
||||||
<input class="to-reroll-input" type="checkbox" data-type="{{@../../key}}" data-part="{{@../key}}" data-dice="{{@key}}" {{checked this.toReroll}} />
|
|
||||||
<i class="fa-solid fa-dice"></i>
|
|
||||||
<span>{{this.selectedResults}}/{{this.maxSelected}} Selected</span>
|
|
||||||
</legend>
|
|
||||||
|
|
||||||
<div class="dice-container">
|
|
||||||
{{#each this.results}}
|
|
||||||
<div
|
|
||||||
class="result-container {{../dice}} {{#if this.active}}selected{{/if}}"
|
|
||||||
data-action="selectRoll" data-type="{{@../../../key}}" data-part="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
|
||||||
>
|
|
||||||
{{this.result}}
|
|
||||||
{{#if this.active}}
|
|
||||||
<a class="to-reroll-result" data-action="toggleResult" data-type="{{@../../../key}}" data-part="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}">
|
|
||||||
<input class="to-reroll-result-input" type="checkbox" {{checked this.toReroll}} />
|
|
||||||
<i class="fa-solid fa-dice"></i>
|
|
||||||
</a>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
<footer>
|
|
||||||
<button type="button" data-action="doReroll" {{disabled disabledReroll}}>{{localize "DAGGERHEART.GENERAL.reroll"}} <i class="fa-solid fa-dice"></i></button>
|
|
||||||
<button type="button" data-action="save" {{disabled saveDisabled}}>{{localize "DAGGERHEART.APPLICATIONS.RerollDialog.acceptCurrentRolls"}}</button>
|
|
||||||
</footer>
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<div class="reroll-outer-container">
|
|
||||||
{{#each damage}}
|
|
||||||
<h2>{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' @key '.name')}}</h2>
|
|
||||||
{{#each this}}
|
|
||||||
<div class="dices-container">
|
|
||||||
{{#each this}}
|
|
||||||
<fieldset class="dice-outer-container">
|
|
||||||
<legend>
|
|
||||||
<input class="to-reroll-input" type="checkbox" data-type="{{@../../key}}" data-part="{{@../key}}" data-dice="{{@key}}" {{checked this.toReroll}} />
|
|
||||||
<i class="fa-solid fa-dice"></i>
|
|
||||||
<span>{{this.selectedResults}}/{{this.results.length}} Selected</span>
|
|
||||||
</legend>
|
|
||||||
|
|
||||||
<div class="dice-container">
|
|
||||||
{{#each this.results}}
|
|
||||||
<div
|
|
||||||
class="result-container {{../dice}} {{#if this.active}}selected{{/if}}"
|
|
||||||
data-action="selectRoll" data-type="{{@../../../key}}" data-part="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
|
||||||
>
|
|
||||||
{{this.result}}
|
|
||||||
{{#if this.active}}
|
|
||||||
<a class="to-reroll-result" data-action="toggleResult" data-type="{{@../../../key}}" data-part="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}">
|
|
||||||
<input class="to-reroll-result-input" type="checkbox" {{checked this.toReroll}} />
|
|
||||||
<i class="fa-solid fa-dice"></i>
|
|
||||||
</a>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue