Starting implementation of the bowling game algorithm
continuous-integration/drone/push Build is failing Details

Arthur_BowlingAlgo
Arthur VALIN 2 years ago
parent 09adc10a76
commit 25d036cc63

@ -66,8 +66,8 @@ abstract class AbstractRound {
previousRound?.update(val); previousRound?.update(val);
} }
void unsubscribe(){ void unsubscribePreviousRound(){
previousRound?.unsubscribe(); previousRound?.unsubscribePreviousRound();
previousRound=null; previousRound=null;
} }

@ -1,3 +1,5 @@
import 'package:bowl_in/model/AbstractRound.dart';
import 'Player.dart'; import 'Player.dart';
import 'Round.dart'; import 'Round.dart';
@ -7,9 +9,8 @@ class GameDetail {
int _winner; int _winner;
int _nbPoints; int _nbPoints;
bool _isFinished; bool _isFinished;
Round? _currentRound;
int _host; int _host;
List<Round> _rounds = []; List<AbstractRound> _rounds = [];
List<Player> _players = []; List<Player> _players = [];
// Constructor // Constructor
@ -19,7 +20,6 @@ class GameDetail {
this._winner, this._winner,
this._nbPoints, this._nbPoints,
this._isFinished, this._isFinished,
this._currentRound,
this._host, this._host,
this._rounds, this._rounds,
this._players); this._players);
@ -55,21 +55,15 @@ class GameDetail {
_isFinished = value; _isFinished = value;
} }
Round? get currentRound => _currentRound;
set currentRound(Round? value) {
_currentRound = value;
}
int get host => _host; int get host => _host;
set host(int value) { set host(int value) {
_host = value; _host = value;
} }
List<Round> get rounds => _rounds; List<AbstractRound> get rounds => _rounds;
set rounds(List<Round> value) { set rounds(List<AbstractRound> value) {
_rounds = value; _rounds = value;
} }

@ -41,7 +41,7 @@ class LastRound extends AbstractRound{
if(previousRound?.isStrike()??false){ if(previousRound?.isStrike()??false){
update(points??0); update(points??0);
} }
unsubscribe(); unsubscribePreviousRound();
} }

@ -13,7 +13,7 @@ class Round extends AbstractRound{
firstThrow=val; firstThrow=val;
if(previousRound?.isSpare() ?? false){ if(previousRound?.isSpare() ?? false){
previousRound?.update(val); previousRound?.update(val);
unsubscribe(); unsubscribePreviousRound();
} }
return false; //Le round n'est pas fini return false; //Le round n'est pas fini
}else if(firstThrow==10){ }else if(firstThrow==10){
@ -35,7 +35,7 @@ class Round extends AbstractRound{
if(isSpareOrStrike()){ if(isSpareOrStrike()){
gamePlayer.onSpareOrStrike(); gamePlayer.onSpareOrStrike();
} }
unsubscribe(); unsubscribePreviousRound();
} }

@ -128,13 +128,11 @@ class StubData extends IManager {
List<GameDetail> _gameDetails = []; List<GameDetail> _gameDetails = [];
void _initGameDetails() { void _initGameDetails() {
gameDetails.add(GameDetail(1, DateTime.now(), players[7].id, 123, true, gameDetails.add(GameDetail(1, DateTime.now(), players[7].id, 123, true, players[7].id, rounds, [players[0], players[1]]));
null, players[7].id, rounds, [players[0], players[1]])); gameDetails.add(GameDetail(2, DateTime.now(), players[0].id, 113, true, players[7].id, rounds, [players[0], players[1], players[7]]));
gameDetails.add(GameDetail(2, DateTime.now(), players[0].id, 113, true, gameDetails.add(GameDetail(3, DateTime.now(), players[7].id, 93, true,
null, players[7].id, rounds, [players[0], players[1], players[7]]));
gameDetails.add(GameDetail(3, DateTime.now(), players[7].id, 93, true, null,
players[7].id, [], [players[0], players[7]])); players[7].id, [], [players[0], players[7]]));
gameDetails.add(GameDetail(4, DateTime.now(), players[7].id, 93, true, null, gameDetails.add(GameDetail(4, DateTime.now(), players[7].id, 93, true,
players[7].id, [], [players[1], players[7]])); players[7].id, [], [players[1], players[7]]));
} }

Loading…
Cancel
Save