From 1fdb296442e3014cdad441d7dfa68e84495ef4aa Mon Sep 17 00:00:00 2001 From: Halit Aksoy Date: Sun, 22 May 2022 17:58:11 +0300 Subject: [PATCH] update pit color when onPitSelect --- src/Home.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Home.tsx b/src/Home.tsx index 8d832b1..f4b1156 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -132,12 +132,20 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => { context.rtmt.sendMessage(channel_leave_game, {}); }; + const getBoardIndex = (index: number) => { + if (userKey === game.player2Id) return index + game.board.pits.length / 2; + return index; + }; + const onHoleSelect = (index: number, pit: Pit) => { //TODO : stoneCount comes from view model! if (pit.stoneCount === 0) { //TODO : warn user return; } + boardViewModel.pits[getBoardIndex(index)].pitColor = + context.themeManager.theme.pitSelectedColor; + updateBoardViewModel(boardViewModel); const gameMove: GameMove = { index: index }; context.rtmt.sendMessage(channel_game_move, gameMove); };