32 lines
		
	
	
		
			976 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			976 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;
 | |
|   }
 | |
| 
 | |
| }
 |