inventory-slots #49
@ -215,11 +215,6 @@ export class AppComponent implements OnInit{
|
||||
gameModel.gamesystems = gamesystems
|
||||
gameModel.generateProductSystemContents()
|
||||
|
||||
const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
|
||||
const characterRelationTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER_RELATION).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
|
||||
const characterParser = new CharacterParser(characterTemplateSystems, characterRelationTemplateSystems, gameModel.scriptAccounts);
|
||||
gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters)
|
||||
|
||||
const itemgroupParser = new ItemgroupParser();
|
||||
itemgroupParser.parseItemgroups(storedGameModel.storedItemgroups);
|
||||
gameModel.itemgroups = itemgroupParser.getParsedTopItemgroups();
|
||||
@ -227,6 +222,13 @@ export class AppComponent implements OnInit{
|
||||
const itemParser = new ItemParser(itemgroupParser.getParsedItemgroups())
|
||||
itemParser.parseItems(storedGameModel.storedItems);
|
||||
|
||||
const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
|
||||
const characterRelationTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER_RELATION).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
|
||||
const characterParser = new CharacterParser(characterTemplateSystems, characterRelationTemplateSystems, gameModel.scriptAccounts, itemgroupParser.getCharacteristics(), itemgroupParser.getParsedItemgroups());
|
||||
gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters)
|
||||
|
||||
|
||||
|
||||
this.gameModel = gameModel;
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,9 @@ import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
||||
import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/SimpleTemplateState";
|
||||
import {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition";
|
||||
import {CharacterRelation} from "../../game-model/characters/CharacterRelation";
|
||||
import {load} from "@angular-devkit/build-angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks";
|
||||
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
|
||||
import {InventorySlotParser} from "./InventorySlotParser";
|
||||
import {ItemGroupCharacteristic} from "../../game-model/inventory/ItemgroupCharacteristic";
|
||||
import {ItemGroup} from "../../game-model/inventory/ItemGroup";
|
||||
|
||||
|
||||
export class CharacterParser {
|
||||
@ -17,12 +18,14 @@ export class CharacterParser {
|
||||
characterRelationSpecificGamesystems: SimpleTemplateGamesystem[]
|
||||
scriptAccountConditionParser: ScriptAccountConditionParser
|
||||
scriptAccountActionParser: ScriptAccountActionParser
|
||||
inventorySlotParser: InventorySlotParser
|
||||
|
||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], characterRelationSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
|
||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], characterRelationSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[], characteristics: ItemGroupCharacteristic[], itemgroups: ItemGroup[]) {
|
||||
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
||||
this.characterRelationSpecificGamesystems = characterRelationSpecificGamesystems;
|
||||
this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts);
|
||||
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
||||
this.inventorySlotParser = new InventorySlotParser(characteristics, itemgroups);
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +49,8 @@ export class CharacterParser {
|
||||
|
||||
const characterRelationGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterRelationGamesystems, this.characterRelationSpecificGamesystems)
|
||||
characterRelationGamesystems.forEach(gamesystem => character.addAsymetricCharacterRelationGamesystem(gamesystem))
|
||||
|
||||
character.inventorySlots = this.inventorySlotParser.parseInventorySlots(characterData.inventorySlots);
|
||||
return character;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
import {ItemGroupCharacteristic} from "../../game-model/inventory/ItemgroupCharacteristic";
|
||||
import {ItemGroup} from "../../game-model/inventory/ItemGroup";
|
||||
import {InventorySlot} from "../../game-model/inventory/intentory-slots/InventorySlot";
|
||||
import {InventorySlotSerializer} from "../../serializer/InventorySlotSerializer";
|
||||
import {InventoryCharacteristic} from "../../game-model/inventory/intentory-slots/InventoryCharacteristic";
|
||||
|
||||
export class InventorySlotParser {
|
||||
private parsedCharacteristics: ItemGroupCharacteristic[]
|
||||
private parsedItemgroups: ItemGroup[]
|
||||
|
||||
|
||||
constructor(parsedCharacteristics: ItemGroupCharacteristic[], parsedItemgroups: ItemGroup[]) {
|
||||
this.parsedCharacteristics = parsedCharacteristics;
|
||||
this.parsedItemgroups = parsedItemgroups;
|
||||
}
|
||||
|
||||
parseInventorySlots(inventorySlotData: any): InventorySlot[] {
|
||||
const result: InventorySlot[] = []
|
||||
for(let i=0; i<inventorySlotData.length; i++) {
|
||||
result.push(this.parseSingleInventorySlot(inventorySlotData[i]))
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private parseSingleInventorySlot(inventorySlotData: any): InventorySlot {
|
||||
const slotName = inventorySlotData.slotName;
|
||||
const slotCharacteristics = this.parseSlotCharacteristics(inventorySlotData.slotCharacteristics)
|
||||
const inheritedGroups = this.parseRequieredInheritedItemgroups(inventorySlotData.requiredInheritances);
|
||||
|
||||
const inventorySlot = new InventorySlot(slotName);
|
||||
inventorySlot.slotCharacteristics = slotCharacteristics;
|
||||
inventorySlot.requiredInheritances = inheritedGroups;
|
||||
return inventorySlot;
|
||||
}
|
||||
|
||||
private parseSlotCharacteristics(slotCharacteristicsData: any): InventoryCharacteristic[] {
|
||||
const characteristics: InventoryCharacteristic[] = []
|
||||
for(let i=0; i<slotCharacteristicsData.length; i++) {
|
||||
const increasingCharacteristic = this.findReferencedCharacteristic(slotCharacteristicsData[i].increasingCharacteristic);
|
||||
const decreasingCharacteristic = this.findReferencedCharacteristic(slotCharacteristicsData[i].decreasingCharacteristic);
|
||||
characteristics.push(new InventoryCharacteristic(increasingCharacteristic!, decreasingCharacteristic!))
|
||||
}
|
||||
return characteristics;
|
||||
}
|
||||
|
||||
private parseRequieredInheritedItemgroups(inheritanceData: any): ItemGroup[] {
|
||||
const result: ItemGroup[] = []
|
||||
for(let i=0; i<inheritanceData.length; i++) {
|
||||
const inheritedGroup = this.findReferencedItemgroup(inheritanceData[i]);
|
||||
if(inheritedGroup != undefined) {
|
||||
result.push(inheritedGroup);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private findReferencedCharacteristic(characteristicName: string) {
|
||||
return this.parsedCharacteristics.find(characteristic => characteristic.characteristicName === characteristicName);
|
||||
}
|
||||
|
||||
private findReferencedItemgroup(groupName: string) {
|
||||
return this.parsedItemgroups.find(group => group.componentName === groupName);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ export class ItemgroupParser {
|
||||
|
||||
private parsedItemgroups: ItemGroup[] = []
|
||||
private topParsedItemgroups: ItemGroup[] = []
|
||||
private parsedCharacteristics: ItemGroupCharacteristic[] = []
|
||||
|
||||
parseItemgroups(storeComponents: StoreComponent[]) {
|
||||
const topologicalSort = this.topologicalSort(storeComponents);
|
||||
@ -81,6 +82,7 @@ export class ItemgroupParser {
|
||||
|
||||
const characteristic = new ItemGroupCharacteristic(name, description, itemgroup);
|
||||
characteristic.itemgroup.addItemgroupCharacteristic(characteristic);
|
||||
this.parsedCharacteristics.push(characteristic)
|
||||
return characteristic;
|
||||
}
|
||||
|
||||
@ -91,4 +93,8 @@ export class ItemgroupParser {
|
||||
getParsedItemgroups() {
|
||||
return this.parsedItemgroups;
|
||||
}
|
||||
|
||||
getCharacteristics() {
|
||||
return this.parsedCharacteristics;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user