diff --git a/libs/features/quest/src/index.ts b/libs/features/quest/src/index.ts index 9a7c36713f..792d404928 100644 --- a/libs/features/quest/src/index.ts +++ b/libs/features/quest/src/index.ts @@ -4,6 +4,7 @@ export * from './gameobject-questender/gameobject-questender.component'; export * from './gameobject-queststarter/gameobject-queststarter.component'; export * from './quest-offer-reward/quest-offer-reward.component'; export * from './quest-preview/quest-preview.component'; +export * from './quest-preview/quest-objectives.component'; export * from './quest-request-items/quest-request-items.component'; export * from './quest-template/quest-template.component'; export * from './quest-template-addon/quest-template-addon.component'; diff --git a/libs/features/quest/src/quest-preview/quest-objectives.component.html b/libs/features/quest/src/quest-preview/quest-objectives.component.html new file mode 100644 index 0000000000..c1ff30b1d2 --- /dev/null +++ b/libs/features/quest/src/quest-preview/quest-objectives.component.html @@ -0,0 +1,39 @@ +
+

Objectives

+ +
+ {{ objectiveText() }} +
+ @if (areaDescription()) { +

+ {{ areaDescription() }} +

+ } + +
+ @for (obj of npcObjectives(); track obj) { +

+ • {{ obj.text$ | async }} {{ obj.count }} +

+ } +
+ +
+ @for (obj of itemObjectives(); track obj) { +

+ •   + {{ obj.name$ | async }} + {{ obj.count }} +

+ } +
+ +
+ @for (f of factionRequirements(); track f) { +

+ • {{ f.name$ | async }} + {{ f.value }} +

+ } +
+
diff --git a/libs/features/quest/src/quest-preview/quest-objectives.component.scss b/libs/features/quest/src/quest-preview/quest-objectives.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/features/quest/src/quest-preview/quest-objectives.component.ts b/libs/features/quest/src/quest-preview/quest-objectives.component.ts new file mode 100644 index 0000000000..2e967e06c3 --- /dev/null +++ b/libs/features/quest/src/quest-preview/quest-objectives.component.ts @@ -0,0 +1,35 @@ +import { AsyncPipe } from '@angular/common'; +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; +import { IconComponent } from '@keira/shared/base-editor-components'; + +export interface NpcOrGoObjective { + text$: Promise; + count: string; +} + +export interface ItemObjective { + id: number; + name$: Promise; + count: string; +} + +export interface FactionRequirement { + name$: Promise; + value: string; +} + +@Component({ + selector: 'keira-quest-objectives', + templateUrl: './quest-objectives.component.html', + styleUrls: ['./quest-objectives.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [IconComponent, AsyncPipe], +}) +export class QuestObjectivesComponent { + readonly objectiveText = input.required(); + readonly areaDescription = input(); + readonly npcObjectives = input([]); + readonly itemObjectives = input([]); + readonly factionRequirements = input([]); +} diff --git a/libs/features/quest/src/quest-preview/quest-preview.component.html b/libs/features/quest/src/quest-preview/quest-preview.component.html index 4a7ce1b5a2..a391aa03ee 100644 --- a/libs/features/quest/src/quest-preview/quest-preview.component.html +++ b/libs/features/quest/src/quest-preview/quest-preview.component.html @@ -186,53 +186,13 @@
{{ service.title }}
} -
-

Objectives

- -
- {{ service.objectiveText }} -
- @if (!!service.questTemplate.AreaDescription) { -

- {{ service.questTemplate.AreaDescription }} -

- } - -
- @for (i of [1, 2, 3, 4]; track i) { - @if (service.isNpcOrGoObj(i)) { -

- • {{ !!service.getObjText(i) ? service.getObjText(i) : (service.getObjective$(i) | async) }} - {{ service.getObjectiveCount(i) }} -

- } - } -
- -
- @for (i of [1, 2, 3, 4, 5, 6]; track i) { - @if (service.questTemplate['RequiredItemId' + i]; as reqItem) { -

- •  {{ - service.mysqlQueryService.getItemNameById(reqItem) | async - }} - {{ service.getObjItemCount(i) }} -

- } - } -
- -
- @for (i of [1, 2]; track i) { - @if (service.questTemplate['RequiredFactionId' + i]; as reqFaction) { -

- • {{ service.sqliteQueryService.getFactionNameById(reqFaction) | async }} - {{ service.getFactionByValue(i) }} -

- } - } -
-
+

Description diff --git a/libs/features/quest/src/quest-preview/quest-preview.component.ts b/libs/features/quest/src/quest-preview/quest-preview.component.ts index c405187bb7..c0c96a2967 100644 --- a/libs/features/quest/src/quest-preview/quest-preview.component.ts +++ b/libs/features/quest/src/quest-preview/quest-preview.component.ts @@ -1,6 +1,12 @@ import { AsyncPipe } from '@angular/common'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, OnInit } from '@angular/core'; import { IconComponent } from '@keira/shared/base-editor-components'; +import { + FactionRequirement, + ItemObjective, + NpcOrGoObjective, + QuestObjectivesComponent, +} from './quest-objectives.component'; import { RacesTextKey, RacesTextValue } from '@keira/shared/constants'; import { PreviewHelperService } from '@keira/shared/preview'; import { CollapseModule } from 'ngx-bootstrap/collapse'; @@ -13,7 +19,7 @@ import { QuestPreviewService } from './quest-preview.service'; selector: 'keira-quest-preview', templateUrl: './quest-preview.component.html', styleUrls: ['./quest-preview.component.scss'], - imports: [IconComponent, CollapseModule, AsyncPipe], + imports: [IconComponent, CollapseModule, AsyncPipe, QuestObjectivesComponent], }) export class QuestPreviewComponent implements OnInit { private readonly changeDetectorRef = inject(ChangeDetectorRef); @@ -72,4 +78,45 @@ export class QuestPreviewComponent implements OnInit { hasPrevOrNext(questLists: { prev?: Quest[] | null; next?: Quest[] | null }): boolean { return !!(questLists.prev && questLists.prev.length > 0) || !!(questLists.next && questLists.next.length > 0); } + + get npcObjectivesData(): NpcOrGoObjective[] { + const array: NpcOrGoObjective[] = []; + for (let i = 1; i <= 4; i++) { + if (this.service.isNpcOrGoObj(i)) { + const text = this.service.getObjText(i); + const text$ = text ? Promise.resolve(text) : this.service.getObjective$(i); + array.push({ text$, count: this.service.getObjectiveCount(i) }); + } + } + return array; + } + + get itemObjectivesData(): ItemObjective[] { + const array: ItemObjective[] = []; + for (let i = 1; i <= 6; i++) { + const reqItem = this.service.questTemplate['RequiredItemId' + i]; + if (reqItem) { + array.push({ + id: reqItem, + name$: this.service.mysqlQueryService.getItemNameById(reqItem), + count: this.service.getObjItemCount(i), + }); + } + } + return array; + } + + get factionRequirementsData(): FactionRequirement[] { + const array: FactionRequirement[] = []; + for (let i = 1; i <= 2; i++) { + const reqFaction = this.service.questTemplate['RequiredFactionId' + i]; + if (reqFaction) { + array.push({ + name$: this.service.sqliteQueryService.getFactionNameById(reqFaction), + value: this.service.getFactionByValue(i), + }); + } + } + return array; + } }