From: Benjamin Auder Date: Mon, 9 Mar 2020 20:31:59 +0000 (+0100) Subject: Small fixes + early draft of Eightpieces variant X-Git-Url: https://git.auder.net/%7B%7B%20path%28%27fos_user_profile_show%27%29%20%7D%7D?a=commitdiff_plain;h=2a8a94c9e539319c76c0a72967b39f2e7e7b279e;p=vchess.git Small fixes + early draft of Eightpieces variant --- diff --git a/client/public/images/pieces/Eightpieces/bj.svg b/client/public/images/pieces/Eightpieces/bj.svg new file mode 100644 index 00000000..18dd5c1a --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bj.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_e.svg b/client/public/images/pieces/Eightpieces/bl_e.svg new file mode 100644 index 00000000..d6ba119e --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_e.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_n.svg b/client/public/images/pieces/Eightpieces/bl_n.svg new file mode 100644 index 00000000..748768b0 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_n.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_ne.svg b/client/public/images/pieces/Eightpieces/bl_ne.svg new file mode 100644 index 00000000..c3873e80 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_ne.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_nw.svg b/client/public/images/pieces/Eightpieces/bl_nw.svg new file mode 100644 index 00000000..aa2c2ed3 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_nw.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_s.svg b/client/public/images/pieces/Eightpieces/bl_s.svg new file mode 100644 index 00000000..8b93bf3f --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_s.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_se.svg b/client/public/images/pieces/Eightpieces/bl_se.svg new file mode 100644 index 00000000..d6f4d489 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_se.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_sw.svg b/client/public/images/pieces/Eightpieces/bl_sw.svg new file mode 100644 index 00000000..51aeb9d2 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_sw.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bl_w.svg b/client/public/images/pieces/Eightpieces/bl_w.svg new file mode 100644 index 00000000..9613643f --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bl_w.svg @@ -0,0 +1,96 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/bs.svg b/client/public/images/pieces/Eightpieces/bs.svg new file mode 100644 index 00000000..25f487e3 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/bs.svg @@ -0,0 +1,95 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wj.svg b/client/public/images/pieces/Eightpieces/wj.svg new file mode 100644 index 00000000..3d283bc5 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wj.svg @@ -0,0 +1,97 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_e.svg b/client/public/images/pieces/Eightpieces/wl_e.svg new file mode 100644 index 00000000..74df7f64 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_e.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_n.svg b/client/public/images/pieces/Eightpieces/wl_n.svg new file mode 100644 index 00000000..709c7501 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_n.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_ne.svg b/client/public/images/pieces/Eightpieces/wl_ne.svg new file mode 100644 index 00000000..d465e729 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_ne.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_nw.svg b/client/public/images/pieces/Eightpieces/wl_nw.svg new file mode 100644 index 00000000..a5aba418 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_nw.svg @@ -0,0 +1,86 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_s.svg b/client/public/images/pieces/Eightpieces/wl_s.svg new file mode 100644 index 00000000..c615a7ac --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_s.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_se.svg b/client/public/images/pieces/Eightpieces/wl_se.svg new file mode 100644 index 00000000..d369fc82 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_se.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_sw.svg b/client/public/images/pieces/Eightpieces/wl_sw.svg new file mode 100644 index 00000000..8ec16795 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_sw.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/wl_w.svg b/client/public/images/pieces/Eightpieces/wl_w.svg new file mode 100644 index 00000000..6c49f43d --- /dev/null +++ b/client/public/images/pieces/Eightpieces/wl_w.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + Unicorn + + + + + + + + + + diff --git a/client/public/images/pieces/Eightpieces/ws.svg b/client/public/images/pieces/Eightpieces/ws.svg new file mode 100644 index 00000000..457c8f28 --- /dev/null +++ b/client/public/images/pieces/Eightpieces/ws.svg @@ -0,0 +1,102 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/client/src/variants/Eightpieces.js b/client/src/variants/Eightpieces.js new file mode 100644 index 00000000..06ece2a6 --- /dev/null +++ b/client/src/variants/Eightpieces.js @@ -0,0 +1,100 @@ +import { ArrayFun } from "@/utils/array"; +import { randInt, shuffle } from "@/utils/alea"; +import { ChessRules, PiPo, Move } from "@/base_rules"; + +export const VariantRules = class EightpiecesRules extends ChessRules { + static get JAILER() { + return "j"; + } + static get SENTRY() { + return "s"; + } + static get LANCER() { + return "l"; + } + + static get PIECES() { + return ChessRules.PIECES.concat([V.JAILER, V.SENTRY, V.LANCER]); + } + + getPpath(b) { + // TODO: more subtle, path depends on the orientations + // lancerOrientations should probably be a 8x8 array, for speed. + return ( + ([V.JAILER, V.SENTRY, V.LANCER].includes(b[1]) + ? "Eightpieces/" : "") + b + ); + } + + static IsGoodFen(fen) { + if (!ChessRules.IsGoodFen(fen)) return false; + const fenParsed = V.ParseFen(fen); + // 5) Check lancers orientations (if there are any left) + if ( + !fenParsed.lancers || + ( + fenParsed.lancers != "-" && + !fenParsed.lancers.match(/^([a-h][1-8][0-7],?)+$/) + ) + ) { + return false; + } + return true; + } + + static ParseFen(fen) { + const fenParts = fen.split(" "); + return Object.assign(ChessRules.ParseFen(fen), { + lancers: fenParts[5], + }); + } + + static GenRandInitFen(randomness) { + // TODO: special conditions + } + + getFen() { + return ( + super.getFen() + " " + this.getLancersFen() + ); + } + + getFenForRepeat() { + return ( + this.getBaseFen() + "_" + + this.getTurnFen() + "_" + + this.getFlagsFen() + "_" + + this.getEnpassantFen() + "_" + + this.getLancersFen() + ); + } + + getLancersFen() { + let res = ""; + this.lancerOrientations.forEach(o => { + res += V.CoordsToSquare(o.sq) + o.dir + ","; + }); + res = res.slice(0, -1); + return res || "-"; + } + + setOtherVariables(fen) { + super.setOtherVariables(fen); + const fenParsed = V.ParseFen(fen); + // Also init lancer orientations (from FEN): + this.lancerOrientations = 32; // TODO + } + + // getPotentialMoves, isAttacked: TODO + + // updatedVariables: update lancers' orientations + + // subTurn : if sentry moved to some enemy piece. + + static get VALUES() { + return Object.assign( + { l: 5, s: 4, j: 5 }, //experimental + ChessRules.VALUES + ); + } +}; diff --git a/client/src/views/MyGames.vue b/client/src/views/MyGames.vue index 5d862073..953c976e 100644 --- a/client/src/views/MyGames.vue +++ b/client/src/views/MyGames.vue @@ -141,11 +141,17 @@ export default { { vname: vname, type: type, - score: "*" + score: "*", + turn: "w" }, gameInfo ); - this[type + "Games"].push(game); + // TODO: the new game isn't sorted. Maybe apply a different strategy: + // 1) Sort all at loading, + // 2) Insert in place when new games arrive, + // 3) Change position when score or turn change. + // And GameList just show list unsorted. + this[type + "Games"].unshift(game); this.tryShowNewsIndicator(type); break; } @@ -165,6 +171,7 @@ export default { g.players[0].sid == this.st.user.sid ? "w" : "b"; + if (!!g.turn) return g.turn == myColor; const rem = g.movesCount % 2; return ( (rem == 0 && myColor == "w") ||