40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
type PromotionPieceType = 'queen' | 'rook' | 'bishop' | 'knight';
|
|
interface PromotionPieceOption {
|
|
type: PromotionPieceType;
|
|
label: string;
|
|
symbol: string;
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-promotion-dialog',
|
|
standalone: true,
|
|
imports: [CommonModule],
|
|
templateUrl: './promotion-dialog.component.html',
|
|
styleUrl: './promotion-dialog.component.css'
|
|
})
|
|
export class PromotionDialogComponent {
|
|
@Input() isOpen = false;
|
|
@Output() promotionSelected = new EventEmitter<PromotionPieceType>();
|
|
@Output() closed = new EventEmitter<void>();
|
|
|
|
promotionPieces: PromotionPieceOption[] = [
|
|
{ type: 'queen', label: 'Queen', symbol: '♕' },
|
|
{ type: 'rook', label: 'Rook', symbol: '♖' },
|
|
{ type: 'bishop', label: 'Bishop', symbol: '♗' },
|
|
{ type: 'knight', label: 'Knight', symbol: '♘' }
|
|
];
|
|
|
|
selectPromotion(type: PromotionPieceType): void {
|
|
this.promotionSelected.emit(type);
|
|
this.isOpen = false;
|
|
}
|
|
|
|
close(): void {
|
|
this.closed.emit();
|
|
this.isOpen = false;
|
|
}
|
|
}
|