Correcting bug with NumberPad maxvalue
continuous-integration/drone/push Build is passing Details

pull/25/head
Arthur VALIN 2 years ago
parent 62a785f489
commit bf4da7a38a

@ -53,6 +53,7 @@ abstract class AbstractRound {
bool computeNext(int val); bool computeNext(int val);
void computePoints(); void computePoints();
bool shotIsStrike(); bool shotIsStrike();
int getMaxPinsThisShot();
bool isStrike() { bool isStrike() {
return firstThrow==10; return firstThrow==10;

@ -95,4 +95,20 @@ class LastRound extends AbstractRound{
return (firstThrow??0)+(secondThrow??0)+(thirdThrow??0); return (firstThrow??0)+(secondThrow??0)+(thirdThrow??0);
} }
@override
int getMaxPinsThisShot() {
if(firstThrow==null){
return 10;
}else if(firstThrow==10 && secondThrow==null){
return 10;
}else if(secondThrow==null){
return 10 - (firstThrow??0);
}else if(secondThrow==10){
return 10;
}else{
return 10 - (secondThrow??0);
}
}
} }

@ -60,6 +60,12 @@ class Round extends AbstractRound{
return (firstThrow ?? 0)+(secondThrow ?? 0); return (firstThrow ?? 0)+(secondThrow ?? 0);
} }
@override
int getMaxPinsThisShot() {
if(firstThrow==null){
return 10;
}else{
return 10 - (firstThrow ?? 0);
}
}
} }

@ -437,17 +437,8 @@ class InGameCardThrow extends StatefulWidget {
class _InGameCardThrowState extends State<InGameCardThrow> { class _InGameCardThrowState extends State<InGameCardThrow> {
GlobalKey<_NumberPadState> _numberPadKey = GlobalKey(); GlobalKey<_NumberPadState> _numberPadKey = GlobalKey();
late var maxValue;
void initState() { void initState() {
if (widget.currentRound.firstThrow == null) {
maxValue = 10;
} else if (widget.currentRound.secondThrow == null) {
maxValue = 10 - (widget.currentRound.firstThrow ?? 0);
} else {
maxValue = 10;
}
super.initState(); super.initState();
} }
@ -522,7 +513,7 @@ class _InGameCardThrowState extends State<InGameCardThrow> {
numberThrow: widget.numberThrow, numberThrow: widget.numberThrow,
setSelectedValue: widget.setSelectedValue, setSelectedValue: widget.setSelectedValue,
currentRound: widget.currentRound, currentRound: widget.currentRound,
maxValue: maxValue, maxValue: widget.currentRound.getMaxPinsThisShot(),
), ),
], ],
), ),

Loading…
Cancel
Save