main #48

Closed
sebastian wants to merge 44 commits from main into inventory
3 changed files with 34 additions and 9 deletions
Showing only changes of commit 7a650524f3 - Show all commits

View File

@ -34,6 +34,7 @@ import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overvie
import {Overview} from "./side-overviews/Overview";
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
import {CharacterCreator} from "./project/game-model/utils/creator/CharacterCreator";
@Component({
selector: 'app-root',
@ -104,6 +105,9 @@ export class AppComponent implements OnInit{
case ModelComponentType.SCRIPTACCOUNT: {
componentCreator = new ScriptAccountCreator(creationContext, this.gameModel!, this.selectedModelComponent);
} break
case ModelComponentType.CHARACTER: {
componentCreator = new CharacterCreator(creationContext, this.gameModel!, this.selectedModelComponent);
} break
}
if(componentCreator) {
@ -188,15 +192,6 @@ export class AppComponent implements OnInit{
}
}
private onCreateNewCharacter() {
const createdCharacter = this.gameModel!.createCharacter("New Character")
if(createdCharacter != undefined) {
this.editor?.openGameModelComponent(createdCharacter);
} else {
console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)");
}
}
private getSelectedModelComponent(): ModelComponent | undefined {
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
if(this.scriptAccountOverview != undefined) {

View File

@ -232,4 +232,12 @@ export class GameModel {
return result;
}
addCharacter(character: Character) {
if(this.characters.find(c => c.componentName === character.componentName) === undefined) {
this.characters.push(character)
return true;
}
return false;
}
}

View File

@ -0,0 +1,22 @@
import {ModelComponentCreator} from "./ModelComponentCreator";
import {GameModel} from "../../GameModel";
import {ModelComponent} from "../../ModelComponent";
import {Character} from "../../characters/Character";
export class CharacterCreator extends ModelComponentCreator{
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
super(context, gameModel, selectedComponent);
}
createModelComponent(): ModelComponent | undefined {
const character = new Character("New Character", "");
if(this.gameModel.addCharacter(character)) {
return character;
}
return undefined;
}
}