ConceptCreator/src/app/project/game-model/gamesystems/Gamesystem.ts
Sebastian Böckelmann ccb53df815
All checks were successful
E2E Testing / test (push) Successful in 1m36s
Refactor Gamesystem Creation
2024-05-09 19:17:43 +02:00

31 lines
975 B
TypeScript

import {SimpleGamesystem} from "./SimpleGamesystem";
import {ProductGamesystem} from "./ProductGamesystem";
import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType";
export abstract class Gamesystem<S, T> extends ModelComponent{
states: S[] = [];
transitions: T[] = [];
parentGamesystem: ProductGamesystem | undefined
generateIsolatedStates: boolean = false
constructor(gamesystemName: string, gamesystemDescription: string) {
super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM);
}
abstract createTransition(startingState: S, endingState: S): T|undefined;
abstract removeState(state: S): boolean;
removeTransition(transition: T): boolean {
const updatedTransitions = this.transitions.filter(t => t !== transition);
if(updatedTransitions.length == this.transitions.length) {
return false;
}
this.transitions = updatedTransitions;
return true;
}
}