Skip to content

Commit

Permalink
implement trial of victory, fix draw new trial
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed Nov 5, 2024
1 parent 61ffc41 commit 692b0e5
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 23 deletions.
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
],
"allowedCommonJsDependencies": [
"autocompleter",
"leaflet"
"leaflet",
"mermaid"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
Expand Down
3 changes: 2 additions & 1 deletion data/fh/trials.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"cardId": 359
},
{
"cardId": 360
"cardId": 360,
"automation": "fully"
}
]
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.102.6",
"version": "0.102.7",
"license": "AGPL3",
"description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.",
"homepage": "https://gloomhaven-secretariat.de",
Expand Down Expand Up @@ -86,7 +86,7 @@
"private": true,
"dependencies": {
"@angular/animations": "^18.2.10",
"@angular/cdk": "^18.2.10",
"@angular/cdk": "^18.2.11",
"@angular/common": "^18.2.10",
"@angular/compiler": "^18.2.10",
"@angular/core": "^18.2.10",
Expand All @@ -100,7 +100,7 @@
"mermaid": "^10.9.1",
"ng-in-viewport": "^16.1.0",
"rxjs": "~7.8.1",
"tslib": "^2.8.0",
"tslib": "^2.8.1",
"uuid": "^11.0.2",
"zone.js": "~0.14.10"
},
Expand Down
7 changes: 6 additions & 1 deletion src/app/game/businesslogic/BattleGoalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export class BattleGoalManager {
}

