Get the delve conditions editable
This commit is contained in:
parent
110823a26b
commit
155685a6c3
3 changed files with 29 additions and 2 deletions
|
|
@ -64,7 +64,8 @@
|
|||
"easy": "Easy",
|
||||
"normal": "Normal",
|
||||
"tough": "Tough",
|
||||
"hard": "Hard"
|
||||
"hard": "Hard",
|
||||
"random": "Random Condition"
|
||||
},
|
||||
"drag": "Drag",
|
||||
"edit": "Edit",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { localizer } from "../utils/Localizer.mjs";
|
|||
import { Logger } from "../utils/Logger.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
const { ContextMenu } = foundry.applications.ui;
|
||||
const { FatePath } = gameTerms;
|
||||
|
||||
const CompassRotations = {
|
||||
|
|
@ -96,6 +97,25 @@ export class DelveDiceHUD extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
// Shortcut because users can't edit
|
||||
if (!game.user.isGM) { return };
|
||||
|
||||
new ContextMenu(
|
||||
this.element,
|
||||
`#delve-difficulty`,
|
||||
[
|
||||
...conditions.map(condition => ({
|
||||
name: localizer(condition.label),
|
||||
callback: DelveDiceHUD.#setDifficulty.bind(this, condition.value),
|
||||
})),
|
||||
{
|
||||
name: localizer(`RipCrypt.common.difficulties.random`),
|
||||
callback: () => {
|
||||
const condition = conditions[Math.floor(Math.random() * conditions.length)];
|
||||
DelveDiceHUD.#setDifficulty.bind(this)(condition.value);
|
||||
},
|
||||
},
|
||||
],
|
||||
{ jQuery: false, fixed: true },
|
||||
);
|
||||
};
|
||||
|
||||
async _preparePartContext(partId, ctx, opts) {
|
||||
|
|
@ -202,6 +222,12 @@ export class DelveDiceHUD extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
this.#animateCompassTo(fate);
|
||||
game.settings.set(`ripcrypt`, `currentFate`, fate);
|
||||
};
|
||||
|
||||
/** @this {DelveDiceHUD} */
|
||||
static async #setDifficulty(value) {
|
||||
this._difficulty = value;
|
||||
game.settings.set(`ripcrypt`, `dc`, value);
|
||||
};
|
||||
// #endregion
|
||||
|
||||
// #region Public API
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class="icon-container"
|
||||
data-tooltip="Difficulty: 8"
|
||||
>
|
||||
<span class="large">8</span>
|
||||
<span class="large">{{dc}}</span>
|
||||
<rc-icon
|
||||
class="hourglass"
|
||||
name="icons/d8-outline"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue