fix: size of pieces and removed text view of the game state

This commit is contained in:
shahdlala66
2026-04-17 23:30:44 +02:00
parent c11c1d4dce
commit c60d00f9d2
5 changed files with 15 additions and 71 deletions
@@ -1,6 +1,6 @@
.board-shell { .board-shell {
width: min(100%, 82dvh, 760px); --bottom-frame-height: clamp(18px, 4.5cqh, 40px);
max-width: calc(100dvw - 2rem); width: min(98cqw, calc(98cqh - var(--bottom-frame-height)));
margin: 0 auto; margin: 0 auto;
} }
@@ -51,8 +51,10 @@
} }
.board-bottom { .board-bottom {
height: var(--bottom-frame-height);
width: 100%; width: 100%;
display: block; display: block;
object-fit: fill;
border: 2px solid #5A2C28; border: 2px solid #5A2C28;
border-top: 0; border-top: 0;
border-radius: 0 0 10px 10px; border-radius: 0 0 10px 10px;
@@ -1,6 +1,6 @@
.piece { .piece {
width: 90%; width: clamp(40px, 9cqh, 130px);
height: 90%; height: clamp(40px, 9cqh, 130px);
display: block; display: block;
object-fit: contain; object-fit: contain;
pointer-events: none; pointer-events: none;
+8 -28
View File
@@ -40,35 +40,9 @@ h2 {
.top-section { .top-section {
display: grid; display: grid;
gap: 0.75rem; gap: 0.5rem;
margin-bottom: 0.75rem;
flex: 0 0 auto;
}
.state-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 0.75rem;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} flex: 0 0 auto;
.panel {
background: #B9C2DA;
border-radius: 10px;
border: 2px solid #5A2C28;
padding: 0.75rem;
}
.panel p {
margin: 0.3rem 0;
}
code {
display: block;
background: #E1EAA9;
border-radius: 8px;
padding: 0.5rem;
overflow-wrap: anywhere;
} }
.move-form { .move-form {
@@ -78,11 +52,17 @@ code {
gap: 0.75rem; gap: 0.75rem;
} }
.board-hint {
margin: 0;
color: #5A2C28;
}
.board-section { .board-section {
flex: 1 1 auto; flex: 1 1 auto;
min-height: 0; min-height: 0;
display: grid; display: grid;
place-items: center; place-items: center;
container-type: size;
padding: clamp(0.35rem, 1vw, 0.75rem); padding: clamp(0.35rem, 1vw, 0.75rem);
border-radius: 10px; border-radius: 10px;
border: 2px solid #5A2C28; border: 2px solid #5A2C28;
+1 -18
View File
@@ -10,29 +10,12 @@
<p>Loading game state...</p> <p>Loading game state...</p>
} @else if (state) { } @else if (state) {
<section class="top-section"> <section class="top-section">
<div class="state-grid">
<div class="panel">
<h2>Status</h2>
<p>Turn: <strong>{{ state.turn }}</strong></p>
<p>Status: <strong>{{ state.status }}</strong></p>
<p>FEN:</p>
<code>{{ state.fen }}</code>
</div>
<div class="panel">
<h2>Moves</h2>
<p>PGN: {{ state.pgn || 'No moves yet' }}</p>
<p>Played UCI: {{ state.moves.length ? state.moves.join(', ') : 'None' }}</p>
<p>Legal UCI: {{ legalMoveUciList.length ? legalMoveUciList.join(', ') : 'None' }}</p>
<p>Board: click your piece to highlight legal targets.</p>
</div>
</div>
<form class="move-form" (ngSubmit)="submitMove()"> <form class="move-form" (ngSubmit)="submitMove()">
<label for="uciMove">Play move (UCI)</label> <label for="uciMove">Play move (UCI)</label>
<input id="uciMove" name="uciMove" [(ngModel)]="moveInput" placeholder="e2e4" /> <input id="uciMove" name="uciMove" [(ngModel)]="moveInput" placeholder="e2e4" />
<button type="submit">Send Move</button> <button type="submit">Send Move</button>
</form> </form>
<p class="board-hint">Click your piece to highlight legal targets.</p>
</section> </section>
<section class="board-section"> <section class="board-section">
-21
View File
@@ -19,7 +19,6 @@ export class GameComponent implements OnInit, OnDestroy {
game: GameFull | null = null; game: GameFull | null = null;
errorMessage = ''; errorMessage = '';
moveInput = ''; moveInput = '';
legalMoves: LegalMove[] = [];
loading = true; loading = true;
selectedSquare: string | null = null; selectedSquare: string | null = null;
highlightedSquares: string[] = []; highlightedSquares: string[] = [];
@@ -38,10 +37,6 @@ export class GameComponent implements OnInit, OnDestroy {
return this.game?.state ?? null; return this.game?.state ?? null;
} }
get legalMoveUciList(): string[] {
return this.legalMoves.map((move) => move.uci);
}
ngOnInit(): void { ngOnInit(): void {
this.routeSubscription = this.route.paramMap.subscribe((paramMap) => { this.routeSubscription = this.route.paramMap.subscribe((paramMap) => {
const id = paramMap.get('gameId'); const id = paramMap.get('gameId');
@@ -110,7 +105,6 @@ export class GameComponent implements OnInit, OnDestroy {
} }
this.moveInput = ''; this.moveInput = '';
this.clearSelection(); this.clearSelection();
this.loadLegalMoves();
}, },
error: (error: { error?: { message?: string } }) => { error: (error: { error?: { message?: string } }) => {
this.errorMessage = error.error?.message ?? 'Move rejected.'; this.errorMessage = error.error?.message ?? 'Move rejected.';
@@ -129,7 +123,6 @@ export class GameComponent implements OnInit, OnDestroy {
next: (game) => { next: (game) => {
this.game = game; this.game = game;
this.loading = false; this.loading = false;
this.loadLegalMoves();
this.startStream(); this.startStream();
this.startPolling(); this.startPolling();
}, },
@@ -140,17 +133,6 @@ export class GameComponent implements OnInit, OnDestroy {
}); });
} }
private loadLegalMoves(): void {
this.gameApi.getLegalMoves(this.gameId).subscribe({
next: (response) => {
this.legalMoves = response.moves;
},
error: () => {
this.legalMoves = [];
}
});
}
private startStream(): void { private startStream(): void {
this.streamSubscription = this.gameApi.streamGame(this.gameId).subscribe({ this.streamSubscription = this.gameApi.streamGame(this.gameId).subscribe({
next: (event) => this.applyStreamEvent(event), next: (event) => this.applyStreamEvent(event),
@@ -172,7 +154,6 @@ export class GameComponent implements OnInit, OnDestroy {
this.game = game; this.game = game;
if (previousMoves !== game.state.moves.join(',')) { if (previousMoves !== game.state.moves.join(',')) {
this.clearSelection(); this.clearSelection();
this.loadLegalMoves();
} }
} }
}); });
@@ -182,7 +163,6 @@ export class GameComponent implements OnInit, OnDestroy {
if (event.type === 'gameFull') { if (event.type === 'gameFull') {
this.game = event.game; this.game = event.game;
this.clearSelection(); this.clearSelection();
this.loadLegalMoves();
return; return;
} }
@@ -192,7 +172,6 @@ export class GameComponent implements OnInit, OnDestroy {
if (event.state.moves.length !== moveCountBefore) { if (event.state.moves.length !== moveCountBefore) {
this.clearSelection(); this.clearSelection();
} }
this.loadLegalMoves();
return; return;
} }