diff --git a/knockoutwhistweb/app/model/sessions/UserSession.scala b/knockoutwhistweb/app/model/sessions/UserSession.scala index 0c1608f..64776fc 100644 --- a/knockoutwhistweb/app/model/sessions/UserSession.scala +++ b/knockoutwhistweb/app/model/sessions/UserSession.scala @@ -64,6 +64,15 @@ class UserSession(val user: User, val host: Boolean, val gameLobby: GameLobby) e case None => println("Card Index not found or is not a number.") } + case "KickPlayer" => + val maybePlayerId: Option[String] = (data \ "playerId").asOpt[String] + maybePlayerId match { + case Some(id) => + val playerUUID = UUID.fromString(id) + gameLobby.leaveGame(playerUUID, true) + case None => + println("Player ID not found or is not a valid UUID.") + } } } lock.unlock() diff --git a/knockoutwhistweb/app/views/lobby/lobby.scala.html b/knockoutwhistweb/app/views/lobby/lobby.scala.html index 32b7fbc..dd7413b 100644 --- a/knockoutwhistweb/app/views/lobby/lobby.scala.html +++ b/knockoutwhistweb/app/views/lobby/lobby.scala.html @@ -60,7 +60,7 @@ Remove } else {
@playersession.name
-
+
Remove
}
diff --git a/knockoutwhistweb/public/javascripts/events.js b/knockoutwhistweb/public/javascripts/events.js index b796bf8..09af240 100644 --- a/knockoutwhistweb/public/javascripts/events.js +++ b/knockoutwhistweb/public/javascripts/events.js @@ -227,7 +227,7 @@ function receiveLobbyUpdateEvent(eventData) { const inner = user.self ? `
${user.name} (You)
Remove` : `
${user.name}
-
Remove
` +
Remove
` newHtml += `
diff --git a/knockoutwhistweb/public/javascripts/interact.js b/knockoutwhistweb/public/javascripts/interact.js index 16eb2b6..f035832 100644 --- a/knockoutwhistweb/public/javascripts/interact.js +++ b/knockoutwhistweb/public/javascripts/interact.js @@ -73,5 +73,7 @@ function handleTrumpSelection(object) { } function handleKickPlayer(playerId) { - // TODO needs implementation + sendEvent("KickPlayer", { + playerId: playerId + }) }