Skip to content

Commit

Permalink
refactor!: Tournament to Competition (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Dec 7, 2023
1 parent 22e4e2c commit 6d0ea4b
Show file tree
Hide file tree
Showing 40 changed files with 735 additions and 735 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Repository for managing Wrestling software client, server and shared libraries.

Tags: scoreboard, wrestling, scoring, bracket, mat, team fight, tournament
Tags: scoreboard, wrestling, scoring, bracket, mat, team fight, competition, tournament

## Screenshots

Expand Down
4 changes: 2 additions & 2 deletions wrestling_scoreboard_client/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Wrestling Scoreboard Client

Wrestling software for managing team bouts and tournaments.
Wrestling software for managing team matches and competitions.

Tags: scoreboard, wrestling, scoring, bracket, mat, team bout, tournament
Tags: scoreboard, wrestling, scoring, bracket, mat, team bout, competition

## Deployment

Expand Down
2 changes: 1 addition & 1 deletion wrestling_scoreboard_client/debian/debian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ control:
Priority: optional
Depends: libgcrypt20, libgstreamer-plugins-base1.0-0, libgstreamer1.0-dev, libgtk-3-0, libjpeg-turbo8, liblz4-1, libstdc++6, libzstd1
Maintainer: August Oberhauser
Description: Wrestling software for managing team bouts and tournaments.
Description: Wrestling software for managing team matches and competitions.

options:
exec_out_dir: build/linux/x64/release/debian/
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Version=0.0.1
Name=Wrestling Scoreboard
GenericName=Sports event administration
Comment=Wrestling software for managing team bouts and tournaments.
Comment=Wrestling software for managing team matches and competitions.
Terminal=false
Type=Application
Categories=Utility
Keywords=Wrestling;Scoreboard;Tournament;Scoring;Bracket;Mat;Ringen;Lutte;
Keywords=Wrestling;Scoreboard;Competition;Tournament;Scoring;Bracket;Mat;Ringen;Lutte;
Icon=wrestling_scoreboard_client
26 changes: 13 additions & 13 deletions wrestling_scoreboard_client/lib/mocks/mock_data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MockDataProvider extends DataProvider {
if (filterObject != null) {
switch (T) {
case const (Bout):
if (filterObject is Tournament) return getBoutsOfTournament(filterObject).cast<T>();
if (filterObject is Competition) return getBoutsOfCompetition(filterObject).cast<T>();
if (filterObject is TeamMatch) return getBoutsOfTeamMatch(filterObject).cast<T>();
throw DataUnimplementedError(CRUD.read, T, filterObject);
case const (Membership):
Expand Down Expand Up @@ -82,7 +82,7 @@ class MockDataProvider extends DataProvider {
if (wrestlingEvent is TeamMatch) {
oldBouts = getBoutsOfTeamMatch(wrestlingEvent);
} else {
oldBouts = getBoutsOfTournament(wrestlingEvent as Tournament);
oldBouts = getBoutsOfCompetition(wrestlingEvent as Competition);
}
final boutsAll = getBouts();
if (isReset) {
Expand All @@ -91,10 +91,10 @@ class MockDataProvider extends DataProvider {
for (var element in oldBouts) {
teamMatchBoutsAll.removeWhere((tmf) => tmf.bout.equalDuringBout(element));
}
} else if (wrestlingEvent is Tournament) {
final tournamentBoutsAll = getTournamentBouts();
} else if (wrestlingEvent is Competition) {
final competitionBoutsAll = getCompetitionBouts();
for (var element in oldBouts) {
tournamentBoutsAll.removeWhere((tof) => tof.bout.equalDuringBout(element));
competitionBoutsAll.removeWhere((tof) => tof.bout.equalDuringBout(element));
}
}

Expand All @@ -112,15 +112,15 @@ class MockDataProvider extends DataProvider {
await dataProvider.readMany<Participation, Lineup>(filterObject: wrestlingEvent.guest);
teamParticipations = [homeParticipations, guestParticipations];
weightClasses = await dataProvider.readMany<WeightClass, League>(filterObject: wrestlingEvent.league);
} else if (wrestlingEvent is Tournament) {
} else if (wrestlingEvent is Competition) {
// TODO get all participations
teamParticipations = [];
weightClasses = [];
// throw UnimplementedError('generate bouts for tournaments not yet implemented');
// throw UnimplementedError('generate bouts for competitions not yet implemented');
} else {
teamParticipations = [];
weightClasses = [];
throw UnimplementedError('generate bouts for tournaments not yet implemented');
throw UnimplementedError('generate bouts for competitions not yet implemented');
}

// Generate new bouts
Expand Down Expand Up @@ -152,16 +152,16 @@ class MockDataProvider extends DataProvider {
teamMatchBoutsAll.add(TeamMatchBout(id: generatedId, teamMatch: wrestlingEvent, bout: element, pos: key));
}
});
} else if (wrestlingEvent is Tournament) {
final tournamentBoutsAll = getTournamentBouts();
} else if (wrestlingEvent is Competition) {
final competitionBoutsAll = getCompetitionBouts();
for (final element in newBoutsWithId) {
if (tournamentBoutsAll.where((tof) => tof.bout.equalDuringBout(element)).isEmpty) {
if (competitionBoutsAll.where((tof) => tof.bout.equalDuringBout(element)).isEmpty) {
int generatedId;
do {
// Generate new id as long it is not taken yet
generatedId = random.nextInt(0x7fffffff);
} while (tournamentBoutsAll.where((t) => t.id == element.id).isNotEmpty);
tournamentBoutsAll.add(TournamentBout(id: generatedId, tournament: wrestlingEvent, bout: element));
} while (competitionBoutsAll.where((t) => t.id == element.id).isNotEmpty);
competitionBoutsAll.add(CompetitionBout(id: generatedId, competition: wrestlingEvent, bout: element));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions wrestling_scoreboard_client/lib/mocks/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final List<Person> _persons = []; // TODO fill
final List<Team> _teams = [_homeTeam, _homeTeamJuniors, _guestTeam];
final List<TeamMatch> _teamMatches = [initMenRPWMatch(), initJnRPWMatch()];
final List<TeamMatchBout> _teamMatchBouts = [];
final List<TournamentBout> _tournamentBouts = [];
final List<CompetitionBout> _competitionBouts = [];
final List<WeightClass> _weightClasses = [wc57, wc130, wc61, wc98, wc66, wc86, wc71, wc80, wc75A, wc75B];

TeamMatch initMenRPWMatch() {
Expand Down Expand Up @@ -147,8 +147,8 @@ List<Club> getClubs() => _clubs;

List<Bout> getBouts() => _bouts;

List<Bout> getBoutsOfTournament(Tournament tournament) {
return getTournamentBouts().where((element) => element.tournament == tournament).map((e) => e.bout).toList();
List<Bout> getBoutsOfCompetition(Competition competition) {
return getCompetitionBouts().where((element) => element.competition == competition).map((e) => e.bout).toList();
}

List<Bout> getBoutsOfTeamMatch(TeamMatch match) {
Expand Down Expand Up @@ -218,7 +218,7 @@ List<TeamMatchBout> getTeamMatchBoutsOfTeamMatch(TeamMatch match) {
return getTeamMatchBouts().where((element) => element.teamMatch == match).toList();
}

List<TournamentBout> getTournamentBouts() => _tournamentBouts;
List<CompetitionBout> getCompetitionBouts() => _competitionBouts;

List<WeightClass> getWeightClasses() => _weightClasses;

Expand Down
2 changes: 1 addition & 1 deletion wrestling_scoreboard_client/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wrestling_scoreboard_client
description: Wrestling software for managing team bouts and tournaments.
description: Wrestling software for managing team matches and competitions.

publish_to: 'none'

Expand Down
2 changes: 1 addition & 1 deletion wrestling_scoreboard_client/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Wrestling software for managing team bouts and tournaments.">
<meta name="description" content="Wrestling software for managing team matches and competitions.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
Expand Down
2 changes: 1 addition & 1 deletion wrestling_scoreboard_client/web/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"display": "standalone",
"background_color": "#0175C2",
"theme_color": "#0175C2",
"description": "Wrestling software for managing team bouts and tournaments.",
"description": "Wrestling software for managing team matches and competitions.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
Expand Down
8 changes: 4 additions & 4 deletions wrestling_scoreboard_common/lib/src/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export 'data/team_match/league_team_participation.dart';
export 'data/team_match/league_weight_class.dart';
export 'data/team_match/team_match.dart';
export 'data/team_match/team_match_bout.dart';
export 'data/tournament/tournament.dart';
export 'data/tournament/tournament_bout.dart';
export 'data/tournament/tournament_person.dart';
export 'data/tournament/tournament_team_participation.dart';
export 'data/competition/competition.dart';
export 'data/competition/competition_bout.dart';
export 'data/competition/competition_person.dart';
export 'data/competition/competition_team_participation.dart';
export 'data/weight_class.dart';
export 'data/wrestling_event.dart';
14 changes: 7 additions & 7 deletions wrestling_scoreboard_common/lib/src/data/bout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ class Bout with _$Bout implements DataObject {
);
}

Bout updateClassificationPoints(List<BoutAction> actions, {bool isTournament = false}) {
Bout updateClassificationPoints(List<BoutAction> actions, {bool isCompetition = false}) {
if (result != null && winnerRole != null) {
var winner = winnerRole == BoutRole.red ? r : b;
var looser = winnerRole == BoutRole.red ? b : r;

int? winnerClassificationPoints;
int? looserClassificationPoints;
if (winner != null) {
winnerClassificationPoints = isTournament
? getClassificationPointsWinnerTournament(result!)
winnerClassificationPoints = isCompetition
? getClassificationPointsWinnerCompetition(result!)
: getClassificationPointsWinnerTeamMatch(
result!,
ParticipantState.getTechnicalPoints(actions, winnerRole!) -
Expand All @@ -77,8 +77,8 @@ class Bout with _$Bout implements DataObject {
}

if (looser != null) {
looserClassificationPoints = isTournament
? getClassificationPointsLooserTournament(result!)
looserClassificationPoints = isCompetition
? getClassificationPointsLooserCompetition(result!)
: getClassificationPointsLooserTeamMatch(result!);
}
return copyWith(
Expand Down Expand Up @@ -107,7 +107,7 @@ class Bout with _$Bout implements DataObject {
@override
String get tableName => 'bout';

static int getClassificationPointsWinnerTournament(BoutResult result) {
static int getClassificationPointsWinnerCompetition(BoutResult result) {
switch (result) {
case BoutResult.vfa:
case BoutResult.vin:
Expand All @@ -127,7 +127,7 @@ class Bout with _$Bout implements DataObject {
}
}

static int getClassificationPointsLooserTournament(BoutResult result) {
static int getClassificationPointsLooserCompetition(BoutResult result) {
switch (result) {
case BoutResult.vsu1:
case BoutResult.vpo1:
Expand Down
2 changes: 1 addition & 1 deletion wrestling_scoreboard_common/lib/src/data/bout_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'data_object.dart';
part 'bout_config.freezed.dart';
part 'bout_config.g.dart';

/// The general configuration for a bout, e.g. in a team competition or tournament.
/// The general configuration for a bout, e.g. in a team match or competition.
@freezed
class BoutConfig with _$BoutConfig implements DataObject {
static const defaultPeriodDuration = Duration(minutes: 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import '../participation.dart';
import '../weight_class.dart';
import '../wrestling_event.dart';

part 'tournament.freezed.dart';
part 'tournament.g.dart';
part 'competition.freezed.dart';
part 'competition.g.dart';

/// For team matches only.
@freezed
class Tournament extends WrestlingEvent with _$Tournament {
const Tournament._();
class Competition extends WrestlingEvent with _$Competition {
const Competition._();

const factory Tournament({
const factory Competition({
int? id,
required String name,
required BoutConfig boutConfig,
Expand All @@ -24,14 +24,14 @@ class Tournament extends WrestlingEvent with _$Tournament {
String? no,
int? visitorsCount,
String? comment,
}) = _Tournament;
}) = _Competition;

factory Tournament.fromJson(Map<String, Object?> json) => _$TournamentFromJson(json);
factory Competition.fromJson(Map<String, Object?> json) => _$CompetitionFromJson(json);

static Future<Tournament> fromRaw(Map<String, dynamic> e, GetSingleOfTypeCallback getSingle) async {
static Future<Competition> fromRaw(Map<String, dynamic> e, GetSingleOfTypeCallback getSingle) async {
final boutConfig = await getSingle<BoutConfig>(e['bout_config_id'] as int);
// TODO fetch lineups, referees, weightClasses, etc.
return Tournament(
return Competition(
id: e['id'] as int?,
name: e['name'],
location: e['location'] as String?,
Expand Down Expand Up @@ -59,10 +59,10 @@ class Tournament extends WrestlingEvent with _$Tournament {
}

@override
String get tableName => 'tournament';
String get tableName => 'competition';

@override
Tournament copyWithId(int? id) {
Competition copyWithId(int? id) {
return copyWith(id: id);
}
}
Loading

0 comments on commit 6d0ea4b

Please sign in to comment.