ConceptCreator/src/app/project/game-model/inventory/ItemQuality.ts
Sebastian Böckelmann 69dce0b4f7
All checks were successful
E2E Testing / test (push) Successful in 1m32s
Introduce ItemQualities and PerQualitiyProperties
2024-04-20 09:37:40 +02:00

31 lines
1.1 KiB
TypeScript

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")
}
}
}