From dc3989e97793fa67c9a3df8a83343d69a13b9eda Mon Sep 17 00:00:00 2001 From: Manuel Rauber Date: Mon, 11 Mar 2024 16:08:06 +0100 Subject: [PATCH] feat: add level to character entity --- .../character-dashboard/character-dashboard.component.html | 4 +++- src/app/models/character/character.entity.ts | 1 + src/app/services/characters.service.ts | 3 ++- src/app/stores/characters.store.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/components/characters/character-dashboard/character-dashboard.component.html b/src/app/components/characters/character-dashboard/character-dashboard.component.html index c207311..8b2e29c 100644 --- a/src/app/components/characters/character-dashboard/character-dashboard.component.html +++ b/src/app/components/characters/character-dashboard/character-dashboard.component.html @@ -1,6 +1,8 @@ {{ character().name }} - {{ character().age }}, {{ character().gender }}, {{ character().nation }} , {{ character().religion }} + Level {{ character().level }} - {{ character().age }}, {{ character().gender }}, {{ character().nation }} , {{ character().religion }} +
diff --git a/src/app/models/character/character.entity.ts b/src/app/models/character/character.entity.ts index 7cddaf6..cd39ed7 100644 --- a/src/app/models/character/character.entity.ts +++ b/src/app/models/character/character.entity.ts @@ -4,6 +4,7 @@ import { Statistics } from './statistics'; export interface CharacterEntity extends Statistics { id: number; + level: number; name: string; gender: string; nation: string; diff --git a/src/app/services/characters.service.ts b/src/app/services/characters.service.ts index 3d271c2..b339636 100644 --- a/src/app/services/characters.service.ts +++ b/src/app/services/characters.service.ts @@ -41,9 +41,10 @@ export class CharactersService { ); } - async add(character: Omit): Promise { + async add(character: Omit): Promise { const characterEntity = await this.charactersTable.add({ ...character, + level: 1, value: { life: 0, power: 0, diff --git a/src/app/stores/characters.store.ts b/src/app/stores/characters.store.ts index 6f229e2..0a59907 100644 --- a/src/app/stores/characters.store.ts +++ b/src/app/stores/characters.store.ts @@ -16,7 +16,7 @@ export const CharactersStore = signalStore( const characters = await charactersService.list(); patchState(store, setAllEntities(characters)); }, - add: async (character: Omit) => { + add: async (character: Omit) => { const newCharacter = await charactersService.add(character); patchState(store, addEntity(newCharacter));