Skip to content

Commit

Permalink
2 pages of npc. fixes to various components
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 10, 2024
1 parent 1de4cf3 commit 41f9dea
Show file tree
Hide file tree
Showing 49 changed files with 1,143 additions and 112 deletions.
23 changes: 23 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"@angular/platform-browser": "18.1.3",
"@angular/platform-browser-dynamic": "18.1.3",
"@angular/router": "18.1.3",
"@ng-icons/core": "29.3.0",
"@ng-icons/heroicons": "29.3.0",
"@ng-select/ng-select": "13.5.2",
"@ngneat/overview": "6.0.0",
"@ngxpert/hot-toast": "3.0.0",
Expand Down
21 changes: 21 additions & 0 deletions src/app/app.icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
heroArrowDownOnSquare,
heroArrowsRightLeft,
heroDocumentDuplicate,
heroDocumentText,
heroMinus,
heroPencil,
heroPlus,
heroTrash,
} from '@ng-icons/heroicons/outline';

export const appIcons = {
heroArrowDownOnSquare,
heroDocumentDuplicate,
heroDocumentText,
heroPencil,
heroPlus,
heroMinus,
heroTrash,
heroArrowsRightLeft,
};
8 changes: 8 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AppRoutingModule } from './app-routing.module';

import { HomeModule } from './home/home.module';

import { NgIconsModule, provideNgIconsConfig } from '@ng-icons/core';
import { provideHotToastConfig } from '@ngxpert/hot-toast';
import { SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import {
Expand All @@ -24,6 +25,7 @@ import {
withNgxWebstorageConfig,
} from 'ngx-webstorage';
import { AppComponent } from './app.component';
import { appIcons } from './app.icons';

@NgModule({
declarations: [AppComponent],
Expand All @@ -43,6 +45,9 @@ import { AppComponent } from './app.component';
SweetAlert2Module.forRoot({
provideSwal: () => import('sweetalert2/dist/sweetalert2.js'),
}),
NgIconsModule.withIcons({
...appIcons,
}),
],
providers: [
provideHttpClient(withInterceptorsFromDi()),
Expand All @@ -51,6 +56,9 @@ import { AppComponent } from './app.component';
withNgxWebstorageConfig({ separator: ':', caseSensitive: true }),
withLocalStorage()
),
provideNgIconsConfig({
size: '1.5em',
}),
],
exports: [],
})
Expand Down
2 changes: 2 additions & 0 deletions src/app/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './constants';
export * from './droptable';
export * from './id';
export * from './item';
export * from './npc';
export * from './recipe';
105 changes: 105 additions & 0 deletions src/app/helpers/npc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {
AlignmentType,
BaseClassType,
INPCDefinition,
MonsterClassType,
} from '../../interfaces';
import { id } from './id';

export const defaultNPC: () => INPCDefinition = () => ({
_id: id(),
sprite: [0],
npcId: '',
name: '',
hostility: 'OnHit',
allegiance: 'Enemy',
monsterClass: undefined as unknown as MonsterClassType,
baseClass: undefined as unknown as BaseClassType,
affiliation: '',
alignment: 'Neutral' as AlignmentType,
cr: 0,
hpMult: 1,
stats: {
str: 0,
dex: 0,
agi: 0,
int: 0,
wis: 0,
wil: 0,
con: 0,
cha: 0,
luk: 0,
},
level: 1,
skillLevels: 1,
skillOnKill: 1,
otherStats: {},
gear: {},
hp: { min: 0, max: 0 },
mp: { min: 0, max: 0 },
giveXp: { min: 0, max: 0 },
gold: { min: 0, max: 0 },
monsterGroup: '',
avoidWater: false,
aquaticOnly: false,
noCorpseDrop: false,
noItemDrop: false,
traitLevels: {},
usableSkills: [],
baseEffects: [],
drops: [],
copyDrops: [],
dropPool: {
choose: {
min: 0,
max: 0,
},
items: [],
},
tansFor: '',
tanSkillRequired: 0,
triggers: {
leash: {
messages: [''],
sfx: {
name: '',
maxChance: 0,
},
},
spawn: {
messages: [''],
sfx: {
name: '',
maxChance: 0,
},
},
combat: {
messages: [],
},
},
items: {
sack: [],
belt: [],
equipment: {
rightHand: [],
leftHand: [],
head: [],
neck: [],
ear: [],
waist: [],
wrists: [],
ring1: [],
ring2: [],
hands: [],
feet: [],
armor: [],
robe1: [],
robe2: [],
trinket: [],
potion: [],
ammo: [],
},
},
repMod: [],
skills: {},
});
5 changes: 5 additions & 0 deletions src/app/home/home.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';

import { HomeRoutingModule } from './home-routing.module';

