|
@@ -1,6 +1,5 @@
|
|
import { Injectable } from '@angular/core';
|
|
import { Injectable } from '@angular/core';
|
|
import Localbase from 'localbase';
|
|
import Localbase from 'localbase';
|
|
-import { Character } from 'src/interfaces/character';
|
|
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
import { BehaviorSubject } from 'rxjs';
|
|
import { BehaviorSubject } from 'rxjs';
|
|
import { Attribute } from 'src/interfaces/attribute';
|
|
import { Attribute } from 'src/interfaces/attribute';
|
|
@@ -16,195 +15,130 @@ import { Food } from 'src/interfaces/food';
|
|
providedIn: 'root',
|
|
providedIn: 'root',
|
|
})
|
|
})
|
|
export class DataService {
|
|
export class DataService {
|
|
- db: any;
|
|
|
|
|
|
+ private db: any;
|
|
|
|
+
|
|
|
|
+ public dataLoaded = false;
|
|
|
|
+ public characterName: string = '';
|
|
|
|
|
|
constructor(private Router: Router) {
|
|
constructor(private Router: Router) {
|
|
- this.db = new Localbase('myDatabase');
|
|
|
|
- // this.test();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // public test(): void {
|
|
|
|
- // let char: Character = {
|
|
|
|
- // characterData: {
|
|
|
|
- // name: 'Eliane',
|
|
|
|
- // class: '',
|
|
|
|
- // race: '',
|
|
|
|
- // level: '',
|
|
|
|
- // subclass: '',
|
|
|
|
- // background: '',
|
|
|
|
- // experience: '',
|
|
|
|
- // inspiration: '',
|
|
|
|
- // proficiencyBonus: '2',
|
|
|
|
- // },
|
|
|
|
- // attributes: {
|
|
|
|
- // strength: ['12', false],
|
|
|
|
- // dexterity: ['14', false],
|
|
|
|
- // constitution: ['16', false],
|
|
|
|
- // intelligence: ['10', false],
|
|
|
|
- // wisdom: ['16', false],
|
|
|
|
- // charisma: ['10', false],
|
|
|
|
- // },
|
|
|
|
- // skills: {
|
|
|
|
- // acrobatics: ['12', false],
|
|
|
|
- // animalHandling: ['11', false],
|
|
|
|
- // arcana: ['11', false],
|
|
|
|
- // athletics: ['11', false],
|
|
|
|
- // deception: ['11', false],
|
|
|
|
- // history: ['12', false],
|
|
|
|
- // insight: ['13', false],
|
|
|
|
- // intimidation: ['14', false],
|
|
|
|
- // investigation: ['16', false],
|
|
|
|
- // medicine: ['15', false],
|
|
|
|
- // nature: ['17', false],
|
|
|
|
- // perception: ['18', false],
|
|
|
|
- // performance: ['19', false],
|
|
|
|
- // persuasion: ['20', false],
|
|
|
|
- // religion: ['9', false],
|
|
|
|
- // sleightOfHand: ['8', false],
|
|
|
|
- // stealth: ['7', false],
|
|
|
|
- // survival: ['6', false],
|
|
|
|
- // },
|
|
|
|
- // combatStats: {
|
|
|
|
- // armorClass: '18',
|
|
|
|
- // initiative: '+2',
|
|
|
|
- // speed: '30',
|
|
|
|
- // hitPointMaximum: '12',
|
|
|
|
- // currentHitPoints: '12',
|
|
|
|
- // temporaryHitPoints: '0',
|
|
|
|
- // hitDice: '',
|
|
|
|
- // deathSaveSuccesses: '0',
|
|
|
|
- // deathSaveFailures: '0',
|
|
|
|
- // },
|
|
|
|
- // appearance: {
|
|
|
|
- // age: '',
|
|
|
|
- // height: '',
|
|
|
|
- // weight: '',
|
|
|
|
- // eyes: '',
|
|
|
|
- // skin: '',
|
|
|
|
- // hair: '',
|
|
|
|
- // },
|
|
|
|
- // personality: {
|
|
|
|
- // personalityTraits: '',
|
|
|
|
- // ideals: '',
|
|
|
|
- // bonds: '',
|
|
|
|
- // flaws: '',
|
|
|
|
- // },
|
|
|
|
- // weapons: {
|
|
|
|
- // name: '',
|
|
|
|
- // attackBonus: '',
|
|
|
|
- // damage: '',
|
|
|
|
- // damageType: '',
|
|
|
|
- // range: '',
|
|
|
|
- // description: '',
|
|
|
|
- // },
|
|
|
|
- // };
|
|
|
|
- // this.character = char;
|
|
|
|
- // // console.log('character: ', this.character);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- public character: any = {};
|
|
|
|
-
|
|
|
|
- // #region character data retrieval
|
|
|
|
-
|
|
|
|
- public getCompleteCharacter(): Character {
|
|
|
|
- return this.character;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getCharacterData(): any {
|
|
|
|
- return this.character.characterData;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getAppearance(): any {
|
|
|
|
- return this.character.appearance;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getAttributes(): any {
|
|
|
|
- return this.character.attributes;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getSkills(): any {
|
|
|
|
- return this.character.skills;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getCombatStats(): any {
|
|
|
|
- return this.character.combatStats;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getPersonality(): any {
|
|
|
|
- return this.character.personality;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // public getWeapons(): any {
|
|
|
|
- // return this.character.weapons;
|
|
|
|
- // }
|
|
|
|
|
|
+ this.db = new Localbase('DNDTools');
|
|
|
|
+ // this.db.config.debug = false;
|
|
|
|
+ }
|
|
|
|
|
|
- // #endregion
|
|
|
|
|
|
+ async loadData(): Promise<any> {
|
|
|
|
+ console.warn('loadData() called');
|
|
|
|
+ this.characterName = sessionStorage.getItem('characterName')!;
|
|
|
|
+ if (this.dataLoaded) {
|
|
|
|
+ return Promise.resolve();
|
|
|
|
+ }
|
|
|
|
+ return this.getCollectionWithKeys(this.characterName).then((data: any) => {
|
|
|
|
+ this.buildCurrentCharacter(data);
|
|
|
|
+ this.dataLoaded = true;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
- // #region data storage
|
|
|
|
|
|
+ // #region character selection and construction
|
|
|
|
|
|
- private weapons: Weapon[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Großschwert',
|
|
|
|
- attackBonus: '+3',
|
|
|
|
- damage: [{ diceNumber: '2', diceType: 'd6', damageType: 'slashing' }],
|
|
|
|
- proficient: true,
|
|
|
|
- range: '5ft',
|
|
|
|
- throwRange: '',
|
|
|
|
- isFinesse: false,
|
|
|
|
- isVersatile: false,
|
|
|
|
- isTwoHanded: true,
|
|
|
|
- isRanged: false,
|
|
|
|
- canBeThrown: false,
|
|
|
|
- weight: 'schwer',
|
|
|
|
- isMagical: false,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Kurzbogen +1',
|
|
|
|
- attackBonus: '+5',
|
|
|
|
- damage: [{ diceNumber: '1', diceType: 'd8', damageType: 'piercing' }],
|
|
|
|
- proficient: false,
|
|
|
|
- range: '80/320ft',
|
|
|
|
- throwRange: '',
|
|
|
|
- isFinesse: false,
|
|
|
|
- isVersatile: false,
|
|
|
|
- isTwoHanded: true,
|
|
|
|
- isRanged: true,
|
|
|
|
- canBeThrown: false,
|
|
|
|
- weight: 'leicht',
|
|
|
|
- isMagical: true,
|
|
|
|
- magicBonus: 1,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Feuerstab',
|
|
|
|
- attackBonus: '+5',
|
|
|
|
- damage: [
|
|
|
|
- { diceNumber: '1', diceType: 'd6', damageType: 'bludgeoning' },
|
|
|
|
- { diceNumber: '1', diceType: 'd4', damageType: 'fire' },
|
|
|
|
- ],
|
|
|
|
- versatileDamage: 'd8',
|
|
|
|
- proficient: true,
|
|
|
|
- range: '5ft',
|
|
|
|
- throwRange: '',
|
|
|
|
- isFinesse: false,
|
|
|
|
- isVersatile: true,
|
|
|
|
- isTwoHanded: false,
|
|
|
|
- isRanged: false,
|
|
|
|
- canBeThrown: false,
|
|
|
|
- weight: 'normal',
|
|
|
|
- isMagical: false,
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ private buildCurrentCharacter(currentCharacterData: any): void {
|
|
|
|
+ console.log('currentCharacterData: ', currentCharacterData);
|
|
|
|
+ const [
|
|
|
|
+ abilitiesData,
|
|
|
|
+ appearanceData,
|
|
|
|
+ attributesData,
|
|
|
|
+ characterData,
|
|
|
|
+ combatStatsData,
|
|
|
|
+ consumablesData,
|
|
|
|
+ favoriteSpellsData,
|
|
|
|
+ favoriteWeaponsData,
|
|
|
|
+ foodData,
|
|
|
|
+ hitPointsData,
|
|
|
|
+ kiPointsData,
|
|
|
|
+ miscellaneousData,
|
|
|
|
+ moneyData,
|
|
|
|
+ personalityData,
|
|
|
|
+ proficienciesData,
|
|
|
|
+ skillsData,
|
|
|
|
+ spellLevel0,
|
|
|
|
+ spellLevel1,
|
|
|
|
+ spellLevel2,
|
|
|
|
+ spellLevel3,
|
|
|
|
+ spellLevel4,
|
|
|
|
+ spellLevel5,
|
|
|
|
+ spellLevel6,
|
|
|
|
+ spellLevel7,
|
|
|
|
+ spellLevel8,
|
|
|
|
+ spellLevel9,
|
|
|
|
+ spellslotsData,
|
|
|
|
+ traitsData,
|
|
|
|
+ weaponsAndArmorData,
|
|
|
|
+ ] = currentCharacterData.map((entry: any) => entry.data);
|
|
|
|
|
|
- public getWeapons(): Weapon[] {
|
|
|
|
- return this.weapons;
|
|
|
|
|
|
+ // currentCharacterData.forEach((entry: any, index: number) => {
|
|
|
|
+ // console.log(entry.key, ' : ', entry.data);
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ console.warn('The whole character: ', currentCharacterData);
|
|
|
|
+
|
|
|
|
+ // Attributes
|
|
|
|
+ Object.keys(attributesData).forEach((key: string) => {
|
|
|
|
+ this.updateAttribute(attributesData[key]);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Skills
|
|
|
|
+ Object.keys(skillsData).forEach((key: string) => {
|
|
|
|
+ this.updateSkill(skillsData[key]);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Hit Points
|
|
|
|
+ this.hitPoints = hitPointsData.hitPoints;
|
|
|
|
+ this.hitDice = hitPointsData.hitDice;
|
|
|
|
+
|
|
|
|
+ // Combat Stats
|
|
|
|
+ this.armorClass = combatStatsData.armorClass;
|
|
|
|
+ this.initiative = combatStatsData.initiative;
|
|
|
|
+ this.movement = combatStatsData.movement;
|
|
|
|
+ this.updateProficiencyBonus(combatStatsData.proficiencyBonus);
|
|
|
|
+ this.deathSaves = combatStatsData.deathSaves;
|
|
|
|
+ this.conditions = combatStatsData.conditions;
|
|
|
|
+ this.exhaustion = combatStatsData.exhaustion;
|
|
|
|
+ this.inspiration = combatStatsData.inspiration;
|
|
|
|
+
|
|
|
|
+ // Spells
|
|
|
|
+ this.spellslots = spellslotsData;
|
|
|
|
+ this.favoriteSpells = favoriteSpellsData.spells;
|
|
|
|
+ this.spellLevel0 = spellLevel0.spells;
|
|
|
|
+ this.spellLevel1 = spellLevel1.spells;
|
|
|
|
+ this.spellLevel2 = spellLevel2.spells;
|
|
|
|
+ this.spellLevel3 = spellLevel3.spells;
|
|
|
|
+ this.spellLevel4 = spellLevel4.spells;
|
|
|
|
+ this.spellLevel5 = spellLevel5.spells;
|
|
|
|
+ this.spellLevel6 = spellLevel6.spells;
|
|
|
|
+ this.spellLevel7 = spellLevel7.spells;
|
|
|
|
+ this.spellLevel8 = spellLevel8.spells;
|
|
|
|
+ this.spellLevel9 = spellLevel9.spells;
|
|
|
|
+
|
|
|
|
+ // Items
|
|
|
|
+ this.favoriteWeapons = favoriteWeaponsData.data;
|
|
|
|
+ this.weaponsAndArmor = weaponsAndArmorData.data;
|
|
|
|
+ this.consumables = consumablesData.data;
|
|
|
|
+ this.miscellaneous = miscellaneousData.data;
|
|
|
|
+ this.food = foodData.data;
|
|
|
|
+ this.money = moneyData;
|
|
|
|
+
|
|
|
|
+ // Abilities and stuff
|
|
|
|
+ this.kiPoints = kiPointsData;
|
|
|
|
+ this.traits = traitsData.data;
|
|
|
|
+ this.abilities = abilitiesData.data;
|
|
|
|
+ this.proficiencies = proficienciesData;
|
|
}
|
|
}
|
|
|
|
|
|
- public setWeapons(weapons: Weapon[]): void {
|
|
|
|
- this.weapons = weapons;
|
|
|
|
- console.log('weapons updated from data service: ', this.weapons);
|
|
|
|
- }
|
|
|
|
|
|
+ // #endregion
|
|
|
|
+
|
|
|
|
+ // #region WEAPONS
|
|
|
|
+
|
|
|
|
+ // #endregion
|
|
|
|
|
|
- // SPELLS
|
|
|
|
|
|
+ // #region # SPELLS
|
|
|
|
|
|
private _favoriteSpells: Spell[] = [
|
|
private _favoriteSpells: Spell[] = [
|
|
{
|
|
{
|
|
@@ -315,7 +249,7 @@ export class DataService {
|
|
|
|
|
|
public set favoriteSpells(spells: Spell[]) {
|
|
public set favoriteSpells(spells: Spell[]) {
|
|
this._favoriteSpells = spells;
|
|
this._favoriteSpells = spells;
|
|
- console.log('spells updated from data service: ', this._favoriteSpells);
|
|
|
|
|
|
+ this.setData('favoriteSpells', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel0: Spell[] = [
|
|
private _spellLevel0: Spell[] = [
|
|
@@ -400,7 +334,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel0(spells: Spell[]) {
|
|
public set spellLevel0(spells: Spell[]) {
|
|
this._spellLevel0 = spells;
|
|
this._spellLevel0 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel0);
|
|
|
|
|
|
+ this.setData('spellLevel0', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel1: Spell[] = [
|
|
private _spellLevel1: Spell[] = [
|
|
@@ -460,7 +394,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel1(spells: Spell[]) {
|
|
public set spellLevel1(spells: Spell[]) {
|
|
this._spellLevel1 = spells;
|
|
this._spellLevel1 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel1);
|
|
|
|
|
|
+ this.setData('spellLevel1', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel2: Spell[] = [
|
|
private _spellLevel2: Spell[] = [
|
|
@@ -524,7 +458,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel2(spells: Spell[]) {
|
|
public set spellLevel2(spells: Spell[]) {
|
|
this._spellLevel2 = spells;
|
|
this._spellLevel2 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel2);
|
|
|
|
|
|
+ this.setData('spellLevel2', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel3: Spell[] = [];
|
|
private _spellLevel3: Spell[] = [];
|
|
@@ -535,7 +469,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel3(spells: Spell[]) {
|
|
public set spellLevel3(spells: Spell[]) {
|
|
this._spellLevel3 = spells;
|
|
this._spellLevel3 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel3);
|
|
|
|
|
|
+ this.setData('spellLevel3', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel4: Spell[] = [];
|
|
private _spellLevel4: Spell[] = [];
|
|
@@ -546,7 +480,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel4(spells: Spell[]) {
|
|
public set spellLevel4(spells: Spell[]) {
|
|
this._spellLevel4 = spells;
|
|
this._spellLevel4 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel4);
|
|
|
|
|
|
+ this.setData('spellLevel4', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel5: Spell[] = [];
|
|
private _spellLevel5: Spell[] = [];
|
|
@@ -557,7 +491,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel5(spells: Spell[]) {
|
|
public set spellLevel5(spells: Spell[]) {
|
|
this._spellLevel5 = spells;
|
|
this._spellLevel5 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel5);
|
|
|
|
|
|
+ this.setData('spellLevel5', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel6: Spell[] = [];
|
|
private _spellLevel6: Spell[] = [];
|
|
@@ -568,7 +502,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel6(spells: Spell[]) {
|
|
public set spellLevel6(spells: Spell[]) {
|
|
this._spellLevel6 = spells;
|
|
this._spellLevel6 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel6);
|
|
|
|
|
|
+ this.setData('spellLevel6', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel7: Spell[] = [];
|
|
private _spellLevel7: Spell[] = [];
|
|
@@ -579,7 +513,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel7(spells: Spell[]) {
|
|
public set spellLevel7(spells: Spell[]) {
|
|
this._spellLevel7 = spells;
|
|
this._spellLevel7 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel7);
|
|
|
|
|
|
+ this.setData('spellLevel7', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel8: Spell[] = [];
|
|
private _spellLevel8: Spell[] = [];
|
|
@@ -590,7 +524,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel8(spells: Spell[]) {
|
|
public set spellLevel8(spells: Spell[]) {
|
|
this._spellLevel8 = spells;
|
|
this._spellLevel8 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel8);
|
|
|
|
|
|
+ this.setData('spellLevel8', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
private _spellLevel9: Spell[] = [];
|
|
private _spellLevel9: Spell[] = [];
|
|
@@ -601,7 +535,7 @@ export class DataService {
|
|
|
|
|
|
public set spellLevel9(spells: Spell[]) {
|
|
public set spellLevel9(spells: Spell[]) {
|
|
this._spellLevel9 = spells;
|
|
this._spellLevel9 = spells;
|
|
- console.log('spells updated from data service: ', this._spellLevel9);
|
|
|
|
|
|
+ this.setData('spellLevel9', { spells: spells });
|
|
}
|
|
}
|
|
|
|
|
|
public getAllPreparedSpells(): Spell[] {
|
|
public getAllPreparedSpells(): Spell[] {
|
|
@@ -619,197 +553,104 @@ export class DataService {
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
- //
|
|
|
|
|
|
+ // #endregion
|
|
|
|
|
|
- private abilities: Ability[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Feenschritt',
|
|
|
|
- charges: 8,
|
|
|
|
- currentlyUsedCharges: 4,
|
|
|
|
- cost: 'bonus',
|
|
|
|
- shortDescription:
|
|
|
|
- 'Als Bonusaktion kannst du dich bis zu 30 Fuß zu einem Punkt teleportieren, den du sehen kannst.',
|
|
|
|
- longDescription:
|
|
|
|
- 'Als Bonusaktion kannst du dich auf magische Weise bis zu 30 Fuß weit in einen unbesetzten Raum teleportieren, den du sehen kannst. Du kannst diese Eigenschaft so oft einsetzen, wie es deinem Fertigkeitsbonus entspricht, und du erhältst alle verbrauchten Einsätze zurück, wenn du eine lange Pause machst.',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Durchschnaufen',
|
|
|
|
- charges: 1,
|
|
|
|
- currentlyUsedCharges: 0,
|
|
|
|
- cost: 'bonus',
|
|
|
|
- shortDescription:
|
|
|
|
- 'Als Bonusaktion kannst du dich um 1 d10 + Fighter Level Trefferpunkten heilen.',
|
|
|
|
- longDescription:
|
|
|
|
- 'Als Bonusaktion kannst du dich um 1 d10 + Fighter Level Trefferpunkten heilen. Du kannst diese Fähigkeit einmal pro langer Rast einsetzen.',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Tatendrang',
|
|
|
|
- charges: 1,
|
|
|
|
- currentlyUsedCharges: 1,
|
|
|
|
- cost: 'none',
|
|
|
|
- shortDescription: 'Du kannst eine weitere Aktion ausführen.',
|
|
|
|
- longDescription:
|
|
|
|
- 'Du kannst eine weitere Aktion ausführen. Du kannst diese Fähigkeit einmal pro langer Rast einsetzen.',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ // #region ABILITIES
|
|
|
|
|
|
- public getAbilities(): Ability[] {
|
|
|
|
- return this.abilities;
|
|
|
|
|
|
+ private _abilities: Ability[] = [];
|
|
|
|
+
|
|
|
|
+ public get abilities(): Ability[] {
|
|
|
|
+ return this._abilities;
|
|
}
|
|
}
|
|
|
|
|
|
- public setSAbilities(abilities: Ability[]): void {
|
|
|
|
- this.abilities = abilities;
|
|
|
|
- console.log('abilities updated from data service: ', this.abilities);
|
|
|
|
|
|
+ public set abilities(abilities: Ability[]) {
|
|
|
|
+ this._abilities = abilities;
|
|
|
|
+ console.warn('abilities: ', abilities);
|
|
}
|
|
}
|
|
|
|
|
|
- private traits: Trait[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Feenblut',
|
|
|
|
- shortDescription:
|
|
|
|
- 'Du hast Vorteil auf alle Rettungswürfe gegen Zauber und andere magische Effekte.',
|
|
|
|
- longDescription:
|
|
|
|
- 'Du hast Vorteil auf alle Rettungswürfe gegen Zauber und andere magische Effekte.',
|
|
|
|
- origin: 'Elf',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Dunkelsicht',
|
|
|
|
- shortDescription: 'Du hast 60 ft. Dunkelsicht.',
|
|
|
|
- longDescription:
|
|
|
|
- 'Du hast 60 ft. Dunkelsicht. Du kannst in völliger Dunkelheit so klar sehen wie am Tag.',
|
|
|
|
- origin: 'Elf',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Fey Ancestry',
|
|
|
|
- shortDescription:
|
|
|
|
- 'Du meditierst und musst nicht schlafen. Du kannst nicht durch Magie in Schlaf versetzt werden.',
|
|
|
|
- longDescription:
|
|
|
|
- 'Du meditierst und musst nicht schlafen. Du kannst nicht durch Magie in Schlaf versetzt werden.',
|
|
|
|
- origin: 'Elf',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ private _traits: Trait[] = [];
|
|
|
|
|
|
- public getTraits(): Trait[] {
|
|
|
|
- return this.traits;
|
|
|
|
|
|
+ public get traits(): Trait[] {
|
|
|
|
+ return this._traits;
|
|
}
|
|
}
|
|
|
|
|
|
- public setTraits(traits: Trait[]): void {
|
|
|
|
- this.traits = traits;
|
|
|
|
- console.log('traits updated from data service: ', this.traits);
|
|
|
|
|
|
+ public set traits(traits: Trait[]) {
|
|
|
|
+ this._traits = traits;
|
|
|
|
+ this.setData('traits', { data: traits });
|
|
}
|
|
}
|
|
|
|
|
|
- private spellslots: any = {
|
|
|
|
- spellslots: [
|
|
|
|
- { totalSlots: 4, usedSlots: 2 },
|
|
|
|
- { totalSlots: 2, usedSlots: 1 },
|
|
|
|
- ],
|
|
|
|
|
|
+ private _spellslots: any = {
|
|
|
|
+ spellslots: [],
|
|
showSpellslots: true,
|
|
showSpellslots: true,
|
|
};
|
|
};
|
|
|
|
|
|
- public getSpellslots(): any {
|
|
|
|
- return this.spellslots;
|
|
|
|
|
|
+ public get spellslots(): any {
|
|
|
|
+ return this._spellslots;
|
|
}
|
|
}
|
|
|
|
|
|
- public setSpellslots(spellslots: any): void {
|
|
|
|
- this.spellslots = spellslots;
|
|
|
|
- console.log('spellslots updated from data service: ', this.spellslots);
|
|
|
|
|
|
+ public set spellslots(spellslots: any) {
|
|
|
|
+ this._spellslots = spellslots;
|
|
|
|
+ this.setData('spellslots', spellslots);
|
|
}
|
|
}
|
|
|
|
|
|
- private kiPoints: any = {
|
|
|
|
|
|
+ private _kiPoints: any = {
|
|
totalPoints: 4,
|
|
totalPoints: 4,
|
|
usedPoints: 2,
|
|
usedPoints: 2,
|
|
- showKiPoints: true,
|
|
|
|
|
|
+ showKiPoints: false,
|
|
};
|
|
};
|
|
|
|
|
|
- public getKiPoints(): any {
|
|
|
|
- return this.kiPoints;
|
|
|
|
|
|
+ public get kiPoints(): any {
|
|
|
|
+ return this._kiPoints;
|
|
}
|
|
}
|
|
|
|
|
|
- public setKiPoints(kiPoints: any): void {
|
|
|
|
- this.kiPoints = kiPoints;
|
|
|
|
- console.log('kiPoints updated from data service: ', this.kiPoints);
|
|
|
|
|
|
+ public set kiPoints(kiPoints: any) {
|
|
|
|
+ this._kiPoints = kiPoints;
|
|
|
|
+ this.setData('kiPoints', kiPoints);
|
|
}
|
|
}
|
|
|
|
|
|
- private proficiencies: any = {
|
|
|
|
- armor: {
|
|
|
|
- light: true,
|
|
|
|
- medium: true,
|
|
|
|
- heavy: false,
|
|
|
|
- },
|
|
|
|
- weapons: {
|
|
|
|
- simple: true,
|
|
|
|
- martial: true,
|
|
|
|
- other: ['Kurzschwert', 'Gleve'],
|
|
|
|
- },
|
|
|
|
- tools: ['Schmiedewerkzeuge', 'Würfel'],
|
|
|
|
- languages: ['Gemeinsprache', 'Elfisch', 'Zwergisch'],
|
|
|
|
- };
|
|
|
|
|
|
+ private _proficiencies: any = {};
|
|
|
|
|
|
- public getProficiencies(): any {
|
|
|
|
- return this.proficiencies;
|
|
|
|
|
|
+ public get proficiencies(): any {
|
|
|
|
+ return this._proficiencies;
|
|
}
|
|
}
|
|
|
|
|
|
- public setProficiencies(proficiencies: any): void {
|
|
|
|
- this.proficiencies = proficiencies;
|
|
|
|
- console.log(
|
|
|
|
- 'proficiencies updated from data service: ',
|
|
|
|
- this.proficiencies
|
|
|
|
- );
|
|
|
|
|
|
+ public set proficiencies(proficiencies: any) {
|
|
|
|
+ this._proficiencies = proficiencies;
|
|
|
|
+ this.setData('proficiencies', proficiencies);
|
|
}
|
|
}
|
|
|
|
|
|
- // #region Character Data observables
|
|
|
|
|
|
+ // #endregion
|
|
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- * @param newValue The new value of the Character Data
|
|
|
|
- */
|
|
|
|
- public updateCharacterData(newValue: any) {
|
|
|
|
- const functionCall: string = newValue.name + 'Subject.next(newValue)';
|
|
|
|
- eval(`this.${functionCall}`);
|
|
|
|
- console.log('updateProperty: ', newValue.value);
|
|
|
|
- // TODO: Datenbank updaten
|
|
|
|
- }
|
|
|
|
|
|
+ // #region # COMBAT STATS
|
|
|
|
|
|
- private proficiencySubject = new BehaviorSubject<any>({
|
|
|
|
- name: 'proficiencyBonus',
|
|
|
|
- value: 2,
|
|
|
|
- });
|
|
|
|
|
|
+ private proficiencySubject = new BehaviorSubject<number>(2);
|
|
public proficiency$ = this.proficiencySubject.asObservable();
|
|
public proficiency$ = this.proficiencySubject.asObservable();
|
|
|
|
|
|
- private _hitPoints = {
|
|
|
|
- maxHitPoints: 10,
|
|
|
|
- currentHitPoints: 8,
|
|
|
|
- temporaryHitPoints: 1,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- public set hitPoints(hitPointsData: any) {
|
|
|
|
- console.log('hitPointsData: ', hitPointsData);
|
|
|
|
- this._hitPoints = hitPointsData;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get hitPoints(): any {
|
|
|
|
- return this._hitPoints;
|
|
|
|
|
|
+ public updateProficiencyBonus(newValue: number) {
|
|
|
|
+ this.proficiencySubject.next(newValue);
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
- private _armorClass: number = 19;
|
|
|
|
|
|
+ private _armorClass: number = 10;
|
|
|
|
|
|
public get armorClass(): number {
|
|
public get armorClass(): number {
|
|
return this._armorClass;
|
|
return this._armorClass;
|
|
}
|
|
}
|
|
|
|
|
|
public set armorClass(newValue: number) {
|
|
public set armorClass(newValue: number) {
|
|
- console.log('armorClass: ', newValue);
|
|
|
|
this._armorClass = newValue;
|
|
this._armorClass = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
- private _initiative: number = 2;
|
|
|
|
|
|
+ private _initiative: number = 0;
|
|
|
|
|
|
public get initiative(): number {
|
|
public get initiative(): number {
|
|
return this._initiative;
|
|
return this._initiative;
|
|
}
|
|
}
|
|
|
|
|
|
public set initiative(newValue: number) {
|
|
public set initiative(newValue: number) {
|
|
- console.log('initiative: ', newValue);
|
|
|
|
this._initiative = newValue;
|
|
this._initiative = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
private _movement: number = 30;
|
|
private _movement: number = 30;
|
|
@@ -819,19 +660,8 @@ export class DataService {
|
|
}
|
|
}
|
|
|
|
|
|
public set movement(newValue: number) {
|
|
public set movement(newValue: number) {
|
|
- console.log('movement: ', newValue);
|
|
|
|
this._movement = newValue;
|
|
this._movement = newValue;
|
|
- }
|
|
|
|
-
|
|
|
|
- private _hitDice: any[] = [{ diceNumber: '1', diceType: 'd10' }];
|
|
|
|
-
|
|
|
|
- public get hitDice(): any[] {
|
|
|
|
- return this._hitDice;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public set hitDice(newValue: any[]) {
|
|
|
|
- console.log('hitDice: ', newValue);
|
|
|
|
- this._hitDice = newValue;
|
|
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
private _deathSaves: number[] = [0, 0];
|
|
private _deathSaves: number[] = [0, 0];
|
|
@@ -841,8 +671,8 @@ export class DataService {
|
|
}
|
|
}
|
|
|
|
|
|
public set deathSaves(newValue: number[]) {
|
|
public set deathSaves(newValue: number[]) {
|
|
- console.log('deathSaves: ', newValue);
|
|
|
|
this._deathSaves = newValue;
|
|
this._deathSaves = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
private _inspiration: boolean = false;
|
|
private _inspiration: boolean = false;
|
|
@@ -852,8 +682,8 @@ export class DataService {
|
|
}
|
|
}
|
|
|
|
|
|
public set inspiration(newValue: boolean) {
|
|
public set inspiration(newValue: boolean) {
|
|
- console.log('inspiration: ', newValue);
|
|
|
|
this._inspiration = newValue;
|
|
this._inspiration = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
private _experience: number = 0;
|
|
private _experience: number = 0;
|
|
@@ -863,8 +693,8 @@ export class DataService {
|
|
}
|
|
}
|
|
|
|
|
|
public set experience(newValue: number) {
|
|
public set experience(newValue: number) {
|
|
- console.log('experience: ', newValue);
|
|
|
|
this._experience = newValue;
|
|
this._experience = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
private _exhaustion: number = 0;
|
|
private _exhaustion: number = 0;
|
|
@@ -874,77 +704,154 @@ export class DataService {
|
|
}
|
|
}
|
|
|
|
|
|
public set exhaustion(newValue: number) {
|
|
public set exhaustion(newValue: number) {
|
|
- console.log('exhaustion: ', newValue);
|
|
|
|
this._exhaustion = newValue;
|
|
this._exhaustion = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
- private _conditions: string[] = ['Blind', 'Kampfunfähig'];
|
|
|
|
|
|
+ private _conditions: string[] = [];
|
|
|
|
|
|
public get conditions(): string[] {
|
|
public get conditions(): string[] {
|
|
return this._conditions;
|
|
return this._conditions;
|
|
}
|
|
}
|
|
|
|
|
|
public set conditions(newValue: string[]) {
|
|
public set conditions(newValue: string[]) {
|
|
- console.log('conditions: ', newValue);
|
|
|
|
this._conditions = newValue;
|
|
this._conditions = newValue;
|
|
|
|
+ this.writeCombatStatsToDatabase();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private writeCombatStatsToDatabase() {
|
|
|
|
+ const combatStatsData = {
|
|
|
|
+ armorClass: this._armorClass,
|
|
|
|
+ initiative: this._initiative,
|
|
|
|
+ movement: this._movement,
|
|
|
|
+ deathSaves: this._deathSaves,
|
|
|
|
+ proficiencyBonus: this.proficiencySubject.getValue(),
|
|
|
|
+ inspiration: this._inspiration,
|
|
|
|
+ experience: this._experience,
|
|
|
|
+ exhaustion: this._exhaustion,
|
|
|
|
+ conditions: this._conditions,
|
|
|
|
+ };
|
|
|
|
+ this.setData('combatStats', combatStatsData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // #endregion
|
|
|
|
+
|
|
|
|
+ // #region # HIT POINTS
|
|
|
|
+
|
|
|
|
+ private _hitPoints = {
|
|
|
|
+ maxHitPoints: 6,
|
|
|
|
+ currentHitPoints: 6,
|
|
|
|
+ temporaryHitPoints: 1,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ public get hitPoints(): any {
|
|
|
|
+ return this._hitPoints;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public set hitPoints(newValue: any) {
|
|
|
|
+ this._hitPoints = newValue;
|
|
|
|
+ this.updateHitPoints();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private _hitDice = {
|
|
|
|
+ diceNumber: '1',
|
|
|
|
+ diceType: 'd10',
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ public get hitDice(): any {
|
|
|
|
+ return this._hitDice;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public set hitDice(newValue: any) {
|
|
|
|
+ this._hitDice = newValue;
|
|
|
|
+ this.updateHitPoints();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private updateHitPoints() {
|
|
|
|
+ const hitPointsData = {
|
|
|
|
+ hitPoints: this._hitPoints,
|
|
|
|
+ hitDice: this._hitDice,
|
|
|
|
+ };
|
|
|
|
+ this.setData('hitPoints', hitPointsData);
|
|
}
|
|
}
|
|
|
|
|
|
// #endregion
|
|
// #endregion
|
|
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- * @param newValue The new value of the Attribute
|
|
|
|
- */
|
|
|
|
|
|
+ // #region # ATTRIBUTES
|
|
updateAttribute(newValue: Attribute) {
|
|
updateAttribute(newValue: Attribute) {
|
|
const functionCall: string = newValue.name + 'Subject.next(newValue)';
|
|
const functionCall: string = newValue.name + 'Subject.next(newValue)';
|
|
eval(`this.${functionCall}`);
|
|
eval(`this.${functionCall}`);
|
|
- console.log('updateAttribute: ', newValue.name);
|
|
|
|
- // TODO: Datenbank updaten
|
|
|
|
|
|
+ const attributesData = {
|
|
|
|
+ strength: this.strengthSubject.getValue(),
|
|
|
|
+ dexterity: this.dexteritySubject.getValue(),
|
|
|
|
+ constitution: this.constitutionSubject.getValue(),
|
|
|
|
+ intelligence: this.intelligenceSubject.getValue(),
|
|
|
|
+ wisdom: this.wisdomSubject.getValue(),
|
|
|
|
+ charisma: this.charismaSubject.getValue(),
|
|
|
|
+ };
|
|
|
|
+ // TODO: ACTIVATE AGAIN
|
|
|
|
+ this.setData('attributes', attributesData);
|
|
}
|
|
}
|
|
|
|
|
|
private strengthSubject = new BehaviorSubject<Attribute>(
|
|
private strengthSubject = new BehaviorSubject<Attribute>(
|
|
- { name: 'strength', value: 19, proficiency: true } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
|
|
|
|
+ { name: 'strength', value: 10, proficiency: true } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
);
|
|
);
|
|
public strength$ = this.strengthSubject.asObservable();
|
|
public strength$ = this.strengthSubject.asObservable();
|
|
|
|
|
|
private dexteritySubject = new BehaviorSubject<Attribute>(
|
|
private dexteritySubject = new BehaviorSubject<Attribute>(
|
|
- { name: 'dexterity', value: 17, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
|
|
|
|
+ { name: 'dexterity', value: 10, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
);
|
|
);
|
|
public dexterity$ = this.dexteritySubject.asObservable();
|
|
public dexterity$ = this.dexteritySubject.asObservable();
|
|
|
|
|
|
private constitutionSubject = new BehaviorSubject<Attribute>(
|
|
private constitutionSubject = new BehaviorSubject<Attribute>(
|
|
- { name: 'constitution', value: 12, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
|
|
|
|
+ { name: 'constitution', value: 10, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
);
|
|
);
|
|
public constitution$ = this.constitutionSubject.asObservable();
|
|
public constitution$ = this.constitutionSubject.asObservable();
|
|
|
|
|
|
private intelligenceSubject = new BehaviorSubject<Attribute>(
|
|
private intelligenceSubject = new BehaviorSubject<Attribute>(
|
|
- { name: 'intelligence', value: 13, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
|
|
|
|
+ { name: 'intelligence', value: 10, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
);
|
|
);
|
|
public intelligence$ = this.intelligenceSubject.asObservable();
|
|
public intelligence$ = this.intelligenceSubject.asObservable();
|
|
|
|
|
|
private wisdomSubject = new BehaviorSubject<Attribute>(
|
|
private wisdomSubject = new BehaviorSubject<Attribute>(
|
|
- { name: 'wisdom', value: 13, proficiency: true } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
|
|
|
|
+ { name: 'wisdom', value: 10, proficiency: true } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
);
|
|
);
|
|
public wisdom$ = this.wisdomSubject.asObservable();
|
|
public wisdom$ = this.wisdomSubject.asObservable();
|
|
|
|
|
|
private charismaSubject = new BehaviorSubject<Attribute>(
|
|
private charismaSubject = new BehaviorSubject<Attribute>(
|
|
- { name: 'charisma', value: 19, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
|
|
|
|
+ { name: 'charisma', value: 10, proficiency: false } //erstmal nur gemockt, später muss der Wert aus der Datenbank kommen
|
|
);
|
|
);
|
|
public charisma$ = this.charismaSubject.asObservable();
|
|
public charisma$ = this.charismaSubject.asObservable();
|
|
|
|
|
|
// #endregion
|
|
// #endregion
|
|
|
|
|
|
- // #region Skill observables
|
|
|
|
|
|
+ // #region # SKILLS
|
|
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- * @param newValue The new value of the skill
|
|
|
|
- */
|
|
|
|
updateSkill(newValue: Skill) {
|
|
updateSkill(newValue: Skill) {
|
|
const functionCall: string = newValue.name + 'Subject.next(newValue)';
|
|
const functionCall: string = newValue.name + 'Subject.next(newValue)';
|
|
eval(`this.${functionCall}`);
|
|
eval(`this.${functionCall}`);
|
|
- console.log('updateSkill: ', newValue.name);
|
|
|
|
- // TODO: Datenbank updaten
|
|
|
|
|
|
+ const skillsData = {
|
|
|
|
+ acrobatics: this.acrobaticsSubject.getValue(),
|
|
|
|
+ animalHandling: this.animalHandlingSubject.getValue(),
|
|
|
|
+ arcana: this.arcanaSubject.getValue(),
|
|
|
|
+ athletics: this.athleticsSubject.getValue(),
|
|
|
|
+ deception: this.deceptionSubject.getValue(),
|
|
|
|
+ history: this.historySubject.getValue(),
|
|
|
|
+ insight: this.insightSubject.getValue(),
|
|
|
|
+ intimidation: this.intimidationSubject.getValue(),
|
|
|
|
+ investigation: this.investigationSubject.getValue(),
|
|
|
|
+ medicine: this.medicineSubject.getValue(),
|
|
|
|
+ nature: this.natureSubject.getValue(),
|
|
|
|
+ perception: this.perceptionSubject.getValue(),
|
|
|
|
+ performance: this.performanceSubject.getValue(),
|
|
|
|
+ persuasion: this.persuasionSubject.getValue(),
|
|
|
|
+ religion: this.religionSubject.getValue(),
|
|
|
|
+ sleightOfHand: this.sleightOfHandSubject.getValue(),
|
|
|
|
+ stealth: this.stealthSubject.getValue(),
|
|
|
|
+ survival: this.survivalSubject.getValue(),
|
|
|
|
+ };
|
|
|
|
+ // TODO: ACTIVATE AGAIN
|
|
|
|
+ // this.setData('skills', skillsData);
|
|
}
|
|
}
|
|
|
|
|
|
private acrobaticsSubject = new BehaviorSubject<Skill>(
|
|
private acrobaticsSubject = new BehaviorSubject<Skill>(
|
|
@@ -1039,87 +946,39 @@ export class DataService {
|
|
|
|
|
|
// #endregion
|
|
// #endregion
|
|
|
|
|
|
- // #region inventory
|
|
|
|
|
|
+ // #region # inventory
|
|
|
|
|
|
- private _items: SimpleItem[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Kurzbogen +1',
|
|
|
|
- weight: 5,
|
|
|
|
- value: 50,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Hallo',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Helebade',
|
|
|
|
- weight: 10,
|
|
|
|
- value: 5,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Hallo',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Armbrust',
|
|
|
|
- weight: 8,
|
|
|
|
- value: 6,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Hallo',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ private _favoriteWeapons: Weapon[] = [];
|
|
|
|
|
|
- public get items(): SimpleItem[] {
|
|
|
|
- return this._items;
|
|
|
|
|
|
+ public get favoriteWeapons(): Weapon[] {
|
|
|
|
+ return this._favoriteWeapons;
|
|
}
|
|
}
|
|
|
|
|
|
- public set items(newValue: SimpleItem[]) {
|
|
|
|
- console.log('items: ', newValue);
|
|
|
|
- this._items = newValue;
|
|
|
|
|
|
+ public set favoriteWeapons(weapons: Weapon[]) {
|
|
|
|
+ this._favoriteWeapons = weapons;
|
|
|
|
+ this.setData('favoriteWeapons', { data: this._favoriteWeapons });
|
|
}
|
|
}
|
|
|
|
|
|
- private _food: Food[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Brot',
|
|
|
|
- quantity: 7,
|
|
|
|
- isReady: true,
|
|
|
|
- weight: 0.5,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Suppe',
|
|
|
|
- quantity: 4,
|
|
|
|
- isReady: true,
|
|
|
|
- weight: 0.5,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Fleisch',
|
|
|
|
- quantity: 2,
|
|
|
|
- isReady: false,
|
|
|
|
- weight: 0.5,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Käse',
|
|
|
|
- quantity: 1,
|
|
|
|
- isReady: false,
|
|
|
|
- weight: 0.5,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Bier',
|
|
|
|
- quantity: 1,
|
|
|
|
- isReady: false,
|
|
|
|
- weight: 0.5,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Wein',
|
|
|
|
- quantity: 1,
|
|
|
|
- isReady: false,
|
|
|
|
- weight: 0.5,
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ private _weaponsAndArmor: SimpleItem[] = [];
|
|
|
|
+
|
|
|
|
+ public get weaponsAndArmor(): SimpleItem[] {
|
|
|
|
+ return this._weaponsAndArmor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public set weaponsAndArmor(newValue: SimpleItem[]) {
|
|
|
|
+ this._weaponsAndArmor = newValue;
|
|
|
|
+ this.setData('weaponsAndArmor', { data: this._weaponsAndArmor });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private _food: Food[] = [];
|
|
|
|
|
|
public get food(): Food[] {
|
|
public get food(): Food[] {
|
|
return this._food;
|
|
return this._food;
|
|
}
|
|
}
|
|
|
|
|
|
public set food(newValue: Food[]) {
|
|
public set food(newValue: Food[]) {
|
|
- // console.log('food: ', newValue);
|
|
|
|
this._food = newValue;
|
|
this._food = newValue;
|
|
|
|
+ this.setData('food', { data: this._food });
|
|
}
|
|
}
|
|
|
|
|
|
private _money: any = {
|
|
private _money: any = {
|
|
@@ -1135,60 +994,30 @@ export class DataService {
|
|
}
|
|
}
|
|
|
|
|
|
public set money(newValue: any) {
|
|
public set money(newValue: any) {
|
|
- console.log('money: ', newValue);
|
|
|
|
this._money = newValue;
|
|
this._money = newValue;
|
|
|
|
+ this.setData('money', this._money);
|
|
}
|
|
}
|
|
|
|
|
|
- private _consumbales: SimpleItem[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Heiltrank',
|
|
|
|
- weight: 0.5,
|
|
|
|
- value: 50,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Heilt 1W8 + 2 Trefferpunkte',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Öl',
|
|
|
|
- weight: 1,
|
|
|
|
- value: 1,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Brennt',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ private _consumbales: SimpleItem[] = [];
|
|
|
|
|
|
public get consumables(): SimpleItem[] {
|
|
public get consumables(): SimpleItem[] {
|
|
return this._consumbales;
|
|
return this._consumbales;
|
|
}
|
|
}
|
|
|
|
|
|
public set consumables(newValue: SimpleItem[]) {
|
|
public set consumables(newValue: SimpleItem[]) {
|
|
- console.log('consumables: ', newValue);
|
|
|
|
this._consumbales = newValue;
|
|
this._consumbales = newValue;
|
|
|
|
+ this.setData('consumables', { data: this._consumbales });
|
|
}
|
|
}
|
|
|
|
|
|
- private _miscellaneous: SimpleItem[] = [
|
|
|
|
- {
|
|
|
|
- name: 'Rucksack',
|
|
|
|
- weight: 5,
|
|
|
|
- value: 2,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Hallo',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: 'Seil',
|
|
|
|
- weight: 5,
|
|
|
|
- value: 2,
|
|
|
|
- quantity: 1,
|
|
|
|
- description: 'Hallo',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ private _miscellaneous: SimpleItem[] = [];
|
|
|
|
|
|
public get miscellaneous(): SimpleItem[] {
|
|
public get miscellaneous(): SimpleItem[] {
|
|
return this._miscellaneous;
|
|
return this._miscellaneous;
|
|
}
|
|
}
|
|
|
|
|
|
public set miscellaneous(newValue: SimpleItem[]) {
|
|
public set miscellaneous(newValue: SimpleItem[]) {
|
|
- console.log('misc: ', newValue);
|
|
|
|
this._miscellaneous = newValue;
|
|
this._miscellaneous = newValue;
|
|
|
|
+ this.setData('miscellaneous', { data: this._miscellaneous });
|
|
}
|
|
}
|
|
|
|
|
|
// #endregion
|
|
// #endregion
|
|
@@ -1225,125 +1054,17 @@ export class DataService {
|
|
return this.db.collection(collection).get({ keys: true });
|
|
return this.db.collection(collection).get({ keys: true });
|
|
}
|
|
}
|
|
|
|
|
|
- public deleteCollection(collection: string) {
|
|
|
|
- this.db.collection(collection).delete();
|
|
|
|
|
|
+ public setData(key: string, data: any) {
|
|
|
|
+ return this.db
|
|
|
|
+ .collection(this.characterName)
|
|
|
|
+ .doc(key)
|
|
|
|
+ .set(data)
|
|
|
|
+ .then(() => {});
|
|
}
|
|
}
|
|
|
|
|
|
- // #endregion
|
|
|
|
-
|
|
|
|
- // #region character selection and construction
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- * @param character The name of the character that was selected
|
|
|
|
- */
|
|
|
|
- public async selectCharacter(character: string) {
|
|
|
|
- console.log('selectCharacter ausgewählt');
|
|
|
|
- const characterData = await this.getCollectionWithKeys(character);
|
|
|
|
- this.character = this.buildCurrentCharacter(characterData);
|
|
|
|
- console.log('character: ', this.character);
|
|
|
|
- this.Router.navigate(['journal']);
|
|
|
|
|
|
+ public deleteCollection(collection: string) {
|
|
|
|
+ this.db.collection(collection).delete();
|
|
}
|
|
}
|
|
|
|
|
|
- private buildCurrentCharacter(currentCharacterData: any): Character {
|
|
|
|
- const [
|
|
|
|
- appearanceData,
|
|
|
|
- attributesData,
|
|
|
|
- characterData,
|
|
|
|
- combatStatsData,
|
|
|
|
- personalityData,
|
|
|
|
- skillsData,
|
|
|
|
- weaponsData,
|
|
|
|
- ] = currentCharacterData.map((entry: any) => entry.data);
|
|
|
|
-
|
|
|
|
- const appearance = {
|
|
|
|
- age: appearanceData.age,
|
|
|
|
- height: appearanceData.height,
|
|
|
|
- weight: appearanceData.weight,
|
|
|
|
- eyes: appearanceData.eyes,
|
|
|
|
- skin: appearanceData.skin,
|
|
|
|
- hair: appearanceData.hair,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const attributes = {
|
|
|
|
- strength: attributesData.strength,
|
|
|
|
- dexterity: attributesData.dexterity,
|
|
|
|
- constitution: attributesData.constitution,
|
|
|
|
- intelligence: attributesData.intelligence,
|
|
|
|
- wisdom: attributesData.wisdom,
|
|
|
|
- charisma: attributesData.charisma,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const character = {
|
|
|
|
- name: characterData.name,
|
|
|
|
- race: characterData.race,
|
|
|
|
- class: characterData.class,
|
|
|
|
- subclass: characterData.subclass,
|
|
|
|
- level: characterData.level,
|
|
|
|
- background: characterData.background,
|
|
|
|
- experience: characterData.experience,
|
|
|
|
- inspiration: characterData.inspiration,
|
|
|
|
- proficiencyBonus: characterData.proficiencyBonus,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const combatStats = {
|
|
|
|
- armorClass: combatStatsData.armorClass,
|
|
|
|
- initiative: combatStatsData.initiative,
|
|
|
|
- speed: combatStatsData.speed,
|
|
|
|
- hitPointMaximum: combatStatsData.hitPointMaximum,
|
|
|
|
- currentHitPoints: combatStatsData.currentHitPoints,
|
|
|
|
- temporaryHitPoints: combatStatsData.temporaryHitPoints,
|
|
|
|
- hitDice: combatStatsData.hitDice,
|
|
|
|
- deathSaveSuccesses: combatStatsData.deathSaveSuccesses,
|
|
|
|
- deathSaveFailures: combatStatsData.deathSaveFailures,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const personality = {
|
|
|
|
- personalityTraits: personalityData.personalityTraits,
|
|
|
|
- ideals: personalityData.ideals,
|
|
|
|
- bonds: personalityData.bonds,
|
|
|
|
- flaws: personalityData.flaws,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const skills = {
|
|
|
|
- acrobatics: skillsData.acrobatics,
|
|
|
|
- animalHandling: skillsData.animalHandling,
|
|
|
|
- arcana: skillsData.arcana,
|
|
|
|
- athletics: skillsData.athletics,
|
|
|
|
- deception: skillsData.deception,
|
|
|
|
- history: skillsData.history,
|
|
|
|
- insight: skillsData.insight,
|
|
|
|
- intimidation: skillsData.intimidation,
|
|
|
|
- investigation: skillsData.investigation,
|
|
|
|
- medicine: skillsData.medicine,
|
|
|
|
- nature: skillsData.nature,
|
|
|
|
- perception: skillsData.perception,
|
|
|
|
- performance: skillsData.performance,
|
|
|
|
- persuasion: skillsData.persuasion,
|
|
|
|
- religion: skillsData.religion,
|
|
|
|
- sleightOfHand: skillsData.sleightOfHand,
|
|
|
|
- stealth: skillsData.stealth,
|
|
|
|
- survival: skillsData.survival,
|
|
|
|
- };
|
|
|
|
- const weapons = {
|
|
|
|
- name: weaponsData.name,
|
|
|
|
- attackBonus: weaponsData.attackBonus,
|
|
|
|
- damage: weaponsData.damage,
|
|
|
|
- damageType: weaponsData.damageType,
|
|
|
|
- range: weaponsData.range,
|
|
|
|
- description: weaponsData.damageDice,
|
|
|
|
- };
|
|
|
|
- const newCharacter: Character = {
|
|
|
|
- appearance: appearance,
|
|
|
|
- attributes: attributes,
|
|
|
|
- characterData: character,
|
|
|
|
- combatStats: combatStats,
|
|
|
|
- personality: personality,
|
|
|
|
- skills: skills,
|
|
|
|
- weapons: weapons,
|
|
|
|
- };
|
|
|
|
- console.log('newCharacter: ', newCharacter);
|
|
|
|
- return newCharacter;
|
|
|
|
- }
|
|
|
|
// #endregion
|
|
// #endregion
|
|
}
|
|
}
|