Skip to content

Commit

Permalink
fix entities/conditions dialog, add shortcuts to entities menu, direc…
Browse files Browse the repository at this point in the history
…tly remove unused monsters when set
  • Loading branch information
Lurkars committed Jun 9, 2024
1 parent fc6516f commit b8d3077
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 76 deletions.
115 changes: 65 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gloomhavensecretariat",
"version": "0.99.5",
"version": "0.99.6",
"license": "AGPL3",
"description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.",
"homepage": "https://gloomhaven-secretariat.de",
Expand Down Expand Up @@ -91,8 +91,8 @@
"ng-in-viewport": "^16.1.0",
"rxjs": "~7.8.1",
"tslib": "^2.6.3",
"uuid": "^9.0.1",
"zone.js": "~0.14.6"
"uuid": "^10.0.0",
"zone.js": "~0.14.7"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.0.3",
Expand Down
5 changes: 5 additions & 0 deletions src/app/game/businesslogic/GameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export class GameManager {
this.scenarioRulesManager.addScenarioRulesAlways();
this.scenarioRulesManager.applyScenarioRulesAlways();
}
if (settingsManager.settings.removeUnusedMonster) {
this.game.figures.filter((figure) => figure instanceof Monster && figure.off && figure.entities.length == 0).forEach((figure) => {
this.monsterManager.removeMonster(figure as Monster);
})
}
this.roundManager.firstRound = this.game.round == 0 && this.game.roundResets.length == 0 && this.game.roundResetsHidden.length == 0;
}
})
Expand Down
9 changes: 0 additions & 9 deletions src/app/game/businesslogic/MonsterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ export class MonsterManager {
}

next() {
let removeMonster: Monster[] = [];
this.game.figures.forEach((figure) => {
if (figure instanceof Monster) {
const ability = this.getAbility(figure);
Expand Down Expand Up @@ -654,16 +653,8 @@ export class MonsterManager {
})

figure.off = figure.entities.length == 0;

if (figure.off && settingsManager.settings.removeUnusedMonster) {
removeMonster.push(figure);
}
}
})

removeMonster.forEach((monster) => {
this.removeMonster(monster);
})
}

draw() {
Expand Down
14 changes: 4 additions & 10 deletions src/app/ui/figures/conditions/conditions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Component, EventEmitter, HostListener, Input, OnInit, Output } from "@angular/core";
import { GameManager, gameManager } from "src/app/game/businesslogic/GameManager";
import { SettingsManager, settingsManager } from "src/app/game/businesslogic/SettingsManager";
import { Character } from "src/app/game/model/Character";
import { Entity } from "src/app/game/model/Entity";
import { Figure } from "src/app/game/model/Figure";
import { Monster } from "src/app/game/model/Monster";
import { MonsterEntity } from "src/app/game/model/MonsterEntity";
import { ObjectiveContainer } from "src/app/game/model/ObjectiveContainer";
import { Condition, ConditionName, ConditionType, EntityCondition, EntityConditionState } from "src/app/game/model/data/Condition";
Expand Down Expand Up @@ -146,18 +144,14 @@ export class ConditionsComponent implements OnInit {
immune = this.immunities.indexOf(conditionName) != -1;
}

if (!immune && this.figure instanceof Monster) {
if (!(this.entity instanceof MonsterEntity)) {
immune = this.entities.every((entity) => this.figure instanceof Monster && entity instanceof MonsterEntity && gameManager.entityManager.isImmune(entity, this.figure, conditionName, true));
} else {
if (!immune) {
if (this.entity) {
immune = gameManager.entityManager.isImmune(this.entity, this.figure, conditionName, true);
} else if (this.entities) {
immune = this.entities.every((entity) => gameManager.entityManager.isImmune(entity, this.figure, conditionName, true));
}
}

if (!immune && this.figure instanceof Character) {
immune = gameManager.entityManager.isImmune(this.entity, this.figure, conditionName, true);
}

return immune;
}

Expand Down
29 changes: 28 additions & 1 deletion src/app/ui/figures/entities-menu/entities-menu-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DialogRef, DIALOG_DATA } from "@angular/cdk/dialog";
import { Component, Inject } from "@angular/core";
import { Component, HostListener, Inject } from "@angular/core";
import { GameManager, gameManager } from "src/app/game/businesslogic/GameManager";
import { SettingsManager, settingsManager } from "src/app/game/businesslogic/SettingsManager";
import { ConditionName, ConditionType, EntityCondition, EntityConditionState } from "src/app/game/model/data/Condition";
Expand Down Expand Up @@ -66,6 +66,33 @@ export class EntitiesMenuDialogComponent {
this.update();
}

@HostListener('document:keydown', ['$event'])
keyboardShortcuts(event: KeyboardEvent) {
if (!event.altKey && !event.metaKey && (!window.document.activeElement || window.document.activeElement.tagName != 'INPUT' && window.document.activeElement.tagName != 'SELECT' && window.document.activeElement.tagName != 'TEXTAREA')) {
if (!event.ctrlKey && !event.shiftKey && event.key === 'ArrowRight') {
this.changeHealth(1);
event.preventDefault();
event.stopPropagation();
} else if (!event.ctrlKey && !event.shiftKey && event.key === 'ArrowLeft') {
this.changeHealth(-1);
event.preventDefault();
event.stopPropagation();
} else if (!event.ctrlKey && !event.shiftKey && event.key === 'ArrowUp') {
this.changeMaxHealth(1);
event.preventDefault();
event.stopPropagation();
} else if (!event.ctrlKey && !event.shiftKey && event.key === 'ArrowDown') {
this.changeMaxHealth(-1);
event.preventDefault();
event.stopPropagation();
} else if (!event.ctrlKey && !event.shiftKey && (event.key.toLowerCase() === 'k' || event.key.toLowerCase() === 'd')) {
this.toggleDead();
event.preventDefault();
event.stopPropagation();
}
}
}

update() {
this.entityConditions = [];

Expand Down
2 changes: 1 addition & 1 deletion src/assets/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@
},
"removeUnusedMonster": {
".": "Nicht genutze Monster entfernen",
"hint": "Entferne automatische alle nicht genutzen Monster am Ende der Runde"
"hint": "Entferne automatische alle nicht genutzen Monster"
},
"scenarioNumberInput": {
".": "Numerische Szenario Eingabe",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@
},
"removeUnusedMonster": {
".": "Remove unused",
"hint": "Automatically remove all unused monsters at end of round."
"hint": "Automatically remove all unused monsters."
},
"scenarioNumberInput": {
".": "Scenario Number Input",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@
},
"removeUnusedMonster": {
".": "Retirer les monstres inutilisés",
"hint": "Supprime automatiquement tous les monstres inutilisés à la fin du tour."
"hint": "Supprime automatiquement tous les monstres inutilisés."
},
"scenarioNumberInput": {
".": "Numéro de scénario Entrée"
Expand Down

0 comments on commit b8d3077

Please sign in to comment.