diff --git a/app/src/components/Hero.jsx b/app/src/components/Hero.jsx index f74b786..992f7ef 100644 --- a/app/src/components/Hero.jsx +++ b/app/src/components/Hero.jsx @@ -19,6 +19,9 @@ const Hero = () => { let number_of_defenders = 0; let number_of_strikers = 0; + let shooterX = 0; + let shooterY = 0; + // zmienne globalne bedace danymi wejsciowymi do modelu @@ -60,14 +63,16 @@ const Hero = () => { if (ball) { var x = ball.style.left; var y = ball.style.top; - var query = "http://localhost:5000/LRegresion" + x + "&" + y - + var query = "http://localhost:5000/LRegresion" + shooterX + "&" + shooterY fetch(query).then( + res=> res.json() + ).then( data => { - setData(data) - console.log(data) + setData(data) + console.log(data) } - ) + ) + alert(data.response) } else { alert('Piłka nie jest obecnie na boisku.'); } @@ -75,17 +80,23 @@ const Hero = () => { /* Funkcja dodająca listener do boiska*/ function boiskoListener(){ + var x = event.clientX - footballField.getBoundingClientRect().left; var y = event.clientY - footballField.getBoundingClientRect().top; + shooterX = (x * 105)/600 + shooterY = ((400 - y) * 69)/ 400 + // Przypadek kiedy zaznaczamy strzelca if(active_bbt == "bbt1"){ var existingBall = document.querySelector('.football'); + if (!existingBall) { var ball = document.createElement('div'); ball.className = 'football'; ball.style.left = x + 'px'; ball.style.top = y + 'px'; footballField.appendChild(ball); + } else { alert('Możesz dodać tylko jedną piłkę!'); } diff --git a/app/src/flask-server/modele/__pycache__/modele.cpython-310.pyc b/app/src/flask-server/modele/__pycache__/modele.cpython-310.pyc index a50d4e9..df36aa9 100644 Binary files a/app/src/flask-server/modele/__pycache__/modele.cpython-310.pyc and b/app/src/flask-server/modele/__pycache__/modele.cpython-310.pyc differ diff --git a/app/src/flask-server/server.py b/app/src/flask-server/server.py index 1f46d43..2952555 100644 --- a/app/src/flask-server/server.py +++ b/app/src/flask-server/server.py @@ -15,12 +15,12 @@ def members(): @app.route("/LRegresion&") def LRegresion(x,y): - - x = int(x[0:2]) - y = int(y[0:2]) - response = LogisticRegression_predict_proba(9.23, -2.24, 9.5, 13.67, 13, 3, 0, 1, 0) - return {"response":[str(response),"proces"]} + x = round(x,2) + y = round(y,2) + + response = LogisticRegression_predict_proba(x, y, 9.5, 13.67, 13, 3, 0, 1, 0) + return {"response":[str(response)]} # uruchomienie serwera if __name__ == "__main__":