From b979c7d337b1609fed2e458e3a8fb753971c23ec Mon Sep 17 00:00:00 2001 From: Kyle Kemp Date: Thu, 15 Aug 2024 18:22:44 -0500 Subject: [PATCH] closes #33 --- .../input-quest/input-quest.component.html | 25 +++++++++ .../input-quest/input-quest.component.scss | 0 .../input-quest/input-quest.component.ts | 55 +++++++++++++++++++ src/app/shared/shared.module.ts | 3 + .../items-editor/items-editor.component.html | 5 ++ .../items-editor/items-editor.component.ts | 5 +- 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/app/shared/components/input-quest/input-quest.component.html create mode 100644 src/app/shared/components/input-quest/input-quest.component.scss create mode 100644 src/app/shared/components/input-quest/input-quest.component.ts diff --git a/src/app/shared/components/input-quest/input-quest.component.html b/src/app/shared/components/input-quest/input-quest.component.html new file mode 100644 index 0000000..552ae43 --- /dev/null +++ b/src/app/shared/components/input-quest/input-quest.component.html @@ -0,0 +1,25 @@ +
+ + + +
+
+ {{ item.value }} +
+
+
+ + +
+
+ {{ item.value }} +
+ +

{{ item.desc }}

+
+
+
+ + {{ label() }} +
\ No newline at end of file diff --git a/src/app/shared/components/input-quest/input-quest.component.scss b/src/app/shared/components/input-quest/input-quest.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/shared/components/input-quest/input-quest.component.ts b/src/app/shared/components/input-quest/input-quest.component.ts new file mode 100644 index 0000000..11d6499 --- /dev/null +++ b/src/app/shared/components/input-quest/input-quest.component.ts @@ -0,0 +1,55 @@ +import { + Component, + computed, + inject, + input, + model, + OnInit, + output, +} from '@angular/core'; +import { IQuest } from '../../../../interfaces'; +import { ModService } from '../../../services/mod.service'; + +@Component({ + selector: 'app-input-quest', + templateUrl: './input-quest.component.html', + styleUrl: './input-quest.component.scss', +}) +export class InputQuestComponent implements OnInit { + private modService = inject(ModService); + + public quest = model(); + public defaultValue = input(); + public label = input('Quest'); + public change = output(); + + public values = computed(() => { + const mod = this.modService.mod(); + + return [ + ...mod.quests.map((q) => ({ + value: q.name, + desc: `[${q.giver}] ${q.desc}`, + })), + ]; + }); + + ngOnInit() { + const defaultItem = this.defaultValue(); + if (defaultItem) { + const foundItem = this.values().find((i) => i.value === defaultItem); + this.quest.set(foundItem as unknown as IQuest); + } + } + + public itemCompare( + itemA: { value: string; desc: string }, + itemB: { value: string; desc: string } + ): boolean { + return itemA.value === itemB.value; + } + + public search(term: string, item: { value: string }) { + return item.value.toLowerCase().includes(term.toLowerCase()); + } +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index a53d253..05d62f0 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -45,6 +45,7 @@ import { InputQuestrewardComponent } from './components/input-questreward/input- import { InputMapnpcComponent } from './components/input-mapnpc/input-mapnpc.component'; import { SpriteWithInlineNameComponent } from './components/sprite-with-inline-name/sprite-with-inline-name.component'; import { InputRecipeComponent } from './components/input-recipe/input-recipe.component'; +import { InputQuestComponent } from './components/input-quest/input-quest.component'; @NgModule({ declarations: [ @@ -86,6 +87,7 @@ import { InputRecipeComponent } from './components/input-recipe/input-recipe.com InputMapnpcComponent, SpriteWithInlineNameComponent, InputRecipeComponent, + InputQuestComponent, ], imports: [ CommonModule, @@ -135,6 +137,7 @@ import { InputRecipeComponent } from './components/input-recipe/input-recipe.com InputMapnpcComponent, SpriteWithInlineNameComponent, InputRecipeComponent, + InputQuestComponent, ], }) export class SharedModule {} diff --git a/src/app/tabs/items/items-editor/items-editor.component.html b/src/app/tabs/items/items-editor/items-editor.component.html index 42f7e85..bd80c62 100644 --- a/src/app/tabs/items/items-editor/items-editor.component.html +++ b/src/app/tabs/items/items-editor/items-editor.component.html @@ -500,6 +500,11 @@ + +
+ +
} diff --git a/src/app/tabs/items/items-editor/items-editor.component.ts b/src/app/tabs/items/items-editor/items-editor.component.ts index 7b9ffdb..9307453 100644 --- a/src/app/tabs/items/items-editor/items-editor.component.ts +++ b/src/app/tabs/items/items-editor/items-editor.component.ts @@ -128,7 +128,7 @@ export class ItemsEditorComponent item.useEffect ??= { name: '', potency: 0, duration: 0 }; item.equipEffect ??= { name: '', potency: 0 }; item.breakEffect ??= { name: '', potency: 0 }; - item.requirements ??= { baseClass: undefined, level: 0 }; + item.requirements ??= { baseClass: undefined, level: 0, quest: undefined }; item.cosmetic ??= { name: '', isPermanent: false }; item.trait ??= { name: '', level: 0 }; item.randomTrait ??= { name: [], level: { min: 0, max: 0 } }; @@ -348,7 +348,8 @@ export class ItemsEditorComponent if ( item.requirements && !item.requirements.baseClass && - !item.requirements.level + !item.requirements.level && + !item.requirements.quest ) { delete item.requirements; }