diff --git a/module/Apps/CryptApp.mjs b/module/Apps/CryptApp.mjs index 1882623..f7c2e7c 100644 --- a/module/Apps/CryptApp.mjs +++ b/module/Apps/CryptApp.mjs @@ -4,6 +4,13 @@ import { Logger } from "../utils/Logger.mjs"; const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api; +const conditions = [ + { label: `RipCrypt.common.difficulties.easy`, value: 4 }, + { label: `RipCrypt.common.difficulties.normal`, value: 5 }, + { label: `RipCrypt.common.difficulties.tough`, value: 6 }, + { label: `RipCrypt.common.difficulties.hard`, value: 7 }, +]; + export class CryptApp extends GenericAppMixin(HandlebarsApplicationMixin(ApplicationV2)) { // #region Options static DEFAULT_OPTIONS = { @@ -18,9 +25,11 @@ export class CryptApp extends GenericAppMixin(HandlebarsApplicationMixin(Applica minimizable: false, }, position: { - width: 100, + width: `auto`, + }, + actions: { + randomCondition: this.#randomCondition, }, - actions: {}, }; static PARTS = { @@ -79,17 +88,17 @@ export class CryptApp extends GenericAppMixin(HandlebarsApplicationMixin(Applica }; _prepareDifficulty(ctx) { - ctx.options = [ - { label: `RipCrypt.common.difficulties.easy`, value: 4 }, - { label: `RipCrypt.common.difficulties.normal`, value: 5 }, - { label: `RipCrypt.common.difficulties.tough`, value: 6 }, - { label: `RipCrypt.common.difficulties.hard`, value: 7 }, - ]; + ctx.options = conditions; ctx.difficulty = game.settings.get(`ripcrypt`, `dc`); return ctx; }; // #endregion // #region Actions + static async #randomCondition() { + const dc = conditions[Math.floor(Math.random() * conditions.length)]; + await game.settings.set(`ripcrypt`, `dc`, dc.value); + await this.render({ parts: [`delveConditions`] }); + }; // #endregion }; diff --git a/templates/Apps/CryptApp/delveConditions.hbs b/templates/Apps/CryptApp/delveConditions.hbs index fa36f8c..4e0f00d 100644 --- a/templates/Apps/CryptApp/delveConditions.hbs +++ b/templates/Apps/CryptApp/delveConditions.hbs @@ -8,9 +8,21 @@
{{ difficulty }} {{#if meta.editable}} - +
+ + +
{{/if}}
diff --git a/templates/Apps/CryptApp/style.css b/templates/Apps/CryptApp/style.css index f849cb0..9d6c772 100644 --- a/templates/Apps/CryptApp/style.css +++ b/templates/Apps/CryptApp/style.css @@ -10,4 +10,9 @@ background: var(--base-background); padding: 4px; }; + + .row { + display: flex; + flex-direction: row; + } }