Automatically initialize CharacteristicValues for manually Inherited groups
All checks were successful
E2E Testing / test (push) Successful in 1m32s

This commit is contained in:
Sebastian Böckelmann 2024-05-09 07:19:05 +02:00
parent 34c139eecf
commit aa6c051246
4 changed files with 6 additions and 2 deletions

View File

@ -29,7 +29,7 @@ export class GameModel {
this.gameModelName = gameModelName; this.gameModelName = gameModelName;
this.addAbstractItemgroup("Clothing", undefined); this.addAbstractItemgroup("Clothing", undefined);
this.addAbstractItemgroup("Inventory", undefined); this.addConcreteItemgroup("Inventory", undefined);
this.addConcreteItemgroup("Oberteil", GameModel.findItemgroupByName("Clothing", this.itemgroups)! as AbstractItemGroup); this.addConcreteItemgroup("Oberteil", GameModel.findItemgroupByName("Clothing", this.itemgroups)! as AbstractItemGroup);
this.addConcreteItemgroup("Hose", GameModel.findItemgroupByName("Clothing", this.itemgroups)! as AbstractItemGroup); this.addConcreteItemgroup("Hose", GameModel.findItemgroupByName("Clothing", this.itemgroups)! as AbstractItemGroup);
@ -50,7 +50,7 @@ export class GameModel {
} }
} }
addConcreteItemgroup(groupName: string, parentgroup: AbstractItemGroup) { addConcreteItemgroup(groupName: string, parentgroup: AbstractItemGroup | undefined) {
//Ensure that Itemgroup does not exist //Ensure that Itemgroup does not exist
if(parentgroup == undefined) { if(parentgroup == undefined) {
if(GameModel.findItemgroupByName(groupName, this.itemgroups) == undefined) { if(GameModel.findItemgroupByName(groupName, this.itemgroups) == undefined) {

View File

@ -11,6 +11,7 @@ export class AbstractItemGroup extends ItemGroup {
} }
protected addCharacteristicValue(characteristic: ItemGroupCharacteristic): void { protected addCharacteristicValue(characteristic: ItemGroupCharacteristic): void {
console.log("Abstract Characteristic Value: Do nothing (" , characteristic.characteristicName , ")")
//Do Nothing //Do Nothing
} }

View File

@ -30,6 +30,7 @@ export class Item extends ModelComponent {
addInheritedGroup(itemgroup: ItemGroup) { addInheritedGroup(itemgroup: ItemGroup) {
if(this.findItemgroupByName(itemgroup.componentName) == undefined) { if(this.findItemgroupByName(itemgroup.componentName) == undefined) {
this.manuallyInheritedGroups.push(itemgroup); this.manuallyInheritedGroups.push(itemgroup);
itemgroup.manuallyInheritedItems.push(this);
this.initializeItemCharacteristicsOfItemgroup(itemgroup); this.initializeItemCharacteristicsOfItemgroup(itemgroup);
} }
} }
@ -40,6 +41,7 @@ export class Item extends ModelComponent {
} }
addCharacteristic(characteristic: ItemGroupCharacteristic) { addCharacteristic(characteristic: ItemGroupCharacteristic) {
console.log("Add Characteristic: " , characteristic)
const characteristicValue = new ItemgroupCharacteristicValue(characteristic, 0); const characteristicValue = new ItemgroupCharacteristicValue(characteristic, 0);
if(!this.isValueInitialized(characteristic)) { if(!this.isValueInitialized(characteristic)) {
this.itemCharacteristicValues.push(characteristicValue); this.itemCharacteristicValues.push(characteristicValue);

View File

@ -12,6 +12,7 @@ export abstract class ItemGroup extends ModelComponent {
addItemgroupCharacteristic(itemgroupCharacteristic: ItemGroupCharacteristic) { addItemgroupCharacteristic(itemgroupCharacteristic: ItemGroupCharacteristic) {
this.itemGroupCharacteristics.push(itemgroupCharacteristic); this.itemGroupCharacteristics.push(itemgroupCharacteristic);
this.addCharacteristicValueForManuallyItems(itemgroupCharacteristic); this.addCharacteristicValueForManuallyItems(itemgroupCharacteristic);
console.log("[Itemgroup] Add ItemgroupCharacteristic ", itemgroupCharacteristic);
this.addCharacteristicValue(itemgroupCharacteristic); this.addCharacteristicValue(itemgroupCharacteristic);
} }