Skip to content

Commit

Permalink
fix: User german adaption for passivity P / activity period A
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Aug 2, 2024
1 parent 1a99ec9 commit 2141336
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,18 @@ class ByGermanyWrestlingApi extends WrestlingApi {
BoutActionType actionType;
switch (actionStr) {
case 'A':
case 'P':
if (weightClass.style == WrestlingStyle.greco) {
throw Exception('Activity Time "A" should be only available in free style: $boutJson');
}
// Germany handles passivity as activity period 'A' in free style.
actionType = BoutActionType.passivity;
case 'P':
if (weightClass.style == WrestlingStyle.greco) {
actionType = BoutActionType.passivity;
} else {
// Germany handles the first a verbal admonition before an activity period as passivity 'P' in free style.
actionType = BoutActionType.verbal;
}
case 'V':
actionType = BoutActionType.verbal;
case 'O':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,21 @@ class NrwGermanyWrestlingReporter extends WrestlingReporter {
].join(';');
final boutInfos = boutMap.entries.map((entry) {
final bout = entry.key;
var points = entry.value.map((BoutAction action) {
return '${bout.weightClass?.style == WrestlingStyle.free && action.actionType == BoutActionType.passivity ? 'A' : action.actionValue}${action.role == BoutRole.red ? 'R' : 'B'}${action.duration.inSeconds}';
var points = entry.value.asMap().entries.map((boutActionEntry) {
final boutActionIndex = boutActionEntry.key;
final action = boutActionEntry.value;
String actionValue = action.actionValue;
if (bout.weightClass?.style == WrestlingStyle.free) {
// In germany: 'P' is handled as 'A' activity period, whereas a verbal admonition 'V' before a passivity ('P' / 'A' in Germany) is written as first 'P'.
if (action.actionType == BoutActionType.passivity) {
actionValue = 'A';
} else if (action.actionType == BoutActionType.caution &&
entry.value.length > (boutActionIndex + 1) &&
entry.value[boutActionIndex + 1].actionType == BoutActionType.passivity) {
actionValue = 'P';
}
}
return '$actionValue${action.role == BoutRole.red ? 'R' : 'B'}${action.duration.inSeconds}';
}).join(',');
if (points.isNotEmpty) {
points = '(points $points)';
Expand Down
5 changes: 3 additions & 2 deletions wrestling_scoreboard_common/test/services/apis_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ void main() {
),
),
);
// "2R26,2B37,PB98,AB124,1R156,PR252,AR292,1B326,1R337,AB360,2B360"
expect(bouts, <Bout, Iterable<BoutAction>>{
expectedBout: <BoutAction>[
BoutAction(
Expand All @@ -553,7 +554,7 @@ void main() {
bout: expectedBout),
BoutAction(
role: BoutRole.blue,
actionType: BoutActionType.passivity,
actionType: BoutActionType.verbal,
duration: Duration(seconds: 98),
pointCount: null,
bout: expectedBout),
Expand All @@ -571,7 +572,7 @@ void main() {
bout: expectedBout),
BoutAction(
role: BoutRole.red,
actionType: BoutActionType.passivity,
actionType: BoutActionType.verbal,
duration: Duration(seconds: 252),
pointCount: null,
bout: expectedBout),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void main() {
expect(
report,
'rdbi;2.0.0;MK;matchNo;Test League;1.1.2000;Team A;Team B;4;0;5;Referee;Mr.;Match comment: Semicolon OpeningParenthesis&#40;ClosingParenthesis&#41;LessThan&lt;GreaterThan&gt;AndSign&amp;00000000000000000000000000000000000000000000000000000000000000000000000000000000000000...\n'
'10;LL;LizNoA;SurnameA;PrenameA;JN;LizNoB;SurnameB;PrenameB;JEU;4;0;SS;4:2(points PB30,4R60,2B120)',
'10;LL;LizNoA;SurnameA;PrenameA;JN;LizNoB;SurnameB;PrenameB;JEU;4;0;SS;4:2(points AB30,4R60,2B120)',
);
});
});
Expand Down

0 comments on commit 2141336

Please sign in to comment.