Introduce Symetric and Asymetric Template Relation Systems #40
@ -14,3 +14,12 @@
|
||||
<button mat-stroked-button class="specify-btn" (click)="openTemplateSpecificator()">Specify Templatesystem</button>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Character-Relations</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p *ngFor="let characterRelation of character!.characterRelations">{{characterRelation.firstCharacter.componentName}} - {{characterRelation.secondCharacter.componentName}}</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
@ -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);
|
||||
|
@ -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<any, any>[] = []
|
||||
|
||||
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
|
||||
}
|
||||
|
14
src/app/project/game-model/characters/CharacterRelation.ts
Normal file
14
src/app/project/game-model/characters/CharacterRelation.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user