This commit is contained in:
Maciej Caderek
2022-02-18 04:21:35 +01:00
parent 70b2245570
commit ec4a63b59b
8 changed files with 123 additions and 31 deletions

View File

@@ -7,6 +7,7 @@ import drawPieces from "./layers/drawPieces";
import drawHeader from "./layers/drawHeader";
import drawExtraInfo from "./layers/drawExtraInfo";
import boards from "./styles-board";
import isLink from "../utils/isLink";
const defaultConfig: BoardConfig = {
size: 720,
@@ -130,6 +131,7 @@ class Board {
setStyle(style: BoardStyle) {
this.style = boards[style];
this.cfg.boardStyle = style;
this.refresh();
return this;
}
@@ -146,6 +148,26 @@ class Board {
return this;
}
flipWhite() {
if (!this.cfg.flipped) {
return;
}
this.cfg.flipped = false;
this.refresh();
return this;
}
flipBlack() {
if (this.cfg.flipped) {
return;
}
this.cfg.flipped = true;
this.refresh();
return this;
}
hideBorder() {
this.cfg.showBorder = false;
this.setSize(this.size);
@@ -182,8 +204,14 @@ class Board {
Black: "Anonymous",
WhitePretty: "Anonymous",
BlackPretty: "Anonymous",
Site: isLink(this.header.Site) ? null : this.header.Site,
}
: this.header;
: {
...this.header,
Site: isLink(this.header.Site)
? (this.header.Site as string).replace(/^http[s]*:\/\//, "")
: this.header.Site,
};
}
async titleFrame(header: Header) {