Load CharacterSpecific Gamesystems (at least considered states)
All checks were successful
E2E Testing / test (push) Successful in 1m35s
All checks were successful
E2E Testing / test (push) Successful in 1m35s
This commit is contained in:
parent
2df08661e0
commit
5cb535a264
@ -204,7 +204,7 @@ export class AppComponent implements OnInit{
|
|||||||
const gamesystemParser = new GamesystemParser(scriptAccounts);
|
const gamesystemParser = new GamesystemParser(scriptAccounts);
|
||||||
const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems);
|
const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems);
|
||||||
|
|
||||||
const characterParser = new CharacterParser();
|
const characterParser = new CharacterParser(gamesystemParser.getAllParsedGamesystems(), scriptAccounts);
|
||||||
const characters = characterParser.parseCharacters(storedGameModel.storedCharacters);
|
const characters = characterParser.parseCharacters(storedGameModel.storedCharacters);
|
||||||
|
|
||||||
gameModel.scriptAccounts = scriptAccounts
|
gameModel.scriptAccounts = scriptAccounts
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
import {StoreComponent} from "../../../../../app/storage/StoreComponent";
|
import {StoreComponent} from "../../../../../app/storage/StoreComponent";
|
||||||
import {Character} from "../../game-model/characters/Character";
|
import {Character} from "../../game-model/characters/Character";
|
||||||
|
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import {TemplateParser} from "../templateParser/TemplateParser";
|
||||||
|
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
|
||||||
|
|
||||||
|
|
||||||
export class CharacterParser {
|
export class CharacterParser {
|
||||||
|
|
||||||
|
private templateParser: TemplateParser
|
||||||
|
|
||||||
|
constructor(gamesystems: Gamesystem<any, any>[], scriptAccounts: ScriptAccount[]) {
|
||||||
|
this.templateParser = new TemplateParser(gamesystems, scriptAccounts)
|
||||||
|
}
|
||||||
|
|
||||||
public parseCharacters(characters: StoreComponent[]): Character[] {
|
public parseCharacters(characters: StoreComponent[]): Character[] {
|
||||||
const loadedCharacters: 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))))
|
||||||
@ -11,6 +20,9 @@ export class CharacterParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private parseSingleCharacter(characterData: any): Character {
|
private parseSingleCharacter(characterData: any): Character {
|
||||||
return new Character(characterData.componentName, characterData.componentDescription);
|
const character = new Character(characterData.componentName, characterData.componentDescription);
|
||||||
|
character.characterSpecificGamesystems = this.templateParser.parseTemplateGamesystems(characterData.characterSpecificGamesystems)
|
||||||
|
console.log(character.characterSpecificGamesystems)
|
||||||
|
return character;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,4 +86,7 @@ export class GamesystemParser {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllParsedGamesystems() {
|
||||||
|
return this.parsedGamesystems
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
45
src/app/project/parser/templateParser/TemplateParser.ts
Normal file
45
src/app/project/parser/templateParser/TemplateParser.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
|
||||||
|
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import {TemplateGamesystem} from "../../game-model/gamesystems/TemplateGamesystem";
|
||||||
|
import {StateParser} from "../gamesystemParser/StateParser";
|
||||||
|
import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem";
|
||||||
|
import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
|
||||||
|
|
||||||
|
export class TemplateParser {
|
||||||
|
private gamesystems: Gamesystem<any, any>[]
|
||||||
|
private stateParser: StateParser
|
||||||
|
|
||||||
|
|
||||||
|
constructor(gamesystems: Gamesystem<any, any>[], scriptAccounts: ScriptAccount[]) {
|
||||||
|
this.gamesystems = gamesystems;
|
||||||
|
this.stateParser = new StateParser(scriptAccounts);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseTemplateGamesystems(templateGamesystemData: any): TemplateGamesystem[] {
|
||||||
|
const templateGamesystems: TemplateGamesystem[] = []
|
||||||
|
for(let i=0; i<templateGamesystemData.length; i++) {
|
||||||
|
const templateSystem = this.parseSingleTemplateGamesystem(templateGamesystemData[i]);
|
||||||
|
if(templateSystem != undefined) {
|
||||||
|
templateGamesystems.push(templateSystem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return templateGamesystems;
|
||||||
|
}
|
||||||
|
|
||||||
|
private parseSingleTemplateGamesystem(templateGamesystemData: any) {
|
||||||
|
const referencedGamesystem = this.findReferendGamesystem(templateGamesystemData.referenceGamesystem)
|
||||||
|
if(referencedGamesystem == undefined || referencedGamesystem instanceof ProductGamesystem) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const templateStates = this.stateParser.parseStates(templateGamesystemData.templateStates)
|
||||||
|
const templateSystem = new TemplateGamesystem(referencedGamesystem as SimpleGamesystem);
|
||||||
|
templateSystem.templateStates = templateStates
|
||||||
|
|
||||||
|
return templateSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
private findReferendGamesystem(gamesystemName: string) {
|
||||||
|
return this.gamesystems.find(gamesystem => gamesystem.componentName === gamesystemName);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user