Implement "password"-based session joining.

This commit is contained in:
2018-05-25 15:29:22 -07:00
parent f01c891cec
commit 75a386539e
5 changed files with 46 additions and 31 deletions

View File

@@ -14,11 +14,13 @@ module Go
class Game
property size : Size
property blackPass : String
property whitePass : String
property board : Board
property turn : Color
property sockets : Array(HTTP::WebSocket)
def initialize(size : Size)
def initialize(size : Size, @blackPass, @whitePass)
@size = size
@board = Board.new
@turn = Color::Black
@@ -56,6 +58,7 @@ module Go
def update(x, y, color)
@board[{x, y}] = color
@turn = @turn == Color::Black ? Color::White : Color::Black
end
private def color_char(color)

View File

@@ -9,6 +9,9 @@
.black-cell {
background-color: black;
}
.white-cell {
background-color: white;
}
.board {
max-width: 360px;
}
@@ -22,7 +25,7 @@
var app = Elm.Main.embed(node, {
'black' : <%= black %>,
'url' : "<%= "ws://" + URL + ":" + Kemal.config.port.to_s %>",
'id' : <%= id %>,
'id' : "<%= id %>",
'size' : <%= size %>
})
</script>