mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Compare commits
6 commits
de0d4ef9b4
...
e6f26deab9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6f26deab9 | ||
|
|
3b87e1d4a8 | ||
|
|
f977163534 | ||
|
|
7ab7cc9787 | ||
|
|
9fba339230 | ||
|
|
e25cf0c4cd |
4 changed files with 75 additions and 11 deletions
|
|
@ -3253,7 +3253,8 @@
|
||||||
"knowTheTide": "Know The Tide gained a token",
|
"knowTheTide": "Know The Tide gained a token",
|
||||||
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
|
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
|
||||||
"noTokenTargeted": "No token is targeted",
|
"noTokenTargeted": "No token is targeted",
|
||||||
"behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM"
|
"behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM",
|
||||||
|
"comboDiceOnlyTwoDiceError": "Combo dice functionality only works on a single pair of two dice"
|
||||||
},
|
},
|
||||||
"Progress": {
|
"Progress": {
|
||||||
"migrationLabel": "Performing system migration. Please wait and do not close Foundry."
|
"migrationLabel": "Performing system migration. Please wait and do not close Foundry."
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,61 @@ import { adjustDice } from '../../helpers/utils.mjs';
|
||||||
export default class BaseDie extends foundry.dice.terms.Die {
|
export default class BaseDie extends foundry.dice.terms.Die {
|
||||||
static MODIFIERS = {
|
static MODIFIERS = {
|
||||||
...foundry.dice.terms.Die.MODIFIERS,
|
...foundry.dice.terms.Die.MODIFIERS,
|
||||||
|
cc: 'compoundComboDice',
|
||||||
c: 'comboDice'
|
c: 'comboDice'
|
||||||
};
|
};
|
||||||
|
|
||||||
async comboDice(modifier) {
|
async compoundComboDice() {
|
||||||
/* ComboDice only works with exactly two dice and both have to be the same denomination */
|
return this.handleComboDice(true);
|
||||||
if (this.number !== 2) return false;
|
}
|
||||||
|
|
||||||
const maxIncreasesDiceSize = modifier.endsWith('1');
|
async comboDice() {
|
||||||
return this.continueCombo(maxIncreasesDiceSize);
|
return this.handleComboDice(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleComboDice(maxIncreasesDiceSize) {
|
||||||
|
/* ComboDice only works with exactly two dice and both have to be the same denomination */
|
||||||
|
if (this.number !== 2) {
|
||||||
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.comboDiceOnlyTwoDiceError'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await this.continueCombo(maxIncreasesDiceSize);
|
||||||
|
|
||||||
|
/* The flow of DiceSoNice has no way of knowign that some of the results of a Die should be a different denomination
|
||||||
|
We solve this by marking the results as hidden so they're not picked up by the auto roll of DiceSoNice.
|
||||||
|
The actual rolls are done here in place so every dice gets the correct denomination.
|
||||||
|
*/
|
||||||
|
if (game.modules.get('dice-so-nice')?.active) {
|
||||||
|
const rolls = [];
|
||||||
|
for (const result of this.results) {
|
||||||
|
const roll = await (new Roll(`1${result.denomination ?? this.denomination}`)).evaluate();
|
||||||
|
roll.terms[0].results = [result];
|
||||||
|
roll._evaluateTotal();
|
||||||
|
rolls.push(roll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If there are other dice that will be rolled we cannot await here. The other dice will be awaited in the normal flow */
|
||||||
|
if (this._root.dice.length > 1) {
|
||||||
|
for (const roll of rolls) {
|
||||||
|
game.dice3d.showForRoll(roll, game.user, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await Promise.allSettled(rolls.map(roll => game.dice3d.showForRoll(roll, game.user, true)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const result of this.results)
|
||||||
|
result.hidden = true;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async continueCombo(maxIncreasesDiceSize) {
|
async continueCombo(maxIncreasesDiceSize) {
|
||||||
const lastIndex = this.results.length - 1;
|
const lastIndex = this.results.length - 1;
|
||||||
|
|
||||||
/* The Combo only continues if the latest roll was higher than the previous */
|
/* The Combo only continues if the latest roll was higher or equal to the previous */
|
||||||
if (this.results[lastIndex].result <= this.results[lastIndex - 1].result) return false;
|
if (this.results[lastIndex].result < this.results[lastIndex - 1].result) return false;
|
||||||
|
|
||||||
const lastFaces = this.results[lastIndex].denomination?.slice(1) ?? this.faces;
|
const lastFaces = this.results[lastIndex].denomination?.slice(1) ?? this.faces;
|
||||||
const increaseDiceSize = maxIncreasesDiceSize && lastFaces < 12 && this.results[lastIndex].result === lastFaces;
|
const increaseDiceSize = maxIncreasesDiceSize && lastFaces < 12 && this.results[lastIndex].result === lastFaces;
|
||||||
|
|
@ -28,6 +67,25 @@ export default class BaseDie extends foundry.dice.terms.Die {
|
||||||
this.results.push({ result: newRoll.total, denomination: denomination, active: true });
|
this.results.push({ result: newRoll.total, denomination: denomination, active: true });
|
||||||
this.number += 1;
|
this.number += 1;
|
||||||
|
|
||||||
return this.continueCombo();
|
return this.continueCombo(maxIncreasesDiceSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
getResultCSS(result) {
|
||||||
|
const hasSuccess = result.success !== undefined;
|
||||||
|
const hasFailure = result.failure !== undefined;
|
||||||
|
const isMax = result.result === this.faces;
|
||||||
|
const isMin = result.result === 1;
|
||||||
|
return [
|
||||||
|
this.constructor.name.toLowerCase(),
|
||||||
|
result.denomination ?? this.denomination, // Accomodating ComboDie as a result can have a different denomination than the die as a whole
|
||||||
|
result.success ? 'success' : null,
|
||||||
|
result.failure ? 'failure' : null,
|
||||||
|
result.rerolled ? 'rerolled' : null,
|
||||||
|
result.exploded ? 'exploded' : null,
|
||||||
|
result.discarded ? 'discarded' : null,
|
||||||
|
!(hasSuccess || hasFailure) && isMin ? 'min' : null,
|
||||||
|
!(hasSuccess || hasFailure) && isMax ? 'max' : null
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
{{#unless discarded}}
|
{{#unless discarded}}
|
||||||
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
||||||
<div
|
<div
|
||||||
class="dice reroll-button {{../dice}}"
|
class="dice reroll-button {{ifThen denomination denomination ../dice}}"
|
||||||
data-die-index="0" data-type="damage" data-damage-type="{{@../../../key}}" data-part="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
data-die-index="0" data-type="damage" data-damage-type="{{@../../../key}}" data-part="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
||||||
>
|
>
|
||||||
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,13 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#each roll.dice}}
|
{{#each roll.dice}}
|
||||||
{{#each results}}
|
{{#each results}}
|
||||||
|
{{debug this}}
|
||||||
<div class="roll-die {{#unless (or @../first discarded)}} has-plus{{/unless}}">
|
<div class="roll-die {{#unless (or @../first discarded)}} has-plus{{/unless}}">
|
||||||
<div class="dice {{../denomination}}{{#if discarded}} discarded{{else}}{{#if (and @../first ../../roll.advantage.type)}}{{#if (eq ../../roll.advantage.type 1)}} color-adv{{else}} color-dis{{/if}}{{/if}}{{#if success}} color-adv{{/if}}{{/if}}">
|
<div class="
|
||||||
|
dice
|
||||||
|
{{ifThen denomination denomination ../denomination}}
|
||||||
|
{{#if discarded}} discarded{{else}}{{#if (and @../first ../../roll.advantage.type)}}{{#if (eq ../../roll.advantage.type 1)}} color-adv{{else}} color-dis{{/if}}{{/if}}{{#if success}} color-adv{{/if}}{{/if}}
|
||||||
|
">
|
||||||
{{result}}
|
{{result}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue