Convert Interaction into Sequence
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				E2E Testing / test (push) Successful in 1m13s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	E2E Testing / test (push) Successful in 1m13s
				
			This commit is contained in:
		
							parent
							
								
									685270bd4f
								
							
						
					
					
						commit
						3d899251eb
					
				| @ -230,8 +230,7 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader =>  new Transl | |||||||
|     MatExpansionPanelDescription, |     MatExpansionPanelDescription, | ||||||
|     MatAutocomplete, |     MatAutocomplete, | ||||||
|     MatAutocompleteTrigger, |     MatAutocompleteTrigger, | ||||||
|     MatNoDataRow, |     MatNoDataRow | ||||||
|     InteractionSequenceEditorComponent |  | ||||||
|   ], |   ], | ||||||
|   providers: [], |   providers: [], | ||||||
|   bootstrap: [AppComponent] |   bootstrap: [AppComponent] | ||||||
|  | |||||||
| @ -145,6 +145,8 @@ | |||||||
|             <app-interaction-sequence-editor [interactionSequence]="element" [gameModel]="gameModel" [character]="character"></app-interaction-sequence-editor> |             <app-interaction-sequence-editor [interactionSequence]="element" [gameModel]="gameModel" [character]="character"></app-interaction-sequence-editor> | ||||||
|           </mat-expansion-panel> |           </mat-expansion-panel> | ||||||
|         </mat-accordion> |         </mat-accordion> | ||||||
|  | 
 | ||||||
|  |         <button mat-raised-button color="accent" *ngIf="!isInteractionSequence(element)" (click)="convertToSequence(element)">Convert to Sequence</button> | ||||||
|       </div> |       </div> | ||||||
|     </td> |     </td> | ||||||
|   </ng-container> |   </ng-container> | ||||||
|  | |||||||
| @ -104,4 +104,11 @@ export class CharacterInteractionEditorComponent implements OnInit{ | |||||||
|       interaction.removeAction(action); |       interaction.removeAction(action); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   convertToSequence(interaction: Interaction) { | ||||||
|  |     const interactionSequence = new InteractionSequences(interaction, interaction.interactionLabel); | ||||||
|  |     this.gameModel!.removeCharacterInteraction(interaction); | ||||||
|  |     this.gameModel!.addCharacterInteraction(interactionSequence); | ||||||
|  |     this.interactionDatasource.data = this.gameModel!.characterInteractions; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,55 @@ | |||||||
|  | table { | ||||||
|  |   width: 100%; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | tr.example-detail-row { | ||||||
|  |   height: 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | tr.example-element-row:not(.example-expanded-row):hover { | ||||||
|  |   background: #4e5157; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | tr.example-element-row:not(.example-expanded-row):active { | ||||||
|  |   background: #545456; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .example-element-row td { | ||||||
|  |   border-bottom-width: 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .example-element-detail { | ||||||
|  |   overflow: hidden; | ||||||
|  |   width: 100%; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .example-element-diagram { | ||||||
|  |   min-width: 80px; | ||||||
|  |   border: 2px solid black; | ||||||
|  |   padding: 8px; | ||||||
|  |   font-weight: lighter; | ||||||
|  |   margin: 8px 0; | ||||||
|  |   height: 104px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .example-element-symbol { | ||||||
|  |   font-weight: bold; | ||||||
|  |   font-size: 40px; | ||||||
|  |   line-height: normal; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .example-element-description { | ||||||
|  |   padding: 16px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .example-element-description-attribution { | ||||||
|  |   opacity: 0.5; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .mat-column-delete, .mat-column-edit, .mat-column-expand, .mat-column-sequence { | ||||||
|  |   width: 32px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .warning { | ||||||
|  |   color: red; | ||||||
|  | } | ||||||
| @ -8,11 +8,19 @@ import {MatSnackBar} from "@angular/material/snack-bar"; | |||||||
| import {AbstractInteraction} from "../../../project/game-model/interactions/AbstractInteraction"; | import {AbstractInteraction} from "../../../project/game-model/interactions/AbstractInteraction"; | ||||||
| import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; | import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; | ||||||
| import {ScriptAccountAction} from "../../../project/game-model/gamesystems/actions/ScriptAccountAction"; | import {ScriptAccountAction} from "../../../project/game-model/gamesystems/actions/ScriptAccountAction"; | ||||||
|  | import {animate, state, style, transition, trigger} from "@angular/animations"; | ||||||
| 
 | 
 | ||||||
| @Component({ | @Component({ | ||||||
|   selector: 'app-interaction-sequence-editor', |   selector: 'app-interaction-sequence-editor', | ||||||
|   templateUrl: './interaction-sequence-editor.component.html', |   templateUrl: './interaction-sequence-editor.component.html', | ||||||
|   styleUrl: './interaction-sequence-editor.component.scss' |   styleUrl: './interaction-sequence-editor.component.scss', | ||||||
|  |   animations: [ | ||||||
|  |     trigger('detailExpand', [ | ||||||
|  |       state('collapsed,void', style({height: '0px', minHeight: '0'})), | ||||||
|  |       state('expanded', style({height: '*'})), | ||||||
|  |       transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), | ||||||
|  |     ]), | ||||||
|  |   ], | ||||||
| }) | }) | ||||||
| export class InteractionSequenceEditorComponent implements OnInit{ | export class InteractionSequenceEditorComponent implements OnInit{ | ||||||
|   @Input() interactionSequence: InteractionSequences | undefined; |   @Input() interactionSequence: InteractionSequences | undefined; | ||||||
| @ -35,10 +43,9 @@ export class InteractionSequenceEditorComponent implements OnInit{ | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private assignData() { |   private assignData() { | ||||||
|  |     this.currentInteractionNode = this.interactionSequence!.rootInteraction.root; | ||||||
|     if(this.currentInteractionNode != undefined) { |     if(this.currentInteractionNode != undefined) { | ||||||
|       this.sequenceDatasource.data = this.interactionSequence!.findInteraction(this.currentInteractionNode)!.children.map(node => node.root); |       this.sequenceDatasource.data = this.interactionSequence!.findInteraction(this.currentInteractionNode)!.children.map(node => node.root); | ||||||
|     } else { |  | ||||||
|       this.sequenceDatasource.data = [this.interactionSequence!.rootInteraction.root]; |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -52,7 +59,10 @@ export class InteractionSequenceEditorComponent implements OnInit{ | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(this.editedElement!.validate(this.character!)) { |     if(this.editedElement!.validate(this.character!)) { | ||||||
|       this.gameModel!.addCharacterInteraction(this.editedElement); |       const node = this.interactionSequence!.findInteraction(this.currentInteractionNode!); | ||||||
|  |       if(node != undefined) { | ||||||
|  |         node.addInteraction(this.editedElement!); | ||||||
|  |       } | ||||||
|       this.editedElement = undefined; |       this.editedElement = undefined; | ||||||
|     } else { |     } else { | ||||||
|       this.snackbar.open("Invalid Interaction", "", {duration: 2000}); |       this.snackbar.open("Invalid Interaction", "", {duration: 2000}); | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ export abstract class AbstractInteraction { | |||||||
|   interactionLabel: string |   interactionLabel: string | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|   constructor(sourceCharacter: Character, targetCharacter: Character | undefined, interactionLabel: string) { |   protected constructor(sourceCharacter: Character, targetCharacter: Character | undefined, interactionLabel: string, conditions: Condition[] = []) { | ||||||
|     this.sourceCharacter = sourceCharacter; |     this.sourceCharacter = sourceCharacter; | ||||||
|     this.targetCharacter = targetCharacter; |     this.targetCharacter = targetCharacter; | ||||||
|     this.interactionLabel = interactionLabel; |     this.interactionLabel = interactionLabel; | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ export class InteractionSequences extends AbstractInteraction { | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|   constructor(interaction: Interaction, interactionLabel: string) { |   constructor(interaction: Interaction, interactionLabel: string) { | ||||||
|     super(interaction.sourceCharacter, interaction.targetCharacter, interactionLabel); |     super(interaction.sourceCharacter, interaction.targetCharacter, interactionLabel, interaction.conditions); | ||||||
|     this.rootInteraction = new InteractionSequenceNode(interaction, []); |     this.rootInteraction = new InteractionSequenceNode(interaction, []); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -89,4 +89,8 @@ class InteractionSequenceNode { | |||||||
|   removeChildInteraction(interaction: Interaction) { |   removeChildInteraction(interaction: Interaction) { | ||||||
|     this.children = this.children.filter(child => child.root !== interaction); |     this.children = this.children.filter(child => child.root !== interaction); | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   addInteraction(interaction: Interaction) { | ||||||
|  |     this.children.push(new InteractionSequenceNode(interaction, [])); | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user