diff --git a/android/gradle.properties b/android/gradle.properties index 81949dfd2077495aaea8a6bc81ad9c75442f9ebb..957c40bc42f3a742d2266dc3a403ad014458ba3f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.0.14 -app.versionCode=14 +app.versionName=0.0.15 +app.versionCode=15 diff --git a/fastlane/metadata/android/en-US/changelogs/15.txt b/fastlane/metadata/android/en-US/changelogs/15.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa67307650088d1c80ae2c429818c49a9cce7244 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/15.txt @@ -0,0 +1 @@ +Shuffle available colors, improve colors theme. diff --git a/fastlane/metadata/android/fr-FR/changelogs/15.txt b/fastlane/metadata/android/fr-FR/changelogs/15.txt new file mode 100644 index 0000000000000000000000000000000000000000..253e217afc19c8adc2ce0dd5266024ea1cd0e0a5 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/15.txt @@ -0,0 +1 @@ +Mélange les couleurs disponibles, amélioration du thème de couleurs. diff --git a/lib/cubit/game_cubit.dart b/lib/cubit/game_cubit.dart index b6096a87372387ecbbf4e0865f0717bb265d0bd4..1eb55172b98e245dc79cd2f69a0b3be28a9c42a9 100644 --- a/lib/cubit/game_cubit.dart +++ b/lib/cubit/game_cubit.dart @@ -24,6 +24,7 @@ class GameCubit extends HydratedCubit<GameState> { final Game game = Game( board: state.currentGame.board, settings: state.currentGame.settings, + shuffledColors: state.currentGame.shuffledColors, isRunning: state.currentGame.isRunning, isFinished: state.currentGame.isFinished, availableBlocksCount: state.currentGame.availableBlocksCount, diff --git a/lib/models/game.dart b/lib/models/game.dart index 31f0c9f9e78e0ae83c8f53c45252d7ba8ec746c1..94f253860ad7ce29a9e558e14a9378b69fa86e29 100644 --- a/lib/models/game.dart +++ b/lib/models/game.dart @@ -4,10 +4,12 @@ import 'package:jeweled/models/game_board.dart'; import 'package:jeweled/models/game_cell.dart'; import 'package:jeweled/models/cell_location.dart'; import 'package:jeweled/models/game_settings.dart'; +import 'package:jeweled/utils/color_theme.dart'; class Game { final GameBoard board; final GameSettings settings; + List<int> shuffledColors = []; bool isRunning = false; bool isFinished = false; int availableBlocksCount = 0; @@ -17,6 +19,7 @@ class Game { Game({ required this.board, required this.settings, + required this.shuffledColors, this.isRunning = false, this.isFinished = false, this.availableBlocksCount = 0, @@ -28,6 +31,7 @@ class Game { return Game( board: GameBoard.createNull(), settings: GameSettings.createDefault(), + shuffledColors: shuffleColors(), ); } @@ -37,10 +41,18 @@ class Game { return Game( board: GameBoard.createRandom(settings), settings: settings, + shuffledColors: shuffleColors(), isRunning: true, ); } + static List<int> shuffleColors() { + List<int> values = new List<int>.generate(ColorTheme.getColorsCount(), (i) => i + 1); + values.shuffle(); + + return values; + } + GameCell getCell(CellLocation cellLocation) { return this.board.cells[cellLocation.row][cellLocation.col]; } @@ -49,6 +61,11 @@ class Game { return this.getCell(cellLocation).value; } + int? getCellValueShuffled(CellLocation cellLocation) { + final int? value = this.getCell(cellLocation).value; + return value != null ? this.shuffledColors[value - 1] : null; + } + void updateCellValue(CellLocation locationToUpdate, int? value) { this.board.cells[locationToUpdate.row][locationToUpdate.col].value = value; } @@ -250,6 +267,7 @@ class Game { print(' movesCount: ' + movesCount.toString()); print(' score: ' + score.toString()); print(' availableBlocksCount: ' + availableBlocksCount.toString()); + print(' shuffledColors: ' + shuffledColors.toString()); print(''); } @@ -261,6 +279,7 @@ class Game { return <String, dynamic>{ 'board': this.board.toJson(), 'settings': this.settings.toJson(), + 'shuffledColors': this.shuffledColors, 'isRunning': this.isRunning, 'isFinished': this.isFinished, 'availableBlocksCount': this.availableBlocksCount, diff --git a/lib/ui/painters/game_board_painter.dart b/lib/ui/painters/game_board_painter.dart index 5bb11b449d3c403ce63966f8e4b8c1a461b407bf..0b476e574930a3cccf9a94deb7526df3f9f19b57 100644 --- a/lib/ui/painters/game_board_painter.dart +++ b/lib/ui/painters/game_board_painter.dart @@ -2,7 +2,6 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:jeweled/models/game_cell.dart'; import 'package:jeweled/models/game.dart'; import 'package:jeweled/models/cell_location.dart'; import 'package:jeweled/utils/color_theme.dart'; @@ -32,9 +31,9 @@ class GameBoardPainter extends CustomPainter { final double x = cellSize * col; final CellLocation cellLocation = CellLocation.go(row, col); - final GameCell cell = game.getCell(cellLocation); - if (cell.value != null) { - final int colorCode = ColorTheme.getColorCode(cell.value); + final int? cellValue = game.getCellValueShuffled(cellLocation); + if (cellValue != null) { + final int colorCode = ColorTheme.getColorCode(cellValue); final Animation<double>? translation = this.animations[row][col]; final double y = yOrigin + (translation?.value ?? 0) * cellSize; diff --git a/lib/utils/color_theme.dart b/lib/utils/color_theme.dart index 18d2006fc56b8a320b4caa921e2577aaf93216e2..c6172db55c6a28ea7610c19d0c2572022239bb69 100644 --- a/lib/utils/color_theme.dart +++ b/lib/utils/color_theme.dart @@ -3,26 +3,45 @@ import 'package:flutter/material.dart'; class ColorTheme { static Map<String, List<int>> itemColors = { 'default': [ - 0xffffff, - 0xe63a3f, - 0x708cfd, - 0x359c35, - 0xffce2c, - 0xff6f43, - 0xa13cb1, - 0x38ffff, - 0xf2739d, + 0x000000, + 0x9D9D9D, + 0xFFFFFF, + 0xBE2633, + 0xE06F8B, + 0x493C2B, + 0xA46422, + 0xEB8931, + 0xF7E26B, + 0x2F484E, + 0x44891A, + 0xA3CE27, + 0x1B2632, + 0x005784, + 0x31A2F2, + 0xB2DCEF, ], }; static int defaultItemColor = 0x808080; + static int getColorsCount() { + const skin = 'default'; + + if (itemColors.containsKey(skin) && null != itemColors[skin]) { + List<int> skinColors = itemColors[skin] ?? []; + + return skinColors.length; + } + + return 0; + } + static int getColorCode(int? value) { const skin = 'default'; if (value != null && itemColors.containsKey(skin) && null != itemColors[skin]) { List<int> skinColors = itemColors[skin] ?? []; if (skinColors.length > value) { - return (skinColors[value]) | 0xFF000000; + return (skinColors[value % getColorsCount()]) | 0xFF000000; } } return defaultItemColor | 0xFF000000; diff --git a/pubspec.yaml b/pubspec.yaml index e4140c6070a4d6c8b98355f2c9f0aa80155eeda1..caa9a7c3d0b81ca818846ea2d166a61bbee5aaf8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Jeweled Game publish_to: 'none' -version: 0.0.14+14 +version: 0.0.15+15 environment: sdk: '^3.0.0'