X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=scribe%2Fscribe.jsx;h=7b68ff05afe8ac16d78b74d6b74d49b7f4fe73cf;hp=06a8541297059bdc046f6f40ae3ac129d8ff2e74;hb=262b36e22be80ba638872f837332f79aa8e8a8c6;hpb=6c0ef34689d35ec9deada19903f7e307f5ac618a diff --git a/scribe/scribe.jsx b/scribe/scribe.jsx index 06a8541..7b68ff0 100644 --- a/scribe/scribe.jsx +++ b/scribe/scribe.jsx @@ -79,14 +79,31 @@ events.addEventListener("game-state", event => { * Game and supporting classes * *********************************************************/ +function copy_to_clipboard(id) +{ + const tmp = document.createElement("input"); + tmp.setAttribute("value", document.getElementById(id).innerHTML); + document.body.appendChild(tmp); + tmp.select(); + document.execCommand("copy"); + document.body.removeChild(tmp); +} + function GameInfo(props) { if (! props.id) return null; return (
-

{props.id}

- Invite a friend to play by sending this URL: {props.url} + {props.id} + {" "} + Share this link to invite a friend:{" "} + {props.url} + {" "} +
); } @@ -132,7 +149,7 @@ function PlayerInfo(props) { return (
-

Players

+ Players: {props.player.name} {props.player.team ? ` (${props.player.team})` : ""} {props.first_move ? "" : " "} @@ -148,6 +165,39 @@ function PlayerInfo(props) { ); } +function Glyph(props) { + + const glyph_dots = []; + + for (let row = 0; row < 3; row++) { + for (let col = 0; col < 3; col++) { + if (props.squares[3 * row + col]) { + let cy = 10 + 20 * row; + let cx = 10 + 20 * col; + glyph_dots.push( + + ); + } + } + } + + return (
+ {props.name} +
+ + + {glyph_dots} + + +
+
+ ); +} + function Square(props) { let className = "square"; @@ -251,7 +301,7 @@ class Game extends React.Component { game_info: {}, player_info: {}, other_players: [], - squares: Array(9).fill(null).map(() => Array(9).fill(null)), + squares: [...Array(9)].map(() => Array(9).fill(null)), moves: 0, next_to_play: "+" }; @@ -398,6 +448,122 @@ class Game extends React.Component { onClick={(i,j) => this.handle_click(i, j, first_move)} />
+ , +
+ + + + + + + + + + + + + + + + + + +
]; }