Correcting bug when computing points
continuous-integration/drone/push Build is passing Details

code_smells
Arthur VALIN 2 years ago
parent b8b67380c1
commit 723808a563

@ -1,5 +1,7 @@
import 'Player.dart';
final maxScoreInFrame = 30;
abstract class AbstractRound {
int? _firstThrow;
int? _secondThrow;
@ -28,7 +30,11 @@ abstract class AbstractRound {
int? get points => _points;
set points(int? value) {
_points = value;
if((value??0)>=maxScoreInFrame){
_points=maxScoreInFrame;
}else {
_points = value;
}
}
@ -76,11 +82,14 @@ abstract class AbstractRound {
}
void update(int val){
print(" ROUND " + number.toString() + "UPDATE : " + val.toString());
points = (points ?? 0) + val;
previousRound?.update(val);
}
void unsubscribePreviousRound(){
print("UNSUBSCRIBE");
previousRound?.unsubscribePreviousRound();
previousRound=null;
}

@ -102,6 +102,7 @@ class GameDetail {
print("====COMPUTE POINTS====");
for(var element in rounds){
points[element.player] = (points[element.player] ?? 0) + (element.points ?? 0);
print(element.points);
}
computeWinner();
addGameToUsers();

@ -38,6 +38,7 @@ class LastRound extends AbstractRound{
@override
void computePoints() {
points = (firstThrow??0)+(secondThrow??0)+(thirdThrow??0);
print("Compute points : " + points.toString());
if(previousRound?.isStrike()??false){
update(points??0);

@ -31,7 +31,6 @@ class Round extends AbstractRound{
if(previousRound?.isStrike() ?? false){
previousRound?.update(points ?? 0);
}
unsubscribePreviousRound();
}
@override

Loading…
Cancel
Save