X-Git-Url: https://git.auder.net/js/rpsls.js?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=0e4d574b0539b61f5666691a2b87f6e69e247040;hb=c01212801607b7f6336d6378ad64872a19bb4f15;hp=5b537d8555cb57a42aedbfb0d54aa82641c9b0b5;hpb=13227d6124e1cf465d329373e32c407d6fd351d3;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 5b537d85..0e4d574b 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -128,7 +128,8 @@ main ) | {{ st.tr["Observe"] }} button.player-action( - v-else-if="isFocusedOnHall(sid)" + v-else-if="st.user.sid != sid" + :class="{focused: isFocusedOnHall(sid)}" @click="challenge(sid)" ) | {{ st.tr["Challenge"] }} @@ -561,9 +562,12 @@ export default { }, // o: challenge or game classifyObject: function(o) { - // Consider imports as live games (TODO) - if (!!o.id && !!o.id.toString().match(/^i/)) return "live"; - return o.cadence.indexOf("d") === -1 ? "live" : "corr"; + // No imported games here + return ( + o.cadence.indexOf("d") >= 0 + ? "corr" + : (o.cadence.indexOf("/") >= 0 ? "simul" : "live") + ); }, setDisplay: function(letter, type, e) { this[letter + "display"] = type; @@ -853,6 +857,10 @@ export default { } break; } + case "entersimul": + // TODO: confirm box accept/refuse. + // If accept, update seat (array in this case) + break; case "game": // Individual request case "newgame": { const game = data.data; @@ -1217,24 +1225,33 @@ export default { alert(this.st.tr["Please log in to accept corr challenges"]); return; } - c.accepted = true; - await import("@/variants/" + c.vname + ".js") - .then((vModule) => { - window.V = vModule[c.vname + "Rules"]; - if (!!c.to) { - // c.to == this.st.user.name (connected) - if (!!c.fen) { - const parsedFen = V.ParseFen(c.fen); - this.tchallDiag = getDiagram({ - position: parsedFen.position, - orientation: parsedFen.turn - }); + if (c.type == "simul") { + // Just notify that I wanna enter the simultaneous game(s) + // TODO: dans défi, indiquer si positions aleatoires, si tjours blancs ou noirs + // --> /w30 ou b1h ou juste 30 (random, sans préfixe). + // => message "entersimul" to c.from + return; + } + else { + c.accepted = true; + await import("@/variants/" + c.vname + ".js") + .then((vModule) => { + window.V = vModule[c.vname + "Rules"]; + if (!!c.to) { + // c.to == this.st.user.name (connected) + if (!!c.fen) { + const parsedFen = V.ParseFen(c.fen); + this.tchallDiag = getDiagram({ + position: parsedFen.position, + orientation: parsedFen.turn + }); + } + this.curChallToAccept = c; + document.getElementById("modalAccept").checked = true; } - this.curChallToAccept = c; - document.getElementById("modalAccept").checked = true; - } - else this.finishProcessingChallenge(c); - }); + else this.finishProcessingChallenge(c); + }); + } } else { // My challenge @@ -1245,12 +1262,19 @@ export default { { data: { id: c.id } } ); } + else if (c.type == "simul" && !!c.seat && Array.isArray(c.seat)) + // TODO: if some players entered, start game + this.launchSimultaneous(c); this.send("deletechallenge_s", { data: { cid: c.id } }); } // In all cases, the challenge is consumed: ArrayFun.remove(this.challenges, ch => ch.id == c.id); }, // NOTE: when launching game, the challenge is already being deleted + // TODO: adapt for simultaneous games, or just write a new function (better) + launchSimultaneous: function(c) { + // TODO + }, launchGame: function(c) { // White player index 0, black player index 1: let players = @@ -1415,6 +1439,8 @@ div#peopleWrap > .card button.player-action margin-left: 32px + &.focused + background-color: #E6D271 .somethingnew background-color: #90C4EC !important