tentative de passage par lien

pull/98/head
Pierre Ferreira 7 months ago
parent 54f63188f0
commit d4e1f28c64

@ -17,36 +17,51 @@ import { FormattedMessage } from 'react-intl';
import Stub from '../model/Stub';
import { useGame } from '../Contexts/GameContext';
import { positionToEmoji } from '../ColorHelper';
function DeducCheck() {
const theme = useTheme();
//const indices = Stub.GenerateIndice();
const params = new URLSearchParams(window.location.search);
const NbPlayer = params.get('NbPlayer');
const actualPlayerIndex = params.get('actualId') ?? '0';
console.log(parseInt(NbPlayer ?? 'nnnnnnnnnnuuuuuuuuuuuuulllllll'))
console.log(parseInt(actualPlayerIndex ?? 'nnnnnnnnnnuuuuuuuuuuuuulllllllooooooooosssssssss'))
//const { actualPlayerIndex, players } = useGame();
// let playerstmp
// if (players.length == 0) playerstmp = ["1", "2", "3", "4", "5", "4"];
// else { playerstmp = players}
// const { players } = useGame();
//* Gestion players
const playerList = Array.from({ length: parseInt(NbPlayer ?? '1') }, (_, index) => (index + 1).toString());
const playerColors = playerList.map((_, index) => positionToEmoji(index, true));
const players = playerColors.filter((_, index) => index !== parseInt(actualPlayerIndex ?? '0'));
// const players = [
// "🔵",
// "🟢",
// "🟡",
// "🟣",
// "🔴"
//]
//console.log(players)
// console.log(playerColors)
// console.log(actualPlayerIndex)
//* Gestion indices
const indices = Stub.GenerateIndice();
const halfLength = Math.ceil(indices.length / 2);
const firstHalfIndices = indices.slice(0, halfLength);
const secondHalfIndices = indices.slice(halfLength);
const players = [
"🔵",
"🟢",
"🟡",
"🟣",
"🔴"]
// const players = [
// "bla",
// "bli",
// "blou",
// "blu",
// "ble",
// ]
console.log(players)
return (
<div style={{ margin: '20px', display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex', flexDirection: 'row', overflowX: 'auto' }}>
@ -55,7 +70,7 @@ function DeducCheck() {
<thead>
<tr>
<th>Indices</th>
{players.map((player, index) => (
{playerColors.map((player, index) => (
<th key={index}>{player}</th>
))}
</tr>
@ -64,7 +79,7 @@ function DeducCheck() {
{firstHalfIndices.map((indice, rowIndex) => (
<tr key={rowIndex}>
<td>{indice.ToString("fr")}</td>
{players.map((player, colIndex) => (
{playerColors.map((player, colIndex) => (
<td key={colIndex}>
{/* <input type="checkbox"/> */}
<Form.Check aria-label="option 1" />
@ -80,7 +95,7 @@ function DeducCheck() {
<thead>
<tr>
<th>Indices</th>
{players.map((player, index) => (
{playerColors.map((player, index) => (
<th key={index}>{player}</th>
))}
</tr>
@ -89,7 +104,7 @@ function DeducCheck() {
{secondHalfIndices.map((indice, rowIndex) => (
<tr key={rowIndex}>
<td>{indice.ToString("fr")}</td>
{players.map((player, colIndex) => (
{playerColors.map((player, colIndex) => (
<td key={colIndex}>
{/* <input type="checkbox"/> */}
<Form.Check aria-label="option 1" />

@ -278,8 +278,10 @@ const InGame = ({locale, changeLocale}) => {
const [SwitchEnabled, setSwitchEnabled] = useState(false)
const allIndices = Stub.GenerateIndice()
const { indice, players } = useGame();
const { indice, players, actualPlayerIndex} = useGame();
const nbPlayer = players.length;
const navdeduc = '/deduc?actualId=' + actualPlayerIndex + '&nbPlayer=' + nbPlayer;
return (
<div id="mainDiv">
@ -373,12 +375,9 @@ const InGame = ({locale, changeLocale}) => {
<img src={Info} alt="info" height="40"/>
</button>
</Link>
{/* <button className='button' onClick={() => openInNewTab('http://localhost:3000/play')}> //! avec url =={'>'} dangereux
<img src={Check} alt="check" height="40"/>
</button> */}
{!IsSolo &&
<Link to='/deduc' target='_blank'>
<Link to={navdeduc} target='_blank'>
<button className='button'
style={{
backgroundColor: theme.colors.tertiary,

Loading…
Cancel
Save