|
|
|
@ -17,37 +17,62 @@ interface PlayerStatusProps {
|
|
|
|
|
setPlayerTouched: (newPlayerTouch: number) => void;
|
|
|
|
|
playerTouched: number
|
|
|
|
|
showCircle: boolean
|
|
|
|
|
playerIndex: number
|
|
|
|
|
}
|
|
|
|
|
let touchedPlayer = -1
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle}) => {
|
|
|
|
|
const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle, playerIndex}) => {
|
|
|
|
|
const theme=useTheme();
|
|
|
|
|
const {players} = useGame()
|
|
|
|
|
const {players, actualPlayerIndex} = useGame()
|
|
|
|
|
if (players[index] instanceof Bot){
|
|
|
|
|
img = BotImg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const [buffer, setBuffer] = useState("")
|
|
|
|
|
|
|
|
|
|
const [touchedPlayer, setTouchedPlayer] = useState(-2)
|
|
|
|
|
useEffect(() =>{
|
|
|
|
|
setTouchedPlayer(playerTouched)
|
|
|
|
|
}, [playerTouched])
|
|
|
|
|
|
|
|
|
|
let IsActualPlayer = index != actualPlayerIndex
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (playerIndex===index){
|
|
|
|
|
setBuffer('solid 1px green')
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
setBuffer('')
|
|
|
|
|
}
|
|
|
|
|
}, [playerIndex])
|
|
|
|
|
|
|
|
|
|
function onTouch(){
|
|
|
|
|
if (IsActualPlayer){
|
|
|
|
|
setPlayerTouched(index)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className='centerDivV' onClick={() => setPlayerTouched(index)}>
|
|
|
|
|
<img src={img} alt="player" height="60" width="60"/>
|
|
|
|
|
<h5>{name}</h5>
|
|
|
|
|
|
|
|
|
|
{(touchedPlayer == index && showCircle) ?(
|
|
|
|
|
<div className='statusDiv' style={{ backgroundColor: "gold" }}>
|
|
|
|
|
<img src={state} alt="state" height="30" width="30"/>
|
|
|
|
|
</div>
|
|
|
|
|
): showCircle &&
|
|
|
|
|
(
|
|
|
|
|
<div className='statusDiv' style={{ backgroundColor: theme.colors.primary }}>
|
|
|
|
|
<img src={state} alt="state" height="30" width="30"/>
|
|
|
|
|
</div>
|
|
|
|
|
) }
|
|
|
|
|
<div style={{border:buffer}}>
|
|
|
|
|
<div className='centerDivV' onClick={() => onTouch()}>
|
|
|
|
|
<img src={img} alt="player" height="60" width="60"/>
|
|
|
|
|
<h5>{name}</h5>
|
|
|
|
|
|
|
|
|
|
{IsActualPlayer && (
|
|
|
|
|
(touchedPlayer == index && showCircle) ?(
|
|
|
|
|
<div className='statusDiv' style={{ backgroundColor: "gold" }}>
|
|
|
|
|
<img src={state} alt="state" height="30" width="30"/>
|
|
|
|
|
</div>
|
|
|
|
|
): showCircle &&
|
|
|
|
|
(
|
|
|
|
|
<div className='statusDiv' style={{ backgroundColor: theme.colors.primary }}>
|
|
|
|
|
<img src={state} alt="state" height="30" width="30"/>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|