template-systems #41
@ -219,7 +219,8 @@ export class AppComponent implements OnInit{
|
||||
gameModel.generateProductSystemContents()
|
||||
|
||||
const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
|
||||
const characterParser = new CharacterParser(characterTemplateSystems, gameModel.scriptAccounts);
|
||||
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)
|
||||
|
||||
this.gameModel = gameModel;
|
||||
|
@ -14,7 +14,7 @@ export class Character extends ModelComponent implements TemplateElement {
|
||||
|
||||
characterRelations: CharacterRelation[] = []
|
||||
|
||||
assymetricCharacterRelationSpecificTemplateSystems: Gamesystem<any, any>[] = []
|
||||
characterRelationGamesystems: Gamesystem<any, any>[] = []
|
||||
|
||||
constructor(componentName: string, componentDescription: string) {
|
||||
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
||||
@ -44,10 +44,12 @@ export class Character extends ModelComponent implements TemplateElement {
|
||||
addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem<any, any>, recursiveCall: boolean = false) {
|
||||
if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) {
|
||||
if(gamesystem instanceof SimpleTemplateGamesystem) {
|
||||
this.assymetricCharacterRelationSpecificTemplateSystems.push(gamesystem);
|
||||
this.characterRelationGamesystems.push(gamesystem);
|
||||
gamesystem.addTemplateElement(this);
|
||||
console.log("Should have been added")
|
||||
console.log(this.characterRelationGamesystems)
|
||||
} else if(gamesystem instanceof ProductTemplateSystem) {
|
||||
this.characterSpecificTemplateSystems.push(gamesystem);
|
||||
this.characterRelationGamesystems.push(gamesystem);
|
||||
gamesystem.addTemplateElement(this);
|
||||
|
||||
if(!recursiveCall) {
|
||||
@ -59,6 +61,9 @@ export class Character extends ModelComponent implements TemplateElement {
|
||||
this.addAsymetricCharacterRelationGamesystem(gamesystem.parentGamesystem, true)
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("Was already added")
|
||||
console.log(this)
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +76,7 @@ export class Character extends ModelComponent implements TemplateElement {
|
||||
}
|
||||
|
||||
private isTemplateSystemCharacterRelationSpecific(gamesystemName: string) {
|
||||
return this.assymetricCharacterRelationSpecificTemplateSystems.find(gamesystem =>
|
||||
return this.characterRelationGamesystems.find(gamesystem =>
|
||||
gamesystem.componentName === gamesystemName) != undefined;
|
||||
|
||||
}
|
||||
|
@ -8,16 +8,19 @@ import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/S
|
||||
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";
|
||||
|
||||
|
||||
export class CharacterParser {
|
||||
|
||||
characterSpecificGamesystems: SimpleTemplateGamesystem[]
|
||||
characterRelationSpecificGamesystems: SimpleTemplateGamesystem[]
|
||||
scriptAccountConditionParser: ScriptAccountConditionParser
|
||||
scriptAccountActionParser: ScriptAccountActionParser
|
||||
|
||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
|
||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], characterRelationSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
|
||||
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
||||
this.characterRelationSpecificGamesystems = characterRelationSpecificGamesystems;
|
||||
this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts);
|
||||
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
||||
}
|
||||
@ -38,23 +41,26 @@ export class CharacterParser {
|
||||
character.addCharacterRelation(characterRelation)
|
||||
})
|
||||
|
||||
const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems);
|
||||
const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems, this.characterSpecificGamesystems);
|
||||
templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system))
|
||||
|
||||
const characterRelationGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterRelationGamesystems, this.characterRelationSpecificGamesystems)
|
||||
characterRelationGamesystems.forEach(gamesystem => character.addAsymetricCharacterRelationGamesystem(gamesystem))
|
||||
return character;
|
||||
|
||||
}
|
||||
|
||||
private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem[] {
|
||||
private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem[] {
|
||||
const result: SimpleTemplateGamesystem[] = []
|
||||
for(let i=0; i<characterSpecificGamesystems.length; i++) {
|
||||
const characterSpecificGamesystem = characterSpecificGamesystems[i];
|
||||
result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem)!)
|
||||
result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem, templateGamesystems)!)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any): SimpleTemplateGamesystem | undefined{
|
||||
const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName)
|
||||
private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem | undefined{
|
||||
const referencedGamesystem = this.findCharacterSpecificGamesystem(templateGamesystems, characterSpecificGamesystem.componentName)
|
||||
|
||||
if(referencedGamesystem != undefined) {
|
||||
for(let i=0; i<characterSpecificGamesystem.states.length; i++) {
|
||||
@ -82,8 +88,8 @@ export class CharacterParser {
|
||||
|
||||
return referencedGamesystem;
|
||||
}
|
||||
private findCharacterSpecificGamesystem(componentName: string): SimpleTemplateGamesystem | undefined{
|
||||
return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName)
|
||||
private findCharacterSpecificGamesystem(gamesystems: SimpleTemplateGamesystem[], componentName: string): SimpleTemplateGamesystem | undefined{
|
||||
return gamesystems.find(gamesystem => gamesystem.componentName === componentName)
|
||||
}
|
||||
|
||||
private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) {
|
||||
|
@ -7,7 +7,7 @@ import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
|
||||
|
||||
export class CharacterSerializer {
|
||||
|
||||
private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions']
|
||||
private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions', 'characterRelations']
|
||||
|
||||
public static serializeCharacters(characters: Character[]): StoreComponent[] {
|
||||
const storedCharacters: StoreComponent[] = []
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"componentName": "Astrid Hofferson",
|
||||
"componentDescription": "",
|
||||
"characterSpecificTemplateSystems": []
|
||||
"characterSpecificTemplateSystems": [],
|
||||
"characterRelationGamesystems": []
|
||||
}
|
@ -1,5 +1,50 @@
|
||||
{
|
||||
"componentName": "Hicks Haddock",
|
||||
"componentDescription": "",
|
||||
"characterSpecificTemplateSystems": []
|
||||
"characterSpecificTemplateSystems": [],
|
||||
"characterRelationGamesystems": [
|
||||
{
|
||||
"componentName": "Characterbeziehungssystem",
|
||||
"states": [
|
||||
{
|
||||
"stateLabel": "Feind",
|
||||
"conditionMap": []
|
||||
},
|
||||
{
|
||||
"stateLabel": "Freund",
|
||||
"conditionMap": []
|
||||
},
|
||||
{
|
||||
"stateLabel": "Fester Freund",
|
||||
"conditionMap": []
|
||||
}
|
||||
],
|
||||
"transitions": [
|
||||
{
|
||||
"startingState": "Feind",
|
||||
"endingState": "Freund",
|
||||
"conditionMap": [],
|
||||
"actionMap": []
|
||||
},
|
||||
{
|
||||
"startingState": "Freund",
|
||||
"endingState": "Feind",
|
||||
"conditionMap": [],
|
||||
"actionMap": []
|
||||
},
|
||||
{
|
||||
"startingState": "Freund",
|
||||
"endingState": "Fester Freund",
|
||||
"conditionMap": [],
|
||||
"actionMap": []
|
||||
},
|
||||
{
|
||||
"startingState": "Fester Freund",
|
||||
"endingState": "Feind",
|
||||
"conditionMap": [],
|
||||
"actionMap": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user