parent
4f7d8d8d5d
commit
6ace079ccd
@ -211,7 +211,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(gamesystemParser.getParsedTemplateGamesystems(TemplateType.CHARACTER), scriptAccounts);
|
const characterParser = new CharacterParser(gamesystemParser.getParsedTemplateGamesystems(TemplateType.CHARACTER));
|
||||||
const characters = characterParser.parseCharacters(storedGameModel.storedCharacters);
|
const characters = characterParser.parseCharacters(storedGameModel.storedCharacters);
|
||||||
|
|
||||||
gameModel.scriptAccounts = scriptAccounts
|
gameModel.scriptAccounts = scriptAccounts
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
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 {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTemplateGamesystem";
|
import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTemplateGamesystem";
|
||||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
|
||||||
import {ScriptAccountParser} from "../ScriptAccountParser";
|
|
||||||
import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser";
|
|
||||||
|
|
||||||
|
|
||||||
export class CharacterParser {
|
export class CharacterParser {
|
||||||
|
|
||||||
characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[]
|
characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[]
|
||||||
scriptAccountConditionParser: ScriptAccountConditionParser
|
|
||||||
|
|
||||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[], scriptAccounts: ScriptAccount[]) {
|
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[]) {
|
||||||
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
||||||
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public parseCharacters(characters: StoreComponent[]): Character[] {
|
public parseCharacters(characters: StoreComponent[]): Character[] {
|
||||||
@ -25,6 +20,7 @@ export class CharacterParser {
|
|||||||
private parseSingleCharacter(characterData: any): Character {
|
private parseSingleCharacter(characterData: any): Character {
|
||||||
const character = new Character(characterData.componentName, characterData.componentDescription);
|
const character = new Character(characterData.componentName, characterData.componentDescription);
|
||||||
character.characterSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificGamesystems);
|
character.characterSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificGamesystems);
|
||||||
|
console.log("Parsed Character", character)
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,14 +41,13 @@ export class CharacterParser {
|
|||||||
const stateReference = characterSpecificGamesystem.states[i];
|
const stateReference = characterSpecificGamesystem.states[i];
|
||||||
const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)!
|
const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)!
|
||||||
|
|
||||||
const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap);
|
state.conditionMap.set(character, [])
|
||||||
|
|
||||||
state.conditionMap.set(character, conditions)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return referencedGamesystem;
|
return referencedGamesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private findCharacterSpecificGamesystem(componentName: string): SimpleTemplateGamesystem<Character> | undefined{
|
private findCharacterSpecificGamesystem(componentName: string): SimpleTemplateGamesystem<Character> | undefined{
|
||||||
return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName)
|
return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user