Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: scott branch #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/**/dist
/.pnp
.pnp.js
.yarn
.yarnrc.yml

# testing
/coverage
Expand Down
2 changes: 1 addition & 1 deletion client/.eslintcache

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"socket.io-client": "^3.1.2",
"socket.io-msgpack-parser": "^3.0.2",
"styled-components": "^5.2.1",
"sweetalert2": "^11.0.16",
"sweetalert2-react-content": "^4.0.1",
"typescript": "^4.1.3"
},
"proxy": "http://localhost:4000",
"scripts": {
"start": "react-scripts start",
"start": "rm .eslintcache && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/game/GungiGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const GungiGame: React.FC<GameProps> = observer(
board={gameState.board}
orientation={orientation}
socketPlayer={socketPlayer}
isTurn={gameState?.turn}
makeMoveCallback={makeMoveCallback}
/>
</BoardWrapper>
Expand Down Expand Up @@ -353,6 +354,7 @@ export const GungiGame: React.FC<GameProps> = observer(
playerName={`${blackPlayer?.username}`}
playerStockPile={gameState?.stockpile_black}
armySize={gameState.armysize_black}
isSocketPlayer={socketPlayer?.userType === 'opponent'}
/>

<br />
Expand All @@ -361,6 +363,7 @@ export const GungiGame: React.FC<GameProps> = observer(
playerName={`${whitePlayer?.username}`}
playerStockPile={gameState?.stockpile_white}
armySize={gameState.armysize_white}
isSocketPlayer={socketPlayer?.userType === 'creator'}
/>

<SpectatorsWrapper>
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/gameboard/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ interface BoardProps {
board: (PieceType | null)[][][];
orientation: string;
socketPlayer: User | undefined;
isTurn: string;
makeMoveCallback: (move: Move) => void;
}

export const Board: React.FC<BoardProps> = ({
board,
orientation,
socketPlayer,
isTurn,
makeMoveCallback,
}) => {
const squares: any[] = [];
Expand Down Expand Up @@ -74,6 +76,7 @@ export const Board: React.FC<BoardProps> = ({
icon={`${topPiece?.color}${topIndex + 1}${topPiece?.type}.svg`}
orientation={orientation}
socketPlayerColor={socketPlayerColor}
isSocketPlayer={isTurn === socketPlayerColor}
belowIcon={
pieceBelow
? `${pieceBelow?.color}${topIndex}${pieceBelow?.type}.svg`
Expand Down
10 changes: 6 additions & 4 deletions client/src/components/gameboard/Piece.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface PieceProps {
stockId?: string;
orientation?: string;
socketPlayerColor?: string;
isSocketPlayer?: boolean;
}

export const Piece: React.FC<PieceProps> = observer(
Expand All @@ -43,6 +44,7 @@ export const Piece: React.FC<PieceProps> = observer(
stockId,
orientation,
socketPlayerColor,
isSocketPlayer
}) => {
const [state, setState] = useState({
isDragging: false,
Expand Down Expand Up @@ -76,7 +78,7 @@ export const Piece: React.FC<PieceProps> = observer(
translation,
}));

gungiStore.isDragging = true;
gungiStore.setIsDragging(true)
gungiStore.currentSelected = squareId ?? stockId;
if (gungiStore.currentSelected === squareId && squareId !== undefined) {
const pos = squareId.split('-');
Expand Down Expand Up @@ -144,7 +146,7 @@ export const Piece: React.FC<PieceProps> = observer(
isDragging: false,
}));

gungiStore.isDragging = false;
gungiStore.setIsDragging(false)
}, [gungiStore]);

useEffect(() => {
Expand All @@ -168,12 +170,12 @@ export const Piece: React.FC<PieceProps> = observer(
transform: `translate(${state.translation.x}px, ${state.translation.y}px)`,
zIndex: state.isDragging ? 900 : 4,
position: state.isDragging ? 'absolute' : 'relative',
pointerEvents: state.isDragging ? 'none' : '',
pointerEvents: state.isDragging || !isSocketPlayer ? 'none' : '',
width: variant === 'normal' ? '80%' : '2.5rem',
display: 'block',
margin: variant === 'normal' ? '10.02% auto' : '0',
}),
[state.isDragging, state.translation, variant]
[state.isDragging, state.translation, variant, isSocketPlayer]
);

return (
Expand Down
Loading