|
@@ -13,20 +13,49 @@ import { TraitModalComponent } from '../../journal-stats/ability-panel/trait-tab
|
|
styleUrl: './species.component.scss',
|
|
styleUrl: './species.component.scss',
|
|
})
|
|
})
|
|
export class SpeciesComponent {
|
|
export class SpeciesComponent {
|
|
|
|
+ public characterData: any;
|
|
species: any;
|
|
species: any;
|
|
speciesName: string = '';
|
|
speciesName: string = '';
|
|
|
|
+ public showContent: boolean[] = [];
|
|
|
|
|
|
public constructor(
|
|
public constructor(
|
|
public speciesAccessor: SpeciesService,
|
|
public speciesAccessor: SpeciesService,
|
|
public dataAccessor: DataService,
|
|
public dataAccessor: DataService,
|
|
public modalAccessor: ModalService,
|
|
public modalAccessor: ModalService,
|
|
) {
|
|
) {
|
|
- this.speciesName = this.dataAccessor.characterData.race;
|
|
|
|
|
|
+ this.characterData = this.dataAccessor.characterData;
|
|
|
|
+ this.speciesName = this.characterData.race;
|
|
this.species = speciesAccessor.getSpeciesDetails(this.speciesName);
|
|
this.species = speciesAccessor.getSpeciesDetails(this.speciesName);
|
|
|
|
+ this.showContent = this.characterData.speciesArray;
|
|
|
|
+ if (this.showContent === undefined) {
|
|
|
|
+ this.showContent = new Array(this.species.content.length).fill(true);
|
|
|
|
+ }
|
|
|
|
+ this.updateDatabase();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Toggles the visibility of the content at the given index.
|
|
|
|
+ * @param index The index of the content to be toggled.
|
|
|
|
+ */
|
|
|
|
+ public toggleContentVisibility(index: number) {
|
|
|
|
+ this.showContent[index] = !this.showContent[index];
|
|
|
|
+ this.updateDatabase();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Updates the database with the new content visibility.
|
|
|
|
+ */
|
|
|
|
+ private updateDatabase() {
|
|
|
|
+ this.characterData.speciesArray = this.showContent;
|
|
|
|
+ this.dataAccessor.characterData = this.characterData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks if it is an ability or a trait. If the key ability is present, it is an ability, otherwise it is a trait.
|
|
|
|
+ * @param feature The feature or trait to be added to the character dashboard.
|
|
|
|
+ */
|
|
public addFeature(feature: any) {
|
|
public addFeature(feature: any) {
|
|
- if ('ability' in feature) {
|
|
|
|
|
|
+ if (feature.isAbility) {
|
|
this.addAbility(feature);
|
|
this.addAbility(feature);
|
|
} else {
|
|
} else {
|
|
this.addTrait(feature);
|
|
this.addTrait(feature);
|
|
@@ -91,3 +120,51 @@ export class SpeciesComponent {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// public characterData: any;
|
|
|
|
+// species: any;
|
|
|
|
+// speciesName: string = '';
|
|
|
|
+// public showContent: boolean[] = [];
|
|
|
|
+
|
|
|
|
+// public constructor(
|
|
|
|
+// public speciesAccessor: SpeciesService,
|
|
|
|
+// public dataAccessor: DataService,
|
|
|
|
+// public modalAccessor: ModalService,
|
|
|
|
+// ) {
|
|
|
|
+// this.characterData = this.dataAccessor.characterData;
|
|
|
|
+// this.speciesName = this.characterData.species;
|
|
|
|
+// this.species = speciesAccessor.getSpeciesDetails(this.speciesName);
|
|
|
|
+// this.showContent = this.characterData.speciesArray;
|
|
|
|
+// console.log('speciesName: ', this.speciesName);
|
|
|
|
+
|
|
|
|
+// console.log('species: ', this.species);
|
|
|
|
+
|
|
|
|
+// if (this.showContent === undefined) {
|
|
|
|
+// this.showContent = new Array(this.species.content.length - 1);
|
|
|
|
+// }
|
|
|
|
+// this.updateDatabase();
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// public updateShowContentArray(index: number) {
|
|
|
|
+// this.showContent[index] = !this.showContent[index];
|
|
|
|
+// this.updateDatabase();
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// private updateDatabase() {
|
|
|
|
+// console.log('arry: ', this.showContent);
|
|
|
|
+
|
|
|
|
+// this.characterData.speciesArray = this.showContent;
|
|
|
|
+// this.dataAccessor.characterData = this.characterData;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * Checks if it is an ability or a trait. If the key ability is present, it is an ability, otherwise it is a trait.
|
|
|
|
+// * @param feature The feature or trait to be added to the character dashboard.
|
|
|
|
+// */
|
|
|
|
+// public addFeature(feature: any) {
|
|
|
|
+// if ('ability' in feature) {
|
|
|
|
+// this.addAbility(feature);
|
|
|
|
+// } else {
|
|
|
|
+// this.addTrait(feature);
|
|
|
|
+// }
|
|
|
|
+// }
|