mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
[V14] Message Rolls Rework (#1757)
* Basic rework to the roll data in messages * . * Fixed advantage/disadvantage * . * . * Fixed TagTeamDialog * Reuse getter in faces setter * Simplify fate roll type css class * Add more caution to the dualityRoll fromData function * Apply suggestion from @CarlosFdez * Compute modifiers using deterministic terms (#1758) --------- Co-authored-by: Carlos Fernandez <cfern1990@gmail.com> Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
This commit is contained in:
parent
dbd5ef8bb0
commit
f156b12d79
20 changed files with 267 additions and 249 deletions
|
|
@ -200,6 +200,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
|
||||
partContext.members[partId] = {
|
||||
...data,
|
||||
roll: data.roll,
|
||||
isEditable: actor.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER),
|
||||
key: partId,
|
||||
readyToRoll: Boolean(data.rollChoice),
|
||||
|
|
@ -448,24 +449,19 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
const { member, diceType } = button.dataset;
|
||||
const memberData = this.party.system.tagTeam.members[member];
|
||||
|
||||
const dieIndex = diceType === 'hope' ? 0 : diceType === 'fear' ? 2 : 4;
|
||||
|
||||
const { parsedRoll, newRoll } = await game.system.api.dice.DualityRoll.reroll(
|
||||
memberData.rollData,
|
||||
dieIndex,
|
||||
diceType,
|
||||
false
|
||||
);
|
||||
const rollData = parsedRoll.toJSON();
|
||||
const dieIndex = diceType === 'hope' ? 0 : diceType === 'fear' ? 1 : 2;
|
||||
const newRoll = game.system.api.dice.DualityRoll.fromData(memberData.rollData);
|
||||
const dice = newRoll.dice[dieIndex];
|
||||
await dice.reroll(`/r1=${dice.total}`, {
|
||||
liveRoll: {
|
||||
roll: newRoll,
|
||||
isReaction: true
|
||||
}
|
||||
});
|
||||
const rollData = newRoll.toJSON();
|
||||
this.updatePartyData(
|
||||
{
|
||||
[`system.tagTeam.members.${member}.rollData`]: {
|
||||
...rollData,
|
||||
options: {
|
||||
...rollData.options,
|
||||
roll: newRoll
|
||||
}
|
||||
}
|
||||
[`system.tagTeam.members.${member}.rollData`]: rollData
|
||||
},
|
||||
this.getUpdatingParts(button)
|
||||
);
|
||||
|
|
@ -700,7 +696,9 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
const error = this.checkInitiatorHopeError(this.party.system.tagTeam.initiator);
|
||||
if (error) return error;
|
||||
|
||||
const mainRoll = (await this.getJoinedRoll()).rollData;
|
||||
const joinedRoll = await this.getJoinedRoll();
|
||||
const mainRoll = joinedRoll.rollData;
|
||||
const finalRoll = foundry.utils.deepClone(joinedRoll.roll);
|
||||
|
||||
const mainActor = this.party.system.partyMembers.find(x => x.uuid === mainRoll.options.source.actor);
|
||||
mainRoll.options.title = game.i18n.localize('DAGGERHEART.APPLICATIONS.TagTeamSelect.chatMessageRollTitle');
|
||||
|
|
@ -711,7 +709,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
title: game.i18n.localize('DAGGERHEART.APPLICATIONS.TagTeamSelect.title'),
|
||||
speaker: cls.getSpeaker({ actor: mainActor }),
|
||||
system: mainRoll.options,
|
||||
rolls: [mainRoll],
|
||||
rolls: [JSON.stringify(joinedRoll.roll)],
|
||||
sound: null,
|
||||
flags: { core: { RollTable: true } }
|
||||
};
|
||||
|
|
@ -723,7 +721,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
const fearUpdate = { key: 'fear', value: null, total: null, enabled: true };
|
||||
for (let memberId in tagTeamData.members) {
|
||||
const resourceUpdates = [];
|
||||
const rollGivesHope = mainRoll.options.roll.isCritical || mainRoll.options.roll.result.duality === 1;
|
||||
const rollGivesHope = finalRoll.isCritical || finalRoll.withHope;
|
||||
if (memberId === tagTeamData.initiator.memberId) {
|
||||
const value = tagTeamData.initiator.cost
|
||||
? rollGivesHope
|
||||
|
|
@ -734,9 +732,8 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
} else if (rollGivesHope) {
|
||||
resourceUpdates.push({ key: 'hope', value: 1, total: -1, enabled: true });
|
||||
}
|
||||
if (mainRoll.options.roll.isCritical)
|
||||
resourceUpdates.push({ key: 'stress', value: -1, total: 1, enabled: true });
|
||||
if (mainRoll.options.roll.result.duality === -1) {
|
||||
if (finalRoll.isCritical) resourceUpdates.push({ key: 'stress', value: -1, total: 1, enabled: true });
|
||||
if (finalRoll.withFear) {
|
||||
fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1;
|
||||
fearUpdate.total = fearUpdate.total === null ? -1 : fearUpdate.total - 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue