dodanie automatycznego liczenie eX , naprawa bledu zlego generowania kafelkow zawodnikow

This commit is contained in:
Szymon Obst 2024-01-15 16:33:39 +01:00
parent 5b3ae8684e
commit 3749cf22b0
2 changed files with 37 additions and 20 deletions

View File

@ -14,31 +14,39 @@ const Hero = () => {
const [afterDribbling, SetafterDribbling] = useState(''); const [afterDribbling, SetafterDribbling] = useState('');
const [redirect, SetRedirect] = useState(''); const [redirect, SetRedirect] = useState('');
const handleMinuteChange = (e) => setGameMinute(e.target.value); const handleMinuteChange = (e) => { setGameMinute(e.target.value);
sentQuestion()
}
const handleFirstShotChange = (event) => { const handleFirstShotChange = (event) => {
setfirstShot(event.target.checked); setfirstShot(event.target.checked);
sentQuestion();
}; };
const handleOneOnOneChange = (event) => { const handleOneOnOneChange = (event) => {
SetoneOnOne(event.target.checked); SetoneOnOne(event.target.checked);
}; sentQuestion()
};
const handleAfterAirDuelChange = (event) => { const handleAfterAirDuelChange = (event) => {
SetafterAirDuele(event.target.checked); SetafterAirDuele(event.target.checked);
}; sentQuestion()
};
const handleOpenGoalChange = (event) => { const handleOpenGoalChange = (event) => {
SetOpenGoal(event.target.checked); SetOpenGoal(event.target.checked);
}; sentQuestion();
};
const handleAfterDribblingChange = (event) => { const handleAfterDribblingChange = (event) => {
SetafterDribbling(event.target.checked); SetafterDribbling(event.target.checked);
}; sentQuestion();
};
const handleRedirectChange = (event) => { const handleRedirectChange = (event) => {
SetRedirect(event.target.checked); SetRedirect(event.target.checked);
}; sentQuestion();
};
const [data, setData] = useState(""); const [data, setData] = useState("");
@ -144,6 +152,7 @@ const handleRedirectChange = (event) => {
}else if(possition == 0){ }else if(possition == 0){
setNumberOfShooters(number_of_shooters_rev.current -= 1); setNumberOfShooters(number_of_shooters_rev.current -= 1);
} }
sentQuestion()
} }
// funkcja zsczytuje pozycje zawodnikow przed wyslaniem zapytania do serwera // funkcja zsczytuje pozycje zawodnikow przed wyslaniem zapytania do serwera
@ -207,7 +216,7 @@ const handleRedirectChange = (event) => {
// div z pozycja gracza // div z pozycja gracza
var posytion = document.createElement('div') var posytion = document.createElement('div')
posytion.style.fontSize = "12px" posytion.style.fontSize = "12px"
posytion.innerHTML = "Lokalizacja: " + konwerturX(ball.style.left) + " m, " + konwetujY(ball.style.top) + " m"; posytion.innerHTML = konwerturX(ball.style.left) + " m, " + konwetujY(ball.style.top) + " m";
player.setAttribute('possition',[konwerturX(ball.style.left),konwetujY(ball.style.top)]) player.setAttribute('possition',[konwerturX(ball.style.left),konwetujY(ball.style.top)])
//div z przyciskiem usuwającym //div z przyciskiem usuwającym
var btnDelete = document.createElement('button') var btnDelete = document.createElement('button')
@ -262,8 +271,8 @@ const handleRedirectChange = (event) => {
tekst.style.color = "white" tekst.style.color = "white"
posytion.style.color = "white" posytion.style.color = "white"
x = parseFloat(x) -2 x = parseFloat(x) -3
y = parseFloat(y) -2 y = parseFloat(y) -3
if(bojo.parentNode.querySelector(":hover")){ if(bojo.parentNode.querySelector(":hover")){
ball.style.left = x + "%" ball.style.left = x + "%"
@ -273,14 +282,19 @@ const handleRedirectChange = (event) => {
//var shooterY = konwetujY(ball.style.top) //var shooterY = konwetujY(ball.style.top)
posytion.innerHTML = "x:" + konwerturX(ball.style.left) + "m " + "y:" + konwetujY(ball.style.top) + "m"; posytion.innerHTML = "x:" + konwerturX(ball.style.left) + "m " + "y:" + konwetujY(ball.style.top) + "m";
player.setAttribute('possition',[konwerturX(ball.style.left),konwetujY(ball.style.top)]); player.setAttribute('possition',[konwerturX(ball.style.left),konwetujY(ball.style.top)]);
bojo.addEventListener("mouseup", function(){ bojo.addEventListener("mouseup", function afterUp(){
ball.style.background = pColor ball.style.background = pColor
bojo.removeEventListener("mousemove", whileMove) bojo.removeEventListener("mousemove", whileMove)
bojo.removeEventListener("mouseup", afterUp)
}) })
})
bojo.addEventListener("mouseup", function reload(){
sentQuestion();
bojo.removeEventListener("mouseup",reload)
}) })
}) })
sentQuestion();
} }
// // Wyłanie zapytania do serwera // // Wyłanie zapytania do serwera
function sentQuestion() { function sentQuestion() {
@ -353,8 +367,6 @@ const handleRedirectChange = (event) => {
ball.style.background = "#fc6703" ball.style.background = "#fc6703"
}else{alert("maksymalna liczba napastnikow")} }else{alert("maksymalna liczba napastnikow")}
} }
} }
// funkcja działą po utworzeniu komponentów, dodaje listenry do elementów // funkcja działą po utworzeniu komponentów, dodaje listenry do elementów
@ -383,11 +395,12 @@ const handleRedirectChange = (event) => {
<div className="container"> <div className="container">
{/* Listy zwijane */} {/* Listy zwijane */}
<div className="top-bar"> <div className="top-bar" id = "top-bar">
<form className="dropdown" id = "bodyPartList"> <form className="dropdown" id = "bodyPartList">
<select className="dropbtn" <select className="dropbtn"
onChange={event => setBodyPart(event.target.value)} onChange={event => {setBodyPart(event.target.value);
sentQuestion}}
defaultValue={bodyPart}> defaultValue={bodyPart}>
<option value = "Right Foot">Noga Prawa</option> <option value = "Right Foot">Noga Prawa</option>
<option value = "Left Foot">Noga Lewa</option> <option value = "Left Foot">Noga Lewa</option>
@ -400,7 +413,9 @@ const handleRedirectChange = (event) => {
<form className="dropdown" id = "shootTypeList"> <form className="dropdown" id = "shootTypeList">
<select className="dropbtn" onChange={event => setTechnique(event.target.value)} <select className="dropbtn" onChange={event => {setTechnique(event.target.value);
sentQuestion()
}}
defaultValue = {technique}> defaultValue = {technique}>
<option value="Normal"> Zwykły </option> <option value="Normal"> Zwykły </option>
<option value = "Volley"> Wolej </option> <option value = "Volley"> Wolej </option>
@ -412,7 +427,8 @@ const handleRedirectChange = (event) => {
</select> </select>
</form> </form>
<form className="dropdown" id = "actionTypeList" onChange={event => setActionType(event.target.value)} <form className="dropdown" id = "actionTypeList" onChange={event => {setActionType(event.target.value);
sentQuestion}}
defaultValue={technique}> defaultValue={technique}>
<select className="dropbtn"> <select className="dropbtn">
<option value = "Open Play"> Atak Pozycyjny </option> <option value = "Open Play"> Atak Pozycyjny </option>
@ -422,7 +438,8 @@ const handleRedirectChange = (event) => {
</select> </select>
</form> </form>
<form className="dropdown" id = "possitionList" <form className="dropdown" id = "possitionList"
onChange={event => setPossition(event.target.value)} onChange={event => {setPossition(event.target.value);
sentQuestion}}
defaultValue={shooterPossition}> defaultValue={shooterPossition}>
<select className="dropbtn"> <select className="dropbtn">
<option value="Right Center Forward">Prawy Środkowy Napastnik</option> <option value="Right Center Forward">Prawy Środkowy Napastnik</option>
@ -477,7 +494,7 @@ const handleRedirectChange = (event) => {
</div> </div>
</div> </div>
<div className="additional-parameters"> <div className="additional-parameters">
<h3>Parametry strzału</h3> <h3>Parametry strzału</h3>
<label> <label>
<input type="checkbox" id="firstShot" onChange={handleFirstShotChange} /> <input type="checkbox" id="firstShot" onChange={handleFirstShotChange} />