mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-24 08:23:38 +02:00
Compare commits
8 commits
686c660e86
...
766c1742d7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
766c1742d7 | ||
|
|
a7c4549e6f | ||
|
|
980cbc7ae0 | ||
|
|
3cdea0c789 | ||
|
|
714d4edc16 | ||
|
|
fe0cb4468c | ||
|
|
bf5a6d2a4d | ||
|
|
a6500f6801 |
12 changed files with 124 additions and 93 deletions
|
|
@ -35,7 +35,7 @@ CONFIG.Dice.daggerheart = {
|
|||
FateRoll: FateRoll
|
||||
};
|
||||
|
||||
CONFIG.Dice.termTypes.DualityDie = dice.diceTypes.DualityDie;
|
||||
Object.assign(CONFIG.Dice.termTypes, dice.diceTypes);
|
||||
|
||||
CONFIG.Actor.documentClass = documents.DhpActor;
|
||||
CONFIG.Actor.dataModels = models.actors.config;
|
||||
|
|
|
|||
|
|
@ -452,8 +452,12 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
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: true });
|
||||
await newRoll._evaluate();
|
||||
await dice.reroll(`/r1=${dice.total}`, {
|
||||
liveRoll: {
|
||||
roll: newRoll,
|
||||
isReaction: true
|
||||
}
|
||||
});
|
||||
const rollData = newRoll.toJSON();
|
||||
this.updatePartyData(
|
||||
{
|
||||
|
|
@ -694,6 +698,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
|
||||
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');
|
||||
|
|
@ -712,34 +717,33 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
await cls.create(msgData);
|
||||
|
||||
/* Handle resource updates from the finished TagTeamRoll */
|
||||
// const tagTeamData = this.party.system.tagTeam;
|
||||
// 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;
|
||||
// if (memberId === tagTeamData.initiator.memberId) {
|
||||
// const value = tagTeamData.initiator.cost
|
||||
// ? rollGivesHope
|
||||
// ? 1 - tagTeamData.initiator.cost
|
||||
// : -tagTeamData.initiator.cost
|
||||
// : 1;
|
||||
// resourceUpdates.push({ key: 'hope', value: value, total: -value, enabled: true });
|
||||
// } 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) {
|
||||
// fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1;
|
||||
// fearUpdate.total = fearUpdate.total === null ? -1 : fearUpdate.total - 1;
|
||||
// }
|
||||
const tagTeamData = this.party.system.tagTeam;
|
||||
const fearUpdate = { key: 'fear', value: null, total: null, enabled: true };
|
||||
for (let memberId in tagTeamData.members) {
|
||||
const resourceUpdates = [];
|
||||
const rollGivesHope = finalRoll.isCritical || finalRoll.withHope;
|
||||
if (memberId === tagTeamData.initiator.memberId) {
|
||||
const value = tagTeamData.initiator.cost
|
||||
? rollGivesHope
|
||||
? 1 - tagTeamData.initiator.cost
|
||||
: -tagTeamData.initiator.cost
|
||||
: 1;
|
||||
resourceUpdates.push({ key: 'hope', value: value, total: -value, enabled: true });
|
||||
} else if (rollGivesHope) {
|
||||
resourceUpdates.push({ key: 'hope', value: 1, total: -1, enabled: true });
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
// game.actors.get(memberId).modifyResource(resourceUpdates);
|
||||
// }
|
||||
game.actors.get(memberId).modifyResource(resourceUpdates);
|
||||
}
|
||||
|
||||
// if (fearUpdate.value) {
|
||||
// mainActor.modifyResource([fearUpdate]);
|
||||
// }
|
||||
if (fearUpdate.value) {
|
||||
mainActor.modifyResource([fearUpdate]);
|
||||
}
|
||||
|
||||
/* Fin */
|
||||
this.cancelRoll({ confirm: false });
|
||||
|
|
|
|||
|
|
@ -218,7 +218,6 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
isReaction: message.system.roll.options.actionType === 'reaction'
|
||||
}
|
||||
});
|
||||
// await message.system.roll._evaluate();
|
||||
await message.update({
|
||||
rolls: [message.system.roll.toJSON()]
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ export { default as DamageRoll } from './damageRoll.mjs';
|
|||
export { default as DHRoll } from './dhRoll.mjs';
|
||||
export { default as DualityRoll } from './dualityRoll.mjs';
|
||||
export { default as FateRoll } from './fateRoll.mjs';
|
||||
export { Dice, diceTypes } from './die/_module.mjs';
|
||||
export { diceTypes } from './die/_module.mjs';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import DualityDie from './dualityDie.mjs';
|
||||
|
||||
export const Dice = [DualityDie];
|
||||
import AdvantageDie from './advantageDie.mjs';
|
||||
import DisadvantageDie from './disadvantageDie.mjs';
|
||||
|
||||
export const diceTypes = {
|
||||
DualityDie
|
||||
DualityDie,
|
||||
AdvantageDie,
|
||||
DisadvantageDie
|
||||
};
|
||||
|
|
|
|||
7
module/dice/die/advantageDie.mjs
Normal file
7
module/dice/die/advantageDie.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export default class AdvantageDie extends foundry.dice.terms.Die {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.modifiers = [];
|
||||
}
|
||||
}
|
||||
7
module/dice/die/disadvantageDie.mjs
Normal file
7
module/dice/die/disadvantageDie.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export default class DisadvantageDie extends foundry.dice.terms.Die {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.modifiers = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -17,22 +17,6 @@ export default class DualityRoll extends D20Roll {
|
|||
|
||||
static DefaultDialog = D20RollDialog;
|
||||
|
||||
/**@inheritdoc */
|
||||
static instantiateAST(ast) {
|
||||
/* First two dice are always the DualityDice */
|
||||
const nodes = CONFIG.Dice.parser.flattenTree(ast);
|
||||
const dieNodes = nodes.filter(x => x.class === 'DiceTerm');
|
||||
if (dieNodes.length > 1) {
|
||||
dieNodes[0].class = 'DualityDie';
|
||||
dieNodes[1].class = 'DualityDie';
|
||||
}
|
||||
|
||||
return nodes.map(node => {
|
||||
const cls = foundry.dice.terms[node.class] ?? foundry.dice.terms.RollTerm;
|
||||
return cls.fromParseNode(node);
|
||||
});
|
||||
}
|
||||
|
||||
get title() {
|
||||
return game.i18n.localize(
|
||||
`DAGGERHEART.GENERAL.${this.options?.actionType === 'reaction' ? 'reactionRoll' : 'dualityRoll'}`
|
||||
|
|
@ -40,27 +24,31 @@ export default class DualityRoll extends D20Roll {
|
|||
}
|
||||
|
||||
get dHope() {
|
||||
if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
if (!(this.dice[0] instanceof game.system.api.dice.diceTypes.DualityDie)) this.createBaseDice();
|
||||
return this.dice[0];
|
||||
}
|
||||
|
||||
set dHope(faces) {
|
||||
if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
this.dice[0].faces = this.getFaces(faces);
|
||||
// TODO this should not be asymmetrical with the getter. updateRollConfiguration() should use dHope.faces
|
||||
this.dHope.faces = this.getFaces(faces);
|
||||
}
|
||||
|
||||
get dFear() {
|
||||
if (!(this.dice[1] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
if (!(this.dice[1] instanceof game.system.api.dice.diceTypes.DualityDie)) this.createBaseDice();
|
||||
return this.dice[1];
|
||||
}
|
||||
|
||||
set dFear(faces) {
|
||||
if (!(this.dice[1] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
this.dice[1].faces = this.getFaces(faces);
|
||||
// TODO this should not be asymmetrical with the getter. updateRollConfiguration() should use dFear.faces
|
||||
this.dFear.faces = this.getFaces(faces);
|
||||
}
|
||||
|
||||
get dAdvantage() {
|
||||
return this.dice[2];
|
||||
return this.dice[2] instanceof game.system.api.dice.diceTypes.AdvantageDie ? this.dice[2] : null;
|
||||
}
|
||||
|
||||
get dDisadvantage() {
|
||||
return this.dice[2] instanceof game.system.api.dice.diceTypes.DisadvantageDie ? this.dice[2] : null;
|
||||
}
|
||||
|
||||
get advantageFaces() {
|
||||
|
|
@ -79,6 +67,11 @@ export default class DualityRoll extends D20Roll {
|
|||
this._advantageNumber = Number(value);
|
||||
}
|
||||
|
||||
get extraDice() {
|
||||
const { DualityDie, AdvantageDie, DisadvantageDie } = game.system.api.dice.diceTypes;
|
||||
return this.dice.filter(x => ![DualityDie, AdvantageDie, DisadvantageDie].some(die => x instanceof die));
|
||||
}
|
||||
|
||||
/* This isn't fullproof, but trying to cover parathetical situations is ridiculously complex */
|
||||
get modifierTotal() {
|
||||
let modifierTotal = 0;
|
||||
|
|
@ -145,6 +138,16 @@ export default class DualityRoll extends D20Roll {
|
|||
return [...(hooks ?? []), 'Duality'];
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static fromData(data) {
|
||||
data.terms[0].class = 'DualityDie';
|
||||
data.terms[2].class = 'DualityDie';
|
||||
if (data.options.roll.advantage?.type && data.terms[4]?.faces) {
|
||||
data.terms[4].class = data.options.roll.advantage.type === 1 ? 'AdvantageDie' : 'DisadvantageDie';
|
||||
}
|
||||
return super.fromData(data);
|
||||
}
|
||||
|
||||
createBaseDice() {
|
||||
if (
|
||||
this.dice[0] instanceof game.system.api.dice.diceTypes.DualityDie &&
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ export default class FateRoll extends D20Roll {
|
|||
}
|
||||
|
||||
set dHope(faces) {
|
||||
if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
this.dice[0].faces = this.getFaces(faces);
|
||||
// TODO this should not be asymmetrical with the getter. updateRollConfiguration() should use dHope.faces
|
||||
this.dHope.faces = this.getFaces(faces);
|
||||
}
|
||||
|
||||
get dFear() {
|
||||
|
|
@ -31,8 +31,8 @@ export default class FateRoll extends D20Roll {
|
|||
}
|
||||
|
||||
set dFear(faces) {
|
||||
if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||
this.dice[0].faces = this.getFaces(faces);
|
||||
// TODO this should not be asymmetrical with the getter. updateRollConfiguration() should use dFear.faces
|
||||
this.dFear.faces = this.getFaces(faces);
|
||||
}
|
||||
|
||||
get isCritical() {
|
||||
|
|
@ -43,6 +43,22 @@ export default class FateRoll extends D20Roll {
|
|||
return this.data.fateType;
|
||||
}
|
||||
|
||||
get withHope() {
|
||||
if (!this._evaluatedl) return;
|
||||
return this.dHope.total >= this.dFear.total;
|
||||
}
|
||||
|
||||
get withFear() {
|
||||
if (!this._evaluated) return;
|
||||
return this.dHope.total < this.dFear.total;
|
||||
}
|
||||
|
||||
get totalLabel() {
|
||||
const label = this.withHope ? 'DAGGERHEART.GENERAL.hope' : 'DAGGERHEART.GENERAL.fear';
|
||||
|
||||
return game.i18n.localize(label);
|
||||
}
|
||||
|
||||
static getHooks(hooks) {
|
||||
return [...(hooks ?? []), 'Fate'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,8 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
}
|
||||
if (this.type === 'fateRoll') {
|
||||
html.classList.add('fate');
|
||||
if (this.system.roll?.fate.fateDie == 'Hope') {
|
||||
html.classList.add('hope');
|
||||
}
|
||||
if (this.system.roll?.fate.fateDie == 'Fear') {
|
||||
html.classList.add('fear');
|
||||
if (this.system.roll?.fateDie) {
|
||||
html.classList.add(this.system.roll.fateDie.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@
|
|||
{{#if @root.advantage}}
|
||||
{{#if (eq @root.advantage 1)}}
|
||||
<div class="dice-option">
|
||||
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/adv/' @root.roll.dAdvantage.denomination '.svg'}}" alt="">
|
||||
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/adv/d' @root.roll.advantageFaces '.svg'}}" alt="">
|
||||
<div class="dice-select">
|
||||
<span class="label">{{localize "DAGGERHEART.GENERAL.Advantage.full"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{else if (eq @root.advantage -1)}}
|
||||
<div class="dice-option">
|
||||
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/disadv/' @root.roll.dAdvantage.denomination '.svg'}}" alt="">
|
||||
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/disadv/d' @root.roll.advantageFaces '.svg'}}" alt="">
|
||||
<div class="dice-select">
|
||||
<span class="label">{{localize "DAGGERHEART.GENERAL.Disadvantage.full"}}</span>
|
||||
</div>
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
{{/times}}
|
||||
</select>
|
||||
<select name="roll.dice.advantageFaces"{{#unless advantage}} disabled{{/unless}}>
|
||||
{{selectOptions diceOptions selected=@root.roll.dAdvantage.denomination}}
|
||||
{{selectOptions diceOptions selected=(concat 'd' @root.roll.advantageFaces)}}
|
||||
</select>
|
||||
</div>
|
||||
{{#if abilities}}
|
||||
|
|
|
|||
|
|
@ -29,20 +29,20 @@
|
|||
<div class="dice-tooltip">
|
||||
<div class="wrapper">
|
||||
<div class="roll-dice">
|
||||
{{#if roll.fate}}
|
||||
{{#if (eq roll.fate.fateDie "Hope")}}
|
||||
{{#if roll.fateDie}}
|
||||
{{#if (eq roll.fateDie "Hope")}}
|
||||
<div class="roll-die">
|
||||
<label>{{localize "DAGGERHEART.GENERAL.hope"}}</label>
|
||||
<div class="dice {{roll.fate.dice}} color-hope" data-die-index="0" data-type="hope">
|
||||
{{roll.fate.value}}
|
||||
<div class="dice {{roll.dHope.denomination}} color-hope" data-die-index="0" data-type="hope">
|
||||
{{roll.dHope.total}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if (eq roll.fate.fateDie "Fear")}}
|
||||
{{#if (eq roll.fateDie "Fear")}}
|
||||
<div class="roll-die">
|
||||
<label>{{localize "DAGGERHEART.GENERAL.fear"}}</label>
|
||||
<div class="dice {{roll.fate.dice}} color-fear" data-die-index="0" data-type="fear">
|
||||
{{roll.fate.value}}
|
||||
<div class="dice {{roll.dFear.denomination}} color-fear" data-die-index="0" data-type="fear">
|
||||
{{roll.dFear.total}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
@ -63,14 +63,14 @@
|
|||
</div>
|
||||
</div>
|
||||
{{#if roll.dAdvantage}}
|
||||
<div class="roll-die {{#if roll.hasAdvantage}}has-plus{{else}}has-minus{{/if}}">
|
||||
{{#if roll.hasAdvantage}}
|
||||
<label>{{localize "DAGGERHEART.GENERAL.Advantage.short"}}</label>
|
||||
<div class="dice {{roll.dAdavantage.denomination}} color-adv">{{roll.dAdvantage.total}}</div>
|
||||
{{else}}
|
||||
<label>{{localize "DAGGERHEART.GENERAL.Disadvantage.short"}}</label>
|
||||
<div class="dice {{roll.dAdvantage.denomination}} color-dis">{{roll.dAdvantage.total}}</div>
|
||||
{{/if}}
|
||||
<div class="roll-die has-plus">
|
||||
<label>{{localize "DAGGERHEART.GENERAL.Advantage.short"}}</label>
|
||||
<div class="dice {{roll.dAdvantage.denomination}} color-adv">{{roll.dAdvantage.total}}</div>
|
||||
</div>
|
||||
{{else if roll.dDisadvantage}}
|
||||
<div class="roll-die has-minus">
|
||||
<label>{{localize "DAGGERHEART.GENERAL.Disadvantage.short"}}</label>
|
||||
<div class="dice {{roll.dDisadvantage.denomination}} color-dis">{{roll.dDisadvantage.total}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if roll.rally.dice}}
|
||||
|
|
@ -79,15 +79,11 @@
|
|||
<div class="dice {{roll.rally.dice}}">{{roll.rally.value}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#each roll.extra}}
|
||||
{{#each results}}
|
||||
{{#unless discarded}}
|
||||
<div class="roll-die has-plus">
|
||||
<label></label>
|
||||
<div class="dice {{../dice}}">{{result}}</div>
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{#each roll.extraDice}}
|
||||
<div class="roll-die has-plus">
|
||||
<label></label>
|
||||
<div class="dice {{this.denomination}}">{{this.total}}</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
{{else}}
|
||||
{{#each roll.dice}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue