feat: new boared design

This commit is contained in:
shahdlala66
2026-04-26 13:34:55 +02:00
parent dc9a7b2e32
commit 671886781e
69 changed files with 546 additions and 352 deletions
@@ -1,5 +1,7 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
type BoardTheme = 'arabian' | 'classic';
@Component({
selector: 'app-chess-piece',
standalone: true,
@@ -8,6 +10,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
})
export class ChessPieceComponent {
@Input({ required: true }) pieceCode: string | null = null;
@Input() boardTheme: BoardTheme = 'arabian';
@Input() draggable = false;
@Output() pieceDragStart = new EventEmitter<DragEvent>();
@Output() pieceDragEnd = new EventEmitter<void>();
@@ -30,12 +33,21 @@ export class ChessPieceComponent {
return '';
}
const color = this.pieceCode === this.pieceCode.toUpperCase() ? 'white' : 'black';
const pieceName = this.getPieceName(this.pieceCode.toLowerCase());
return `/arabian-chess/sprites/pieces/${color}_${pieceName}.png`;
const isWhite = this.pieceCode === this.pieceCode.toUpperCase();
const pieceCode = this.pieceCode.toLowerCase();
if (this.boardTheme === 'classic') {
const colorPrefix = isWhite ? 'w' : 'b';
const classicPieceName = this.getClassicPieceName(pieceCode);
return `/assets/ChessAssets/${colorPrefix}_${classicPieceName}.png`;
}
const arabianColor = isWhite ? 'white' : 'black';
const arabianPieceName = this.getArabianPieceName(pieceCode);
return `/assets/arabian-chess/sprites/pieces/${arabianColor}_${arabianPieceName}.png`;
}
private getPieceName(piece: string): string {
private getArabianPieceName(piece: string): string {
switch (piece) {
case 'k':
return 'king';
@@ -53,4 +65,23 @@ export class ChessPieceComponent {
return 'pawn';
}
}
private getClassicPieceName(piece: string): string {
switch (piece) {
case 'k':
return 'King';
case 'q':
return 'Queen';
case 'r':
return 'Rook';
case 'b':
return 'Bishop';
case 'n':
return 'Knight';
case 'p':
return 'Pawn';
default:
return 'Pawn';
}
}
}