Generate Productgamesystem States + Transition after loading them
All checks were successful
E2E Testing / test (push) Successful in 1m28s
All checks were successful
E2E Testing / test (push) Successful in 1m28s
This commit is contained in:
parent
3b0d4e0194
commit
a93a7411a3
@ -8,15 +8,26 @@ import {SimpleGamesystemParser} from "./parser/SimpleGamesystemParser";
|
|||||||
import {SimpleGamesystem} from "../gamesystems/SimpleGamesystem";
|
import {SimpleGamesystem} from "../gamesystems/SimpleGamesystem";
|
||||||
import {ProductGamesystem} from "../gamesystems/ProductGamesystem";
|
import {ProductGamesystem} from "../gamesystems/ProductGamesystem";
|
||||||
import {ProductGamesystemParser} from "./parser/ProductGamesystemParser";
|
import {ProductGamesystemParser} from "./parser/ProductGamesystemParser";
|
||||||
|
import {Gamesystem} from "../gamesystems/Gamesystem";
|
||||||
|
|
||||||
export class ProcessLoadedProject {
|
export class ProcessLoadedProject {
|
||||||
|
|
||||||
static processLoadedProject(loadedProject: LoadedProject): GameModel {
|
static processLoadedProject(loadedProject: LoadedProject): GameModel {
|
||||||
const gameModel = new GameModel(loadedProject.projectName);
|
const gameModel = new GameModel(loadedProject.projectName);
|
||||||
loadedProject.loadedModels.forEach(loadedModel => this.processLoadedModel(gameModel, loadedModel))
|
loadedProject.loadedModels.forEach(loadedModel => this.processLoadedModel(gameModel, loadedModel))
|
||||||
|
//Generate product Gamesystems
|
||||||
|
this.generateProductGamesystems(gameModel.gamesystems)
|
||||||
return gameModel;
|
return gameModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static generateProductGamesystems(gamesystems: Gamesystem<any, any>[]) {
|
||||||
|
gamesystems.forEach(gamesystem => {
|
||||||
|
if(gamesystem instanceof ProductGamesystem) {
|
||||||
|
gamesystem.generateFromChildsystems();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
static processLoadedModel(gameModel: GameModel, loadedModel: LoadModel) {
|
static processLoadedModel(gameModel: GameModel, loadedModel: LoadModel) {
|
||||||
switch (loadedModel.modelType) {
|
switch (loadedModel.modelType) {
|
||||||
case ModelComponentType.SCRIPTACCOUNT: this.processLoadedScriptAccount(gameModel, loadedModel); break;
|
case ModelComponentType.SCRIPTACCOUNT: this.processLoadedScriptAccount(gameModel, loadedModel); break;
|
||||||
|
@ -65,10 +65,25 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
|
|||||||
|
|
||||||
generateFromChildsystems() {
|
generateFromChildsystems() {
|
||||||
//Assume that childsystems that are productsystems are already generated
|
//Assume that childsystems that are productsystems are already generated
|
||||||
|
if(this.innerGamesystems.length < 2) {
|
||||||
|
//currently only safe-guard
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const integratedSystems: Gamesystem<any, any>[] = [this.innerGamesystems[0], this.innerGamesystems[1]];
|
const integratedSystems: Gamesystem<any, any>[] = [this.innerGamesystems[0], this.innerGamesystems[1]];
|
||||||
|
if(this.innerGamesystems[0] instanceof ProductGamesystem) {
|
||||||
|
this.innerGamesystems[0].generateFromChildsystems();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.innerGamesystems[1] instanceof ProductGamesystem) {
|
||||||
|
this.innerGamesystems[1].generateFromChildsystems();
|
||||||
|
}
|
||||||
let gamesystem: ProductGamesystem = ProductGamesystem.generateFromChildsystems(this.innerGamesystems[0], this.innerGamesystems[1], false, integratedSystems);
|
let gamesystem: ProductGamesystem = ProductGamesystem.generateFromChildsystems(this.innerGamesystems[0], this.innerGamesystems[1], false, integratedSystems);
|
||||||
|
|
||||||
for(let i=2; i<this.innerGamesystems.length; i++) {
|
for(let i=2; i<this.innerGamesystems.length; i++) {
|
||||||
|
if(this.innerGamesystems[i] instanceof ProductGamesystem) {
|
||||||
|
(this.innerGamesystems[i] as ProductGamesystem).generateFromChildsystems();
|
||||||
|
}
|
||||||
integratedSystems.push(this.innerGamesystems[i]);
|
integratedSystems.push(this.innerGamesystems[i]);
|
||||||
gamesystem = ProductGamesystem.generateFromChildsystems(gamesystem, this.innerGamesystems[i], true, integratedSystems);
|
gamesystem = ProductGamesystem.generateFromChildsystems(gamesystem, this.innerGamesystems[i], true, integratedSystems);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user