diff --git a/src/Match/MatchView.js b/src/Match/MatchView.js
index 692f761..2e9ea10 100644
--- a/src/Match/MatchView.js
+++ b/src/Match/MatchView.js
@@ -1,12 +1,14 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useState, useRef } from 'react';
import { useParams } from 'react-router-dom';
import UserButtons from '../User/UserButtons';
import { MatchesService } from '../services/MatchesService';
import MovesTable from './MovesTable';
+import {MovesTableButtons} from './MovesTable';
import MatchOverView from './MatchOverView';
import Visualization from './Visualization';
import './MatchView.scss';
+import { set } from 'date-fns';
function getLog(log) {
let table = log.split('\n').map((x) => x.trim());
@@ -55,6 +57,13 @@ export default function MatchView() {
const [match, setMatch] = useState({});
const [log, setLog] = useState({"rounds": [], "result": ""});
const [gameData, setGameData] = useState({ gameStates: [] });
+ const canvasRef = useRef(null);
+ const [round, setRound] = useState(0);
+ const setMove = function (value) {
+ if (value == -2 || value >= log.rounds.length) setRound(log.rounds.length - 1);
+ else setRound(Math.min(Math.max(value,0), log.rounds.length - 1));
+ console.log("round: " + round);
+ }
useEffect(() => {
MatchesService.getMatch(id).then((data) => {
@@ -81,13 +90,13 @@ export default function MatchView() {
return (
-
+
@@ -41,7 +54,6 @@ export default function MovesTable({log}) {
{log.rounds.map((round, index) => {
- //console.log(round.boardState);
boardState = round.boardState.map((x) => {x}
)
playerMove = round.playerMove.map((x) => {x}
)
playerHand = round.playerHand.map((x) => {x}
)
@@ -56,16 +68,9 @@ export default function MovesTable({log}) {
-
-
-
-
-
-
-
-
-
>
-}
\ No newline at end of file
+}
+
+export { MovesTableButtons };
\ No newline at end of file
diff --git a/src/Match/Visualization.js b/src/Match/Visualization.js
index 320eeec..353d899 100644
--- a/src/Match/Visualization.js
+++ b/src/Match/Visualization.js
@@ -1,9 +1,12 @@
import React, { useEffect, useRef, useState } from 'react';
import './Visualization.scss';
-export default function Visualization({ gameData }) {
+export default function Visualization({ gameData, currentMove }) {
const canvasRef = useRef(null);
const [gameStateIndex, setGameStateIndex] = useState(0);
+ useEffect(() => {
+ setGameStateIndex(currentMove);
+ }, [currentMove]);
useEffect(() => {
if (!gameData || !gameData.gameStates || gameData.gameStates.length === 0) return;
@@ -19,7 +22,7 @@ export default function Visualization({ gameData }) {
try {
ctx.fillStyle = kolor.toLowerCase();
ctx.fillRect(x, y, cardWidth, cardHeight);
- ctx.strokeStyle = 'black';
+ ctx.strokeStyle = 'white';
ctx.lineWidth = 2;
ctx.strokeRect(x, y, cardWidth, cardHeight);
ctx.fillStyle = 'black';
@@ -72,7 +75,7 @@ export default function Visualization({ gameData }) {
return (
-
{/* Adjusted canvas size */}
+
);
diff --git a/src/Match/Visualization.scss b/src/Match/Visualization.scss
index a417b08..38b38f4 100644
--- a/src/Match/Visualization.scss
+++ b/src/Match/Visualization.scss
@@ -1,4 +1,6 @@
.visualization-container {
+ background-color: #1a1a1a;
+ border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
@@ -8,8 +10,7 @@
#myCanvas {
border: 1px solid #000;
- max-width: 100%;
- max-height: 100%;
+ width: 100%;
}
#controls {
diff --git a/src/Matches/MatchesFilterPanel.js b/src/Matches/MatchesFilterPanel.js
index be8924a..7057b3c 100644
--- a/src/Matches/MatchesFilterPanel.js
+++ b/src/Matches/MatchesFilterPanel.js
@@ -1,18 +1,141 @@
+import React, { useEffect, useState } from 'react';
+import { GameService } from '../services/GameService';
+import { UserService } from '../services/UserService';
+import { TournamentService } from '../services/TournamentService';
+import './MatchesFilterPanel.scss';
+import { set } from 'date-fns';
+export default function MatchesFilterPanel({triggerFilter}) {
+ const [maxDate, setMaxDate] = useState('');
+ const [minDate, setMinDate] = useState('');
+
+ const [gameName, setGameName] = useState('');
+ const [games, setGames] = useState([]);
+ const [gameType, setGameType] = useState({});
+
+ const [playerName, setPlayerName] = useState('');
+ const [players, setPlayers] = useState([]);
+ const [player, setPlayer] = useState({});
+
+ const [tournamentName, setTournamentName] = useState('');
+ const [tournaments, setTournaments] = useState([]);
+ const [tournament, setTournament] = useState({});
+
+ const composeAndTriggerFilter = () => {
+ const filter = {};
+ if (tournament !== null || tournamentName !== '') {
+ filter.tournamentName = tournamentName;
+ }
+ if (player !== null || playerName !== '') {
+ filter.userParticipation = playerName;
+ }
+ if (gameType !== null || gameName !== '') {
+ filter.gameName = gameName;
+ }
+ if (maxDate !== null || minDate !== null) {
+ filter.maxPlayOutDate = maxDate;
+ }
+ if (minDate !== null || minDate !== null) {
+ filter.minPlayOutDate = minDate;
+ }
+ triggerFilter ? triggerFilter(filter) : console.log(filter);
+ }
+
+ useEffect(() => {
+ if (gameName === '' || gameName === gameType.gameFileName) {
+ setGames([]);
+ return;
+ }
+ GameService.getByName(gameName, 0, 5)
+ .then((response) => {
+ setGames(response.data.data.page);
+ })
+ .catch((error) => {
+ console.log(error);
+ })}, [gameName, gameType]);
+
+ useEffect(() => {
+ if (playerName === '' || playerName === player.login) {
+ setPlayers([]);
+ return;
+ }
+ UserService.searchPlayersByName(playerName, 0, 5)
+ .then((response) => {
+ setPlayers(response.data.data);
+ }).catch((error) => {
+ console.log(error);
+ })}, [playerName, player]);
+
+ useEffect(() => {
+ if (tournamentName === '' || tournamentName === tournament.tournamentTitle) {
+ setTournaments([]);
+ return;
+ }
+ TournamentService.getByName(tournamentName, 0, 5)
+ .then((response) => {
+ setTournaments(response.data.data.page);
+ }).catch((error) => {
+ console.log(error);
+ })}, [tournamentName, tournament]);
+
+ const gameClickHandler = (game) => {
+ return () => {
+ setGameType(game);
+ setGameName(game.gameFileName);
+ }
+ }
+
+ const playerClickHandler = (player) => {
+ return () => {
+ setPlayer(player);
+ setPlayerName(player.login);
+ }
+ }
+
+ const tournamentClickHandler = (tournament) => {
+ return () => {
+ setTournament(tournament);
+ setTournamentName(tournament.tournamentTitle);
+ }
+ }
-export default function MatchesFilterPanel({setTournamentId, setPlayerName, setMaxDate, setMinDate, setGameType}) {
return (
-
-
-
setTournamentId(e.target.value)} />
+
+
+
setTournamentName(e.target.value)} />
+
+
+ {tournaments.map((tournament) => (
+
+ {tournament.tournamentTitle}
+
))}
+
+
-
setPlayerName(e.target.value)} />
+
setPlayerName(e.target.value)} />
+
+
+ {players.map((player) => (
+
+ {player.login}
+
))}
+
+
setMaxDate(e.target.value)} />
setMinDate(e.target.value)} />
-
-
setGameType(e.target.value)} />
+
+
setGameName(e.target.value)} />
+
+
+ {games.map((game) => (
+
+ {game.gameFileName}
+
))}
+
+
+
Filter
);
diff --git a/src/Matches/MatchesFilterPanel.scss b/src/Matches/MatchesFilterPanel.scss
new file mode 100644
index 0000000..7359629
--- /dev/null
+++ b/src/Matches/MatchesFilterPanel.scss
@@ -0,0 +1,75 @@
+.matches-search-filter-panel {
+
+ display: flex;
+ flex-direction: column;
+ align-self: start;
+ gap: 5px;
+ background-color: #181818;
+ padding: 20px;
+
+ * {
+ font-size: 20px;
+ }
+
+ .tournaments-list-container {
+ width: 100%;
+ height: 10px;
+ .tournaments-list {
+ position: relative;
+ width: 100%;
+ background-color: #333;
+ .tournaments-list-element {
+ width: 100%;
+ padding: 5px;
+ transition: all 0.5s ease;
+
+ &:hover {
+ background-color: #111;
+ color: #eee;
+ cursor: pointer;
+ }
+ }
+ }
+ }
+
+ .players-list-container {
+ width: 100%;
+ height: 10px;
+ .players-list {
+ position: relative;
+ width: 100%;
+ background-color: #333;
+ .players-list-element {
+ width: 100%;
+ padding: 5px;
+ transition: all 0.5s ease;
+
+ &:hover {
+ background-color: #111;
+ color: #eee;
+ cursor: pointer;
+ }
+ }
+ }
+ }
+
+ .games-list-container {
+ width: 100%;
+ height: 10px;
+ .games-list {
+ position: relative;
+ width: 100%;
+ background-color: #333;
+ .games-list-element {
+ width: 100%;
+ padding: 5px;
+ transition: all 0.5s ease;
+ &:hover {
+ background-color: #111;
+ color: #eee;
+ cursor: pointer;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Matches/MatchesList.css b/src/Matches/MatchesList.css
deleted file mode 100644
index 7120b6b..0000000
--- a/src/Matches/MatchesList.css
+++ /dev/null
@@ -1,39 +0,0 @@
-.match-list-element {
- justify-content: space-between;
- align-items: center;
- padding: 10px;
- border-bottom: 1px solid #ccc;
-
- border-radius: 5px;
-
- transition: all 0.5s ease-in;
-}
-
-.match-list-element:hover {
- background-color: #333;
- cursor: pointer;
-}
-
-.match-list-element-title {
- font-size: 30px;
-}
-
-.match-list-element-container {
- display: flex;
-}
-
-.match-list-element-container-info {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100%;
-}
-
-.match-list-element-info{
- font-size: medium;
-}
-
-.match-list-container {
- width: 60%;
- margin: 0 auto;
-}
\ No newline at end of file
diff --git a/src/Matches/MatchesList.js b/src/Matches/MatchesList.js
index c462842..9f32ebe 100644
--- a/src/Matches/MatchesList.js
+++ b/src/Matches/MatchesList.js
@@ -1,7 +1,8 @@
-import "./MatchesList.css";
+import "./MatchesList.scss";
import {useNavigate} from 'react-router-dom';
+import Paginator from '../elements/Paginator/Paginator';
-export default function MatchesList({matchList}) {
+export default function MatchesList({matchList, maxPage, pageClickHandle}) {
const navigate = useNavigate();
const handleTournamentClick = (matchId) => {
return () => navigate(`/match/${matchId}`);
@@ -16,16 +17,19 @@ export default function MatchesList({matchList}) {
{matchList.map((match) => (
-
-
{match.tournamentName}
+
+
+
{match.tournamentName}
+
-
{match.players.join(', ')}
-
{match.gameType}
-
{match.date}
+
{match.playersBots.map(e => e.userName).join(', ')}
+
{match.gameName}
+
{match.playedOutDate}
))}
+
>
}
\ No newline at end of file
diff --git a/src/Matches/MatchesList.scss b/src/Matches/MatchesList.scss
new file mode 100644
index 0000000..3f53f14
--- /dev/null
+++ b/src/Matches/MatchesList.scss
@@ -0,0 +1,46 @@
+.match-list-container {
+ width: 90%;
+ margin: 0 auto;
+ background-color: #181818;
+ padding: 20px;
+
+ .match-list-element {
+ justify-content: space-between;
+ align-items: center;
+ padding: 10px;
+ margin: 10px 0;
+ border-bottom: 1px solid #ccc;
+ border-radius: 5px;
+ transition: all 0.5s ease-in;
+
+ .match-list-element-title-checkbox {
+ display: flex;
+ flex-direction: row;
+ gap: 10px;
+
+ .match-list-element-title {
+ font-size: 25px;
+ }
+ }
+
+ &:hover {
+ background-color: #333;
+ cursor: pointer;
+ }
+
+ .match-list-element-container {
+ font-size: 20px;
+
+ .match-list-element-info-container {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 100%;
+
+ .match-list-element-info{
+ font-size: medium;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Matches/MatchesSearch.css b/src/Matches/MatchesSearch.css
deleted file mode 100644
index 38ee97f..0000000
--- a/src/Matches/MatchesSearch.css
+++ /dev/null
@@ -1,4 +0,0 @@
-.matches-list-container {
- display: grid;
- grid-template-columns: 25% 70%;
-}
\ No newline at end of file
diff --git a/src/Matches/MatchesSearch.js b/src/Matches/MatchesSearch.js
index c66d3e0..dcd8d22 100644
--- a/src/Matches/MatchesSearch.js
+++ b/src/Matches/MatchesSearch.js
@@ -1,37 +1,38 @@
import { useParams } from 'react-router-dom';
-import UserButtons from '../User/UserButtons';
+import TournamentNav from '../Tournaments/TournamentNav';
import { useEffect, useState } from 'react';
import { MatchesService } from '../services/MatchesService';
import MatchesList from './MatchesList';
import MatchesFilterPanel from './MatchesFilterPanel';
-import './MatchesSearch.css';
-
-export default function MatchesSearch() {
- const { tournamentid, playername, maxdate, mindate, gametype } = useParams();
-
- const [tournamentId, setTournamentId] = useState(parseInt(tournamentid) ? parseInt(tournamentid) : null);
- const [playerName, setPlayerName] = useState(playername ? playername : null);
- const [maxDate, setMaxDate] = useState(maxdate ? new Date(maxdate) : null);
- const [minDate, setMinDate] = useState(mindate ? new Date(mindate) : null);
- const [gameType, setGameType] = useState(gametype ? gametype : null);
+import './MatchesSearch.scss';
+export default function MatchesSearch({isAuthenticated}) {
+ const [filter, setFilter] = useState({});
const [matches, setMatches] = useState([]);
+ const [page, setPage] = useState({selected: 0});
+ const [maxPage, setMaxPage] = useState(0);
+
useEffect(() => {
- MatchesService.getMatches(1, 10, tournamentId, maxDate, minDate, gameType).then((data) => {
- setMatches(data);
+ if (filter.minPlayOutDate === '') {
+ filter.minPlayOutDate = new Date(1).toISOString();
+ }
+ MatchesService.getMatches(page.selected, 10, filter).then((data) => {
+ console.log(data);
+ setMatches(data.data.page);
+ setMaxPage(data.data.amountOfPages);
}).catch((e) => {
console.log(e);
});
- }, [tournamentId, playerName, maxDate, minDate, gameType]);
+ }, [filter, page]);
return (
);
diff --git a/src/Matches/MatchesSearch.scss b/src/Matches/MatchesSearch.scss
new file mode 100644
index 0000000..3396080
--- /dev/null
+++ b/src/Matches/MatchesSearch.scss
@@ -0,0 +1,6 @@
+.matches-list-container {
+ margin: 20px 0 0 0;
+ display: grid;
+ grid-template-columns: min(25%, 250px) auto;
+ align-items: center;
+}
\ No newline at end of file
diff --git a/src/Navbar.scss b/src/Navbar.scss
index 9fdb917..f5e5c30 100644
--- a/src/Navbar.scss
+++ b/src/Navbar.scss
@@ -12,6 +12,10 @@ $menu-breakpoint: 900px;
border-bottom: 1px solid #0f0;
position: relative;
+ .logo-link {
+ text-decoration: none;
+ }
+
.logo {
display: flex;
justify-content: left;
diff --git a/src/Tournaments/TournamentNav.js b/src/Tournaments/TournamentNav.js
index cdb1ef0..27e3b3d 100644
--- a/src/Tournaments/TournamentNav.js
+++ b/src/Tournaments/TournamentNav.js
@@ -14,9 +14,11 @@ function TournamentNav({ isAuthenticated }) {
return (
-
-
Bot-Wars
-
+
+
+
Bot-Wars
+
+