From 3ca7a846ae7bc5d8f7c628417418534f3c92593a Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Wed, 16 Jan 2019 11:45:45 +0100
Subject: [PATCH] Final thoughts about presentation

---
 .../javascripts/components/challengeList.js   |  2 ++
 public/javascripts/components/chat.js         |  6 ++++-
 public/javascripts/components/game.js         |  7 +++++
 public/javascripts/components/gameSummary.js  |  1 +
 public/javascripts/components/playerList.js   |  1 +
 public/javascripts/components/room.js         | 27 ++++++++++++-------
 6 files changed, 34 insertions(+), 10 deletions(-)
 create mode 100644 public/javascripts/components/challengeList.js
 create mode 100644 public/javascripts/components/gameSummary.js
 create mode 100644 public/javascripts/components/playerList.js

diff --git a/public/javascripts/components/challengeList.js b/public/javascripts/components/challengeList.js
new file mode 100644
index 00000000..bc2ebd03
--- /dev/null
+++ b/public/javascripts/components/challengeList.js
@@ -0,0 +1,2 @@
+//TODO (avec newGame button ?!)
+// ou challengeSummary organisé dans room...
diff --git a/public/javascripts/components/chat.js b/public/javascripts/components/chat.js
index a1489909..5dce3077 100644
--- a/public/javascripts/components/chat.js
+++ b/public/javascripts/components/chat.js
@@ -1,4 +1,8 @@
-			myname: localStorage["username"] || "anonymous",
+// TODO: myname, opppnents (optional, different style), people
+// --> also show messages like "X offers draw ?" (probably not)
+
+
+myname: localStorage["username"] || "anonymous",
 			oppName: "anonymous", //opponent name, revealed after a game (if provided)
 			chats: [], //chat messages after human game
 		
diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js
index d0d81258..dd9cfe4b 100644
--- a/public/javascripts/components/game.js
+++ b/public/javascripts/components/game.js
@@ -1,6 +1,10 @@
 // Game logic on a variant page: 3 modes, analyze, computer or human
 // TODO: envoyer juste "light move", sans FEN ni notation ...etc
 // TODO: if I'm an observer and player(s) disconnect/reconnect, how to find me ?
+//			onClick :: ask full game to remote player, and register as an observer in game
+//			(use gameId to communicate)
+//			on landing on game :: if gameId not found locally, check remotely
+//			==> il manque un param dans game : "remoteId"
 Vue.component('my-game', {
 	// gameId: to find the game in storage (assumption: it exists)
 	// fen: to start from a FEN without identifiers (analyze mode)
@@ -308,6 +312,9 @@ Vue.component('my-game', {
 			}
 		},
 		loadGame: function() {
+			// TODO: ask game to remote peer if this.remoteId is set
+			// (or just if game not found locally)
+			// NOTE: if it's a corr game, ask it from server
 			const game = getGameFromStorage(this.gameId);
 			this.opponent.id = game.oppid; //opponent ID in case of running HH game
 			this.opponent.name = game.oppname; //maye be blank (if anonymous)
diff --git a/public/javascripts/components/gameSummary.js b/public/javascripts/components/gameSummary.js
new file mode 100644
index 00000000..8ad1dfb5
--- /dev/null
+++ b/public/javascripts/components/gameSummary.js
@@ -0,0 +1 @@
+//TODO
diff --git a/public/javascripts/components/playerList.js b/public/javascripts/components/playerList.js
new file mode 100644
index 00000000..8ad1dfb5
--- /dev/null
+++ b/public/javascripts/components/playerList.js
@@ -0,0 +1 @@
+//TODO
diff --git a/public/javascripts/components/room.js b/public/javascripts/components/room.js
index 84c82f7c..d3dda053 100644
--- a/public/javascripts/components/room.js
+++ b/public/javascripts/components/room.js
@@ -23,7 +23,8 @@ fin de partie corr: garder maxi nbPlayers lastMove sur serveur, pendant 7 jours
 Vue.component('my-room', {
 	props: ["conn","settings"],
 	data: {
-		something: "", //TODO
+		remoteGames: [],
+		corrGames: [],
 	},
 	// Modal new game, and then sub-components
 	template: `
@@ -42,21 +43,29 @@ Vue.component('my-room', {
 					<button @click="newGame">Launch game</button>
 				</div>
 			</div>
-			<my-chat :conn="conn" :myname="myname" :people="people"></my-chat>
-			<my-challenge-list :conn="conn"></my-challenge-list>
-			<my-player-list :conn="conn"></my-player-list>
-			<my-game-list :conn="conn" ........... my-local-game-list opposed to my-remote-ame-list ?! ...bof></my-game-list>
-			onClick :: ask full game to remote player, and register as an observer in game
-			(use gameId to communicate)
-			on landing on game :: if gameId not found locally, check remotely
-			==> il manque un param dans game : "remoteId"
+			<div>
+				<my-chat :conn="conn" :myname="myname" :people="people"></my-chat>
+				<my-challenge-list :conn="conn"></my-challenge-list>
+			</div>
+			<div>
+				<my-player-list :conn="conn"></my-player-list>
+				// TODO: also corr games (of pther players)
+				// presentation ? table ?!
+				<my-game-summary v-for="g in remoteGames"
+					v-bind:vobj="g" v-bind:game="g" v-bind:key="g.id"
+					@click="() => showGame(g.id,g.uid)">
+				</my-game-summary>
+			</div>
 		</div>
 	`,
 	created: function() {
+		// TODO: ask server for current corr games (all but mines)
 		const socketMessageListener = msg => {
 			const data = JSON.parse(msg.data);
 			switch (data.code)
 			{
+				// TODO: also receive remote games summaries (update)
+				// (just players names, time control, and ID + player ID)
 				case "newgame": //challenge accepted
 					// oppid: opponent socket ID (or DB id if registered)
 					this.newGame("human", data.fen, data.color, data.oppid, data.gameid);
-- 
2.44.0