|
|
@ -7,8 +7,14 @@ import { useTheme } from '../Style/ThemeContext';
|
|
|
|
/* Ressources */
|
|
|
|
/* Ressources */
|
|
|
|
import Person from '../res/img/Person.png'
|
|
|
|
import Person from '../res/img/Person.png'
|
|
|
|
import BotImg from '../res/img/bot.png'
|
|
|
|
import BotImg from '../res/img/bot.png'
|
|
|
|
import { useGame } from '../Contexts/GameContext';
|
|
|
|
|
|
|
|
|
|
|
|
/* Model */
|
|
|
|
import Bot from '../model/Bot';
|
|
|
|
import Bot from '../model/Bot';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Context */
|
|
|
|
|
|
|
|
import { useGame } from '../Contexts/GameContext';
|
|
|
|
|
|
|
|
import { positionToColor } from '../ColorHelper';
|
|
|
|
|
|
|
|
|
|
|
|
interface PlayerStatusProps {
|
|
|
|
interface PlayerStatusProps {
|
|
|
|
img: any
|
|
|
|
img: any
|
|
|
|
state: any
|
|
|
|
state: any
|
|
|
@ -19,8 +25,9 @@ interface PlayerStatusProps {
|
|
|
|
showCircle: boolean
|
|
|
|
showCircle: boolean
|
|
|
|
playerIndex: number
|
|
|
|
playerIndex: number
|
|
|
|
askedWrong: boolean
|
|
|
|
askedWrong: boolean
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let touchedPlayer = -1
|
|
|
|
|
|
|
|
|
|
|
|
let touchedPlayer = -1
|
|
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
//@ts-ignore
|
|
|
|
const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle, playerIndex, askedWrong}) => {
|
|
|
|
const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person, name = "Dummy", index, playerTouched, setPlayerTouched, showCircle, playerIndex, askedWrong}) => {
|
|
|
@ -41,7 +48,7 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (playerIndex===index){
|
|
|
|
if (playerIndex===index){
|
|
|
|
setBuffer('solid 1px green')
|
|
|
|
setBuffer('solid 3px green')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
setBuffer('')
|
|
|
|
setBuffer('')
|
|
|
@ -52,31 +59,79 @@ const PersonStatus: React.FC<PlayerStatusProps> = ({img = Person, state= Person,
|
|
|
|
if (IsActualPlayer && !askedWrong){
|
|
|
|
if (IsActualPlayer && !askedWrong){
|
|
|
|
setPlayerTouched(index)
|
|
|
|
setPlayerTouched(index)
|
|
|
|
setTouchedPlayer(index)
|
|
|
|
setTouchedPlayer(index)
|
|
|
|
|
|
|
|
//setIsClicked(!isClicked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//* Code pour le cercle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//const [isClicked, setIsClicked] = useState(false); // État du bouton, par défaut false
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
|
|
|
|
onTouch();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const circleStyle: React.CSSProperties = {
|
|
|
|
|
|
|
|
backgroundColor: touchedPlayer == index && showCircle ? 'gold' : positionToColor(index), // Changement de la couleur en fonction de la condition
|
|
|
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
|
|
|
width: '80px',
|
|
|
|
|
|
|
|
height: '80px',
|
|
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
|
|
position: 'relative',
|
|
|
|
|
|
|
|
objectFit: 'cover'
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const circleStyleInt: React.CSSProperties = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backgroundColor:'white',
|
|
|
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
|
|
|
width: '70px',
|
|
|
|
|
|
|
|
height: '70px',
|
|
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
|
|
position: 'relative',
|
|
|
|
|
|
|
|
objectFit: 'cover'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const imageStyle: React.CSSProperties = {
|
|
|
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
|
|
|
width: '60px',
|
|
|
|
|
|
|
|
height: '60px',
|
|
|
|
|
|
|
|
objectFit: 'cover', // image est ajustée pour couvrir le cercle
|
|
|
|
|
|
|
|
position: 'relative',
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div style={{border:buffer}}>
|
|
|
|
<div className='centerDivV'>
|
|
|
|
<div className='centerDivV' onClick={() => onTouch()}>
|
|
|
|
{/* <div className='centerDivV' style={{border:buffer, borderRadius: '50%', padding:'1px'}}> */}
|
|
|
|
<img src={img} alt="player" height="60" width="60"/>
|
|
|
|
<div className='centerDivV' style={circleStyle} onClick={() => handleClick()}>
|
|
|
|
<h5>{name}</h5>
|
|
|
|
<div className='centerDivV' style={circleStyleInt}>
|
|
|
|
|
|
|
|
<img src={img} alt="player" height="40" width="40" style={{ ...imageStyle, objectFit: 'cover' }}/>
|
|
|
|
{IsActualPlayer && (
|
|
|
|
|
|
|
|
(touchedPlayer == index && showCircle) ?(
|
|
|
|
|
|
|
|
<div className='statusDiv' style={{ backgroundColor: "gold" }}>
|
|
|
|
|
|
|
|
<img src={state} alt="state" height="30" width="30"/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
): showCircle &&
|
|
|
|
{/* </div> */}
|
|
|
|
(
|
|
|
|
|
|
|
|
<div className='statusDiv' style={{ backgroundColor: theme.colors.primary }}>
|
|
|
|
|
|
|
|
<img src={state} alt="state" height="30" width="30"/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
<div className='playerNameDisplay' style={{border:buffer}}>
|
|
|
|
)}
|
|
|
|
<h5>{actualPlayerIndex !== index ? (name.substring(0, name.length - 2).length > 7 ? name.substring(0, name.length - 2).substring(0, 7) + '...' : name) : 'vous'}</h5>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default PersonStatus;
|
|
|
|
export default PersonStatus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// {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>
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// )}
|