drawBattleGoal(character: Character, splice: boolean = false) {
const battleGoals = this.getBattleGoals().filter((battleGoal) => !this.game.figures.find((figure) => figure instanceof Character && figure.battleGoals && figure.battleGoals.find((identifier) => battleGoal.edition == identifier.edition && battleGoal.name == identifier.name)));
let battleGoals = this.getBattleGoals().filter((battleGoal) => !this.game.figures.find((figure) => figure instanceof Character && figure.battleGoals && figure.battleGoals.find((identifier) => battleGoal.edition == identifier.edition && battleGoal.name == identifier.name)));

if (gameManager.trialsManager.apply && gameManager.trialsManager.activeTrial('fh', 360)) {
battleGoals = battleGoals.filter((battleGoal) => battleGoal.checks == 2);
}

let battleGoal = battleGoals[Math.floor(Math.random() * battleGoals.length)];
character.battleGoals = character.battleGoals || [];
if (splice && character.battleGoals.length > 2) {
Expand Down
12 changes: 7 additions & 5 deletions src/app/game/businesslogic/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,15 @@ export class SettingsManager {
return result;
};

getEditionByUrl(url: string) {
if (!gameManager.editionData.some((editionData) => editionData.url == url)) {
console.error("No edition data found for url '" + url + "'");
return;
getEditionByUrl(url: string) : string {
const editionData = gameManager.editionData.find((editionData) => editionData.url == url);

if (editionData) {
return editionData.url;
}

return gameManager.editionData.find((editionData) => editionData.url == url)?.edition;
console.error("No edition data found for url '" + url + "'");
return "";
}

async addEditionDataUrl(editionDataUrl: string): Promise<EditionData | undefined> {
Expand Down
19 changes: 13 additions & 6 deletions src/app/game/businesslogic/TrialsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,22 @@ export class TrialsManager {
})
}
} else {
this.game.party.trials = -1;
this.game.figures.forEach((figure) => {
if (figure instanceof Character && figure.progress.trial) {
figure.progress.trial = undefined;
}
})
const hall = gameManager.fhRules() && this.game.party.buildings.find((buildingModel) => buildingModel.name == 'hall-of-revelry' && buildingModel.level == 1);
if (!hall) {
this.game.party.trials = -1;
this.game.figures.forEach((figure) => {
if (figure instanceof Character && figure.progress.trial) {
figure.progress.trial = undefined;
}
})
}
}
}

activeTrial(edition: string, cardId: number): boolean {
return this.trialsEnabled && this.game.figures.find((figure) => figure instanceof Character && figure.progress.trial && figure.progress.trial.edition == edition && figure.progress.trial.name == '' + cardId) != undefined;
}

applyFavorPoints() {
this.game.favorPoints.forEach((point) => {
const attackModifier = this.game.monsterAttackModifierDeck.cards.find((am) => point == 1 ? am.type == AttackModifierType.minus1 : am.type == AttackModifierType.minus2);
Expand Down
6 changes: 4 additions & 2 deletions src/app/ui/figures/battlegoal/dialog/battlegoal-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ export class CharacterBattleGoalsDialog implements OnDestroy {
this.character.battleGoals = [];
this.character.battleGoal = false;
gameManager.battleGoalManager.drawBattleGoal(this.character);
gameManager.battleGoalManager.drawBattleGoal(this.character);
if (gameManager.fhRules() || settingsManager.settings.battleGoalsFh) {
if (!gameManager.trialsManager.apply || !gameManager.trialsManager.activeTrial('fh', 360)) {
gameManager.battleGoalManager.drawBattleGoal(this.character);
if (gameManager.fhRules() || settingsManager.settings.battleGoalsFh) {
gameManager.battleGoalManager.drawBattleGoal(this.character);
}
}
gameManager.stateManager.after();
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/ui/figures/party/party-sheet-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ export class PartySheetDialogComponent implements OnInit, OnDestroy {
}
})
this.update();

this.dialogRef.closed.subscribe({
next: () => {
gameManager.trialsManager.applyTrialCards();
}
})
}

uiChangeSubscription: Subscription | undefined;
Expand Down
9 changes: 6 additions & 3 deletions src/app/ui/figures/party/scenario-chart/scenario-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,14 @@ export class ScenarioChartDialogComponent implements OnInit, AfterViewInit {
var parser = new DOMParser();
var svgElement = parser.parseFromString(svg, "image/svg+xml").lastChild as SVGElement;

let subgraphs = svgElement.getElementsByClassName('clusters').length ? svgElement.getElementsByClassName('clusters')[0].getElementsByTagName("rect") : [];
let subgraphs: HTMLCollectionOf<SVGRectElement> | undefined[] = svgElement.getElementsByClassName('clusters').length ? svgElement.getElementsByClassName('clusters')[0].getElementsByTagName("rect") : [];

for (let i = 0; i < subgraphs.length; i++) {
subgraphs[i].setAttribute("rx", "20");
subgraphs[i].setAttribute("ry", "20");
const subgraph = subgraphs[i];
if (subgraph) {
subgraph.setAttribute("rx", "20");
subgraph.setAttribute("ry", "20");
}
}

const viewBox = svgElement.getAttribute('viewBox') || "0 0 600 600";
Expand Down
2 changes: 2 additions & 0 deletions src/app/ui/footer/scenario/summary/scenario-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ export class ScenarioSummaryComponent implements OnDestroy {
if (gameManager.challengesManager.enabled && this.challenges) {
gameManager.game.challengeDeck.finished += this.challenges;
}

gameManager.trialsManager.applyTrialCards();
}
if (this.conclusionOnly) {
gameManager.scenarioManager.finishScenario(this.scenario, true, this.conclusion, false, undefined, settingsManager.settings.scenarioRewards && (this.characterProgress || this.forceCampaign), this.gainRewards || this.forceCampaign, true);
Expand Down
3 changes: 2 additions & 1 deletion src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ body {
--ghs-filter-blue: invert(72%) sepia(96%) saturate(1077%) hue-rotate(164deg) brightness(97%) contrast(94%);
--ghs-filter-green: invert(56%) sepia(53%) saturate(536%) hue-rotate(39deg) brightness(95%) contrast(93%);
--ghs-filter-red: invert(26%) sepia(70%) saturate(2000%) hue-rotate(348deg) brightness(104%) contrast(97%);
--ghs-filter-darkred: invert(10%) sepia(24%) saturate(6391%) hue-rotate(357deg) brightness(92%) contrast(106%);
--ghs-filter-brown: brightness(0) saturate(100%) invert(21%) sepia(11%) saturate(2303%) hue-rotate(347deg) brightness(93%) contrast(89%);
--ghs-filter-shadow: drop-shadow(2px 2px 2px var(--ghs-color-darkgray));
--ghs-filter-shadow-thin: drop-shadow(1px 1px 1px var(--ghs-color-darkgray));
Expand Down Expand Up @@ -879,7 +880,7 @@ ghs-pointer-input {
filter: none;

img {
filter: var(--ghs-filter-gray);
filter: var(--ghs-filter-darkred);
}
}

Expand Down

0 comments on commit 692b0e5

Please sign in to comment.