import { NgIconsModule } from '@ng-icons/core';
import { SweetAlert2Module } from '@sweetalert2/ngx-sweetalert2';
import { AgGridModule } from 'ag-grid-angular';
import { NgxFloatUiModule } from 'ngx-float-ui';
Expand All @@ -13,6 +14,7 @@ import { DroptablesComponent } from '../tabs/droptables/droptables.component';
import { ItemsEditorComponent } from '../tabs/items/items-editor/items-editor.component';
import { ItemsComponent } from '../tabs/items/items.component';
import { MapsComponent } from '../tabs/maps/maps.component';
import { NpcsEditorComponent } from '../tabs/npcs/npcs-editor/npcs-editor.component';
import { NpcsComponent } from '../tabs/npcs/npcs.component';
import { QuestsComponent } from '../tabs/quests/quests.component';
import { RecipesEditorComponent } from '../tabs/recipes/recipes-editor/recipes-editor.component';
Expand All @@ -34,6 +36,7 @@ import { HomeComponent } from './home.component';
RecipesComponent,
RecipesEditorComponent,
SpawnersComponent,
NpcsEditorComponent,
],
imports: [
CommonModule,
Expand All @@ -42,6 +45,8 @@ import { HomeComponent } from './home.component';
SweetAlert2Module,
AgGridModule,
NgxFloatUiModule,
NgIconsModule,
],
exports: [NpcsEditorComponent],
})
export class HomeModule {}
26 changes: 26 additions & 0 deletions src/app/services/mod.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IEditorMap,
IItemDefinition,
IModKit,
INPCDefinition,
IRecipe,
} from '../../interfaces';

Expand Down Expand Up @@ -258,4 +259,29 @@ export class ModService {

this.updateMod(mod);
}

// npc functions
public addNPC(npc: INPCDefinition) {
const mod = this.mod();
mod.npcs.push(npc);

this.updateMod(mod);
}

public editNPC(oldNPC: INPCDefinition, newNPC: INPCDefinition) {
const mod = this.mod();
const foundItemIdx = mod.npcs.findIndex((i) => i._id === oldNPC._id);
if (foundItemIdx === -1) return;

mod.npcs[foundItemIdx] = newNPC;

this.updateMod(mod);
}

public removeNPC(npc: INPCDefinition) {
const mod = this.mod();
mod.npcs = mod.npcs.filter((i) => i !== npc);

this.updateMod(mod);
}
}
25 changes: 4 additions & 21 deletions src/app/shared/components/cell-buttons/cell-buttons.component.html
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
<div class="flex justify-end items-center h-full">
@if(params.showCopyButton) {
<button class="ml-2 btn btn-sm btn-info" (click)="params.copyCallback?.(params.data)" floatUi="Copy">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" />
</svg>
<ng-icon name="heroDocumentDuplicate"></ng-icon>
</button>
}

@if(params.showRenameButton) {
<button class="ml-2 btn btn-sm btn-info" (click)="params.renameCallback?.(params.data)" floatUi="Rename">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
</svg>

<ng-icon name="heroDocumentText"></ng-icon>
</button>
}

@if(params.showEditButton) {
<button class="ml-2 btn btn-sm btn-info" (click)="params.editCallback?.(params.data)" floatUi="Edit">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" />
</svg>
<ng-icon name="heroPencil"></ng-icon>
</button>
}

@if(params.showDeleteButton) {
<button class="ml-2 btn btn-sm btn-warning" [swal]="deleteItem" floatUi="Delete">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
<ng-icon name="heroTrash"></ng-icon>
</button>

<swal #deleteItem title="Delete This?" text="This cannot be undone." icon="warning" [showCancelButton]="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<div class="flex justify-end items-center h-full w-full">
@if(params.showImportButton) {
<button class="ml-2 btn btn-sm btn-secondary" (click)="params.importCallback()" floatUi="Import">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M9 8.25H7.5a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 0 0 2.25 2.25h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25H15M9 12l3 3m0 0 3-3m-3 3V2.25" />
</svg>
<ng-icon name="heroArrowDownOnSquare"></ng-icon>
</button>
}

@if(params.showNewButton) {
<button class="ml-2 btn btn-sm btn-secondary" (click)="params.newCallback()" floatUi="New">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>


<ng-icon name="heroPlus"></ng-icon>
</button>
}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="relative">
<ng-select class="form-control" [items]="values" [(ngModel)]="alignment" placeholder="Select alignment..."
(change)="change.emit($event)"></ng-select>

<app-input-floating-label>Alignment</app-input-floating-label>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, model, output } from '@angular/core';
import { Alignment, AlignmentType } from '../../../../interfaces';

@Component({
selector: 'app-input-alignment',
templateUrl: './input-alignment.component.html',
styleUrl: './input-alignment.component.scss',
})
export class InputAlignmentComponent {
public alignment = model.required<AlignmentType | undefined>();
public change = output<Alignment>();

public values = [...Object.keys(Alignment)];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="relative">
<ng-select class="form-control" [items]="values" [(ngModel)]="allegiance" placeholder="Select faction..."
(change)="change.emit($event)"></ng-select>

<app-input-floating-label>Faction</app-input-floating-label>
</div>
Empty file.
Loading

0 comments on commit 41f9dea

Please sign in to comment.