Skip to content

Commit

Permalink
feat: add level to character entity
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelRauber committed Mar 11, 2024
1 parent b893b36 commit dc3989e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<pap-h1
>{{ character().name }}
<pap-secondary-h1>{{ character().age }}, {{ character().gender }}, {{ character().nation }} , {{ character().religion }} </pap-secondary-h1>
<pap-secondary-h1
>Level {{ character().level }} - {{ character().age }}, {{ character().gender }}, {{ character().nation }} , {{ character().religion }}
</pap-secondary-h1>
</pap-h1>

<form [formGroup]="formGroup">
Expand Down
1 change: 1 addition & 0 deletions src/app/models/character/character.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Statistics } from './statistics';

export interface CharacterEntity extends Statistics {
id: number;
level: number;
name: string;
gender: string;
nation: string;
Expand Down
3 changes: 2 additions & 1 deletion src/app/services/characters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export class CharactersService {
);
}

async add(character: Omit<CharacterEntity, 'id' | 'value'>): Promise<CharacterEntity> {
async add(character: Omit<CharacterEntity, 'id' | 'value' | 'level'>): Promise<CharacterEntity> {
const characterEntity = await this.charactersTable.add({
...character,
level: 1,
value: {
life: 0,
power: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/app/stores/characters.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const CharactersStore = signalStore(
const characters = await charactersService.list();
patchState(store, setAllEntities(characters));
},
add: async (character: Omit<CharacterEntity, 'id' | 'value'>) => {
add: async (character: Omit<CharacterEntity, 'id' | 'value' | 'level'>) => {
const newCharacter = await charactersService.add(character);
patchState(store, addEntity(newCharacter));

Expand Down

0 comments on commit dc3989e

Please sign in to comment.