Skip to content

Commit

Permalink
fix scenario summary, improve AM deck rolling behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed Jan 16, 2024
1 parent 87421e2 commit 6d3662d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gloomhavensecretariat",
"version": "0.84.8",
"version": "0.84.9",
"license": "AGPL3",
"description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.",
"homepage": "https://gloomhaven-secretariat.de",
Expand Down
18 changes: 9 additions & 9 deletions src/app/ui/figures/attackmodifier/attackmodifierdeck.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
[ghs-label-attribute]="'title'" [ngClass]="{'town-guard' : townGuard, 'disabled' : disabled }">
<span class="number" [ngClass]="{'has-shuffle' : deck.current == deck.cards.length -1}"> {{ deck.current <
deck.cards.length - 1 ? (deck.cards.length - deck.current - 1) + '/' + deck.cards.length : '' }} </span>
<img *ngIf="deck.current == deck.cards.length -1" class="shuffle" [ghs-label]="'game.cards.openDialog'"
[ghs-label-attribute]="'title'" src="./assets/images/shuffle.svg">
<img *ngIf="deck.current == deck.cards.length -1" class="shuffle" [ghs-label]="'game.cards.openDialog'"
[ghs-label-attribute]="'title'" src="./assets/images/shuffle.svg">

<span *ngIf="!characterIcon && !townGuard && !bottom" class="numeration">{{numeration}}</span>
<span *ngIf="characterIcon && !bottom" class="character-icon">
<img [src]="characterIcon" />
</span>
<span *ngIf="!characterIcon && !townGuard && !bottom" class="numeration">{{numeration}}</span>
<span *ngIf="characterIcon && !bottom" class="character-icon">
<img [src]="characterIcon" />
</span>
</div>

<span class="fullscreen" [ghs-label]="'game.cards.fullscreen'" [ghs-label-attribute]="'title'"
Expand All @@ -44,9 +44,9 @@
<div class="am-container"
*ngIf="index <= current + 1 && (rollingIndex[index] > 0 || index > current - 3 || index >= current && attackModifier.active && deck.disgarded.indexOf(index) == -1)"
[style.z-index]="index > current ? deck.cards.length - index : deck.cards.length + index + 1"
[ngClass]="{'disgarded' : index < current - 1, 'current' : index == current, 'last' : index == current - 1, 'bottom' : bottom, 'rolling' : attackModifier.rolling && index <= current, 'active' : attackModifier.active && index <= current && deck.disgarded.indexOf(index) == -1, 'disgard-active': deck.disgarded.indexOf(index) != -1, 'animate' : index < current - 1 && rollingIndex[index] > rollingIndexPrev[index], 'animate-reverse' : index < current - 1 && rollingIndex[index] < rollingIndexPrev[index], 'disabled' : disabled}"
[style.left]="attackModifier.rolling && !vertical && rollingIndex[index] ? 'calc(75% + ' + (rollingIndex[index] - 1) + ' * 25%)' : ''"
[style.top]="attackModifier.rolling && vertical && rollingIndex[index] ? 'calc(' + (rollingIndex[index] - 1) * (drawCard.offsetHeight / 1.3) + 'px)' : ''"
[ngClass]="{'disgarded' : index < current - 1, 'current' : index == current, 'last' : index == current - 1, 'bottom' : bottom, 'rolling' : (attackModifier.rolling || rollingIndex[index]) && index <= current, 'active' : attackModifier.active && index <= current && deck.disgarded.indexOf(index) == -1, 'disgard-active': deck.disgarded.indexOf(index) != -1, 'animate' : index < current - 1 && rollingIndex[index] > rollingIndexPrev[index], 'animate-reverse' : index < current - 1 && rollingIndex[index] < rollingIndexPrev[index], 'disabled' : disabled}"
[style.left]="!vertical && rollingIndex[index] ? 'calc(75% + ' + (rollingIndex[index] - 1) + ' * 25%)' : ''"
[style.top]="vertical && rollingIndex[index] ? 'calc(' + (rollingIndex[index] - 1) * (drawCard.offsetHeight / 1.3) + 'px)' : ''"
[ghs-label]="'game.cards.openDialog'" [ghs-label-attribute]="'title'" (click)="clickCard(index, $event)">
<ghs-attackmodifier class="am" [attackModifier]="attackModifier" [numeration]="numeration"
[characterIcon]="characterIcon" [ally]="ally" [flipped]="index <= current"
Expand Down
22 changes: 14 additions & 8 deletions src/app/ui/figures/attackmodifier/attackmodifierdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ export class AttackModifierDeckComponent implements OnInit, OnDestroy, OnChanges
this.current = this.deck.current;
this.compact = !this.drawing && this.fullscreen && settingsManager.settings.automaticAttackModifierFullscreen && settingsManager.settings.portraitMode && (window.innerWidth < 800 || window.innerHeight < 400);

