From abae8f8b244fb68eeb5286922423ca7bd2ef2356 Mon Sep 17 00:00:00 2001 From: Kimberly Date: Sun, 2 Aug 2020 18:54:38 -0700 Subject: [PATCH 01/36] snackService.js added. --- client/src/services/snackService.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 client/src/services/snackService.js diff --git a/client/src/services/snackService.js b/client/src/services/snackService.js new file mode 100644 index 000000000..bff49957a --- /dev/null +++ b/client/src/services/snackService.js @@ -0,0 +1,8 @@ +import BaseService from "./baseService"; + +export default { + async sendMessage(gameID, message, showSnack) { + //console.log('snack status:', showSnack); + return BaseService.post(`/api/games/${gameID}/sendMessage`, {value: message, showSnack}); + }, +} \ No newline at end of file From c9899500bdb81726a29b5f2d49b1edbeaac09bf1 Mon Sep 17 00:00:00 2001 From: Kimberly Date: Mon, 3 Aug 2020 16:12:51 -0700 Subject: [PATCH 02/36] removed sendmessage and cooresponding text box and button --- client/src/views/Game.vue | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 0cbb4e82e..b7da5e1e8 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -162,16 +162,6 @@ - - - - - Send Message - - -
@@ -349,10 +339,6 @@ export default { this.gameState = res.data; } }, - sendMessage() { - this.snackbarText = this.username + " says: " + this.newMessage; - this.snackbar = true; - }, async drawCard() { let res = await unoService.drawCard(this.$route.params.id); From a8621df72b022a0c7f3e8a713ad30a4b818f859b Mon Sep 17 00:00:00 2001 From: Kimberly Date: Mon, 3 Aug 2020 19:53:56 -0700 Subject: [PATCH 03/36] working global snackbar --- client/src/App.vue | 22 +++++++++++++++++++- client/src/services/snackService.js | 4 ++++ client/src/views/Game.vue | 31 ++++------------------------- client/src/views/Lobby.vue | 1 + 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/client/src/App.vue b/client/src/App.vue index 18836b4bd..8c8ec512a 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -17,7 +17,16 @@ - + + {{snackbarText}} + + + Close + + @@ -25,15 +34,26 @@ diff --git a/client/src/services/snackService.js b/client/src/services/snackService.js index bff49957a..d60e66aae 100644 --- a/client/src/services/snackService.js +++ b/client/src/services/snackService.js @@ -5,4 +5,8 @@ export default { //console.log('snack status:', showSnack); return BaseService.post(`/api/games/${gameID}/sendMessage`, {value: message, showSnack}); }, + notifyOne(message) { + //success = snack.text = message + return null //success + } } \ No newline at end of file diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index b7da5e1e8..db372d371 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -151,17 +151,6 @@ - - {{snackbarText}} - - - Close - - -
@@ -211,18 +200,6 @@ - - {{snackbarText}} - - - Close - - -
@@ -230,6 +207,7 @@ import unoService from "../services/unoService"; import Card from "../components/Card"; import Chat from "../components/Chat"; +//import AppVue from '../App.vue'; export default { name: "Game", @@ -258,8 +236,6 @@ export default { colors: { 'red': 0, 'blue': 1 , 'green': 2, 'yellow': 3, 'wild': 4}, values: { '1' : 0, '2' : 1, '3' : 2, '4' : 3, '5' : 4, '6' : 5, '7' : 6, '8' : 7, '9' : 8, 'S' : 9, 'R' : 10, 'W' : 11, 'D2' : 12, 'W4' : 13}, - snackbar: false, - snackbarText: "", newMessageName: "", }; }, @@ -315,10 +291,11 @@ export default { runsnackbar(name, message) { this.newMessageName = name; - this.snackbarText = name + " says: " + message; - this.snackbar = true; + var newMessage = name + " says: " + message; + this.$root.$emit('updateSnack', newMessage); }, + selectWildColor(card) { this.chooseColorDialog.card = card; diff --git a/client/src/views/Lobby.vue b/client/src/views/Lobby.vue index 1a6f844c4..2282bc11e 100644 --- a/client/src/views/Lobby.vue +++ b/client/src/views/Lobby.vue @@ -200,6 +200,7 @@ export default { this.$router.push({path: `/game/${res.data.game.game_id}`}); } else { alert ("Failed to create & join game"); + //snackService.notifyOne("failed to create"); } }, From feaf2b3fa7b72aad5959024b1187676a0b9694ec Mon Sep 17 00:00:00 2001 From: Andrew McMullin Date: Tue, 4 Aug 2020 02:21:08 -0600 Subject: [PATCH 04/36] I finished the Deleting of the Game, for some reason the server is print an error but idk why --- client/src/services/unoService.js | 4 ++++ client/src/views/Lobby.vue | 39 ++++++++++++++++++++++++++++++- server/routeHandlers.go | 13 +++++++++++ server/uno.go | 22 +++++++++++++---- 4 files changed, 73 insertions(+), 5 deletions(-) diff --git a/client/src/services/unoService.js b/client/src/services/unoService.js index 2d764620a..98054f2a9 100644 --- a/client/src/services/unoService.js +++ b/client/src/services/unoService.js @@ -9,6 +9,10 @@ export default { return BaseService.post(`/api/games`, {name: gameName, creator: creatorName}); }, + async deleteGame(gameId) { + return BaseService.get(`/api/games/${gameId}/delete`); + }, + async joinGame(gameId, playerName) { return BaseService.post(`/api/games/${gameId}/join`, { playerName: playerName }); }, diff --git a/client/src/views/Lobby.vue b/client/src/views/Lobby.vue index 1a6f844c4..d1598c918 100644 --- a/client/src/views/Lobby.vue +++ b/client/src/views/Lobby.vue @@ -29,12 +29,33 @@ > mdi-plus + + + Delete Selected Items + + + + + + + + + @@ -138,6 +160,7 @@ export default { return { search: "", headers:[ + { text: "Check", value: "check" }, { text: "Name", value: "name" }, { text: "Creator", value: "creator" }, { text: "# of Players", value: "players.length" }, @@ -224,7 +247,21 @@ export default { } else { alert ("Failed to create & join game"); } - } + }, + deleteItems () { + let plural = (this.games.length > 1) ? 'these items' : 'this item'; + if ( confirm(`Are you sure you want to delete ${plural}?`) ) { + for ( var i = this.games.length - 1; i >= 0; i--) { + + if (this.games[i].selected) { + console.log(i, this.games[i].name) + unoService.deleteGame(this.games[i].id) + this.games.splice(i, 1); + + } + } + } + }, }, mounted() { diff --git a/server/routeHandlers.go b/server/routeHandlers.go index 23d4726ac..961e65107 100644 --- a/server/routeHandlers.go +++ b/server/routeHandlers.go @@ -20,6 +20,7 @@ func setupRoutes(e *echo.Echo) { e.GET("/api/games", getGames) e.POST("/api/games", newGame) e.POST("/api/games/:id/join", joinExistingGame) + e.GET("/api/games/:id/delete", deleteGame) // Create a group that requires a valid JWT group := e.Group("/api") @@ -96,6 +97,18 @@ func newGame(c echo.Context) error { return c.JSON(http.StatusOK, map[string]interface{}{"token": token, "game": buildGameState(game, creator.ID)}) } +func deleteGame(c echo.Context) error { + gameID := c.Param("id") + err := deleteOldGame(gameID) + + if err != nil { + return c.JSON(http.StatusBadRequest, "Unable to Delete Game") + } + + return c.JSON(http.StatusOK, "Successfully Deleted Game") + +} + func joinExistingGame(c echo.Context) error { gameID := c.Param("id") m := echo.Map{} diff --git a/server/uno.go b/server/uno.go index 7d927c63e..0b33ae203 100644 --- a/server/uno.go +++ b/server/uno.go @@ -64,6 +64,20 @@ func createNewGame(gameName string, creatorName string) (*model.Game, *model.Pla return game, creator, nil } +func deleteOldGame(gameID string) error { + database, err := db.GetDb() + if err != nil { + return err + } + + err = database.DeleteGame(gameID) + if err != nil { + return err + } + + return err +} + func joinGame(game string, player *model.Player) (*model.Game, error) { database, err := db.GetDb() if err != nil { @@ -129,11 +143,11 @@ func playCard(game string, playerID string, card model.Card) (*model.Game, error } // Update who plays next, taking into account reverse card and skip card - if (card.Value == "R") { + if card.Value == "R" { gameData.Direction = !gameData.Direction } - if (card.Value == "S") { + if card.Value == "S" { gameData = goToNextPlayer(gameData) } @@ -244,8 +258,8 @@ func dealCards(game *model.Game) (*model.Game, error) { // draw a card for the discard var drawnCard model.Card game, drawnCard = drawTopCard(game) - - // ensure that this first card is a number card + + // ensure that this first card is a number card for !isNumberCard(drawnCard) { // if not, add it back to the draw pile game.DrawPile = append(game.DrawPile, drawnCard) From 820a7ccbf3239575bb9d3e0b6df2975d2c0fec49 Mon Sep 17 00:00:00 2001 From: Kimberly Date: Tue, 4 Aug 2020 10:07:23 -0700 Subject: [PATCH 05/36] alerts replaced with snacks --- client/src/App.vue | 1 - client/src/services/snackService.js | 4 ---- client/src/views/Game.vue | 1 + client/src/views/Lobby.vue | 15 ++++++++------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/client/src/App.vue b/client/src/App.vue index 8c8ec512a..9427ae522 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -53,7 +53,6 @@ export default { }, methods: { // - }, }; diff --git a/client/src/services/snackService.js b/client/src/services/snackService.js index d60e66aae..f0432c243 100644 --- a/client/src/services/snackService.js +++ b/client/src/services/snackService.js @@ -4,9 +4,5 @@ export default { async sendMessage(gameID, message, showSnack) { //console.log('snack status:', showSnack); return BaseService.post(`/api/games/${gameID}/sendMessage`, {value: message, showSnack}); - }, - notifyOne(message) { - //success = snack.text = message - return null //success } } \ No newline at end of file diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index db372d371..2038f3a2d 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -205,6 +205,7 @@ \ No newline at end of file + diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 2e3fc3067..8b1329a21 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -168,13 +168,24 @@ - +
+ +
Date: Wed, 5 Aug 2020 11:52:12 -0600 Subject: [PATCH 13/36] Update App.vue --- client/src/App.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/App.vue b/client/src/App.vue index 54a77509d..906a58305 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -46,7 +46,6 @@ export default { bus.$on('updateSnack', (message) => { this.snackbarText=message; this.snackbar=true; - console.log("you called me!!!!!!!"); }); }, methods: { From 75ed3ecc1febc958cc9e17ad9b56efc2e14fc3e6 Mon Sep 17 00:00:00 2001 From: Kimberly Date: Wed, 5 Aug 2020 10:59:26 -0700 Subject: [PATCH 14/36] review changes (removed comments) --- client/src/App.vue | 1 - client/src/services/snackService.js | 6 ------ client/src/views/Game.vue | 1 - 3 files changed, 8 deletions(-) diff --git a/client/src/App.vue b/client/src/App.vue index 54a77509d..906a58305 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -46,7 +46,6 @@ export default { bus.$on('updateSnack', (message) => { this.snackbarText=message; this.snackbar=true; - console.log("you called me!!!!!!!"); }); }, methods: { diff --git a/client/src/services/snackService.js b/client/src/services/snackService.js index 3142b8149..14a9b7e67 100644 --- a/client/src/services/snackService.js +++ b/client/src/services/snackService.js @@ -1,13 +1,7 @@ import BaseService from "./baseService"; export default { - - //example of how to use - //snackService.notifyAll(this.$route.params.id, "Wild Played!!"); - //TODO: make work when called multiple times in a row with same message. - //currently requires different messages in order to show the snack async notifyAll(gameID, notification) { - console.log('the notification: ', notification); return BaseService.post(`/api/snack/${gameID}/notify`, {notification: notification}); } } \ No newline at end of file diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 65b35d409..6a02b4898 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -232,7 +232,6 @@