refactor-component-creation #47

Merged
sebastian merged 9 commits from refactor-component-creation into main 2024-05-11 08:40:09 +02:00
3 changed files with 51 additions and 1 deletions
Showing only changes of commit ccb53df815 - Show all commits

View File

@ -35,6 +35,7 @@ import {Overview} from "./side-overviews/Overview";
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator"; import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator"; import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
import {CharacterCreator} from "./project/game-model/utils/creator/CharacterCreator"; import {CharacterCreator} from "./project/game-model/utils/creator/CharacterCreator";
import {GamesystemCreator} from "./project/game-model/utils/creator/GamesystemCreator";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -108,6 +109,9 @@ export class AppComponent implements OnInit{
case ModelComponentType.CHARACTER: { case ModelComponentType.CHARACTER: {
componentCreator = new CharacterCreator(creationContext, this.gameModel!, this.selectedModelComponent); componentCreator = new CharacterCreator(creationContext, this.gameModel!, this.selectedModelComponent);
} break } break
case ModelComponentType.GAMESYTEM: {
componentCreator = new GamesystemCreator(creationContext, this.gameModel!, this.selectedModelComponent);
} break
} }
if(componentCreator) { if(componentCreator) {
@ -146,6 +150,7 @@ export class AppComponent implements OnInit{
} }
}break }break
} }
} }

View File

@ -27,5 +27,4 @@ export abstract class Gamesystem<S, T> extends ModelComponent{
this.transitions = updatedTransitions; this.transitions = updatedTransitions;
return true; return true;
} }
} }

View File

@ -0,0 +1,46 @@
import {ModelComponentCreator} from "./ModelComponentCreator";
import {GameModel} from "../../GameModel";
import {ModelComponent} from "../../ModelComponent";
import {TemplateTypeUtilities} from "../../templates/TemplateTypeUtilities";
import {Gamesystem} from "../../gamesystems/Gamesystem";
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../../gamesystems/ProductGamesystem";
import {SimpleTemplateGamesystem} from "../../templates/simpleGamesystem/SimpleTemplateGamesystem";
import {ProductTemplateCreator} from "../../templates/productGamesystem/ProductTemplateCreator";
export class GamesystemCreator extends ModelComponentCreator{
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
super(context, gameModel, selectedComponent);
}
createModelComponent(): ModelComponent | undefined {
const templateType = TemplateTypeUtilities.fromString(this.context);
let simpleGamesystem;
if(templateType == undefined) /**Aka normal**/{
simpleGamesystem = new SimpleGamesystem("New Simple Gamesystem", "");
} else {
simpleGamesystem = new SimpleTemplateGamesystem("New Simple Gamesystem", "", templateType)
}
if(this.selectedComponent !== undefined && this.selectedComponent instanceof Gamesystem)/**Aka productGamesystem**/ {
let productParentsystem: ProductGamesystem;
if(this.selectedComponent instanceof SimpleTemplateGamesystem) {
productParentsystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(this.selectedComponent, this.gameModel!, this.selectedComponent.templateType);
} else if(this.selectedComponent instanceof SimpleGamesystem) {
productParentsystem = ProductGamesystem.constructFromSimpleGamesystem(this.selectedComponent, this.gameModel);
} else {
productParentsystem = this.selectedComponent as ProductGamesystem;
}
productParentsystem.addChildGamesystem(simpleGamesystem);
} else {
this.gameModel!.gamesystems.push(simpleGamesystem);
}
return simpleGamesystem;
}
}