diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index b13fddf..b860b2f 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -14,3 +14,12 @@ + + + + Character-Relations + + +

{{characterRelation.firstCharacter.componentName}} - {{characterRelation.secondCharacter.componentName}}

+
+
diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index b59445a..1089ccc 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -10,6 +10,7 @@ import {TemplateType} from "./templates/TemplateType"; import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem"; import {ProductTemplateSystem} from "./templates/productGamesystem/ProductTemplateSystem"; import {ProductTemplateCreator} from "./templates/productGamesystem/ProductTemplateCreator"; +import {CharacterRelation} from "./characters/CharacterRelation"; export class GameModel { gameModelName: string @@ -127,12 +128,21 @@ export class GameModel { const searchedCharacter = this.characters.find(character => character.componentName === characterName); if(searchedCharacter == undefined) { const character = new Character(characterName, ""); + this.createCharacterRelation(character) this.characters.push(character) return character } return undefined } + private createCharacterRelation(addedCharacter: Character) { + this.characters.forEach(character => { + const characterRelation = new CharacterRelation(character, addedCharacter); + character.addCharacterRelation(characterRelation); + addedCharacter.addCharacterRelation(characterRelation); + }) + } + removeScriptAccount(scriptAccount: ScriptAccount) { if(scriptAccount != undefined) { this.scriptAccounts = this.scriptAccounts.filter(s => s != scriptAccount); diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 4d9bf6c..a8b0bd7 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -6,11 +6,14 @@ import {Gamesystem} from "../gamesystems/Gamesystem"; import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; import {ProductGamesystem} from "../gamesystems/ProductGamesystem"; +import {CharacterRelation} from "./CharacterRelation"; export class Character extends ModelComponent implements TemplateElement { characterSpecificTemplateSystems: Gamesystem[] = [] + characterRelations: CharacterRelation[] = [] + constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); } @@ -36,6 +39,10 @@ export class Character extends ModelComponent implements TemplateElement { } } + addCharacterRelation(characterRelation: CharacterRelation) { + this.characterRelations.push(characterRelation) + } + private isTemplateSystemCharacterSpecific(gamesystemName: string) { return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined } diff --git a/src/app/project/game-model/characters/CharacterRelation.ts b/src/app/project/game-model/characters/CharacterRelation.ts new file mode 100644 index 0000000..b54e4f9 --- /dev/null +++ b/src/app/project/game-model/characters/CharacterRelation.ts @@ -0,0 +1,14 @@ +import {TemplateElement} from "../templates/TemplateElement"; +import {Character} from "./Character"; + +export class CharacterRelation implements TemplateElement{ + + firstCharacter: Character + secondCharacter: Character + + + constructor(firstCharacter: Character, secondCharacter: Character) { + this.firstCharacter = firstCharacter; + this.secondCharacter = secondCharacter; + } +} diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index 0570861..f980445 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -6,6 +6,8 @@ import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountCon 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"; export class CharacterParser { @@ -23,12 +25,19 @@ export class CharacterParser { public parseCharacters(characters: StoreComponent[]): Character[] { const loadedCharacters: Character[] = [] - characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString)))) + characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString), loadedCharacters))) return loadedCharacters; } - private parseSingleCharacter(characterData: any): Character { + private parseSingleCharacter(characterData: any, loadedCharacters: Character[]): Character { const character = new Character(characterData.componentName, characterData.componentDescription); + + loadedCharacters.forEach(loadedCharacter => { + const characterRelation = new CharacterRelation(loadedCharacter, character); + loadedCharacter.addCharacterRelation(characterRelation) + character.addCharacterRelation(characterRelation) + }) + const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems); templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system)) return character;