diff --git a/package.json b/package.json index 25056d758..9b5ab1e58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gloomhavensecretariat", - "version": "0.104.0", + "version": "0.104.1", "license": "AGPL3", "description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.", "homepage": "https://gloomhaven-secretariat.de", diff --git a/src/app/game/businesslogic/SettingsManager.ts b/src/app/game/businesslogic/SettingsManager.ts index aff630c50..a7658857e 100644 --- a/src/app/game/businesslogic/SettingsManager.ts +++ b/src/app/game/businesslogic/SettingsManager.ts @@ -50,7 +50,7 @@ export class SettingsManager { } else { loadDefault = true; } - } catch { + } catch (e) { loadDefault = true; } @@ -65,7 +65,7 @@ export class SettingsManager { }).then((value: Settings) => { this.setSettings(Object.assign(new Settings(), value)); }); - } catch { + } catch (e) { this.setSettings(new Settings()); } } diff --git a/src/app/game/businesslogic/StateManager.ts b/src/app/game/businesslogic/StateManager.ts index 173c52654..cfbad8f90 100644 --- a/src/app/game/businesslogic/StateManager.ts +++ b/src/app/game/businesslogic/StateManager.ts @@ -56,7 +56,7 @@ export class StateManager { const gameModel = await storageManager.readGameModel(); gameModel.server = false; this.game.fromModel(gameModel); - } catch { + } catch (e) { if (!tool) { storageManager.writeGameModel(this.game.toModel()); } @@ -109,7 +109,7 @@ export class StateManager { this.redos = await storageManager.readAll('redo'); this.undoInfos = await storageManager.readAll('undo-infos'); this.updatePermissions(); - } catch { + } catch (e) { this.updatePermissions(); } } @@ -638,7 +638,7 @@ export class StateManager { downloadButton.click(); document.body.removeChild(downloadButton); } - } catch { + } catch (e) { console.warn("Could not create autobackup"); } window.document.body.classList.remove('working'); diff --git a/src/app/game/businesslogic/StorageManager.ts b/src/app/game/businesslogic/StorageManager.ts index 588a3cb19..9cf789c05 100644 --- a/src/app/game/businesslogic/StorageManager.ts +++ b/src/app/game/businesslogic/StorageManager.ts @@ -328,7 +328,7 @@ export class StorageManager { document.body.appendChild(downloadButton); downloadButton.click(); document.body.removeChild(downloadButton); - } catch { + } catch (e) { console.warn("Could not read datadump"); } diff --git a/src/app/game/model/ActionHex.ts b/src/app/game/model/ActionHex.ts index 8c9375054..44f6cd45b 100644 --- a/src/app/game/model/ActionHex.ts +++ b/src/app/game/model/ActionHex.ts @@ -22,23 +22,23 @@ export class ActionHex { this.value = value; } - public static fromString(string: string): ActionHex | null { +} - let groups: RegExpExecArray | null = new RegExp(/^\((\d+),(\d+),(active|target|conditional|ally|blank|invisible)(\:(\w*))?\)$/).exec(string); +export function ActionHexFromString(string: string): ActionHex | null { - if (groups == null) { - return null; - } + let groups: RegExpExecArray | null = new RegExp(/^\((\d+),(\d+),(active|target|conditional|ally|blank|invisible)(\:(\w*))?\)$/).exec(string); - let value = ""; - if (groups.length > 5 && groups[5]) { - value = groups[5]; - } - return new ActionHex(+groups[1], +groups[2], groups[3] as ActionHexType, value); + if (groups == null) { + return null; } - public static toString(actionHex: ActionHex): string { - return "(" + actionHex.x + "," + actionHex.y + "," + ActionHexType[actionHex.type] + (actionHex.value ? ":" + actionHex.value : "") + ")" + let value = ""; + if (groups.length > 5 && groups[5]) { + value = groups[5]; } + return new ActionHex(+groups[1], +groups[2], groups[3] as ActionHexType, value); +} +export function ActionHexToString(actionHex: ActionHex): string { + return "(" + actionHex.x + "," + actionHex.y + "," + ActionHexType[actionHex.type] + (actionHex.value ? ":" + actionHex.value : "") + ")" } diff --git a/src/app/ui/figures/actions/action.ts b/src/app/ui/figures/actions/action.ts index d5152c946..afc27b902 100644 --- a/src/app/ui/figures/actions/action.ts +++ b/src/app/ui/figures/actions/action.ts @@ -237,7 +237,7 @@ export class ActionComponent implements OnInit, OnDestroy { } else { try { statValue = EntityValueFunction(stat.attack, this.level); - } catch { + } catch (e) { sign = false; } } diff --git a/src/app/ui/figures/actions/area/action-hex.html b/src/app/ui/figures/actions/area/action-hex.html index ce180e0f0..30766f8b9 100644 --- a/src/app/ui/figures/actions/area/action-hex.html +++ b/src/app/ui/figures/actions/area/action-hex.html @@ -1,7 +1,7 @@
+ [style.grid-row-end]="hex.y + 1" [title]="ActionHexToString(hex)" (click)="click(hex)"> diff --git a/src/app/ui/figures/actions/area/action-hex.ts b/src/app/ui/figures/actions/area/action-hex.ts index fc9da6892..1c81cc2fc 100644 --- a/src/app/ui/figures/actions/area/action-hex.ts +++ b/src/app/ui/figures/actions/area/action-hex.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, OnChanges, Output } from "@angular/core"; +import { ActionHex, ActionHexFromString, ActionHexToString } from "src/app/game/model/ActionHex"; import { Action } from "src/app/game/model/data/Action"; import { ConditionName } from "src/app/game/model/data/Condition"; -import { ActionHex } from "src/app/game/model/ActionHex"; @Component({ selector: 'ghs-action-hex', @@ -17,6 +17,7 @@ export class ActionHexComponent implements OnChanges { @Output() doubleclickCallback: EventEmitter = new EventEmitter(); hexes: ActionHex[] = []; ActionHex = ActionHex; + ActionHexToString = ActionHexToString; doubleClick: any = null; @@ -26,7 +27,7 @@ export class ActionHexComponent implements OnChanges { this.value = '' + this.action.value; } this.value.split('|').forEach((hexValue) => { - const hex: ActionHex | null = ActionHex.fromString(hexValue); + const hex: ActionHex | null = ActionHexFromString(hexValue); if (hex != null) { this.hexes.push(hex); } diff --git a/src/app/ui/header/menu/datamanagement/datamanagement.ts b/src/app/ui/header/menu/datamanagement/datamanagement.ts index 504e1909e..5e1f82c49 100644 --- a/src/app/ui/header/menu/datamanagement/datamanagement.ts +++ b/src/app/ui/header/menu/datamanagement/datamanagement.ts @@ -30,7 +30,7 @@ export class DatamanagementMenuComponent implements OnInit { if (backups && backups.length > 0) { this.backups = backups.length; } - } catch { + } catch (e) { this.backups = 0; } } @@ -142,7 +142,7 @@ export class DatamanagementMenuComponent implements OnInit { downloadButton.click(); document.body.removeChild(downloadButton); } - } catch { + } catch (e) { console.warn("No game found"); } } @@ -159,7 +159,7 @@ export class DatamanagementMenuComponent implements OnInit { downloadButton.click(); document.body.removeChild(downloadButton); } - } catch { + } catch (e) { console.warn("No backup found"); } } @@ -177,7 +177,7 @@ export class DatamanagementMenuComponent implements OnInit { document.body.removeChild(downloadButton); }) } - } catch { + } catch (e) { console.warn("No backups found"); } } @@ -248,7 +248,7 @@ export class DatamanagementMenuComponent implements OnInit { downloadButton.click(); document.body.removeChild(downloadButton); } - } catch { + } catch (e) { console.warn("No settings found"); } } @@ -360,7 +360,7 @@ export class DatamanagementMenuComponent implements OnInit { gameManager.stateManager.storageBlocked = true; console.info("Reload..."); window.location.reload(); - } catch { + } catch (e) { console.error("Could clear storage"); } } diff --git a/src/app/ui/helper/label.ts b/src/app/ui/helper/label.ts index 2621379e8..d5b37d280 100644 --- a/src/app/ui/helper/label.ts +++ b/src/app/ui/helper/label.ts @@ -2,7 +2,7 @@ import { Directive, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChang import { Subscription } from "rxjs"; import { gameManager } from "src/app/game/businesslogic/GameManager"; import { settingsManager } from "src/app/game/businesslogic/SettingsManager"; -import { ActionHex } from "src/app/game/model/ActionHex"; +import { ActionHex, ActionHexFromString } from "src/app/game/model/ActionHex"; import { Character } from "src/app/game/model/Character"; import { ActionType } from "src/app/game/model/data/Action"; import { AttackModifierValueType } from "src/app/game/model/data/AttackModifier"; @@ -90,7 +90,7 @@ export const applyPlaceholder = function (value: string, placeholder: string[] = } value.split('|').forEach((hexValue) => { - const hex: ActionHex | null = ActionHex.fromString(hexValue); + const hex: ActionHex | null = ActionHexFromString(hexValue); if (hex != null) { replace += ''; } diff --git a/src/app/ui/helper/valueCalc.ts b/src/app/ui/helper/valueCalc.ts index 56c7656d1..096ee1850 100644 --- a/src/app/ui/helper/valueCalc.ts +++ b/src/app/ui/helper/valueCalc.ts @@ -31,7 +31,7 @@ export function valueCalc(value: string | number, level: number | undefined = un if (settingsManager.settings.calculate && (value.match(EntityExpressionRegex) || value.match(EntityValueRegex))) { try { return EntityValueFunction(value, L) - } catch { + } catch (e) { console.error("Could not calculate value for: ", value); return value; } diff --git a/src/app/ui/main.ts b/src/app/ui/main.ts index eef022822..14d2c3082 100644 --- a/src/app/ui/main.ts +++ b/src/app/ui/main.ts @@ -206,7 +206,7 @@ export class MainComponent implements OnInit { document.body.classList.add('no-select'); try { await storageManager.init(); - } catch { + } catch (e) { // continue } await settingsManager.init(!environment.production); @@ -606,7 +606,7 @@ export class MainComponent implements OnInit { document.body.appendChild(downloadButton); downloadButton.click(); document.body.removeChild(downloadButton); - } catch { + } catch (e) { console.warn("Could not read datadump"); } } diff --git a/src/app/ui/tools/editor/action/action.ts b/src/app/ui/tools/editor/action/action.ts index da4bcad6c..c6c78c76c 100644 --- a/src/app/ui/tools/editor/action/action.ts +++ b/src/app/ui/tools/editor/action/action.ts @@ -1,14 +1,14 @@ -import { Dialog, DialogRef, DIALOG_DATA } from "@angular/cdk/dialog"; +import { Dialog, DIALOG_DATA, DialogRef } from "@angular/cdk/dialog"; import { CdkDragDrop, moveItemInArray } from "@angular/cdk/drag-drop"; import { Component, EventEmitter, Inject, Input, OnInit, Output } from "@angular/core"; import { gameManager } from "src/app/game/businesslogic/GameManager"; import { settingsManager } from "src/app/game/businesslogic/SettingsManager"; +import { ActionHex, ActionHexFromString, ActionHexToString, ActionHexType } from "src/app/game/model/ActionHex"; import { Action, ActionCardType, ActionSpecialTarget, ActionType, ActionValueType } from "src/app/game/model/data/Action"; import { Condition, ConditionName, ConditionType } from "src/app/game/model/data/Condition"; -import { SummonData } from "src/app/game/model/data/SummonData"; import { Element } from "src/app/game/model/data/Element"; import { MonsterType } from "src/app/game/model/data/MonsterType"; -import { ActionHex, ActionHexType } from "src/app/game/model/ActionHex"; +import { SummonData } from "src/app/game/model/data/SummonData"; @Component({ selector: 'ghs-editor-action', @@ -45,13 +45,13 @@ export class EditorActionComponent implements OnInit { this.hexAction.value = '' + this.action.value; let hexes: ActionHex[] = []; this.hexAction.value.split('|').forEach((hexValue) => { - const hex: ActionHex | null = ActionHex.fromString(hexValue); + const hex: ActionHex | null = ActionHexFromString(hexValue); if (hex != null) { hexes.push(hex); } }) hexes.forEach((other) => this.fillHexes(other, hexes)); - this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|'); + this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|'); this.change(); } else if (this.action.type == ActionType.condition || this.action.type == ActionType.specialTarget || this.action.type == ActionType.card) { if (('' + this.action.value).indexOf(':') != -1) { @@ -144,7 +144,7 @@ export class EditorActionComponent implements OnInit { let hexes: ActionHex[] = []; ('' + this.hexAction.value).split('|').forEach((hexValue) => { - const hex: ActionHex | null = ActionHex.fromString(hexValue); + const hex: ActionHex | null = ActionHexFromString(hexValue); if (hex != null) { hexes.push(hex); } @@ -160,22 +160,22 @@ export class EditorActionComponent implements OnInit { this.fillHexes(hex, hexes); - this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|'); - this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHex.toString(hex)).join('|'); + this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|'); + this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHexToString(hex)).join('|'); this.change(); } changeHex() { let hexes: ActionHex[] = []; ('' + this.hexAction.value).split('|').forEach((hexValue) => { - const hex: ActionHex | null = ActionHex.fromString(hexValue); + const hex: ActionHex | null = ActionHexFromString(hexValue); if (hex != null) { hexes.push(hex); } }) - this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|'); - this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHex.toString(hex)).join('|'); + this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|'); + this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHexToString(hex)).join('|'); this.change(); } @@ -184,7 +184,7 @@ export class EditorActionComponent implements OnInit { let hexes: ActionHex[] = []; ('' + this.hexAction.value).split('|').forEach((hexValue) => { - const hex: ActionHex | null = ActionHex.fromString(hexValue); + const hex: ActionHex | null = ActionHexFromString(hexValue); if (hex != null) { hexes.push(hex); } @@ -212,8 +212,8 @@ export class EditorActionComponent implements OnInit { hexes.filter((other) => other.type != ActionHexType.invisible).forEach((other) => this.fillHexes(other, hexes)); - this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|'); - this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHex.toString(hex)).join('|'); + this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|'); + this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHexToString(hex)).join('|'); this.change(); } diff --git a/src/app/ui/tools/feedback/feedback-dialog.ts b/src/app/ui/tools/feedback/feedback-dialog.ts index 43f96b286..10dabbccf 100644 --- a/src/app/ui/tools/feedback/feedback-dialog.ts +++ b/src/app/ui/tools/feedback/feedback-dialog.ts @@ -97,7 +97,7 @@ export class FeedbackDialogComponent { document.body.appendChild(downloadButton); downloadButton.click(); document.body.removeChild(downloadButton); - } catch { + } catch (e) { console.warn("Could not read datadump"); } } diff --git a/src/app/ui/tools/standalone/attackmodifier-standalone.ts b/src/app/ui/tools/standalone/attackmodifier-standalone.ts index c5353d30a..6772474a2 100644 --- a/src/app/ui/tools/standalone/attackmodifier-standalone.ts +++ b/src/app/ui/tools/standalone/attackmodifier-standalone.ts @@ -33,7 +33,7 @@ export class AttackModifierStandaloneComponent implements OnInit { async ngOnInit() { try { await storageManager.init(); - } catch { + } catch (e) { // continue } await settingsManager.init(!environment.production); diff --git a/src/app/ui/tools/standalone/loot-deck-standalone.ts b/src/app/ui/tools/standalone/loot-deck-standalone.ts index 5fb31a0dd..e299583c8 100644 --- a/src/app/ui/tools/standalone/loot-deck-standalone.ts +++ b/src/app/ui/tools/standalone/loot-deck-standalone.ts @@ -20,7 +20,7 @@ export class LootDeckStandaloneComponent implements OnInit { async ngOnInit() { try { await storageManager.init(); - } catch { + } catch (e) { // continue } await settingsManager.init(!environment.production);