import {ItemProperty} from "./ItemProperty"; import {ItemPropertyDescription} from "./ItemPropertyDescription"; export class ItemQuality { quality_step: number quality_propertes: ItemProperty[] = [] constructor(quality_step: number) { this.quality_step = quality_step; } removeQualityProperty(propertyName: string) { this.quality_propertes = this.quality_propertes.filter(qualityProperty => qualityProperty.propertyName !== propertyName); } addQualityProperty(qualityProperty: ItemPropertyDescription) { this.quality_propertes.push(new ItemProperty(qualityProperty.propertyName, qualityProperty.propertyDescription, 0)); } editQualityProperty(qualityProperty: ItemPropertyDescription, knownProperties: string[]) { const affectedProperty = this.quality_propertes.find(property => !knownProperties.includes(property.propertyName) ) if(affectedProperty != undefined) { affectedProperty!.propertyName = qualityProperty.propertyName; affectedProperty!.propertyDescription = qualityProperty.propertyDescription; } else { console.log("Property was not found") } } }