From 57078452549f252460d45e91b84c7eea40dd3e9c Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Fri, 1 May 2020 01:10:51 +0200 Subject: [PATCH] Add Kinglet + a few fixes --- client/package.json | 1 + client/public/sounds/SOURCE | 3 ++- client/public/sounds/newgame.flac | 2 +- client/src/components/BaseGame.vue | 1 + client/src/components/MoveList.vue | 21 +++++++++++++++-- client/src/translations/en.js | 1 + client/src/translations/es.js | 2 +- client/src/translations/fr.js | 1 + client/src/translations/rules/Kinglet/en.pug | 24 +++++++++++++++++++- client/src/translations/rules/Kinglet/es.pug | 24 +++++++++++++++++++- client/src/translations/rules/Kinglet/fr.pug | 24 +++++++++++++++++++- client/src/views/Hall.vue | 12 +++++----- server/db/populate.sql | 1 + 13 files changed, 103 insertions(+), 14 deletions(-) diff --git a/client/package.json b/client/package.json index 7a4fa136..1f24074b 100644 --- a/client/package.json +++ b/client/package.json @@ -28,6 +28,7 @@ "pug-plain-loader": "^1.0.0", "raw-loader": "^1.0.0", "sass-loader": "^8.0.2", + "vue-loader": "^15.9.1", "vue-template-compiler": "^2.6.11", "worker-loader": "^2.0.0" }, diff --git a/client/public/sounds/SOURCE b/client/public/sounds/SOURCE index 1182b943..4520401a 100644 --- a/client/public/sounds/SOURCE +++ b/client/public/sounds/SOURCE @@ -1 +1,2 @@ -http://soundbible.com/1531-Temple-Bell.html +(Old sound) http://soundbible.com/1531-Temple-Bell.html +(New sound) https://freesound.org/people/JustInvoke/sounds/446142/ diff --git a/client/public/sounds/newgame.flac b/client/public/sounds/newgame.flac index be9adad2..7b9eae1c 100644 --- a/client/public/sounds/newgame.flac +++ b/client/public/sounds/newgame.flac @@ -1 +1 @@ -#$# git-fat fe8e69ecbc3943ec0f460f46d89268d9b09a8c95 186939 +#$# git-fat 02534398246b0616640ffb851d4c331ad3b39bd8 113247 diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index dc78b2af..d60a16ff 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -51,6 +51,7 @@ div#baseGame :firstNum="firstMoveNumber" :moves="moves" :cursor="cursor" + :vname="game.vname" @download="download" @showrules="showRules" @analyze="toggleAnalyze" diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 2fc7bacb..96d67049 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -19,7 +19,8 @@ div // NOTE: variants pages already have a "Rules" link on top span#rulesBtn( v-if="!$route.path.match('/variants/')" - @click="$emit('showrules')" + @click="clickRulesBtn()" + :class="btnRulesClass" ) | {{ st.tr["Rules"] }} button( @@ -70,7 +71,7 @@ export default { name: "my-move-list", props: [ "moves", "show", "canAnalyze", "canDownload", - "cursor", "score", "message", "firstNum"], + "vname", "cursor", "score", "message", "firstNum"], data: function() { return { st: store.state @@ -121,6 +122,10 @@ export default { computed: { evenNumbers: function() { return [...Array(this.moves.length).keys()].filter(i => i%2==0); + }, + btnRulesClass: function() { + // "rr" for "rules read" + return { highlightRules: !localStorage.getItem("rr_" + this.vname) }; } }, methods: { @@ -142,6 +147,14 @@ export default { btnTooltipClass: function() { return { tooltip: !("ontouchstart" in window) }; }, + clickRulesBtn: function() { + const key = "rr_" + this.vname; + if (!localStorage.getItem(key)) { + localStorage.setItem(key, '1'); + document.getElementById("rulesBtn").classList.remove("highlightRules"); + } + this.$emit("showrules"); + }, gotoMove: function(index) { // Goto move except if click on current move: if (this.cursor != index) this.$emit("goto-move", index); @@ -194,6 +207,10 @@ export default { .td.highlight-lm background-color: plum +.highlightRules + padding: 3px 5px + background-color: yellow + #boardSizeBtnContainer width: 100% text-align: center diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 909a3e35..c9d6efad 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -220,6 +220,7 @@ export const translations = { "Play opponent's pieces": "Play opponent's pieces", "Powerful pieces": "Powerful pieces", "Prolongated captures": "Prolongated captures", + "Protect your pawns": "Protect your pawns", "Push and pull": "Push and pull", "Queen disguised as a pawn": "Queen disguised as a pawn", "Reposition pieces": "Reposition pieces", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index 08aa2449..986adb1f 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -84,7 +84,6 @@ export const translations = { "New correspondance game:": "Nueva partida por correspondencia:", "New game": "Nueva partida", "New problem": "Nuevo problema", - News: "Noticias", "No challenges found :( Click on 'New game'!": "No se encontró ningún desafío :( ¡Haz clic en 'Nueva partida'!", "No games found :( Send a challenge!": "No se encontró partidas :( ¡Envía un desafío!", "No more problems": "No mas problemas", @@ -221,6 +220,7 @@ export const translations = { "Play opponent's pieces": "Jugar piezas opuestas", "Powerful pieces": "Piezas poderosas", "Prolongated captures": "Capturas extendidas", + "Protect your pawns": "Protege tus peones", "Push and pull": "Empujar y tirar", "Queen disguised as a pawn": "Reina disfrazada de peón", "Reposition pieces": "Reposicionar las piezas", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index f14632e3..95ad59b7 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -220,6 +220,7 @@ export const translations = { "Play opponent's pieces": "Jouez les pièces adverses", "Powerful pieces": "Pièces puissantes", "Prolongated captures": "Captures prolongées", + "Protect your pawns": "Protégez vos pions", "Push and pull": "Pousser et tirer", "Queen disguised as a pawn": "Reine déguisée en pion", "Reposition pieces": "Replacer les pièces", diff --git a/client/src/translations/rules/Kinglet/en.pug b/client/src/translations/rules/Kinglet/en.pug index 21203baa..7b6521e7 100644 --- a/client/src/translations/rules/Kinglet/en.pug +++ b/client/src/translations/rules/Kinglet/en.pug @@ -1 +1,23 @@ -p.boxed TODO +p.boxed + | Capture all enemy pawns to win. + +p. + The king is a normal piece: there are no checks or checkmate. + A player loses when he has no pawns remaining. + Pawns can disappear by capture or promotion. + Pawns always promote to kings. + +figure.diagram-container + .diagram + | fen:4n3/k3p2p/8/2r5/8/2K5/2P5/2RB4: + figcaption White to play: the c2 pawn cannot be defended. + +h3 Source + +p + | The + a(href="https://www.chessvariants.com/winning.dir/kinglet.html") + | Kinglet variant + |  on chessvariants.com. + +p Inventor: Vernon R. Parton (1953) diff --git a/client/src/translations/rules/Kinglet/es.pug b/client/src/translations/rules/Kinglet/es.pug index 21203baa..687aeeef 100644 --- a/client/src/translations/rules/Kinglet/es.pug +++ b/client/src/translations/rules/Kinglet/es.pug @@ -1 +1,23 @@ -p.boxed TODO +p.boxed + | Captura todos los peones opuestos para ganar. + +p. + El rey es una pieza normal: no hay jaque ni jaque mate. + Un jugador pierde cuando se queda sin peones. + Los peones desaparecen por captura o por promoción. + Los peones siempre son promovidos a reyes. + +figure.diagram-container + .diagram + | fen:4n3/k3p2p/8/2r5/8/2K5/2P5/2RB4: + figcaption Las blancas para jugar: se capturará el peón c2. + +h3 Fuente + +p + | La + a(href="https://www.chessvariants.com/winning.dir/kinglet.html") + | variante Kinglet + |  en chessvariants.com. + +p Inventor: Vernon R. Parton (1953) diff --git a/client/src/translations/rules/Kinglet/fr.pug b/client/src/translations/rules/Kinglet/fr.pug index 21203baa..4bfa69be 100644 --- a/client/src/translations/rules/Kinglet/fr.pug +++ b/client/src/translations/rules/Kinglet/fr.pug @@ -1 +1,23 @@ -p.boxed TODO +p.boxed + | Capturez tous les pions adverses pour gagner. + +p. + Le roi est une pièce normale : il y a ni échec ni mat. + Un joueur perd quand il n'a plus de pions. + Les pions disparaissent soit par capture, soit par promotion. + Les pions sont toujours promus en rois. + +figure.diagram-container + .diagram + | fen:4n3/k3p2p/8/2r5/8/2K5/2P5/2RB4: + figcaption Trait aux blancs: le pion c2 va être capturé. + +h3 Source + +p + | La + a(href="https://www.chessvariants.com/winning.dir/kinglet.html") + | variante Kinglet + |  sur chessvariants.com. + +p Inventeur : Vernon R. Parton (1953) diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 4a481df7..0e2c1c60 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -1288,13 +1288,13 @@ export default { () => { const myIdx = (game.players[0].sid == this.st.user.sid ? 0 : 1); GameStorage.add(game, (err) => { - // If an error occurred, game is not added: a tab already - // added the game. Maybe a focused one, maybe not. - // We know for sure that it emitted the gong start sound. - // ==> Do not play it again. - if (!err && this.st.settings.sound) - new Audio("/sounds/newgame.flac").play().catch(() => {}); + // If an error occurred, game is not added: the focused tab + // already added the game. if (!this.focus) { + if (this.st.settings.sound) + // This will be played several times if several hidden tabs + // on Hall... TODO: fix that (how ?!) + new Audio("/sounds/newgame.flac").play().catch(() => {}); notify( "New live game", { body: "vs " + game.players[1-myIdx].name || "@nonymous" } diff --git a/server/db/populate.sql b/server/db/populate.sql index a41f194a..51e1a225 100644 --- a/server/db/populate.sql +++ b/server/db/populate.sql @@ -51,6 +51,7 @@ insert or ignore into Variants (name, description) values ('Hamilton', 'Walk on a graph'), ('Horde', 'A pawns cloud'), ('Interweave', 'Interweaved colorbound teams'), + ('Kinglet', 'Protect your pawns'), ('Knightmate', 'Mate the knight'), ('Knightrelay1', 'Move like a knight (v1)'), ('Knightrelay2', 'Move like a knight (v2)'), -- 2.44.0