Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
student-tournament-hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Schneider Stefan
student-tournament-hub
Commits
763fee43
Commit
763fee43
authored
1 year ago
by
Bauer Lucca
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
d8272a69
5dd47d38
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
Dev in Main Merge
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sth-backend/pom.xml
+7
-2
7 additions, 2 deletions
sth-backend/pom.xml
sth-backend/src/main/java/hdm/mi/sthbackend/service/TournamentService.java
+32
-1
32 additions, 1 deletion
...ain/java/hdm/mi/sthbackend/service/TournamentService.java
with
39 additions
and
3 deletions
sth-backend/pom.xml
+
7
−
2
View file @
763fee43
...
...
@@ -20,6 +20,7 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-security
</artifactId>
<version>
3.2.1
</version>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
...
...
@@ -71,8 +72,12 @@
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<dependency>
<groupId>
org.springdoc
</groupId>
<artifactId>
springdoc-openapi-starter-webmvc-ui
</artifactId>
<version>
2.3.0
</version>
</dependency>
</dependencies>
<build>
<plugins>
...
...
This diff is collapsed.
Click to expand it.
sth-backend/src/main/java/hdm/mi/sthbackend/service/TournamentService.java
+
32
−
1
View file @
763fee43
...
...
@@ -261,10 +261,41 @@ public class TournamentService {
else
{
throw
new
BracketAlreadyInitializedException
(
tournamentId
);
}
linkMatchesInNextRound
(
tournamentId
);
tournamentRepository
.
save
(
tournament
);
return
tournament
;
}
public
void
linkMatchesInNextRound
(
UUID
tournamentId
)
throws
TournamentIdNotFoundException
{
Tournament
tournament
=
tournamentRepository
.
findById
(
tournamentId
)
.
orElseThrow
(()
->
new
TournamentIdNotFoundException
(
tournamentId
));
int
timesUsed
=
0
;
Map
<
UUID
,
Match
>
nextRoundMatches
;
for
(
int
i
=
0
;
i
<
tournament
.
getBracket
().
size
()
-
1
;
i
++)
{
nextRoundMatches
=
tournament
.
getBracket
().
get
(
i
+
1
).
getMatches
();
List
<
UUID
>
nextRoundMatchIds
=
nextRoundMatches
.
keySet
().
stream
().
toList
();
for
(
Map
.
Entry
<
UUID
,
Match
>
entry
:
tournament
.
getBracket
().
get
(
i
).
getMatches
().
entrySet
())
{
UUID
nextMatch
=
nextRoundMatchIds
.
get
(
0
);
entry
.
getValue
().
setNextMatchId
(
nextMatch
);
if
(
timesUsed
>
0
)
{
nextRoundMatchIds
.
removeFirst
();
timesUsed
=
0
;
}
else
{
timesUsed
+=
1
;
}
}
}
tournamentRepository
.
save
(
tournament
);
}
public
Tournament
fillBracketRandom
(
UUID
tournamentId
)
throws
TournamentIdNotFoundException
{
Tournament
tournament
=
tournamentRepository
.
findById
(
tournamentId
)
.
orElseThrow
(()
->
new
TournamentIdNotFoundException
(
tournamentId
));
...
...
@@ -273,7 +304,7 @@ public class TournamentService {
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
2
;
i
++){
for
(
Match
match:
tournament
.
getBracket
().
get
(
0
).
getMatches
().
values
()){
if
(
teams
.
size
()
>
0
){
if
(
!
teams
.
isEmpty
()
){
int
teamIndex
=
random
.
nextInt
(
0
,
teams
.
size
());
match
.
getTeamScores
().
put
(
teams
.
get
(
teamIndex
).
getTeamId
(),
0
);
teams
.
remove
(
teamIndex
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment