From d84ecd91a1dff4d7ced539476240f6945a564de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20G=C3=B3reczny?= Date: Tue, 12 Jan 2021 14:07:49 +0100 Subject: [PATCH 1/9] SES-145 Tables in GM screen are now connected to backend --- .../ClientApp/src/app/app.module.ts | 15 ++++++- .../game-master-armors-table.component.ts | 44 +++++++++--------- .../game-master-spells-table.component.ts | 44 +++++++++--------- .../game-master-weapons-table.component.css | 5 +-- .../game-master-weapons-table.component.html | 8 ++-- .../game-master-weapons-table.component.ts | 45 ++++++++++--------- .../ClientApp/src/services/armor.service.ts | 34 ++++++++++++++ .../src/services/other-equipment.service.ts | 12 +++++ .../ClientApp/src/services/spell.service.ts | 33 ++++++++++++++ .../ClientApp/src/services/weapon.service.ts | 34 ++++++++++++++ .../spell-viewmodels/SpellViewModel.ts | 17 +++++++ 11 files changed, 221 insertions(+), 70 deletions(-) create mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/services/armor.service.ts create mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/services/other-equipment.service.ts create mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/services/spell.service.ts create mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/services/weapon.service.ts create mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/types/viewmodels/spell-viewmodels/SpellViewModel.ts diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts index b475db3..ab57d47 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts @@ -26,6 +26,7 @@ import { MatTableModule, MatSortModule, MatDialogModule, + MatTooltipModule, } from '@angular/material'; import { UserService } from '../services/user.service'; import { StoreModule } from '@ngrx/store'; @@ -39,6 +40,10 @@ import { GameMasterArmorsTableComponent } from './components/game-master-armors- import { GameMasterCharacterActionsDialogComponent } from './components/game-master-character-actions-dialog/game-master-character-actions-dialog.component'; import { GameMasterWeaponsTableComponent } from './components/game-master-weapons-table/game-master-weapons-table.component'; import { AbilitiesComponent } from './components/abilities/abilities.component'; +import { SpellService } from '../services/spell.service'; +import { WeaponService } from '../services/weapon.service'; +import { ArmorService } from '../services/armor.service'; +import { OtherEquipmentService } from '../services/other-equipment.service'; @NgModule({ declarations: [ @@ -81,8 +86,16 @@ import { AbilitiesComponent } from './components/abilities/abilities.component'; }), MatTableModule, MatSortModule, + MatTooltipModule, + ], + providers: [ + UserService, + CharacterService, + SpellService, + WeaponService, + ArmorService, + OtherEquipmentService, ], - providers: [UserService, CharacterService], bootstrap: [AppComponent], entryComponents: [ GameMasterSpellsTableComponent, diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts index 0af906c..139871c 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts @@ -3,6 +3,10 @@ import { MatTableDataSource } from '@angular/material/table'; import { ArmorViewModel } from '../../../types/viewmodels/armor-viewmodels/ArmorViewModel'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; +import { first } from 'rxjs/operators'; +import { ErrorResponse } from '../../../types/ErrorResponse'; +import { HttpErrorResponse } from '@angular/common/http'; +import { ArmorService } from '../../../services/armor.service'; @Component({ selector: 'app-game-master-armors-table', @@ -22,29 +26,27 @@ export class GameMasterArmorsTableComponent implements OnInit { @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatSort, { static: true }) sort: MatSort; - constructor() { - const armors = [ - { - id: 1, - name: 'Test', - category: 'Testowa', - minimumStrength: 12, - weight: 98, - cost: 123, - armorClassBase: 10, - haveDexterityBonus: false, - haveStealthDisadvantage: false, - currencyType: 1, - }, - ]; - - this.dataSource = new MatTableDataSource(armors); + constructor(private armorService: ArmorService) { + armorService + .GetAllArmors() + .pipe(first()) + .subscribe( + (result) => { + console.log(result); + this.dataSource = new MatTableDataSource(result); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + }, + (error: ErrorResponse | HttpErrorResponse) => { + if (error instanceof HttpErrorResponse) { + error = error.error as ErrorResponse; + } + console.log(error.message); + } + ); } - ngOnInit() { - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; - } + ngOnInit() {} applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.ts index 8da89fa..7005445 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.ts @@ -2,13 +2,11 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; - -export interface SpellData { - name: string; - range: string; - level: number; - school: string; -} +import { SpellViewModel } from '../../../types/viewmodels/spell-viewmodels/SpellViewModel'; +import { SpellService } from '../../../services/spell.service'; +import { first } from 'rxjs/operators'; +import { ErrorResponse } from '../../../types/ErrorResponse'; +import { HttpErrorResponse } from '@angular/common/http'; @Component({ selector: 'app-game-master-spells-table', @@ -17,25 +15,31 @@ export interface SpellData { }) export class GameMasterSpellsTableComponent implements OnInit { displayedColumns: string[] = ['Name', 'Range', 'Level', 'School']; - dataSource: MatTableDataSource; + dataSource: MatTableDataSource; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatSort, { static: true }) sort: MatSort; - constructor() { - const users = Array.from({ length: 100 }, (_, k) => this.createSepll()); - - this.dataSource = new MatTableDataSource(users); + constructor(private spellService: SpellService) { + spellService + .GetAllSpells() + .pipe(first()) + .subscribe( + (result) => { + this.dataSource = new MatTableDataSource(result); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + }, + (error: ErrorResponse | HttpErrorResponse) => { + if (error instanceof HttpErrorResponse) { + error = error.error as ErrorResponse; + } + console.log(error.message); + } + ); } - createSepll(): SpellData { - return { name: 'test', range: 'asd', level: 2, school: 'UAM!!!!' }; - } - - ngOnInit() { - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; - } + ngOnInit() {} applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.css b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.css index 83e5e96..c83a0ea 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.css +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.css @@ -1,11 +1,11 @@ -.description-weapon-column { +.text-cut { + max-width: 60px; /* feel free to include any other value */ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } table { - width: 100%; background-color: initial; } @@ -34,5 +34,4 @@ mat-paginator { td, th { color: whitesmoke; - width: 25%; } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html index 966d65d..ab3bbf1 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html @@ -3,8 +3,8 @@ -
- +
+
@@ -28,7 +28,9 @@ - + diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts index 4a17e31..24bdcbf 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts @@ -3,6 +3,10 @@ import { MatTableDataSource } from '@angular/material/table'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { WeaponViewModel } from '../../../types/viewmodels/weapon-viewmodels/WeaponViewModel'; +import { WeaponService } from '../../../services/weapon.service'; +import { first } from 'rxjs/operators'; +import { ErrorResponse } from '../../../types/ErrorResponse'; +import { HttpErrorResponse } from '@angular/common/http'; @Component({ selector: 'app-game-master-weapons-table', @@ -22,30 +26,27 @@ export class GameMasterWeaponsTableComponent implements OnInit { @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatSort, { static: true }) sort: MatSort; - constructor() { - const weapons = [ - { - id: 1, - name: 'Test', - cost: 123, - weight: 98, - diceCount: 2, - diceValue: 20, - twoHandDamageType: 'Toxic', - description: - 'A japanase battleaxe with a spike on the opposite side of the blade.', - weaponType: 'Two-Handed Melee Weapons', - rangeMeele: 50, - }, - ]; - - this.dataSource = new MatTableDataSource(weapons); + constructor(private weaponService: WeaponService) { + weaponService + .GetAllWeapons() + .pipe(first()) + .subscribe( + (result) => { + console.log(result); + this.dataSource = new MatTableDataSource(result); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + }, + (error: ErrorResponse | HttpErrorResponse) => { + if (error instanceof HttpErrorResponse) { + error = error.error as ErrorResponse; + } + console.log(error.message); + } + ); } - ngOnInit() { - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; - } + ngOnInit() {} applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/services/armor.service.ts b/SessionCompanion/SessionCompanion/ClientApp/src/services/armor.service.ts new file mode 100644 index 0000000..9651317 --- /dev/null +++ b/SessionCompanion/SessionCompanion/ClientApp/src/services/armor.service.ts @@ -0,0 +1,34 @@ +import { Inject, Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable, of, throwError } from 'rxjs'; +import { WeaponViewModel } from '../types/viewmodels/weapon-viewmodels/WeaponViewModel'; +import { Either } from '../types/Either'; +import { ErrorResponse } from '../types/ErrorResponse'; +import { switchMap } from 'rxjs/operators'; +import { ArmorViewModel } from '../types/viewmodels/armor-viewmodels/ArmorViewModel'; + +Injectable({ + providedIn: 'root', +}); +export class ArmorService { + private baseUrl = 'api/armor/'; + constructor(private http: HttpClient, @Inject('BASE_URL') baseUrl: string) { + this.baseUrl = baseUrl + this.baseUrl; + } + + GetAllArmors(): Observable { + return this.http + .get>( + this.baseUrl + 'getAllArmor' + ) + .pipe( + switchMap((response) => { + if (response.isLeft) { + return of(response.left); + } else { + return throwError(response.right); + } + }) + ); + } +} diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/services/other-equipment.service.ts b/SessionCompanion/SessionCompanion/ClientApp/src/services/other-equipment.service.ts new file mode 100644 index 0000000..3799e0b --- /dev/null +++ b/SessionCompanion/SessionCompanion/ClientApp/src/services/other-equipment.service.ts @@ -0,0 +1,12 @@ +import { Inject, Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +Injectable({ + providedIn: 'root', +}); +export class OtherEquipmentService { + private baseUrl = 'api/otherEquipment/'; + constructor(private http: HttpClient, @Inject('BASE_URL') baseUrl: string) { + this.baseUrl = baseUrl + this.baseUrl; + } +} diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/services/spell.service.ts b/SessionCompanion/SessionCompanion/ClientApp/src/services/spell.service.ts new file mode 100644 index 0000000..bdbcaa0 --- /dev/null +++ b/SessionCompanion/SessionCompanion/ClientApp/src/services/spell.service.ts @@ -0,0 +1,33 @@ +import { Inject, Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Observable, of, throwError } from 'rxjs'; +import { SpellViewModel } from '../types/viewmodels/spell-viewmodels/SpellViewModel'; +import { Either } from '../types/Either'; +import { ErrorResponse } from '../types/ErrorResponse'; +import { switchMap } from 'rxjs/operators'; + +Injectable({ + providedIn: 'root', +}); +export class SpellService { + private baseUrl = 'api/spell/'; + constructor(private http: HttpClient, @Inject('BASE_URL') baseUrl: string) { + this.baseUrl = baseUrl + this.baseUrl; + } + + GetAllSpells(): Observable { + return this.http + .get>( + this.baseUrl + 'getAllSpells' + ) + .pipe( + switchMap((response) => { + if (response.isLeft) { + return of(response.left); + } else { + return throwError(response.right); + } + }) + ); + } +} diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/services/weapon.service.ts b/SessionCompanion/SessionCompanion/ClientApp/src/services/weapon.service.ts new file mode 100644 index 0000000..480d1bd --- /dev/null +++ b/SessionCompanion/SessionCompanion/ClientApp/src/services/weapon.service.ts @@ -0,0 +1,34 @@ +import { Inject, Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable, of, throwError } from 'rxjs'; +import { SpellViewModel } from '../types/viewmodels/spell-viewmodels/SpellViewModel'; +import { Either } from '../types/Either'; +import { ErrorResponse } from '../types/ErrorResponse'; +import { switchMap } from 'rxjs/operators'; +import { WeaponViewModel } from '../types/viewmodels/weapon-viewmodels/WeaponViewModel'; + +Injectable({ + providedIn: 'root', +}); +export class WeaponService { + private baseUrl = 'api/weapon/'; + constructor(private http: HttpClient, @Inject('BASE_URL') baseUrl: string) { + this.baseUrl = baseUrl + this.baseUrl; + } + + GetAllWeapons(): Observable { + return this.http + .get>( + this.baseUrl + 'getAllWeapons' + ) + .pipe( + switchMap((response) => { + if (response.isLeft) { + return of(response.left); + } else { + return throwError(response.right); + } + }) + ); + } +} diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/types/viewmodels/spell-viewmodels/SpellViewModel.ts b/SessionCompanion/SessionCompanion/ClientApp/src/types/viewmodels/spell-viewmodels/SpellViewModel.ts new file mode 100644 index 0000000..93c6936 --- /dev/null +++ b/SessionCompanion/SessionCompanion/ClientApp/src/types/viewmodels/spell-viewmodels/SpellViewModel.ts @@ -0,0 +1,17 @@ +export interface SpellViewModel { + id: number; + name: string; + descriptions: string[]; + higherLevel: string[]; + range: string; + components: string; + material: string; + ritual: boolean; + duration: string; + concentration: boolean; + castingTime: string; + level: number; + school: string; + classes: string; + subclasses: string; +} From 11b117d85cfed0b6319315ce2c708a6c58dad377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20G=C3=B3reczny?= Date: Tue, 12 Jan 2021 15:46:38 +0100 Subject: [PATCH 2/9] SES-145 Removed console logs --- .../abilities/abilities.component.ts | 50 +++++++++++-------- .../game-master-armors-table.component.ts | 1 - .../game-master-weapons-table.component.ts | 1 - 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/abilities/abilities.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/abilities/abilities.component.ts index 13d52ee..d0d7d49 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/abilities/abilities.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/abilities/abilities.component.ts @@ -1,38 +1,48 @@ import { Component, OnInit } from '@angular/core'; -import {CharacterStatsViewModel} from "../../../types/viewmodels/character-viewmodels/CharacterStatsViewModel"; -import {Store} from "@ngrx/store"; -import {AppState} from "../../store/models/app-state.model"; -import {CharacterService} from "../../../services/character.service"; -import {first} from "rxjs/operators"; -import {ErrorResponse} from "../../../types/ErrorResponse"; -import {HttpErrorResponse} from "@angular/common/http"; +import { CharacterStatsViewModel } from '../../../types/viewmodels/character-viewmodels/CharacterStatsViewModel'; +import { Store } from '@ngrx/store'; +import { AppState } from '../../store/models/app-state.model'; +import { CharacterService } from '../../../services/character.service'; +import { first } from 'rxjs/operators'; +import { ErrorResponse } from '../../../types/ErrorResponse'; +import { HttpErrorResponse } from '@angular/common/http'; @Component({ selector: 'app-abilities', templateUrl: './abilities.component.html', - styleUrls: ['./abilities.component.css'] + styleUrls: ['./abilities.component.css'], }) export class AbilitiesComponent implements OnInit { characterStats: CharacterStatsViewModel[]; - constructor(private store: Store, private characterService: CharacterService) {} + constructor( + private store: Store, + private characterService: CharacterService + ) {} ngOnInit() { this.getCharacterStats(); } getCharacterStats() { - this.store.select( s => s.playerStore.characterId).pipe(first()).subscribe((characterId) => { - this.characterService.getCharacterStats(characterId).pipe(first()).subscribe((characterStats) => { - console.log(characterStats) - this.characterStats = characterStats; - }, (error: ErrorResponse | HttpErrorResponse) => { - if (error instanceof HttpErrorResponse) { - error = error.error as ErrorResponse; - } - console.error(error.message); + this.store + .select((s) => s.playerStore.characterId) + .pipe(first()) + .subscribe((characterId) => { + this.characterService + .getCharacterStats(characterId) + .pipe(first()) + .subscribe( + (characterStats) => { + this.characterStats = characterStats; + }, + (error: ErrorResponse | HttpErrorResponse) => { + if (error instanceof HttpErrorResponse) { + error = error.error as ErrorResponse; + } + console.error(error.message); + } + ); }); - }) } - } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts index 139871c..74bbd25 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-armors-table/game-master-armors-table.component.ts @@ -32,7 +32,6 @@ export class GameMasterArmorsTableComponent implements OnInit { .pipe(first()) .subscribe( (result) => { - console.log(result); this.dataSource = new MatTableDataSource(result); this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts index 24bdcbf..e4e3497 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.ts @@ -32,7 +32,6 @@ export class GameMasterWeaponsTableComponent implements OnInit { .pipe(first()) .subscribe( (result) => { - console.log(result); this.dataSource = new MatTableDataSource(result); this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; From 55077fc27bbdf6308e2f4100e8477d08b0588a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20G=C3=B3reczny?= Date: Tue, 12 Jan 2021 16:02:58 +0100 Subject: [PATCH 3/9] fix % in range --- .../game-master-spells-table.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.html index 515e687..bcbc20f 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.html +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-spells-table/game-master-spells-table.component.html @@ -13,7 +13,7 @@ - + From 057f4f2e52716d08690a3949631e928146be6a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20G=C3=B3reczny?= Date: Tue, 12 Jan 2021 16:13:52 +0100 Subject: [PATCH 4/9] fix footer not showing up --- .../game-master-weapons-table.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html index ab3bbf1..a7855d1 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-weapons-table/game-master-weapons-table.component.html @@ -3,8 +3,8 @@ -
-
Name Description {{row.description}} + {{row.description}} +
Range {{row.range}}% {{row.range}}
+
+
From b2af139799e2da86206dfb9b5cc09d0c97de1e88 Mon Sep 17 00:00:00 2001 From: Natalia Gawron Date: Tue, 12 Jan 2021 17:42:47 +0100 Subject: [PATCH 5/9] SES-163 implemented clean store if user click on logout --- .../game-master-dashboard.component.html | 5 +++++ .../game-master-dashboard.component.ts | 11 +++++++++++ .../player-dashboard.component.html | 4 ++-- .../player-dashboard.component.ts | 19 ++++++++++++++----- .../src/app/store/actions/app.actions.ts | 11 +++++++++-- .../src/app/store/actions/player.action.ts | 15 ++++++++++++--- .../src/app/store/reducers/app.reducer.ts | 2 ++ .../src/app/store/reducers/player.reducer.ts | 2 ++ 8 files changed, 57 insertions(+), 12 deletions(-) diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.html index a610274..adc827d 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.html +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.html @@ -41,6 +41,11 @@ + + exit_to_app + Log out + + diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.ts index bd03815..364948c 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/game-master-dashboard/game-master-dashboard.component.ts @@ -16,6 +16,10 @@ import { GameMasterArmorsTableComponent } from '../game-master-armors-table/game import { MatDialog } from '@angular/material'; import { GameMasterCharacterActionsDialogComponent } from '../game-master-character-actions-dialog/game-master-character-actions-dialog.component'; import { GameMasterWeaponsTableComponent } from '../game-master-weapons-table/game-master-weapons-table.component'; +import { ClearStore } from '../../store/actions/app.actions'; +import { Store } from '@ngrx/store'; +import { AppState } from '../../store/models/app-state.model'; +import { Router } from '@angular/router'; @Component({ selector: 'app-game-master-dashboard', @@ -61,6 +65,8 @@ export class GameMasterDashboardComponent implements OnInit, OnDestroy { loggedCharacters: LoggedCharactersViewModel[]; constructor( + private store: Store, + private router: Router, private signalRService: GMSignalRService, private characterService: CharacterService, public dialog: MatDialog @@ -129,6 +135,11 @@ export class GameMasterDashboardComponent implements OnInit, OnDestroy { } } + onLogoutClick() { + this.store.dispatch(new ClearStore()); + this.router.navigate(['/']); + } + private SubscribeToEvents(): void { this.signalRService.message.subscribe((message: string) => { if ( diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.html index e045996..d209480 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.html +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.html @@ -19,7 +19,7 @@ query_stats Statistic and throws - + local_mall Equipment @@ -40,7 +40,7 @@ Shop - + exit_to_app Log out diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts index 11d9924..1ed96bf 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/player-dashboard/player-dashboard.component.ts @@ -1,9 +1,12 @@ import { Component, OnInit } from '@angular/core'; -import { PlayerSignalRService } from "../../shared/signalR-service/player-signalR.service"; -import { first } from "rxjs/operators"; +import { PlayerSignalRService } from '../../shared/signalR-service/player-signalR.service'; +import { first } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { AppState } from 'src/app/store/models/app-state.model'; import { AbilitiesComponent } from '../abilities/abilities.component'; +import {ClearStore, ClearUserId} from '../../store/actions/app.actions'; +import { Router } from '@angular/router'; +import {ClearCharacterId} from "../../store/actions/player.action"; @Component({ selector: 'app-player-dashboard', @@ -15,13 +18,13 @@ export class PlayerDashboardComponent implements OnInit { isExpanded = false; selected = false; - constructor(private signalRService: PlayerSignalRService, private store: Store) {} + constructor(private signalRService: PlayerSignalRService, private store: Store, private router: Router) {} ngOnInit() { this.store.select(s => s.playerStore.characterId).pipe(first()).subscribe((id) => { this.signalRService.Login(id); + this.SwitchMiddleComponent('AbilitiesComponent'); }); - this.SwitchMiddleComponent('AbilitiesComponent'); } toggle() { @@ -29,9 +32,15 @@ export class PlayerDashboardComponent implements OnInit { } SwitchMiddleComponent(componentName: string) { - switch(componentName){ + switch (componentName) { case 'AbilitiesComponent': this.middleComponent = AbilitiesComponent; } } + + onLogoutClick() { + this.store.dispatch(new ClearCharacterId()); + this.store.dispatch(new ClearStore()); + this.router.navigate(['/']); + } } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/app.actions.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/app.actions.ts index 362b983..75ac697 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/app.actions.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/app.actions.ts @@ -3,7 +3,8 @@ import {Action} from '@ngrx/store'; export enum AppActionTypes { ADD_USER_ID = '[APP] Add user id', ADD_ROLE = '[APP] Add role', - CLEAR_USER_ID = '[APP] Clear user id' + CLEAR_USER_ID = '[APP] Clear user id', + CLEAR_STORE = '[APP] Clear user id and user role' } export class AddUserId implements Action { @@ -27,6 +28,12 @@ export class ClearUserId implements Action { } } +export class ClearStore implements Action { + readonly type = AppActionTypes.CLEAR_STORE; + + constructor() { + } +} -export type AppAction = AddUserId | AddRole | ClearUserId; +export type AppAction = AddUserId | AddRole | ClearUserId | ClearStore; diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/player.action.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/player.action.ts index 45c74d8..690c305 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/player.action.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/actions/player.action.ts @@ -1,7 +1,8 @@ -import {Action} from "@ngrx/store"; +import {Action} from '@ngrx/store'; export enum PlayerActionTypes { - ADD_CHARACTER_ID= '[PLAYER] Add character id' + ADD_CHARACTER_ID= '[PLAYER] Add character id', + CLEAR_CHARACTER_ID = '[PLAYER] Clear character id' } export class AddCharacterId implements Action { @@ -12,4 +13,12 @@ export class AddCharacterId implements Action { } } -export type PlayerAction = AddCharacterId; +export class ClearCharacterId implements Action { + readonly type = PlayerActionTypes.CLEAR_CHARACTER_ID; + + constructor() { + + } +} + +export type PlayerAction = AddCharacterId | ClearCharacterId; diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/app.reducer.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/app.reducer.ts index d86c636..aa6de48 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/app.reducer.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/app.reducer.ts @@ -14,6 +14,8 @@ export function AppReducer(state: AppStoreModel = initialState, action: AppActio return {...state, role: action.payload.role}; case AppActionTypes.CLEAR_USER_ID: return {...state, userId: null}; + case AppActionTypes.CLEAR_STORE: + return {userId: null, role: null}; default: return state; } diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/player.reducer.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/player.reducer.ts index 3077834..9a12b52 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/player.reducer.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/store/reducers/player.reducer.ts @@ -9,6 +9,8 @@ export function PlayerReducer(state: PlayerStoreModel = initialState, action: Pl switch (action.type) { case PlayerActionTypes.ADD_CHARACTER_ID: return {...state, characterId: action.payload.characterId}; + case PlayerActionTypes.CLEAR_CHARACTER_ID: + return { characterId: null}; default: return state; } From 22557778402f46ba972459dd2688cf7d0ba6f08e Mon Sep 17 00:00:00 2001 From: Natalia Gawron Date: Tue, 12 Jan 2021 17:59:36 +0100 Subject: [PATCH 6/9] constitution ability style css fix --- .../src/app/components/ability-card/ability-card.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/ability-card/ability-card.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/ability-card/ability-card.component.ts index 752a21a..d6eb61d 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/components/ability-card/ability-card.component.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/ability-card/ability-card.component.ts @@ -29,7 +29,7 @@ export class AbilityCardComponent implements OnInit { this.headStyle.bgColor = '#4BBE9C'; break; case 'Constitution': - this.headStyle.bgColor = 'red'; + this.headStyle.bgColor = '#e9cca7'; break; case 'Intelligence': this.headStyle.bgColor = '#5AA9E6'; From f31b41f942b7b873c99d0ce44aa810a364bc0e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Tue, 12 Jan 2021 20:47:09 +0100 Subject: [PATCH 7/9] SES-143 Add Monster releated tables --- .../Tables/GameAction.cs | 30 ++++ .../Tables/LegendaryAction.cs | 23 +++ .../Tables/Monster.cs | 162 ++++++++++++++++++ .../Tables/MonsterAction.cs | 24 +++ .../Tables/MonsterLegendaryAction.cs | 24 +++ .../Tables/MonsterSpecialAbility.cs | 28 +++ .../Tables/SpecialAbility.cs | 27 +++ 7 files changed, 318 insertions(+) create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/GameAction.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/LegendaryAction.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/Monster.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/MonsterAction.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/MonsterLegendaryAction.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/MonsterSpecialAbility.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Tables/SpecialAbility.cs diff --git a/SessionCompanion/SessionCompanion.Database/Tables/GameAction.cs b/SessionCompanion/SessionCompanion.Database/Tables/GameAction.cs new file mode 100644 index 0000000..a523153 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/GameAction.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class GameAction : BaseEntity + { + // + /// Nazwa akcji + /// + public string Name { get; set; } + + /// + /// Opis akcji + /// + public string Description { get; set; } + + public int AttackBonus { get; set; } + + public int? DamageDice { get; set; } + public int? DamageDiceAmount { get; set; } + + public int? DamageBonus { get; set; } + + public virtual ICollection MonsterActions { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Tables/LegendaryAction.cs b/SessionCompanion/SessionCompanion.Database/Tables/LegendaryAction.cs new file mode 100644 index 0000000..32c16a0 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/LegendaryAction.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class LegendaryAction : BaseEntity + { + // + /// Nazwa legendarnej akcji + /// + public string Name { get; set; } + + /// + /// Opis akcji + /// + public string Description { get; set; } + + public virtual ICollection MonsterLegendaryActions { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Tables/Monster.cs b/SessionCompanion/SessionCompanion.Database/Tables/Monster.cs new file mode 100644 index 0000000..6c641ab --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/Monster.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class Monster : BaseEntity + { + /// + /// Nazwa potwora + /// + public string Name { get; set; } + + /// + /// Rozmiar potwora + /// + public string Size { get; set; } + + /// + /// Rodzaj potwora + /// + public string Type { get; set; } + + /// + /// Podtyp potwora + /// + public string Subtype { get; set; } + + /// + /// Charakter potwora + /// + public string Alignment { get; set; } + + /// + /// Poziom pancerza potwora + /// + public int ArmorClass { get; set; } + + /// + /// Iloś punktów zycia potwora + /// + public int HitPoints { get; set; } + + /// + /// Ilość kości określajacych punkty życia potwora + /// + public int HitDiceAmount { get; set; } + + /// + /// Kość którą rzucamy aby określić punkty życia potwora + /// + public int HitDiceType { get; set; } + + /// + /// Szybkość chodzenia potwora + /// + public string WalkSpeed { get; set; } + + /// + /// Szybkość pływania potwora + /// + public string SwimSpeed { get; set; } + + /// + /// Szybkość latania potwora + /// + public string FlySpeed { get; set; } + + /// + /// Punkty zręczności potwora + /// + public int Dexterity { get; set; } + public int? DexteritySave { get; set; } + + /// + /// Punkty siły potwora + /// + public int Strength { get; set; } + public int? StrengthSave { get; set; } + + /// + /// Punkty kondycji potwora + /// + public int Constitution { get; set; } + public int? ConstitutionSave { get; set; } + + /// + /// Punkty inteligencji potwora + /// + public int Intelligence { get; set; } + public int? IntelligenceSave { get; set; } + + /// + /// Punkty mądrości potwora + /// + public int Wisdom { get; set; } + public int? WisdomSave { get; set; } + + /// + /// Punkty charyzmy potwora + /// + public int Charisma { get; set; } + public int? CharismaSave { get; set; } + + /// + /// Poziom trudności potwora + /// + public int ChallengeRating { get; set; } + + /// + /// Punkty doświadczenia za zabicie potwora + /// + public int ExperiencePoints { get; set; } + + /// + /// Połączenie z tabelą MonsterActions + /// + public virtual ICollection MonsterAction { get; set; } + + /// + /// Na jakie stany odporny jest potwor + /// + public string MonsterConditionImmunities { get; set; } + + /// + /// Na jakie obrazenia odporny jest potwor + /// + public string MonsterDamageImmunities { get; set; } + + /// + /// Na jakie obrazenia potwor ma zmniejszoną słabosc + /// + public string MonsterDamageResistances { get; set; } + + /// + /// Na co potwor jest wrazliwy + /// + public string MonsterDamageVulnerabilities { get; set; } + + /// + /// Jezyki jakimi wlada potwor + /// + public string MonsterLanguages { get; set; } + + /// + /// Połączenie z tabelą MonsterLegendaryActions + /// + public virtual ICollection MonsterLegendaryAction { get; set; } + + /// + /// Połączenie z tabelą MonsterSenses + /// + public string MonsterSenses { get; set; } + + /// + /// Połączenie z tabelą MonsterSpecialAbilities + /// + public virtual ICollection MonsterSpecialAbility { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Tables/MonsterAction.cs b/SessionCompanion/SessionCompanion.Database/Tables/MonsterAction.cs new file mode 100644 index 0000000..d3b9b88 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/MonsterAction.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class MonsterAction : BaseEntity + { + /// + /// Id potwora + /// + public int MonsterId { get; set; } + + /// + /// Połączenie z tabelą Monsters + /// + public virtual Monster Monster { get; set; } + + public int GameActionId { get; set; } + public virtual GameAction GameAction { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Tables/MonsterLegendaryAction.cs b/SessionCompanion/SessionCompanion.Database/Tables/MonsterLegendaryAction.cs new file mode 100644 index 0000000..7d8c47e --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/MonsterLegendaryAction.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class MonsterLegendaryAction : BaseEntity + { + /// + /// Id potwora + /// + public int MonsterId { get; set; } + public int LegendaryActionId { get; set; } + + /// + /// Połączenie z tabelą Monster + /// + public virtual Monster Monster { get; set; } + + public virtual LegendaryAction LegendaryActions { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Tables/MonsterSpecialAbility.cs b/SessionCompanion/SessionCompanion.Database/Tables/MonsterSpecialAbility.cs new file mode 100644 index 0000000..d2e1492 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/MonsterSpecialAbility.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class MonsterSpecialAbility : BaseEntity + { + public int SpecialAbilityId { get; set; } + + + public int? DamageDice { get; set; } + + public int? DamageDiceAmount { get; set; } + /// + /// Id potwora + /// + public int? MonsterId { get; set; } + + public virtual SpecialAbility SpecialAbility { get; set; } + /// + /// Połączenie z tabelą Monster + /// + public virtual Monster Monster { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Tables/SpecialAbility.cs b/SessionCompanion/SessionCompanion.Database/Tables/SpecialAbility.cs new file mode 100644 index 0000000..edb0380 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Tables/SpecialAbility.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.Database.Tables +{ + public class SpecialAbility : BaseEntity + { + // + /// Nazwa umiejętności + /// + public string Name { get; set; } + + /// + /// Opis umiejętności + /// + public string Description { get; set; } + + public int? DamageDice { get; set; } + + public int? DamageDiceAmount { get; set; } + + public virtual ICollection MonsterSpecialAbilities { get; set; } + } +} From fad8b27797e4aad30fc1799ac3119aada8e1b935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Tue, 12 Jan 2021 20:47:33 +0100 Subject: [PATCH 8/9] SES-143 Add monster related reposittories and ViewModel --- .../ApplicationDbContext.cs | 1 + .../Repositories/GameActionRepository.cs | 14 ++ .../Repositories/LegendaryActionRepository.cs | 14 ++ .../Repositories/MonsterActionsRepository.cs | 14 ++ .../MonsterLegendaryActionsRepository.cs | 14 ++ .../Repositories/MonsterRepository.cs | 14 ++ .../MonsterSpecialAbilitiesRepository.cs | 14 ++ .../Repositories/SpecialAbilityRepository.cs | 14 ++ .../GameActionViewModel.cs | 24 +++ .../LegendaryActionViewModel.cs | 20 +++ .../MonsterActionsViewModel.cs | 17 ++ .../MonsterLegendaryActionsViewModel.cs | 13 ++ .../MonsterSpecialAbilitiesViewModel.cs | 13 ++ .../MonsterAllInformationViewModel.cs | 156 ++++++++++++++++++ .../MonsterViewModels/MonsterViewModel.cs | 146 ++++++++++++++++ .../SpecialAbilityViewModel.cs | 24 +++ .../Configurations/RepositoryConfiguration.cs | 7 + 17 files changed, 519 insertions(+) create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/GameActionRepository.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/LegendaryActionRepository.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/MonsterActionsRepository.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/MonsterLegendaryActionsRepository.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/MonsterRepository.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/MonsterSpecialAbilitiesRepository.cs create mode 100644 SessionCompanion/SessionCompanion.Database/Repositories/SpecialAbilityRepository.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/GameActionViewModels/GameActionViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/LegendaryActionViewModels/LegendaryActionViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/MonsterActionsViewModels/MonsterActionsViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/MonsterLegendaryActionsViewModels/MonsterLegendaryActionsViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/MonsterSpecialAbilitiesViewModels/MonsterSpecialAbilitiesViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterAllInformationViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterViewModel.cs create mode 100644 SessionCompanion/SessionCompanion.ViewModels/SpecialAbilityViewModels/SpecialAbilityViewModel.cs diff --git a/SessionCompanion/SessionCompanion.Database/ApplicationDbContext.cs b/SessionCompanion/SessionCompanion.Database/ApplicationDbContext.cs index 9b78d69..c5359f5 100644 --- a/SessionCompanion/SessionCompanion.Database/ApplicationDbContext.cs +++ b/SessionCompanion/SessionCompanion.Database/ApplicationDbContext.cs @@ -127,3 +127,4 @@ namespace SessionCompanion.Database } } } + diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/GameActionRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/GameActionRepository.cs new file mode 100644 index 0000000..4c08429 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/GameActionRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class GameActionRepository : Repository, IRepository + { + public GameActionRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/LegendaryActionRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/LegendaryActionRepository.cs new file mode 100644 index 0000000..6cd9a0c --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/LegendaryActionRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class LegendaryActionRepository : Repository, IRepository + { + public LegendaryActionRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/MonsterActionsRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterActionsRepository.cs new file mode 100644 index 0000000..73817a4 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterActionsRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class MonsterActionsRepository : Repository, IRepository + { + public MonsterActionsRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/MonsterLegendaryActionsRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterLegendaryActionsRepository.cs new file mode 100644 index 0000000..b68cd81 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterLegendaryActionsRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class MonsterLegendaryActionsRepository : Repository, IRepository + { + public MonsterLegendaryActionsRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/MonsterRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterRepository.cs new file mode 100644 index 0000000..d79da11 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class MonsterRepository : Repository, IRepository + { + public MonsterRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/MonsterSpecialAbilitiesRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterSpecialAbilitiesRepository.cs new file mode 100644 index 0000000..ea2f25b --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/MonsterSpecialAbilitiesRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class MonsterSpecialAbilitiesRepository : Repository, IRepository + { + public MonsterSpecialAbilitiesRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.Database/Repositories/SpecialAbilityRepository.cs b/SessionCompanion/SessionCompanion.Database/Repositories/SpecialAbilityRepository.cs new file mode 100644 index 0000000..77c2764 --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/Repositories/SpecialAbilityRepository.cs @@ -0,0 +1,14 @@ +using SessionCompanion.Database.Repositories.Base; +using SessionCompanion.Database.Tables; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.Database.Repositories +{ + public class SpecialAbilityRepository : Repository, IRepository + { + public SpecialAbilityRepository(ApplicationDbContext _dbContext) : base(_dbContext) + { } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/GameActionViewModels/GameActionViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/GameActionViewModels/GameActionViewModel.cs new file mode 100644 index 0000000..ea919c9 --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/GameActionViewModels/GameActionViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.GameActionViewModels +{ + public class GameActionViewModel + { + public int Id { get; set; } + public string Name { get; set; } + + /// + /// Opis akcji + /// + public string Description { get; set; } + + public int AttackBonus { get; set; } + + public int? DamageDice { get; set; } + public int? DamageDiceAmount { get; set; } + + public int? DamageBonus { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/LegendaryActionViewModels/LegendaryActionViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/LegendaryActionViewModels/LegendaryActionViewModel.cs new file mode 100644 index 0000000..0e5b6f2 --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/LegendaryActionViewModels/LegendaryActionViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.LegendaryActionViewModels +{ + public class LegendaryActionViewModel + { + public int Id { get; set; } + // + /// Nazwa legendarnej akcji + /// + public string Name { get; set; } + + /// + /// Opis akcji + /// + public string Description { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/MonsterActionsViewModels/MonsterActionsViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/MonsterActionsViewModels/MonsterActionsViewModel.cs new file mode 100644 index 0000000..84dda2d --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/MonsterActionsViewModels/MonsterActionsViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.MonsterActionsViewModels +{ + public class MonsterActionsViewModel + { + public int Id { get; set; } + /// + /// Id potwora + /// + public int MonsterId { get; set; } + + public int GameActionId { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/MonsterLegendaryActionsViewModels/MonsterLegendaryActionsViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/MonsterLegendaryActionsViewModels/MonsterLegendaryActionsViewModel.cs new file mode 100644 index 0000000..b5f546d --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/MonsterLegendaryActionsViewModels/MonsterLegendaryActionsViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.MonsterLegendaryActionsViewModels +{ + public class MonsterLegendaryActionsViewModel + { + public int Id { get; set; } + public int MonsterId { get; set; } + public int LegendaryActionId { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/MonsterSpecialAbilitiesViewModels/MonsterSpecialAbilitiesViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/MonsterSpecialAbilitiesViewModels/MonsterSpecialAbilitiesViewModel.cs new file mode 100644 index 0000000..de1eb2f --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/MonsterSpecialAbilitiesViewModels/MonsterSpecialAbilitiesViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.MonsterSpecialAbilitiesViewModels +{ + public class MonsterSpecialAbilitiesViewModel + { + public int Id { get; set; } + public int MonsterId { get; set; } + public int LegendaryActionId { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterAllInformationViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterAllInformationViewModel.cs new file mode 100644 index 0000000..270c9d4 --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterAllInformationViewModel.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.MonsterViewModels +{ + using SessionCompanion.ViewModels.GameActionViewModels; + using SessionCompanion.ViewModels.LegendaryActionViewModels; + using SessionCompanion.ViewModels.SpecialAbilityViewModels; + + public class MonsterAllInformationViewModel + { + public int Id { get; set; } + /// + /// Nazwa potwora + /// + public string Name { get; set; } + + /// + /// Rozmiar potwora + /// + public string Size { get; set; } + + /// + /// Rodzaj potwora + /// + public string Type { get; set; } + + /// + /// Podtyp potwora + /// + public string Subtype { get; set; } + + /// + /// Charakter potwora + /// + public string Alignment { get; set; } + + /// + /// Poziom pancerza potwora + /// + public int ArmorClass { get; set; } + + /// + /// Iloś punktów zycia potwora + /// + public int HitPoints { get; set; } + + /// + /// Ilość kości określajacych punkty życia potwora + /// + public int HitDiceAmount { get; set; } + + /// + /// Kość którą rzucamy aby określić punkty życia potwora + /// + public int HitDiceType { get; set; } + + /// + /// Szybkość chodzenia potwora + /// + public string WalkSpeed { get; set; } + + /// + /// Szybkość pływania potwora + /// + public string SwimSpeed { get; set; } + + /// + /// Szybkość latania potwora + /// + public string FlySpeed { get; set; } + + /// + /// Punkty zręczności potwora + /// + public int Dexterity { get; set; } + public int? DexteritySave { get; set; } + + /// + /// Punkty siły potwora + /// + public int Strength { get; set; } + public int? StrengthSave { get; set; } + + /// + /// Punkty kondycji potwora + /// + public int Constitution { get; set; } + public int? ConstitutionSave { get; set; } + + /// + /// Punkty inteligencji potwora + /// + public int Intelligence { get; set; } + public int? IntelligenceSave { get; set; } + + /// + /// Punkty mądrości potwora + /// + public int Wisdom { get; set; } + public int? WisdomSave { get; set; } + + /// + /// Punkty charyzmy potwora + /// + public int Charisma { get; set; } + public int? CharismaSave { get; set; } + + /// + /// Poziom trudności potwora + /// + public int ChallengeRating { get; set; } + + /// + /// Punkty doświadczenia za zabicie potwora + /// + public int ExperiencePoints { get; set; } + + /// + /// Na jakie stany odporny jest potwor + /// + public string MonsterConditionImmunities { get; set; } + + /// + /// Na jakie obrazenia odporny jest potwor + /// + public string MonsterDamageImmunities { get; set; } + + /// + /// Na jakie obrazenia potwor ma zmniejszoną słabosc + /// + public string MonsterDamageResistances { get; set; } + + /// + /// Na co potwor jest wrazliwy + /// + public string MonsterDamageVulnerabilities { get; set; } + + /// + /// Jezyki jakimi wlada potwor + /// + public string MonsterLanguages { get; set; } + + /// + /// Połączenie z tabelą MonsterSenses + /// + public string MonsterSenses { get; set; } + + public ICollection MonsterGameActions { get; set; } + + public ICollection MonsteLegendaryActions { get; set; } + + public ICollection MonsterSpecialAbilities { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterViewModel.cs new file mode 100644 index 0000000..00c89f0 --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/MonsterViewModels/MonsterViewModel.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.MonsterViewModels +{ + public class MonsterViewModel + { + public int Id { get; set; } + /// + /// Nazwa potwora + /// + public string Name { get; set; } + + /// + /// Rozmiar potwora + /// + public string Size { get; set; } + + /// + /// Rodzaj potwora + /// + public string Type { get; set; } + + /// + /// Podtyp potwora + /// + public string Subtype { get; set; } + + /// + /// Charakter potwora + /// + public string Alignment { get; set; } + + /// + /// Poziom pancerza potwora + /// + public int ArmorClass { get; set; } + + /// + /// Iloś punktów zycia potwora + /// + public int HitPoints { get; set; } + + /// + /// Ilość kości określajacych punkty życia potwora + /// + public int HitDiceAmount { get; set; } + + /// + /// Kość którą rzucamy aby określić punkty życia potwora + /// + public int HitDiceType { get; set; } + + /// + /// Szybkość chodzenia potwora + /// + public string WalkSpeed { get; set; } + + /// + /// Szybkość pływania potwora + /// + public string SwimSpeed { get; set; } + + /// + /// Szybkość latania potwora + /// + public string FlySpeed { get; set; } + + /// + /// Punkty zręczności potwora + /// + public int Dexterity { get; set; } + public int? DexteritySave { get; set; } + + /// + /// Punkty siły potwora + /// + public int Strength { get; set; } + public int? StrengthSave { get; set; } + + /// + /// Punkty kondycji potwora + /// + public int Constitution { get; set; } + public int? ConstitutionSave { get; set; } + + /// + /// Punkty inteligencji potwora + /// + public int Intelligence { get; set; } + public int? IntelligenceSave { get; set; } + + /// + /// Punkty mądrości potwora + /// + public int Wisdom { get; set; } + public int? WisdomSave { get; set; } + + /// + /// Punkty charyzmy potwora + /// + public int Charisma { get; set; } + public int? CharismaSave { get; set; } + + /// + /// Poziom trudności potwora + /// + public int ChallengeRating { get; set; } + + /// + /// Punkty doświadczenia za zabicie potwora + /// + public int ExperiencePoints { get; set; } + + /// + /// Na jakie stany odporny jest potwor + /// + public string MonsterConditionImmunities { get; set; } + + /// + /// Na jakie obrazenia odporny jest potwor + /// + public string MonsterDamageImmunities { get; set; } + + /// + /// Na jakie obrazenia potwor ma zmniejszoną słabosc + /// + public string MonsterDamageResistances { get; set; } + + /// + /// Na co potwor jest wrazliwy + /// + public string MonsterDamageVulnerabilities { get; set; } + + /// + /// Jezyki jakimi wlada potwor + /// + public string MonsterLanguages { get; set; } + + /// + /// Połączenie z tabelą MonsterSenses + /// + public string MonsterSenses { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion.ViewModels/SpecialAbilityViewModels/SpecialAbilityViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/SpecialAbilityViewModels/SpecialAbilityViewModel.cs new file mode 100644 index 0000000..570140d --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/SpecialAbilityViewModels/SpecialAbilityViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SessionCompanion.ViewModels.SpecialAbilityViewModels +{ + public class SpecialAbilityViewModel + { + public int Id { get; set; } + // + /// Nazwa umiejętności + /// + public string Name { get; set; } + + /// + /// Opis umiejętności + /// + public string Description { get; set; } + + public int? DamageDice { get; set; } + + public int? DamageDiceAmount { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion/Configurations/RepositoryConfiguration.cs b/SessionCompanion/SessionCompanion/Configurations/RepositoryConfiguration.cs index 1e9659d..3ae65db 100644 --- a/SessionCompanion/SessionCompanion/Configurations/RepositoryConfiguration.cs +++ b/SessionCompanion/SessionCompanion/Configurations/RepositoryConfiguration.cs @@ -36,6 +36,13 @@ namespace SessionCompanion.Configurations services.AddScoped, CharacterOtherEquipmentRepository>(); services.AddScoped, WeaponRepository>(); services.AddScoped, CharacterWeaponRepository>(); + services.AddScoped, GameActionRepository>(); + services.AddScoped, LegendaryActionRepository>(); + services.AddScoped, MonsterActionsRepository>(); + services.AddScoped, MonsterLegendaryActionsRepository>(); + services.AddScoped, MonsterRepository>(); + services.AddScoped, MonsterSpecialAbilitiesRepository>(); + services.AddScoped, SpecialAbilityRepository>(); return services; } } From 81d3be7dd87d4e974eb0976ba86ab1f598ff8b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Tue, 12 Jan 2021 22:22:56 +0100 Subject: [PATCH 9/9] SES-155 Added endpoint that retuns basic infor for template character --- .../JsonData/characters_templates.json | 985 ++++++++++++++++++ .../SessionCompanion.Database.csproj | 4 - .../Intefraces/ICharacterService.cs | 3 + .../Services/CharacterService.cs | 30 +- .../CharacterFromTemplatesSimpleViewModel.cs | 28 + .../Controllers/CharacterController.cs | 31 +- 6 files changed, 1075 insertions(+), 6 deletions(-) create mode 100644 SessionCompanion/SessionCompanion.Database/JsonData/characters_templates.json create mode 100644 SessionCompanion/SessionCompanion.ViewModels/CharacterViewModels/CharacterFromTemplatesSimpleViewModel.cs diff --git a/SessionCompanion/SessionCompanion.Database/JsonData/characters_templates.json b/SessionCompanion/SessionCompanion.Database/JsonData/characters_templates.json new file mode 100644 index 0000000..c739b8f --- /dev/null +++ b/SessionCompanion/SessionCompanion.Database/JsonData/characters_templates.json @@ -0,0 +1,985 @@ +[ + { + "id": 1, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 4, + "Initiative": 2, + "HealthPoints": 8, + "CurrentHealthPoints": 8, + "ArmorClass": 5, + "Proficiency": 2 + }, + "biography": { + "Name": "Ulora", + "ClassId": 2, + "RaceId": 3, + "AlignmentId": "LawfulGood", + "BackgroundId": 2, + "Sex": "Female", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 11, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 12, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 44 + }, + { + "SpellId": 57 + } + ], + "charisma": { + "Value": 5, + "Modification": -2, + "SavingThrows": 0, + "CanSavingThrows": false, + "Deception": 0, + "CanDeception": false, + "Intimidation": 0, + "CanIntimidation": false, + "Performance": 0, + "CanPerformance": false, + "Persuasion": 0, + "CanPersuasion": false + }, + "constitution": { + "Value": 12, + "Modification": 2, + "SavingThrows": 2, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 15, + "Modification": 2, + "SavingThrows": 3, + "CanSaveThrows": true, + "Acrobatics": 3, + "CanAcrobatics": true, + "SleightOfHand": 2, + "CanSleightOfHand": true, + "Stealth": 3, + "canStealth": true + }, + "intelligence": { + "Value": 14, + "Modification": 4, + "SavingThrows": 2, + "CanSaveThrows": true, + "arcana": 2, + "canArcana": true, + "History": 4, + "CanHistory": true, + "Investigation": 3, + "CanInvestigation": true, + "Nature": 1, + "CanNature": true, + "Religion": 0, + "canReligion": false + }, + "strength": { + "Value": 8, + "Modification": -1, + "SavingThrows": 0, + "CanSaveThrows": false, + "Athletics": 0, + "canAthletics": false + }, + "wisdom": { + "Value": 10, + "Modification": 0, + "SavingThrows": 0, + "CanSaveThrows": false, + "AnimalHandling": 1, + "CanAnimalHandling": true, + "Insight": 0, + "canInsight": false, + "medicine": 0, + "CanMedicine": false, + "Perception": 2, + "CanPerception": true, + "Survival": 0, + "CanSurvival": false + } + }, + { + "id": 2, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 3, + "Initiative": 5, + "HealthPoints": 12, + "CurrentHealthPoints": 11, + "ArmorClass": 4, + "Proficiency": 1 + }, + "biography": { + "Name": "Nucate", + "ClassId": 1, + "RaceId": 1, + "AlignmentId": "LawfulGood", + "BackgroundId": 1, + "Sex": "Male", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 30, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 25, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 2 + }, + { + "SpellId": 42 + } + ], + "charisma": { + "Value": 10, + "Modification": 3, + "SavingThrows": 0, + "CanSavingThrows": false, + "Deception": 0, + "CanDeception": false, + "Intimidation": 1, + "CanIntimidation": true, + "Performance": 2, + "CanPerformance": true, + "Persuasion": 0, + "CanPersuasion": false + }, + "constitution": { + "Value": 11, + "Modification": 4, + "SavingThrows": 2, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 10, + "Modification": 1, + "SavingThrows": 4, + "CanSaveThrows": true, + "Acrobatics": 3, + "CanAcrobatics": true, + "SleightOfHand": 1, + "CanSleightOfHand": true, + "Stealth": 2, + "canStealth": true + }, + "intelligence": { + "Value": 6, + "Modification": -2, + "SavingThrows": 1, + "CanSaveThrows": true, + "arcana": 1, + "canArcana": true, + "History": 4, + "CanHistory": true, + "Investigation": 0, + "CanInvestigation": false, + "Nature": 1, + "CanNature": true, + "Religion": 3, + "canReligion": true + }, + "strength": { + "Value": 10, + "Modification": 1, + "SavingThrows": 0, + "CanSaveThrows": false, + "Athletics": 2, + "canAthletics": true + }, + "wisdom": { + "Value": 11, + "Modification": 3, + "SavingThrows": 1, + "CanSaveThrows": true, + "AnimalHandling": 2, + "canAnimalHandling": true, + "Insight": 1, + "canInsight": true, + "medicine": 0, + "CanMedicine": false, + "Perception": 5, + "CanPerception": true, + "Survival": 2, + "CanSurvival": true + } + }, + { + "id": 3, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 4, + "Initiative": 2, + "HealthPoints": 17, + "CurrentHealthPoints": 16, + "ArmorClass": 6, + "Proficiency": 3 + }, + "biography": { + "Name": "Muraraj", + "ClassId": 2, + "RaceId": 2, + "AlignmentId": "LawfulGood", + "BackgroundId": 1, + "Sex": "Male", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 1, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 2, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + }, + { + "WeaponId": 10, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 42 + } + ], + "charisma": { + "Value": 15, + "Modification": 2, + "SavingThrows": 2, + "CanSaveThrows": true, + "Deception": 1, + "CanDeception": true, + "Intimidation": 4, + "CanIntimidation": true, + "Performance": 2, + "CanPerformance": true, + "Persuasion": 2, + "CanPersuasion": true + }, + "constitution": { + "Value": 15, + "Modification": 4, + "SavingThrows": 2, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 8, + "Modification": -1, + "SavingThrows": 0, + "CanSaveThrows": false, + "Acrobatics": 0, + "CanAcrobatics": false, + "SleightOfHand": 0, + "CanSleightOfHand": false, + "Stealth": 0, + "canStealth": false + }, + "intelligence": { + "Value": 8, + "Modification": -1, + "SavingThrows": 0, + "CanSaveThrows": false, + "arcana": 0, + "canArcana": false, + "History": 0, + "CanHistory": false, + "Investigation": 0, + "CanInvestigation": false, + "Nature": 0, + "CanNature": false, + "Religion": 0, + "canReligion": false + }, + "strength": { + "Value": 18, + "Modification": 4, + "SavingThrows": 3, + "CanSaveThrows": true, + "Athletics": 5, + "canAthletics": true + }, + "wisdom": { + "Value": 6, + "Modification": -3, + "SavingThrows": 0, + "CanSaveThrows": false, + "AnimalHandling": 0, + "CanAnimalHandling": false, + "Insight": 0, + "canInsight": false, + "medicine": 0, + "CanMedicine": false, + "Perception": 0, + "CanPerception": false, + "Survival": 0, + "CanSurvival": false + } + }, + { + "id": 5, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 8, + "Initiative": 7, + "HealthPoints": 7, + "CurrentHealthPoints": 7, + "ArmorClass": 2, + "Proficiency": 3 + }, + "biography": { + "Name": "Amarena", + "ClassId": 2, + "RaceId": 1, + "AlignmentId": "LawfulGood", + "BackgroundId": 2, + "Sex": "Female", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 2, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 14, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + }, + { + "WeaponId": 4, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 2 + } + ], + "charisma": { + "Value": 7, + "Modification": -2, + "SavingThrows": 0, + "CanSavingThrows": false, + "Deception": 0, + "CanDeception": false, + "Intimidation": 0, + "CanIntimidation": false, + "Performance": 0, + "CanPerformance": false, + "Persuasion": 0, + "CanPersuasion": false + }, + "constitution": { + "Value": 11, + "Modification": 1, + "SavingThrows": 1, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 17, + "Modification": 4, + "SavingThrows": 3, + "CanSaveThrows": true, + "Acrobatics": 4, + "CanAcrobatics": true, + "SleightOfHand": 2, + "CanSleightOfHand": true, + "Stealth": 5, + "canStealth": true + }, + "intelligence": { + "Value": 10, + "Modification": 0, + "SavingThrows": 0, + "CanSaveThrows": false, + "arcana": 0, + "canArcana": false, + "History": 0, + "CanHistory": false, + "Investigation": 0, + "CanInvestigation": false, + "Nature": 0, + "CanNature": false, + "Religion": 0, + "canReligion": false + }, + "strength": { + "Value": 14, + "Modification": 2, + "SavingThrows": 1, + "CanSaveThrows": true, + "Athletics": 3, + "canAthletics": true + }, + "wisdom": { + "Value": 7, + "Modification": 0, + "SavingThrows": 0, + "CanSaveThrows": false, + "AnimalHandling": 0, + "canAnimalHandling": false, + "Insight": 0, + "canInsight": false, + "medicine": 0, + "CanMedicine": false, + "Perception": 0, + "CanPerception": false, + "Survival": 0, + "CanSurvival": false + } + }, + { + "id": 6, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 2, + "Initiative": 3, + "HealthPoints": 17, + "CurrentHealthPoints": 17, + "ArmorClass": 5, + "Proficiency": 1 + }, + "biography": { + "Name": "Yaz' uw Emul", + "ClassId": 1, + "RaceId": 3, + "AlignmentId": "LawfulGood", + "BackgroundId": 3, + "Sex": "Male", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 16, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 14, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 2 + }, + { + "SpellId": 65 + }, + { + "SpellId": 44 + } + ], + "charisma": { + "Value": 10, + "Modification": 0, + "SavingThrows": 0, + "CanSavingThrows": false, + "Deception": 1, + "CanDeception": true, + "Intimidation": 2, + "CanIntimidation": true, + "Performance": 0, + "CanPerformance": false, + "Persuasion": 0, + "CanPersuasion": false + }, + "constitution": { + "Value": 14, + "Modification": 4, + "SavingThrows": 1, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 6, + "Modification": -3, + "SavingThrows": 0, + "CanSaveThrows": false, + "Acrobatics": 0, + "CanAcrobatics": false, + "SleightOfHand": 0, + "CanSleightOfHand": false, + "Stealth": 0, + "canStealth": false + }, + "intelligence": { + "Value": 11, + "Modification": 1, + "SavingThrows": 1, + "CanSaveThrows": true, + "arcana": 0, + "canArcana": false, + "History": 2, + "CanHistory": true, + "Investigation": 1, + "CanInvestigation": true, + "Nature": 0, + "CanNature": false, + "Religion": 4, + "canReligion": true + }, + "strength": { + "Value": 18, + "Modification": 4, + "SavingThrows": 2, + "CanSaveThrows": true, + "Athletics": 4, + "canAthletics": true + }, + "wisdom": { + "Value": 9, + "Modification": -1, + "SavingThrows": 0, + "CanSaveThrows": false, + "AnimalHandling": 0, + "canAnimalHandling": false, + "Insight": 0, + "canInsight": false, + "medicine": 0, + "CanMedicine": false, + "Perception": 0, + "CanPerception": false, + "Survival": 0, + "CanSurvival": false + } + }, + { + "id": 7, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 5, + "Initiative": 4, + "HealthPoints": 13, + "CurrentHealthPoints": 13, + "ArmorClass": 2, + "Proficiency": 1 + }, + "biography": { + "Name": "Kamul", + "ClassId": 2, + "RaceId": 1, + "AlignmentId": "LawfulGood", + "BackgroundId": 1, + "Sex": "Female", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 18, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 1, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 3 + }, + { + "SpellId": 85 + }, + { + "SpellId": 94 + } + ], + "charisma": { + "Value": 10, + "Modification": 0, + "SavingThrows": 0, + "CanSavingThrows": false, + "Deception": 2, + "CanDeception": true, + "Intimidation": 0, + "CanIntimidation": false, + "Performance": 1, + "CanPerformance": true, + "Persuasion": 2, + "CanPersuasion": true + }, + "constitution": { + "Value": 8, + "Modification": -2, + "SavingThrows": 0, + "CanSaveThrows": false + }, + "dexterity": { + "Value": 12, + "Modification": 1, + "SavingThrows": 1, + "CanSaveThrows": true, + "Acrobatics": 2, + "CanAcrobatics": true, + "SleightOfHand": 1, + "CanSleightOfHand": true, + "Stealth": 0, + "canStealth": false + }, + "intelligence": { + "Value": 15, + "Modification": 4, + "SavingThrows": 2, + "CanSaveThrows": true, + "arcana": 4, + "canArcana": true, + "History": 1, + "CanHistory": true, + "Investigation": 1, + "CanInvestigation": true, + "Nature": 6, + "CanNature": true, + "Religion": 0, + "canReligion": false + }, + "strength": { + "Value": 13, + "Modification": 1, + "SavingThrows": 1, + "CanSaveThrows": true, + "Athletics": 2, + "canAthletics": true + }, + "wisdom": { + "Value": 13, + "Modification": 2, + "SavingThrows": 2, + "CanSaveThrows": true, + "AnimalHandling": 1, + "canAnimalHandling": true, + "Insight": 4, + "canInsight": true, + "medicine": 2, + "CanMedicine": true, + "Perception": 5, + "CanPerception": true, + "Survival": 2, + "CanSurvival": true + } + }, + { + "id": 8, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 9, + "Initiative": 6, + "HealthPoints": 7, + "CurrentHealthPoints": 7, + "ArmorClass": 4, + "Proficiency": 1 + }, + "biography": { + "Name": "Mu", + "ClassId": 1, + "RaceId": 3, + "AlignmentId": "LawfulGood", + "BackgroundId": 2, + "Sex": "Male", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 1, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 17, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + }, + { + "WeaponId": 27, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 3 + } + ], + "charisma": { + "Value": 11, + "Modification": 1, + "SavingThrows": 1, + "CanSavingThrows": true, + "Deception": 1, + "CanDeception": true, + "Intimidation": 0, + "CanIntimidation": false, + "Performance": 0, + "CanPerformance": false, + "Persuasion": 0, + "CanPersuasion": false + }, + "constitution": { + "Value": 13, + "Modification": 2, + "SavingThrows": 1, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 17, + "Modification": 4, + "SavingThrows": 3, + "CanSaveThrows": true, + "Acrobatics": 3, + "CanAcrobatics": true, + "SleightOfHand": 4, + "CanSleightOfHand": true, + "Stealth": 1, + "canStealth": true + }, + "intelligence": { + "Value": 8, + "Modification": -2, + "SavingThrows": 0, + "CanSaveThrows": false, + "arcana": 0, + "canArcana": false, + "History": 0, + "CanHistory": false, + "Investigation": 0, + "CanInvestigation": false, + "Nature": 0, + "CanNature": false, + "Religion": 0, + "canReligion": false + }, + "strength": { + "Value": 18, + "Modification": 4, + "SavingThrows": 3, + "CanSaveThrows": true, + "Athletics": 5, + "canAthletics": true + }, + "wisdom": { + "Value": 8, + "Modification": -2, + "SavingThrows": 0, + "CanSaveThrows": false, + "AnimalHandling": 0, + "canAnimalHandling": false, + "Insight": 0, + "canInsight": false, + "medicine": 0, + "CanMedicine": false, + "Perception": 0, + "CanPerception": false, + "Survival": 0, + "CanSurvival": false + } + }, + { + "id": 9, + "userId": -1, + "statistics": { + "ExperiencePoints": 0, + "Level": 1, + "Speed": 4, + "Initiative": 3, + "HealthPoints": 12, + "CurrentHealthPoints": 12, + "ArmorClass": 3, + "Proficiency": 1 + }, + "biography": { + "Name": "Aarak", + "ClassId": 2, + "RaceId": 3, + "AlignmentId": "LawfulGood", + "BackgroundId": 2, + "Sex": "Female", + "Languages": "Common", + "background": { + "Origin": "No origin", + "History": "Nothing much" + } + }, + "characterWeapons": [ + { + "WeaponId": 4, + "InUse": true, + "HoldInRightHand": true, + "HoldInLeftHand": false + }, + { + "WeaponId": 7, + "InUse": false, + "HoldInRightHand": false, + "HoldInLeftHand": false + } + ], + "characterSpells": [ + { + "SpellId": 1 + }, + { + "SpellId": 55 + } + ], + "charisma": { + "Value": 12, + "Modification": 2, + "SavingThrows": 1, + "CanSavingThrows": true, + "Deception": 0, + "CanDeception": false, + "Intimidation": 0, + "CanIntimidation": false, + "Performance": 0, + "CanPerformance": false, + "Persuasion": 3, + "CanPersuasion": true + }, + "constitution": { + "Value": 11, + "Modification": 1, + "SavingThrows": 1, + "CanSaveThrows": true + }, + "dexterity": { + "Value": 15, + "Modification": 3, + "SavingThrows": 2, + "CanSaveThrows": true, + "Acrobatics": 2, + "CanAcrobatics": true, + "SleightOfHand": 1, + "CanSleightOfHand": true, + "Stealth": 4, + "canStealth": true + }, + "intelligence": { + "Value": 12, + "Modification": 1, + "SavingThrows": 1, + "CanSaveThrows": true, + "arcana": 0, + "canArcana": false, + "History": 0, + "CanHistory": false, + "Investigation": 0, + "CanInvestigation": false, + "Nature": 2, + "CanNature": true, + "Religion": 0, + "canReligion": false + }, + "strength": { + "Value": 15, + "Modification": 4, + "SavingThrows": 3, + "CanSaveThrows": true, + "Athletics": 2, + "canAthletics": true + }, + "wisdom": { + "Value": 6, + "Modification": -4, + "SavingThrows": 0, + "CanSaveThrows": false, + "AnimalHandling": 0, + "canAnimalHandling": false, + "Insight": 0, + "canInsight": false, + "medicine": 0, + "CanMedicine": false, + "Perception": 0, + "CanPerception": false, + "Survival": 0, + "CanSurvival": false + } + } +] diff --git a/SessionCompanion/SessionCompanion.Database/SessionCompanion.Database.csproj b/SessionCompanion/SessionCompanion.Database/SessionCompanion.Database.csproj index 120ad3e..a157829 100644 --- a/SessionCompanion/SessionCompanion.Database/SessionCompanion.Database.csproj +++ b/SessionCompanion/SessionCompanion.Database/SessionCompanion.Database.csproj @@ -21,8 +21,4 @@ - - - - diff --git a/SessionCompanion/SessionCompanion.Services/Intefraces/ICharacterService.cs b/SessionCompanion/SessionCompanion.Services/Intefraces/ICharacterService.cs index 026f0f7..715f6f3 100644 --- a/SessionCompanion/SessionCompanion.Services/Intefraces/ICharacterService.cs +++ b/SessionCompanion/SessionCompanion.Services/Intefraces/ICharacterService.cs @@ -1,6 +1,8 @@ using SessionCompanion.Database.Tables; using SessionCompanion.Services.Base; using SessionCompanion.ViewModels.CharacterViewModels; +using SessionCompanion.ViewModels.ClassViewModels; +using SessionCompanion.ViewModels.RaceViewModels; using SessionCompanion.ViewModels.UniversalModels; using System; using System.Collections.Generic; @@ -15,5 +17,6 @@ namespace SessionCompanion.Services.Interfaces Task> GetUserLoginCharacters(int userId); Task> GetCharacterStatistics(int characterId); Task GetBasicCharacterbasicInfo(int characterId); + Task> GetCharactersFromTemplate(List raceViewModels, List classViewModels); } } diff --git a/SessionCompanion/SessionCompanion.Services/Services/CharacterService.cs b/SessionCompanion/SessionCompanion.Services/Services/CharacterService.cs index ddbf698..808c168 100644 --- a/SessionCompanion/SessionCompanion.Services/Services/CharacterService.cs +++ b/SessionCompanion/SessionCompanion.Services/Services/CharacterService.cs @@ -16,12 +16,14 @@ using System.IO; using Newtonsoft.Json.Linq; using SessionCompanion.ViewModels.UniversalModels; using SessionCompanion.Services.Helpers; +using SessionCompanion.ViewModels.RaceViewModels; +using SessionCompanion.ViewModels.ClassViewModels; namespace SessionCompanion.Services.Services { public class CharacterService : ServiceBase, ICharacterService { - public CharacterService(IMapper mapper, IRepository repository) : base(mapper, repository) + public CharacterService(IMapper mapper, IRepository repository, IRepository classRepository) : base(mapper, repository) { } /// @@ -111,5 +113,31 @@ namespace SessionCompanion.Services.Services var result = Mapper.Map(character); return result; } + + /// + /// Function returns basic stats from Characters in templates + /// + /// + public async Task> GetCharactersFromTemplate(List raceViewModels, List classViewModels) + { + const string file = "../SessionCompanion.Database/JsonData/characters_templates.json"; + List basicStats = new List(); + using (StreamReader reader = new StreamReader(file)) + { + var json = await reader.ReadToEndAsync(); + foreach (var item in JArray.Parse(json)) + { + CharacterFromTemplatesSimpleViewModel characterFromTemplatesSimpleViewModel = new CharacterFromTemplatesSimpleViewModel() + { + Id = (int)item["id"], + Class = classViewModels.Where(c => c.Id.Equals((int)item["biography"]["ClassId"])).Select(c => c.Name).Single(), + Race = raceViewModels.Where(r => r.Id.Equals((int)item["biography"]["RaceId"])).Select(r => r.Name).Single(), + Name = (string)item["biography"]["Name"] + }; + basicStats.Add(characterFromTemplatesSimpleViewModel); + } + } + return basicStats; + } } } diff --git a/SessionCompanion/SessionCompanion.ViewModels/CharacterViewModels/CharacterFromTemplatesSimpleViewModel.cs b/SessionCompanion/SessionCompanion.ViewModels/CharacterViewModels/CharacterFromTemplatesSimpleViewModel.cs new file mode 100644 index 0000000..dbf4079 --- /dev/null +++ b/SessionCompanion/SessionCompanion.ViewModels/CharacterViewModels/CharacterFromTemplatesSimpleViewModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionCompanion.ViewModels.CharacterViewModels +{ + public class CharacterFromTemplatesSimpleViewModel + { + /// + /// Id postaci + /// + public int Id { get; set; } + /// + /// Imie postaci + /// + public string Name { get; set; } + /// + /// Nazwa rasy postaci + /// + public string Race { get; set; } + /// + /// Nazwa Klasy postaci + /// + public string Class { get; set; } + } +} diff --git a/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs b/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs index f59f3c7..4fd9901 100644 --- a/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/CharacterController.cs @@ -9,6 +9,7 @@ namespace SessionCompanion.Controllers { using SessionCompanion.Hubs; using SessionCompanion.ViewModels.UniversalModels; + using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; @@ -19,11 +20,15 @@ namespace SessionCompanion.Controllers { private readonly ICharacterService _service; private readonly SessionHubData _sessionHubData; + private readonly IRaceService _raceService; + private readonly IClassService _classService; - public CharacterController(ICharacterService service) + public CharacterController(ICharacterService service, IRaceService raceService, IClassService classService) { this._service = service; this._sessionHubData = new SessionHubData(); + this._raceService = raceService; + this._classService = classService; } /// @@ -105,5 +110,29 @@ namespace SessionCompanion.Controllers }; return info; } + + /// + /// Metoda zwraca podstawowe informacje dla postaci z Templatek + /// + /// liste podstawowych informacji o postaciach z templatki + [HttpGet("getTemplateCharacters")] + public async Task>> GetTemplateCharacters() + { + var races = _raceService.Get().ToList(); + var classes = _classService.Get().ToList(); + try + { + var templateCharacters = await _service.GetCharactersFromTemplate(races, classes); + return templateCharacters.ToList(); + } + catch (Exception e) + { + return new ErrorResponse() + { + StatusCode = 500, + Message = e.Message + }; + } + } } } \ No newline at end of file
Name