Skip to content

Commit

Permalink
Fix #1705 Missing materialPoint info in ataxx puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Nov 23, 2024
1 parent a7c499d commit 59a7b99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
19 changes: 13 additions & 6 deletions client/analysisCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { analysisSettings, EngineSettings } from './analysisSettings';
import { setAriaTabClick } from './view';
import { createWebsocket } from "@/socket/webSocketUtils";
import { setPocketRowCssVars } from './pocketRow';
import { updatePoint } from './info';

const EVAL_REGEX = new RegExp(''
+ /^info depth (\d+) seldepth \d+ multipv (\d+) /.source
Expand Down Expand Up @@ -191,14 +192,16 @@ export class AnalysisController extends GameController {
}

if (this.variant.ui.materialPoint) {
const miscW = document.getElementById('misc-infow') as HTMLElement;
const miscB = document.getElementById('misc-infob') as HTMLElement;
miscW.style.textAlign = 'right';
miscB.style.textAlign = 'left';
miscW.style.width = '100px';
miscB.style.width = '100px';
this.vmiscInfoW = document.getElementById('misc-infow') as HTMLElement;

Check failure on line 195 in client/analysisCtrl.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Type 'HTMLElement' is missing the following properties from type 'VNode': sel, data, elm, text, key
this.vmiscInfoB = document.getElementById('misc-infob') as HTMLElement;

Check failure on line 196 in client/analysisCtrl.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Type 'HTMLElement' is missing the following properties from type 'VNode': sel, data, elm, text, key
this.vmiscInfoW.style.textAlign = 'right';

Check failure on line 197 in client/analysisCtrl.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'style' does not exist on type 'VNode'.
this.vmiscInfoB.style.textAlign = 'left';

Check failure on line 198 in client/analysisCtrl.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'style' does not exist on type 'VNode'.
this.vmiscInfoW.style.width = '100px';

Check failure on line 199 in client/analysisCtrl.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'style' does not exist on type 'VNode'.
this.vmiscInfoB.style.width = '100px';

Check failure on line 200 in client/analysisCtrl.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'style' does not exist on type 'VNode'.
patch(document.getElementById('misc-info-center') as HTMLElement, h('div#misc-info-center', '-'));
(document.getElementById('misc-info') as HTMLElement).style.justifyContent = 'space-around';

[this.vmiscInfoW, this.vmiscInfoB] = updatePoint(this.variant, this.fullfen, this.vmiscInfoW, this.vmiscInfoB);
}

if (this.variant.ui.counting) {
Expand Down Expand Up @@ -994,6 +997,10 @@ export class AnalysisController extends GameController {
}
}

if (this.variant.ui.materialPoint) {
[this.vmiscInfoW, this.vmiscInfoB] = updatePoint(this.variant, msg.fen, this.vmiscInfoW, this.vmiscInfoB);
}

// TODO: But sending moves to the server will be useful to implement shared live analysis!
// this.doSend({ type: "analysis_move", gameId: this.gameId, move: move, fen: this.fullfen, ply: this.ply + 1 });
}
Expand Down
5 changes: 5 additions & 0 deletions client/puzzleCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { lmBeforeEp, uci2LastMove, UCIMove, uci2cg } from './chess';
import { updateMovelist } from './movelist';
import { variants } from './variants';
import { RatedSettings, AutoNextSettings } from './puzzleSettings';
import { updatePoint } from './info';


export class PuzzleController extends AnalysisController {
Expand Down Expand Up @@ -300,6 +301,10 @@ export class PuzzleController extends AnalysisController {
this.steps.push(step);
this.ply += 1
updateMovelist(this);

if (this.variant.ui.materialPoint) {
[this.vmiscInfoW, this.vmiscInfoB] = updatePoint(this.variant, this.ffishBoard.fen(), this.vmiscInfoW, this.vmiscInfoB);
}
}

cgConfig = (move: string) => {
Expand Down
6 changes: 1 addition & 5 deletions client/roundCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ export class RoundController extends GameController {
}

if (this.variant.ui.materialPoint) {
this.updatePoint(msg.fen);
[this.vmiscInfoW, this.vmiscInfoB] = updatePoint(this.variant, msg.fen, this.vmiscInfoW, this.vmiscInfoB);
}

const oppclock = !this.flipped() ? 0 : 1;
Expand Down Expand Up @@ -1062,10 +1062,6 @@ export class RoundController extends GameController {
}
}

private updatePoint = (fen: cg.FEN) => {
[this.vmiscInfoW, this.vmiscInfoB] = updatePoint(this.variant, fen, this.vmiscInfoW, this.vmiscInfoB);
}

private updateMaterial(): void {
if (this.variant.material.showDiff && this.materialDifference)
[this.vmaterial0, this.vmaterial1] = updateMaterial(this.variant, this.fullfen, this.vmaterial0, this.vmaterial1, this.flipped(), this.mycolor);
Expand Down

0 comments on commit 59a7b99

Please sign in to comment.