Skip to content

Commit

Permalink
closes #54
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 19, 2024
1 parent d5e3d64 commit 5696494
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>
</div>

@for(drop of editingData.drops; track $index) {
@for(drop of sortDrops(editingData.drops); track $index) {
<div class="form-row split">
<div class="form-column">
<div class="form-row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Component, computed, signal } from '@angular/core';
import { Holiday, IDroptable, IItemDefinition } from '../../../../interfaces';
import { sortBy } from 'lodash';
import {
Holiday,
IDroptable,
IItemDefinition,
Rollable,
} from '../../../../interfaces';
import { EditorBaseComponent } from '../../../shared/components/editor-base/editor-base.component';

@Component({
Expand Down Expand Up @@ -48,4 +54,8 @@ export class DroptablesEditorComponent extends EditorBaseComponent<IDroptable> {
if (!item) return false;
return this.editing().drops.some((d) => d.result === item.name);
}

public sortDrops(drops: Rollable[]): Rollable[] {
return sortBy(drops, 'result');
}
}
4 changes: 2 additions & 2 deletions src/app/tabs/items/items-editor/items-editor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
</div>
</div>

@for(item of editingData.containedItems; track $index) {
@for(item of sortContainedItems(editingData.containedItems || []); track $index) {
<div class="form-row split">
<div class="form-column">
<div class="form-row pl-1">
Expand Down Expand Up @@ -417,7 +417,7 @@
</div>
</div>

@for(traitName of editingData.randomTrait.name; track $index) {
@for(traitName of sortRandomTraits(editingData.randomTrait.name); track $index) {
<div class="form-row split">
<div class="form-column">
<div class="form-row">
Expand Down
13 changes: 12 additions & 1 deletion src/app/tabs/items/items-editor/items-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { isNumber, sortBy } from 'lodash';
import {
IItemDefinition,
ItemClassType,
Rollable,
StatBlock,
StatType,
} from '../../../../interfaces';
Expand Down Expand Up @@ -364,7 +365,7 @@ export class ItemsEditorComponent
private extractStats(item: IItemDefinition) {
this.extractSetStats(item.stats);

Object.keys(item.randomStats).forEach((statKey) => {
Object.keys(item.randomStats ?? {}).forEach((statKey) => {
const stat = statKey as StatType;
const value = item.randomStats?.[stat] ?? { min: 0, max: 0 };
this.allStatEdits.update((s) => [
Expand All @@ -380,6 +381,8 @@ export class ItemsEditorComponent
if (item.randomTrait.name.length > 0) {
this.currentTraitTab.set('random');
}

console.log(item, item.randomTrait, item.trait);
}

private extractSetStats(stats: StatBlock) {
Expand Down Expand Up @@ -569,6 +572,14 @@ export class ItemsEditorComponent
this.editing.set(item);
}

public sortContainedItems(items: Rollable[]): Rollable[] {
return sortBy(items, 'result');
}

public sortRandomTraits(items: string[]): string[] {
return sortBy(items);
}

public doSave() {
const item = this.editing();
this.assignStats(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
</div>


@for(npc of editingData.npcIds; track $index) {
@for(npc of sortNPCIds(editingData.npcIds); track $index) {
<div class="form-row split">
<div class="form-column">
<div class="form-row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, computed, OnInit, signal } from '@angular/core';
import { INPCDefinition, ISpawnerData } from '../../../../interfaces';
import { sortBy } from 'lodash';
import { INPCDefinition, ISpawnerData, Rollable } from '../../../../interfaces';
import { EditorBaseComponent } from '../../../shared/components/editor-base/editor-base.component';

@Component({
Expand Down Expand Up @@ -31,7 +32,8 @@ export class SpawnersEditorComponent
ngOnInit(): void {
const spawner = this.editing();

spawner._paths = spawner.paths.join('\n');
spawner.npcAISettings ??= [];
spawner._paths = spawner.paths?.join('\n') ?? '';

this.editing.set(spawner);

Expand Down Expand Up @@ -75,6 +77,10 @@ export class SpawnersEditorComponent
this.editing.set(spawner);
}

public sortNPCIds(npcIds: Rollable[]): Rollable[] {
return sortBy(npcIds, 'result');
}

public doSave() {
const spawner = this.editing();

Expand Down

0 comments on commit 5696494

Please sign in to comment.