dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit c5b7648f443e441ef192709701a94ad03c2650e2
parent d8c8f6937745dc8b2aeda51f6caed4963d4a3542
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 12 Jun 2023 19:26:34 -0700

cleanup

Diffstat:
Mpkg/web/handlers/chess.go | 2+-
Mpkg/web/handlers/interceptors/chess.go | 4++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go @@ -116,7 +116,7 @@ func ChessGameFormHandler(c echo.Context) error { authUser := c.Get("authUser").(*database.User) g := interceptors.ChessInstance.GetGame(key) game := g.Game - isFlipped := authUser.ID == g.Player2.ID + isFlipped := g.IsBlack(authUser.ID) if game.Outcome() != chess.NoOutcome { return c.NoContent(http.StatusOK) diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -580,6 +580,10 @@ func (b *Chess) SendMove(gameKey string, userID database.UserID, g *ChessGame, c return nil } +func (g *ChessGame) IsBlack(userID database.UserID) bool { + return userID == g.Player2.ID +} + func (g *ChessGame) IsPlayer(userID database.UserID) bool { return g.Player1.ID == userID || g.Player2.ID == userID }