First version of inserting into db
This commit is contained in:
@@ -62,7 +62,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
builder: (context, _) {
|
||||
sortedPlayerIndices = _getSortedPlayerIndices();
|
||||
denseRanks = _calculateDenseRank(
|
||||
gameSession.playerScores, sortedPlayerIndices);
|
||||
gameSession.getPlayerScoresAsList(), sortedPlayerIndices);
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
previousPageTitle: AppLocalizations.of(context).games,
|
||||
@@ -117,7 +117,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
_getPlacementTextWidget(index),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
gameSession.players[playerIndex],
|
||||
gameSession.players[playerIndex].name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
@@ -127,7 +127,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
children: [
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
'${gameSession.playerScores[playerIndex]} '
|
||||
'${gameSession.getPlayerScoresAsList()[playerIndex]} '
|
||||
'${AppLocalizations.of(context).points}')
|
||||
],
|
||||
),
|
||||
@@ -258,15 +258,14 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (_) => CreateGameView(
|
||||
gameTitle:
|
||||
gameSession.gameTitle,
|
||||
gameMode: widget.gameSession
|
||||
.isPointsLimitEnabled ==
|
||||
true
|
||||
? GameMode.pointLimit
|
||||
: GameMode.unlimited,
|
||||
players: gameSession.players,
|
||||
)));
|
||||
gameTitle: gameSession.gameTitle,
|
||||
gameMode: widget.gameSession
|
||||
.isPointsLimitEnabled ==
|
||||
true
|
||||
? GameMode.pointLimit
|
||||
: GameMode.unlimited,
|
||||
players: gameSession
|
||||
.getPlayerNamesAsList())));
|
||||
},
|
||||
),
|
||||
CupertinoListTile(
|
||||
@@ -374,8 +373,8 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
List<int>.generate(gameSession.players.length, (index) => index);
|
||||
// Sort the indices based on the summed points
|
||||
playerIndices.sort((a, b) {
|
||||
int scoreA = gameSession.playerScores[a];
|
||||
int scoreB = gameSession.playerScores[b];
|
||||
int scoreA = gameSession.getPlayerScoresAsList()[a];
|
||||
int scoreB = gameSession.getPlayerScoresAsList()[b];
|
||||
if (scoreA != scoreB) {
|
||||
return scoreA.compareTo(scoreB);
|
||||
}
|
||||
@@ -515,7 +514,8 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
/// Plays the confetti animation and shows a dialog with the winner's information.
|
||||
Future<void> _playFinishAnimation(BuildContext context) async {
|
||||
String winner = widget.gameSession.winner;
|
||||
int winnerPoints = widget.gameSession.playerScores.min;
|
||||
|
||||
int winnerPoints = widget.gameSession.getPlayerScoresAsList().min;
|
||||
int winnerAmount = winner.contains('&') ? 2 : 1;
|
||||
|
||||
confettiController.play();
|
||||
|
||||
@@ -94,7 +94,7 @@ class _GraphViewState extends State<GraphView> {
|
||||
List<LineSeries<(int, num), int>> getCumulativeScores() {
|
||||
final rounds = widget.gameSession.roundList;
|
||||
final playerCount = widget.gameSession.players.length;
|
||||
final playerNames = widget.gameSession.players;
|
||||
final playerNames = widget.gameSession.getPlayerNamesAsList();
|
||||
|
||||
List<List<int>> cumulativeScores = List.generate(playerCount, (_) => []);
|
||||
List<int> runningTotals = List.filled(playerCount, 0);
|
||||
|
||||
@@ -68,7 +68,7 @@ class _PointsViewState extends State<PointsView> {
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
player,
|
||||
player.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -120,7 +120,7 @@ class _PointsViewState extends State<PointsView> {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8),
|
||||
child: Text(
|
||||
player,
|
||||
player.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -236,18 +236,20 @@ class _PointsViewState extends State<PointsView> {
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
)),
|
||||
...widget.gameSession.playerScores.map(
|
||||
(score) => DataCell(
|
||||
Center(
|
||||
child: Text(
|
||||
'$score',
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold),
|
||||
...widget.gameSession
|
||||
.getPlayerScoresAsList()
|
||||
.map(
|
||||
(score) => DataCell(
|
||||
Center(
|
||||
child: Text(
|
||||
'$score',
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -146,7 +146,7 @@ class _RoundViewState extends State<RoundView> {
|
||||
.entries
|
||||
.map((entry) {
|
||||
final index = entry.key;
|
||||
final name = entry.value;
|
||||
final player = entry.value;
|
||||
return MapEntry(
|
||||
index,
|
||||
Padding(
|
||||
@@ -157,7 +157,7 @@ class _RoundViewState extends State<RoundView> {
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
name,
|
||||
player.name,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
@@ -210,7 +210,7 @@ class _RoundViewState extends State<RoundView> {
|
||||
]))
|
||||
]),
|
||||
subtitle: Text(
|
||||
'${widget.gameSession.playerScores[originalIndex]}'
|
||||
'${widget.gameSession.getPlayerScoresAsList()[originalIndex]}'
|
||||
' ${AppLocalizations.of(context).points}'),
|
||||
trailing: SizedBox(
|
||||
width: 100,
|
||||
@@ -329,10 +329,11 @@ class _RoundViewState extends State<RoundView> {
|
||||
/// Rotates the players list based on the previous round's winner.
|
||||
List<String> _getRotatedPlayers() {
|
||||
final winnerIndex = _getPreviousRoundWinnerIndex();
|
||||
final playerList = widget.gameSession.getPlayerNamesAsList();
|
||||
return [
|
||||
widget.gameSession.players[winnerIndex],
|
||||
...widget.gameSession.players.sublist(winnerIndex + 1),
|
||||
...widget.gameSession.players.sublist(0, winnerIndex)
|
||||
playerList[winnerIndex],
|
||||
...playerList.sublist(winnerIndex + 1),
|
||||
...playerList.sublist(0, winnerIndex)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -358,14 +359,14 @@ class _RoundViewState extends State<RoundView> {
|
||||
message: Text(AppLocalizations.of(context).who_has_kamikaze),
|
||||
actions: widget.gameSession.players.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final name = entry.value;
|
||||
final player = entry.value;
|
||||
return CupertinoActionSheetAction(
|
||||
onPressed: () {
|
||||
_kamikazePlayerIndex = index;
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
child: Text(
|
||||
name,
|
||||
player.name,
|
||||
style: TextStyle(color: CustomTheme.kamikazeColor),
|
||||
),
|
||||
);
|
||||
@@ -494,7 +495,7 @@ class _RoundViewState extends State<RoundView> {
|
||||
String _getBonusPopupMessageString(
|
||||
int pointLimit, int bonusPoints, List<int> bonusPlayers) {
|
||||
List<String> nameList =
|
||||
bonusPlayers.map((i) => widget.gameSession.players[i]).toList();
|
||||
bonusPlayers.map((i) => widget.gameSession.players[i].name).toList();
|
||||
String resultText = '';
|
||||
if (nameList.length == 1) {
|
||||
resultText = AppLocalizations.of(context).bonus_points_message(
|
||||
|
||||
Reference in New Issue
Block a user