Introduce Symetric and Asymetric Template Relation Systems #40
@ -219,7 +219,8 @@ export class AppComponent implements OnInit{
|
|||||||
gameModel.generateProductSystemContents()
|
gameModel.generateProductSystemContents()
|
||||||
|
|
||||||
const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem)
|
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)
|
gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters)
|
||||||
|
|
||||||
this.gameModel = gameModel;
|
this.gameModel = gameModel;
|
||||||
|
@ -14,7 +14,7 @@ export class Character extends ModelComponent implements TemplateElement {
|
|||||||
|
|
||||||
characterRelations: CharacterRelation[] = []
|
characterRelations: CharacterRelation[] = []
|
||||||
|
|
||||||
assymetricCharacterRelationSpecificTemplateSystems: Gamesystem<any, any>[] = []
|
characterRelationGamesystems: Gamesystem<any, any>[] = []
|
||||||
|
|
||||||
constructor(componentName: string, componentDescription: string) {
|
constructor(componentName: string, componentDescription: string) {
|
||||||
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
super(componentName, componentDescription, ModelComponentType.CHARACTER);
|
||||||
@ -44,10 +44,12 @@ export class Character extends ModelComponent implements TemplateElement {
|
|||||||
addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem<any, any>, recursiveCall: boolean = false) {
|
addAsymetricCharacterRelationGamesystem(gamesystem: Gamesystem<any, any>, recursiveCall: boolean = false) {
|
||||||
if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) {
|
if(!this.isTemplateSystemCharacterRelationSpecific(gamesystem.componentName)) {
|
||||||
if(gamesystem instanceof SimpleTemplateGamesystem) {
|
if(gamesystem instanceof SimpleTemplateGamesystem) {
|
||||||
this.assymetricCharacterRelationSpecificTemplateSystems.push(gamesystem);
|
this.characterRelationGamesystems.push(gamesystem);
|
||||||
gamesystem.addTemplateElement(this);
|
gamesystem.addTemplateElement(this);
|
||||||
|
console.log("Should have been added")
|
||||||
|
console.log(this.characterRelationGamesystems)
|
||||||
} else if(gamesystem instanceof ProductTemplateSystem) {
|
} else if(gamesystem instanceof ProductTemplateSystem) {
|
||||||
this.characterSpecificTemplateSystems.push(gamesystem);
|
this.characterRelationGamesystems.push(gamesystem);
|
||||||
gamesystem.addTemplateElement(this);
|
gamesystem.addTemplateElement(this);
|
||||||
|
|
||||||
if(!recursiveCall) {
|
if(!recursiveCall) {
|
||||||
@ -59,6 +61,9 @@ export class Character extends ModelComponent implements TemplateElement {
|
|||||||
this.addAsymetricCharacterRelationGamesystem(gamesystem.parentGamesystem, true)
|
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) {
|
private isTemplateSystemCharacterRelationSpecific(gamesystemName: string) {
|
||||||
return this.assymetricCharacterRelationSpecificTemplateSystems.find(gamesystem =>
|
return this.characterRelationGamesystems.find(gamesystem =>
|
||||||
gamesystem.componentName === gamesystemName) != undefined;
|
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 {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition";
|
||||||
import {CharacterRelation} from "../../game-model/characters/CharacterRelation";
|
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 {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 {
|
export class CharacterParser {
|
||||||
|
|
||||||
characterSpecificGamesystems: SimpleTemplateGamesystem[]
|
characterSpecificGamesystems: SimpleTemplateGamesystem[]
|
||||||
|
characterRelationSpecificGamesystems: SimpleTemplateGamesystem[]
|
||||||
scriptAccountConditionParser: ScriptAccountConditionParser
|
scriptAccountConditionParser: ScriptAccountConditionParser
|
||||||
scriptAccountActionParser: ScriptAccountActionParser
|
scriptAccountActionParser: ScriptAccountActionParser
|
||||||
|
|
||||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
|
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], characterRelationSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
|
||||||
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
||||||
|
this.characterRelationSpecificGamesystems = characterRelationSpecificGamesystems;
|
||||||
this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts);
|
this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts);
|
||||||
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
||||||
}
|
}
|
||||||
@ -38,23 +41,26 @@ export class CharacterParser {
|
|||||||
character.addCharacterRelation(characterRelation)
|
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))
|
templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system))
|
||||||
|
|
||||||
|
const characterRelationGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterRelationGamesystems, this.characterRelationSpecificGamesystems)
|
||||||
|
characterRelationGamesystems.forEach(gamesystem => character.addAsymetricCharacterRelationGamesystem(gamesystem))
|
||||||
return character;
|
return character;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem[] {
|
private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem[] {
|
||||||
const result: SimpleTemplateGamesystem[] = []
|
const result: SimpleTemplateGamesystem[] = []
|
||||||
for(let i=0; i<characterSpecificGamesystems.length; i++) {
|
for(let i=0; i<characterSpecificGamesystems.length; i++) {
|
||||||
const characterSpecificGamesystem = characterSpecificGamesystems[i];
|
const characterSpecificGamesystem = characterSpecificGamesystems[i];
|
||||||
result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem)!)
|
result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem, templateGamesystems)!)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any): SimpleTemplateGamesystem | undefined{
|
private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any, templateGamesystems: SimpleTemplateGamesystem[]): SimpleTemplateGamesystem | undefined{
|
||||||
const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName)
|
const referencedGamesystem = this.findCharacterSpecificGamesystem(templateGamesystems, characterSpecificGamesystem.componentName)
|
||||||
|
|
||||||
if(referencedGamesystem != undefined) {
|
if(referencedGamesystem != undefined) {
|
||||||
for(let i=0; i<characterSpecificGamesystem.states.length; i++) {
|
for(let i=0; i<characterSpecificGamesystem.states.length; i++) {
|
||||||
@ -82,8 +88,8 @@ export class CharacterParser {
|
|||||||
|
|
||||||
return referencedGamesystem;
|
return referencedGamesystem;
|
||||||
}
|
}
|
||||||
private findCharacterSpecificGamesystem(componentName: string): SimpleTemplateGamesystem | undefined{
|
private findCharacterSpecificGamesystem(gamesystems: SimpleTemplateGamesystem[], componentName: string): SimpleTemplateGamesystem | undefined{
|
||||||
return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName)
|
return gamesystems.find(gamesystem => gamesystem.componentName === componentName)
|
||||||
}
|
}
|
||||||
|
|
||||||
private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) {
|
private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) {
|
||||||
|
@ -7,7 +7,7 @@ import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
|
|||||||
|
|
||||||
export class CharacterSerializer {
|
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[] {
|
public static serializeCharacters(characters: Character[]): StoreComponent[] {
|
||||||
const storedCharacters: StoreComponent[] = []
|
const storedCharacters: StoreComponent[] = []
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"componentName": "Astrid Hofferson",
|
"componentName": "Astrid Hofferson",
|
||||||
"componentDescription": "",
|
"componentDescription": "",
|
||||||
"characterSpecificTemplateSystems": []
|
"characterSpecificTemplateSystems": [],
|
||||||
|
"characterRelationGamesystems": []
|
||||||
}
|
}
|
@ -1,5 +1,50 @@
|
|||||||
{
|
{
|
||||||
"componentName": "Hicks Haddock",
|
"componentName": "Hicks Haddock",
|
||||||
"componentDescription": "",
|
"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