update pit color when onPitSelect
This commit is contained in:
parent
2a600d6357
commit
1fdb296442
@ -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);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user