Skip to content
Snippets Groups Projects
Commit 0f87f5ad authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Finalize gameplay

parent b965e1de
No related branches found
No related tags found
1 merge request!5Resolve "Finalize gameplay"
Pipeline #1794 passed
Showing
with 91 additions and 20 deletions
Finalisation du jeu minimal.
......@@ -43,19 +43,33 @@ function build_icon() {
optipng ${OPTIPNG_OPTIONS} ${TARGET}
}
function build_icon_for_skin() {
function build_icons_for_skin() {
SKIN_CODE="$1"
build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/mine.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_mine.png
build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/unknown.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_unknown.png
build_icon_for_skin ${SKIN_CODE} button_mark_mine_on
build_icon_for_skin ${SKIN_CODE} button_mark_mine_off
build_icon_for_skin ${SKIN_CODE} tile_mine
build_icon_for_skin ${SKIN_CODE} tile_mine_not_found
build_icon_for_skin ${SKIN_CODE} tile_flag
build_icon_for_skin ${SKIN_CODE} tile_flag_ok
build_icon_for_skin ${SKIN_CODE} tile_flag_ko
build_icon_for_skin ${SKIN_CODE} tile_unknown
for VALUE in {0..8};
do
if [ -f "${CURRENT_DIR}/skins/${SKIN_CODE}/${VALUE}.svg" ]; then
build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/${VALUE}.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_${VALUE}.png
fi
build_icon_for_skin ${SKIN_CODE} tile_${VALUE}
done
}
function build_icon_for_skin() {
SKIN_CODE="$1"
IMAGE_CODE="$2"
build_icon ${CURRENT_DIR}/skins/${SKIN_CODE}/${IMAGE_CODE}.svg ${BASE_DIR}/assets/skins/${SKIN_CODE}_${IMAGE_CODE}.png
}
# Game icons
build_icon ${CURRENT_DIR}/button_back.svg ${BASE_DIR}/assets/icons/button_back.png
build_icon ${CURRENT_DIR}/button_start.svg ${BASE_DIR}/assets/icons/button_start.png
......@@ -71,4 +85,4 @@ build_icon ${CURRENT_DIR}/size_20x20.svg ${BASE_DIR}/assets/icons/size_20x20.png
build_icon ${CURRENT_DIR}/skins/empty.svg ${BASE_DIR}/assets/skins/empty.png
# Skins
build_icon_for_skin "default"
build_icons_for_skin "default"
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 93.665 93.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect x="-.0013123" y="-.0014381" width="93.668" height="93.679" ry="0" fill="#ea9c1f" stroke="#fff" stroke-width=".24146"/><path d="m62.564 39.496c-4.3118 1.5875-7.5974 2.7182-10.487 6.2927-2.5748 3.1852-6.2927 4.2894-10.487 2.1897v11.444h-2.0975v-28.316c0-0.5797 0.46905-1.0487 1.0487-1.0487s1.0487 0.46905 1.0487 1.0487c2.329 3.3859 6.3764 4.1356 10.487 4.195 6.2927 0.09216 10.487 4.195 10.487 4.195zm-18.878 13.913v2.1344c2.4744 0.50594 4.195 1.5793 4.195 2.8309 0 1.737-3.2876 3.1463-7.3413 3.1463s-7.3413-1.4093-7.3413-3.1463c0-1.2516 1.7206-2.3249 4.195-2.8309v-2.1343c-3.8099 0.65962-6.2927 2.5072-6.2927 4.9652 0 3.0869 3.8816 5.2437 9.4389 5.2437s9.4389-2.1569 9.4389-5.2437c0-2.458-2.4826-4.3055-6.2927-4.9652z" fill="#af0303" stroke="#730202" stroke-linejoin="round" stroke-width=".84528"/></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 93.665 93.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect x="-.0013123" y="-.0014381" width="93.668" height="93.679" ry="0" fill="#ea9c1f" stroke="#fff" stroke-width=".24146"/><path d="m84.054 29.467c-10.202 3.7561-17.976 6.4314-24.814 14.889-6.0921 7.5364-14.889 10.149-24.814 5.1809v27.078h-4.9628v-66.998c0-1.3716 1.1098-2.4814 2.4814-2.4814s2.4814 1.1098 2.4814 2.4814c5.5105 8.0113 15.087 9.7852 24.814 9.9257 14.889 0.21806 24.814 9.9257 24.814 9.9257zm-44.666 32.918v5.0502c5.8546 1.1971 9.9257 3.7367 9.9257 6.698 0 4.1099-7.7786 7.4443-17.37 7.4443-9.5913 0-17.37-3.3346-17.37-7.4444 0-2.9613 4.0711-5.5009 9.9257-6.698v-5.05c-9.0146 1.5607-14.889 5.9322-14.889 11.748 0 7.3038 9.1842 12.407 22.333 12.407s22.333-5.1034 22.333-12.407c0-5.8158-5.874-10.187-14.889-11.748z" fill="#af0303" stroke="#730202" stroke-linejoin="round" stroke-width="2"/></svg>
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 100 100" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" ry="2" fill="none"/><path d="m87.221 32.63c-10.202 3.7561-17.976 6.4314-24.814 14.889-6.0921 7.5364-14.889 10.149-24.814 5.1809v27.078h-4.9628v-66.998c0-1.3716 1.1098-2.4814 2.4814-2.4814s2.4814 1.1098 2.4814 2.4814c5.5105 8.0113 15.087 9.7852 24.814 9.9257 14.889 0.21806 24.814 9.9257 24.814 9.9257zm-44.666 32.918v5.0502c5.8546 1.1971 9.9257 3.7367 9.9257 6.698 0 4.1099-7.7786 7.4443-17.37 7.4443-9.5913 0-17.37-3.3346-17.37-7.4444 0-2.9613 4.0711-5.5009 9.9257-6.698v-5.05c-9.0146 1.5607-14.889 5.9322-14.889 11.748 0 7.3038 9.1842 12.407 22.333 12.407s22.333-5.1034 22.333-12.407c0-5.8158-5.874-10.187-14.889-11.748z" fill="#e86f04" stroke="#773802" stroke-linejoin="round" stroke-width="2"/></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 100 100" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" ry="2" fill="none"/><path d="m87.221 32.63c-10.202 3.7561-17.976 6.4314-24.814 14.889-6.0921 7.5364-14.889 10.149-24.814 5.1809v27.078h-4.9628v-66.998c0-1.3716 1.1098-2.4814 2.4814-2.4814s2.4814 1.1098 2.4814 2.4814c5.5105 8.0113 15.087 9.7852 24.814 9.9257 14.889 0.21806 24.814 9.9257 24.814 9.9257zm-44.666 32.918v5.0502c5.8546 1.1971 9.9257 3.7367 9.9257 6.698 0 4.1099-7.7786 7.4443-17.37 7.4443-9.5913 0-17.37-3.3346-17.37-7.4444 0-2.9613 4.0711-5.5009 9.9257-6.698v-5.05c-9.0146 1.5607-14.889 5.9322-14.889 11.748 0 7.3038 9.1842 12.407 22.333 12.407s22.333-5.1034 22.333-12.407c0-5.8158-5.874-10.187-14.889-11.748z" fill="#e80604" stroke="#770302" stroke-linejoin="round" stroke-width="2"/></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 100 100" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" ry="2" fill="none"/><path d="m87.221 32.63c-10.202 3.7561-17.976 6.4314-24.814 14.889-6.0921 7.5364-14.889 10.149-24.814 5.1809v27.078h-4.9628v-66.998c0-1.3716 1.1098-2.4814 2.4814-2.4814s2.4814 1.1098 2.4814 2.4814c5.5105 8.0113 15.087 9.7852 24.814 9.9257 14.889 0.21806 24.814 9.9257 24.814 9.9257zm-44.666 32.918v5.0502c5.8546 1.1971 9.9257 3.7367 9.9257 6.698 0 4.1099-7.7786 7.4443-17.37 7.4443-9.5913 0-17.37-3.3346-17.37-7.4444 0-2.9613 4.0711-5.5009 9.9257-6.698v-5.05c-9.0146 1.5607-14.889 5.9322-14.889 11.748 0 7.3038 9.1842 12.407 22.333 12.407s22.333-5.1034 22.333-12.407c0-5.8158-5.874-10.187-14.889-11.748z" fill="#5aaf03" stroke="#027302" stroke-linejoin="round" stroke-width="2"/></svg>
File moved
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 100 100" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" ry="2" fill="none"/><g transform="matrix(1.0346 0 0 1.0346 -1.7311 -1.7312)" fill="#787878" stroke="#444343" stroke-width="1.9331"><path d="m92.148 55.869c-0.626-0.939-1.482-1.519-2.568-1.739l-6.792-1.242c0.368-5.669-0.727-11.035-3.286-16.096l5.853-4.224c0.939-0.663 1.491-1.574 1.657-2.733 0.202-1.086-0.037-2.071-0.718-2.954l-0.469-0.718c-0.626-0.883-1.537-1.427-2.733-1.629-1.031-0.166-2.016 0.092-2.954 0.773l-5.632 4.059c-3.81-4.215-8.347-7.206-13.611-8.973l1.27-7.731c0.202-1.104-0.037-2.126-0.718-3.065-0.626-0.883-1.482-1.427-2.568-1.629l-0.856-0.166c-1.104-0.147-2.126 0.092-3.065 0.718-0.884 0.681-1.427 1.565-1.629 2.65l-1.16 7.427c-2.503-0.221-4.951-0.175-7.344 0.138-1.362 0.055-2.641 0.294-3.838 0.718-0.626 0.147-1.224 0.331-1.795 0.552l-3.451-7.51c-0.46-0.994-1.215-1.693-2.264-2.098-1.031-0.423-2.043-0.405-3.037 0.055l-0.773 0.414c-0.994 0.405-1.73 1.16-2.209 2.264-0.368 1.031-0.313 2.043 0.166 3.037l3.506 7.648c-0.202 0.11-0.405 0.249-0.607 0.414-5.264 3.681-9.019 8.31-11.265 13.888l-6.958-1.546c-1.086-0.276-2.098-0.074-3.037 0.607-0.994 0.534-1.592 1.344-1.795 2.43l-0.246 0.772c-0.203 1.104-0.018 2.172 0.552 3.203 0.626 0.883 1.491 1.463 2.595 1.739l6.626 1.546c-0.736 5.835 0.101 11.329 2.512 16.483l-5.411 3.672c-0.939 0.626-1.537 1.491-1.795 2.595-0.147 1.086 0.092 2.098 0.718 3.037l0.469 0.635c0.626 0.939 1.454 1.537 2.485 1.795 1.16 0.147 2.209-0.092 3.147-0.718l5.135-3.424c3.7 4.583 8.255 7.887 13.667 9.912l-1.242 6.323c-0.202 1.104 9e-3 2.154 0.635 3.147 0.626 0.883 1.482 1.427 2.568 1.629l0.801 0.166c1.086 0.258 2.098 0.101 3.037-0.469 0.939-0.681 1.509-1.574 1.712-2.678l1.242-6.074c6 0.626 11.651-0.285 16.952-2.733l4.003 6.074c0.626 0.939 1.509 1.518 2.651 1.739 1.049 0.258 2.043 0.074 2.982-0.552l0.69-0.387c0.939-0.626 1.537-1.518 1.795-2.678 0.203-1.086-9e-3 -2.098-0.635-3.037l-3.81-5.936c4.583-3.7 7.841-8.255 9.774-13.667l6.875 1.242c1.086 0.202 2.098-9e-3 3.037-0.635 0.883-0.607 1.427-1.463 1.629-2.568l0.166-0.773c0.202-1.103-0.01-2.143-0.636-3.119zm-50.085-15.013c-0.824 1.929-2.217 3.297-4.178 4.102-1.962 0.806-3.92 0.815-5.876 0.028-1.936-0.778-3.299-2.13-4.09-4.056s-0.774-3.853 0.05-5.782c0.844-1.92 2.247-3.284 4.209-4.089 1.962-0.806 3.91-0.819 5.846-0.041 1.956 0.787 3.329 2.144 4.12 4.069 0.79 1.925 0.763 3.848-0.081 5.769z" fill="#787878" stroke="#444343" stroke-width="1.9331"/></g></svg>
......@@ -7,6 +7,7 @@ class Cell {
bool isMined = false;
bool isExplored = false;
bool isMarked = false;
bool isExploded = false;
int minesCountAround = 0;
Cell(
......@@ -14,17 +15,10 @@ class Cell {
);
Container widget(Data myProvider, int row, int col) {
String imageAsset = 'assets/skins/' + myProvider.skin + '_unknown.png';
bool showSolution = myProvider.gameWin || myProvider.gameFail;
Color backgroundColor = this.getBackgroundColor();
if (this.isExplored) {
if (this.isMined) {
imageAsset = 'assets/skins/' + myProvider.skin + '_mine.png';
} else {
imageAsset = 'assets/skins/' + myProvider.skin + '_' + this.minesCountAround.toString() + '.png';
}
}
Color backgroundColor = this.getBackgroundColor(myProvider);
String imageAsset = this.getImageAssetName(myProvider.skin, showSolution);
return Container(
decoration: BoxDecoration(
......@@ -40,14 +34,64 @@ class Cell {
fit: BoxFit.fill,
),
onTap: () {
if (!(myProvider.gameWin || myProvider.gameFail)) {
if (myProvider.reportMode) {
BoardUtils.reportCell(myProvider, row, col);
} else {
BoardUtils.walkOnCell(myProvider, row, col);
BoardUtils.checkBoardIsSolved(myProvider);
}
}
BoardUtils.checkGameIsFinished(myProvider);
},
),
);
}
Color getBackgroundColor() {
String getImageAssetName(String skin, bool showSolution) {
String imageAsset = 'assets/skins/' + skin + '_tile_unknown.png';
if (!showSolution) {
// Running game
if (this.isExplored) {
if (this.isMined) {
// Boom
imageAsset = 'assets/skins/' + skin + '_tile_mine.png';
} else {
// Show mines count around
imageAsset = 'assets/skins/' + skin + '_tile_' + this.minesCountAround.toString() + '.png';
}
} else {
if (this.isMarked) {
// Danger!
imageAsset = 'assets/skins/' + skin + '_tile_flag.png';
}
}
} else {
// Finished game
if (this.isMined) {
if (this.isExploded) {
// Mine exploded
imageAsset = 'assets/skins/' + skin + '_tile_mine.png';
} else {
// Mine not found
imageAsset = 'assets/skins/' + skin + '_tile_mine_not_found.png';
}
} else {
// Show all mines counts
imageAsset = 'assets/skins/' + skin + '_tile_' + this.minesCountAround.toString() + '.png';
}
}
return imageAsset;
}
Color getBackgroundColor(Data myProvider) {
if (myProvider.gameWin) {
return Colors.green[300];
} else if (myProvider.gameFail) {
return Colors.pink[200];
}
return Colors.white;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment