issue-15 #21
@ -3,7 +3,8 @@
 | 
				
			|||||||
  "ignorePatterns": [
 | 
					  "ignorePatterns": [
 | 
				
			||||||
    "app/**/*", // ignore nodeJs files
 | 
					    "app/**/*", // ignore nodeJs files
 | 
				
			||||||
    "dist/**/*",
 | 
					    "dist/**/*",
 | 
				
			||||||
    "release/**/*"
 | 
					    "release/**/*",
 | 
				
			||||||
 | 
					    "src/**/*"
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  "overrides": [
 | 
					  "overrides": [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
@ -153,7 +153,9 @@ export class AppComponent implements OnInit{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  onLoadProject(storedGameModel: StoredGameModel) {
 | 
					  onLoadProject(storedGameModel: StoredGameModel) {
 | 
				
			||||||
    const gameModel = new GameModel(storedGameModel.gameModelName)
 | 
					    const gameModel = new GameModel(storedGameModel.gameModelName)
 | 
				
			||||||
    const gamesystemParser = new GamesystemParser();
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //const gamesystemParser = new GamesystemParser();
 | 
				
			||||||
    storedGameModel.loadedModels.forEach(storedComponent => {
 | 
					    storedGameModel.loadedModels.forEach(storedComponent => {
 | 
				
			||||||
      switch (storedComponent.componentType) {
 | 
					      switch (storedComponent.componentType) {
 | 
				
			||||||
        case ModelComponentType.SCRIPTACCOUNT: {
 | 
					        case ModelComponentType.SCRIPTACCOUNT: {
 | 
				
			||||||
@ -161,14 +163,14 @@ export class AppComponent implements OnInit{
 | 
				
			|||||||
          gameModel.addScriptAccount(scriptAccount);
 | 
					          gameModel.addScriptAccount(scriptAccount);
 | 
				
			||||||
        } break
 | 
					        } break
 | 
				
			||||||
        case ModelComponentType.GAMESYTEM: {
 | 
					        case ModelComponentType.GAMESYTEM: {
 | 
				
			||||||
          gamesystemParser.parseGamesystem(storedComponent);
 | 
					          //gamesystemParser.parseGamesystem(storedComponent);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => {
 | 
					    /*gamesystemParser.computeGamesystemStructure().forEach(topGamesystem => {
 | 
				
			||||||
      gameModel.addGamesystem(topGamesystem)
 | 
					      gameModel.addGamesystem(topGamesystem)
 | 
				
			||||||
    })
 | 
					    })*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.gameModel = gameModel;
 | 
					    this.gameModel = gameModel;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -3,11 +3,21 @@ import {Gamesystem} from "../../game-model/gamesystems/Gamesystem";
 | 
				
			|||||||
import {ParsedParentGamesystems} from "./ParsedParentGamesystems";
 | 
					import {ParsedParentGamesystems} from "./ParsedParentGamesystems";
 | 
				
			||||||
import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem";
 | 
					import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem";
 | 
				
			||||||
import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
 | 
					import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
 | 
				
			||||||
 | 
					import {StateParser} from "./StateParser";
 | 
				
			||||||
 | 
					import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class GamesystemParser {
 | 
					export class GamesystemParser {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  parsedParentGamesystems: ParsedParentGamesystems[] = []
 | 
					  parsedParentGamesystems: ParsedParentGamesystems[] = []
 | 
				
			||||||
  parsedGamesystems: Gamesystem<any, any>[] = []
 | 
					  parsedGamesystems: Gamesystem<any, any>[] = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  private stateParser: StateParser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  constructor(scriptAccounts: ScriptAccount[]) {
 | 
				
			||||||
 | 
					    this.stateParser = new StateParser(scriptAccounts)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public parseGamesystem(storedGamesystem: StoreComponent) {
 | 
					  public parseGamesystem(storedGamesystem: StoreComponent) {
 | 
				
			||||||
    const parsedGamesystemData = JSON.parse(storedGamesystem.jsonString)
 | 
					    const parsedGamesystemData = JSON.parse(storedGamesystem.jsonString)
 | 
				
			||||||
    let parsedSystem: Gamesystem<any, any>
 | 
					    let parsedSystem: Gamesystem<any, any>
 | 
				
			||||||
@ -21,7 +31,8 @@ export class GamesystemParser {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem {
 | 
					  parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem {
 | 
				
			||||||
    const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
 | 
					    const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
 | 
				
			||||||
 | 
					    const states = this.stateParser.parseStates(gamesystemData)
 | 
				
			||||||
 | 
					    simpleGamesystem.states = states
 | 
				
			||||||
    return simpleGamesystem
 | 
					    return simpleGamesystem
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										34
									
								
								src/app/project/parser/gamesystemParser/StateParser.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/app/project/parser/gamesystemParser/StateParser.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					import {SimpleState} from "../../game-model/gamesystems/states/SimpleState";
 | 
				
			||||||
 | 
					import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
 | 
				
			||||||
 | 
					import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class StateParser {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private scriptAccounts: ScriptAccount[]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    constructor(scriptAccounts: ScriptAccount[]) {
 | 
				
			||||||
 | 
					      this.scriptAccounts = scriptAccounts;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public  parseStates(gamesystemData: any): SimpleState[] {
 | 
				
			||||||
 | 
					      const parsedStates: SimpleState[] = []
 | 
				
			||||||
 | 
					      for(let i=0; i<gamesystemData.states.length; i++) {
 | 
				
			||||||
 | 
					        parsedStates.push(this.parseState(gamesystemData.states[i]))
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      return parsedStates;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   private parseState(stateData: any): SimpleState {
 | 
				
			||||||
 | 
					      const initial = stateData.initial
 | 
				
			||||||
 | 
					      const stateLabel = stateData.stateLabel
 | 
				
			||||||
 | 
					      const stateDescription = stateData.stateDescription
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      const simpleState = new SimpleState(stateLabel, stateDescription);
 | 
				
			||||||
 | 
					      simpleState.initial = initial;
 | 
				
			||||||
 | 
					      return simpleState;
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user