span {{ st.tr["Participant(s):"] }}
span(
v-for="p in Object.values(people)"
- v-if="participateInChat(p)"
+ v-if="!!p.name"
)
| {{ p.name }}
span.anonymous(v-if="someAnonymousPresent()") + @nonymous
img(src="/images/icons/rematch.svg")
#playersInfo
div(v-if="isLargeScreen()")
- span.name(:class="{connected: isConnected(0)}")
- | {{ game.players[0].name || "@nonymous" }}
+ UserBio.user-bio(
+ :class="{connected: isConnected(0)}"
+ :uid="game.players[0].id"
+ :uname="game.players[0].name"
+ )
span.time(
v-if="game.score=='*'"
:class="{yourturn: !!vr && vr.turn == 'w'}"
span.time-right(v-if="!!virtualClocks[0][1]")
| {{ virtualClocks[0][1] }}
span.split-names -
- span.name(:class="{connected: isConnected(1)}")
- | {{ game.players[1].name || "@nonymous" }}
+ UserBio.user-bio(
+ :class="{connected: isConnected(1)}"
+ :uid="game.players[1].id"
+ :uname="game.players[1].name"
+ )
span.time(
v-if="game.score=='*'"
:class="{yourturn: !!vr && vr.turn == 'b'}"
span.time-right(v-if="!!virtualClocks[1][1]")
| {{ virtualClocks[1][1] }}
div(v-else)
- span.name(:class="{connected: isConnected(0)}")
- | {{ game.players[0].name || "@nonymous" }}
+ UserBio.user-bio(
+ :class="{connected: isConnected(0)}"
+ :uid="game.players[0].id"
+ :uname="game.players[0].name"
+ )
span.split-names -
- span.name(:class="{connected: isConnected(1)}")
- | {{ game.players[1].name || "@nonymous" }}
+ UserBio.user-bio(
+ :class="{connected: isConnected(1)}"
+ :uid="game.players[1].id"
+ :uname="game.players[1].name"
+ )
div(v-if="game.score=='*'")
span.time(:class="{yourturn: !!vr && vr.turn == 'w'}")
span.time-left {{ virtualClocks[0][0] }}
<script>
import BaseGame from "@/components/BaseGame.vue";
+import UserBio from "@/components/UserBio.vue";
import Chat from "@/components/Chat.vue";
import { store } from "@/store";
import { GameStorage } from "@/utils/gameStorage";
name: "my-game",
components: {
BaseGame,
- Chat
+ Chat,
+ UserBio
},
data: function() {
return {
game: {}, //passed to BaseGame
focus: !document.hidden, //will not always work... TODO
// virtualClocks will be initialized from true game.clocks
+ // TODO: clock update triggers re-rendering. Should be out of Vue
virtualClocks: [],
vr: null, //"variant rules" object initialized from FEN
rulesContent: "",
// In case of incomplete information variant:
boardDiv.style.visibility = "hidden";
this.atCreation();
- } else
+ }
+ else
// Same game ID
this.nextIds = JSON.parse(this.$route.query["next"] || "[]");
}
)
);
},
- participateInChat: function(p) {
- return Object.keys(p.tmpIds).some(x => p.tmpIds[x].focus) && !!p.name;
- },
someAnonymousPresent: function() {
return (
Object.values(this.people).some(p =>
},
getGameType: function(game) {
if (!!game.id.toString().match(/^i/)) return "import";
- return game.cadence.indexOf("d") >= 0 ? "corr" : "live";
+ return (game.cadence.indexOf("d") >= 0 ? "corr" : "live");
},
// Notify something after a new move (to opponent and me on MyGames page)
notifyMyGames: function(thing, data) {
case "newmove": {
// DEBUG:
-console.log("Receive move");
-console.log(data.data);
-//moveslist not updated when receiving a move? (see in baseGame)
+//console.log("Receive move");
+//console.log(data.data);
+//moveslist not updated when receiving a move? (see in BaseGame)
const movePlus = data.data;
const movesCount = this.game.moves.length;
// Game state (including FEN): will be updated
moves: [],
clocks: [-1, -1], //-1 = unstarted
+ chats: [],
score: "*"
}
);
let gameInfo = {
id: getRandString(), //ignored if corr
fen: V.GenRandInitFen(this.game.randomness),
+ randomness: this.game.randomness,
players: [this.game.players[1], this.game.players[0]],
vid: this.game.vid,
cadence: this.game.cadence
"/games",
"POST",
{
- // cid is useful to delete the challenge:
data: { gameInfo: gameInfo },
success: (response) => {
gameInfo.id = response.gameId;
// - from server (one correspondance game I play[ed] or not)
// - from remote peer (one live game I don't play, finished or not)
fetchGame: function(callback) {
- if (Number.isInteger(this.gameRef) || !isNaN(parseInt(this.gameRef))) {
+ if (
+ Number.isInteger(this.gameRef) ||
+ !isNaN(parseInt(this.gameRef, 10))
+ ) {
// corr games identifiers are integers
ajax(
"/games",
};
if (
this.game.type == "corr" &&
- V.CorrConfirm &&
moveCol == this.game.mycolor &&
!data.receiveMyMove
) {
if (data.score == "*") this.re_setClocks();
}
};
+ if (!V.CorrConfirm) {
+ afterSetScore();
+ return;
+ }
let el = document.querySelector("#buttonsConfirm > .acceptBtn");
// We may play several moves in a row: in case of, remove listener:
let elClone = el.cloneNode(true);
#aboveBoard
text-align: center
+.user-bio
+ display: inline
+ font-size: 1.5rem
+ @media screen and (max-width: 767px)
+ font-size: 1.2rem
+ padding: 0 3px
+
.variant-cadence
padding-right: 10px
padding: 0
width: 10px
-span.name
- font-size: 1.5rem
- @media screen and (max-width: 767px)
- font-size: 1.2rem
- padding: 0 3px
-
span.time
font-size: 2rem
@media screen and (max-width: 767px)