this.deck.cards.forEach((card, index) => {
this.rollingIndex[index] = this.calcRollingIndex(index, this.current);
this.rollingIndexPrev[index] = this.calcRollingIndex(index, this.current - 1);
});
this.calcRolling();

if (!this.init) {
this.drawTimeout = setTimeout(() => {
Expand Down Expand Up @@ -194,10 +191,7 @@ export class AttackModifierDeckComponent implements OnInit, OnDestroy, OnChanges
this.newStyle = true;
}

this.deck.cards.forEach((card, index) => {
this.rollingIndex[index] = this.calcRollingIndex(index, this.current);
this.rollingIndexPrev[index] = this.calcRollingIndex(index, this.current - 1);
});
this.calcRolling();

this.compact = settingsManager.settings.automaticAttackModifierFullscreen && settingsManager.settings.portraitMode && (window.innerWidth < 800 || window.innerHeight < 400);
}
Expand Down Expand Up @@ -277,6 +271,18 @@ export class AttackModifierDeckComponent implements OnInit, OnDestroy, OnChanges
event.stopPropagation();
}

calcRolling() {
this.deck.cards.forEach((card, index) => {
this.rollingIndex[index] = this.calcRollingIndex(index, this.current);
this.rollingIndexPrev[index] = this.calcRollingIndex(index, this.current - 1);
});

this.deck.cards.forEach((card, index) => {
if (this.current > 1 && !card.rolling && index < (this.current - 1) && this.deck.cards[index + 1].rolling && this.deck.cards[this.current - 1].rolling && (this.rollingIndex[index + 1] || index == this.current - 2)) {
this.rollingIndex[index] = this.rollingIndex[index + 1] + (index == this.current - 2 ? 2 : 1);
}
})
}

calcRollingIndex(index: number, current: number): number {
const am: AttackModifier = this.deck.cards[index];
Expand Down
12 changes: 1 addition & 11 deletions src/app/ui/footer/scenario/summary/scenario-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,17 +620,7 @@ export class ScenarioSummaryComponent {
}

if (settingsManager.settings.scenarioRewards && this.success) {
gameManager.game.figures.filter((figure) => figure instanceof Character).map((figure) => figure as Character).sort((a, b) => {
const aName = gameManager.characterManager.characterName(a).toLowerCase();
const bName = gameManager.characterManager.characterName(b).toLowerCase();
if (aName > bName) {
return 1;
}
if (aName < bName) {
return -1;
}
return 0;
}).forEach((character, index) => {
this.characters.forEach((character, index) => {
if (!character.absent) {
if (this.battleGoals[index] > 0) {
character.progress.battleGoals += this.battleGoals[index];
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/header/menu/scenario/scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export class ScenarioMenuComponent implements OnInit, OnDestroy {
this.groups = [];
}

this.groups = gameManager.scenarioManager.scenarioData(this.edition, true).map((scenarioData) => scenarioData.group).filter((value, index, self) => value && self.indexOf(value) === index).sort((a, b) => a && b && (a.toLowerCase() < b.toLowerCase() ? -1 : 1) || 0);
this.groups = [undefined, ...this.groups];
const groups = gameManager.scenarioManager.scenarioData(this.edition, true).map((scenarioData) => scenarioData.group).filter((value, index, self) => value && self.indexOf(value) === index).sort((a, b) => a && b && (a.toLowerCase() < b.toLowerCase() ? -1 : 1) || 0);
this.groups = [undefined, ...groups];
}

scenarios(group: string | undefined = undefined, filterSuccess: boolean = false, includeSpoiler: boolean = false, all: boolean = false): ScenarioCache[] {
Expand Down

0 comments on commit 6d3662d

Please sign in to comment.