Merge branch 'master' of https://codefirst.iut.uca.fr/git/Crypteam/Cryptid into fixRT10
continuous-integration/drone/push Build is passing Details

pull/114/head
Pierre Ferreira 1 year ago
commit 1f00476f7f

@ -75,7 +75,6 @@ let cptHistory = 0
let lastNodes: NodePerson[] = []
let cptEndgame = 0
let endgame= false
let firstHistory = true
let cptSquare = 0
let cptOnAskedWrong = 0
let cptPlayerLeft = 0
@ -86,6 +85,7 @@ let testTemps = 0
let testFirst = false
let gameStartTmp = true
let index = 0
let firstHistory = true
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, difficulty, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey, handleTurn, setChangeGraph, lang}) => {
let cptTour: number = 1
@ -109,6 +109,8 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
const [netEnigme, setNetEnigme] = useState<Map<number, Pair<Indice, boolean>[]> | null>(null)
const [downloaded, setDownloaded] = useState(false)
const [updateHistory, setUpdateHistory] = useState<() => void>(() => {})
useEffect(() => {
if (testFirst){
testTemps = 0
@ -190,7 +192,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
gameStartTmp=gameStart
if (gameStartTmp){
setGameStartData(false)
console.log(gameStart)
setLastIndex(turnPlayerIndex)
setPlayerIndex(playerIndex)
}
@ -416,6 +417,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
link.click();
URL.revokeObjectURL(url);
}
useEffect(() => {
@ -434,11 +436,16 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setIndicesData(choosenIndices)
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
setDailyEnigmeData(map)
addToHistory("<----- [Tour " + 1 +"/"+networkPerson.getPersons().length + "] ----->");
if (solo && (difficulty === "intermediate" || !isDaily)){
addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) +" " + 1 +"/"+networkPerson.getPersons().length + "] ----->");
}
else{
choosenIndices.forEach((indice, index) => {
addToHistory(intl.formatMessage({ id: 'indice' }) + positionToEmoji(index, true) + " : " + indice.ToString(lang))
})
}
changecptTour(1)
testTemps=0
}
useEffect(() => {
@ -494,6 +501,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
}
}
};
const networkData = { nodes: nodes, edges: graph.edges };
const network = new Network(container, networkData, initialOptions);
@ -501,6 +509,17 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setNetwork(network)
setSeedData(network.getSeed())
if (solo){
if (solo && (difficulty === "intermediate" || !isDaily)){
addToHistory("<----- ["+ intl.formatMessage({ id: 'turn' }) +" " + 1 +"/"+networkData.nodes.length + "] ----->");
}
else{
indices.forEach((indice, index) => {
addToHistory(intl.formatMessage({ id: 'indice' }) + positionToEmoji(index, true) + " : " + indice.ToString(lang))
})
}
}
if (isDaily){
setNetworkEnigme(dailyEnigme)
setNetEnigme(dailyEnigme)
@ -519,15 +538,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
})
});
}
else if (difficulty === "easy"){
if (firstHistory){
firstHistory=false
indices.forEach((indice, index) => {
addToHistory(intl.formatMessage({ id: 'indice' }) + positionToEmoji(index, true) + " : " + indice.ToString(lang))
})
}
}
}
socket.on("give network", (playerId) => {
@ -898,6 +908,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setLastIndex(-1)
setPlayerTouched(-1)
setWinnerData(winner)
firstHistory=true
first = true
@ -906,7 +917,6 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
setAskedWrong(false)
askedWrongBot=false
endgame = true
firstHistory=true
cptBug=0
try{
if(isLoggedIn){

@ -178,8 +178,9 @@ function EndGame({lang}: {lang: string}) {
</div>
</div>
</div>
): (
): (
<div>
<div className="head">
<header className='leaderboard-header' style={{ borderColor: theme.colors.primary }}>
<h1>Vous avez gagné !</h1>

@ -106,6 +106,7 @@ const InGame = ({locale, changeLocale}) => {
const [askedWrong, setAskedWrong] = useState(false)
const [importToPdf, setImportToPdf] = useState(false)
const [importToJSON, setImportToJSON] = useState(false)
const [firstHistory, setFirstHistory] = useState(true)
const [putCorrectBackground, setPutCorrectBackground] = useState<() => void>(() => {});
const [putGreyBackgroud, setPutGreyBackground] = useState<() => void>(() => {});
@ -332,17 +333,18 @@ const InGame = ({locale, changeLocale}) => {
//@ts-ignore
const handleNumberChange = (event) => {
if (parseInt(event.target.value)){
setEnteredNumber(parseInt(event.target.value));
}
};
//@ts-ignore
const handleKeyDown = (event) => {
// Vérifier si la touche appuyée est "Entrée"
if (event.key === 'Enter' && user!==null) {
if (event.key === 'Enter' && user!==null && parseInt(event.target.value)) {
const newNumber = Math.max(20, Math.min(50, parseInt(event.target.value, 10)));
user.nbNodes = newNumber;
setEnteredNumber(newNumber);
setHistory([]);
}
};
@ -351,20 +353,27 @@ const InGame = ({locale, changeLocale}) => {
const newNumber = Math.max(20, Math.min(50, enteredNumber));
user.nbNodes = newNumber;
setEnteredNumber(newNumber);
setHistory([]);
}
};
//@ts-ignore
const handleNumberIndicesChange = (event) => {
setEnteredNumberIndices(parseInt(event.target.value));
if (parseInt(event.target.value)){
setEnteredNumberIndices(parseInt(event.target.value));
}
};
useEffect(() => {
if (changeGraph !== undefined){
manager?.userService.changeNodesIndices(enteredNumber, enteredNumberIndices)
changeGraph(enteredNumber, enteredNumberIndices)
if (changeGraph){
if (enteredNumber>=20 && enteredNumber<=50 && enteredNumberIndices>=3 && enteredNumberIndices<=6){
console.log(enteredNumber)
console.log(enteredNumberIndices)
manager?.userService.changeNodesIndices(enteredNumber, enteredNumberIndices)
setHistory([]);
setFirstHistory(true)
changeGraph(enteredNumber, enteredNumberIndices)
}
}
else{
setEnteredNumber(user?.nbNodes || 25)
@ -375,20 +384,18 @@ useEffect(() => {
//@ts-ignore
const handleKeyDownIndice = (event) => {
// Vérifier si la touche appuyée est "Entrée"
if (event.key === 'Enter' && user!=null) {
if (event.key === 'Enter' && user!=null && parseInt(event.target.value)) {
const newNumber = Math.max(3, Math.min(6, parseInt(event.target.value, 10)));
user.nbIndices = newNumber;
setEnteredNumberIndices(newNumber);
setHistory([]);
}
};
const handleBlurIndice = () => {
if (user!==null){
const newNumber = Math.max(3, Math.min(6, enteredNumber));
const newNumber = Math.max(3, Math.min(6, enteredNumberIndices));
setEnteredNumberIndices(newNumber);
user.nbIndices = newNumber;
setHistory([]);
}
};

Loading…
Cancel
Save