You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bowl_in/Sources/bowlin_project/lib/model/GamePlayer.dart

30 lines
725 B

import 'package:flutter/cupertino.dart';
import 'GameDetail.dart';
import 'package:go_router/go_router.dart';
class GamePlayer{
final GameDetail game;
int currentRoundIndex = 0;
final BuildContext context;
GamePlayer(this.game, this.context);
void onNext(bool isRoundFinished){
if(isRoundFinished){
currentRoundIndex++;
}
if(currentRoundIndex>game.rounds.length){
context.go("/scoreboard");
}else{
context.go("/in-game", extra: game.rounds[currentRoundIndex]);
}
}
void onSpareOrStrike(){
if(currentRoundIndex>=game.rounds.length-game.players.length){
game.rounds[currentRoundIndex].subscribe(game.rounds[currentRoundIndex+game.players.length]);
}
}
}