Browse Source

Merge minesweeper from https://github.com/xMasterX/all-the-plugins

Willy-JL 2 years ago
parent
commit
0323977b43
4 changed files with 12 additions and 4 deletions
  1. 3 1
      minesweeper/application.fam
  2. BIN
      minesweeper/img/1.png
  3. BIN
      minesweeper/img/2.png
  4. 9 3
      minesweeper/minesweeper.c

+ 3 - 1
minesweeper/application.fam

@@ -3,10 +3,12 @@ App(
     name="Minesweeper",
     name="Minesweeper",
     apptype=FlipperAppType.EXTERNAL,
     apptype=FlipperAppType.EXTERNAL,
     entry_point="minesweeper_app",
     entry_point="minesweeper_app",
-    cdefines=["APP_MINESWEEPER"],
     requires=["gui"],
     requires=["gui"],
     stack_size=8 * 1024,
     stack_size=8 * 1024,
     fap_category="Games",
     fap_category="Games",
     fap_icon="minesweeper_icon.png",
     fap_icon="minesweeper_icon.png",
     order=35,
     order=35,
+    fap_author="@panki27 & @xMasterX",
+    fap_version="1.1",
+    fap_description="Minesweeper Game",
 )
 )

BIN
minesweeper/img/1.png


BIN
minesweeper/img/2.png


+ 9 - 3
minesweeper/minesweeper.c

@@ -6,7 +6,8 @@
 
 
 #include <notification/notification_messages.h>
 #include <notification/notification_messages.h>
 #include <dialogs/dialogs.h>
 #include <dialogs/dialogs.h>
-#include <m-string.h>
+
+#include <dolphin/dolphin.h>
 
 
 #include "assets.h"
 #include "assets.h"
 
 
@@ -70,6 +71,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
     furi_assert(ctx);
     furi_assert(ctx);
     const Minesweeper* minesweeper_state = ctx;
     const Minesweeper* minesweeper_state = ctx;
     furi_mutex_acquire(minesweeper_state->mutex, FuriWaitForever);
     furi_mutex_acquire(minesweeper_state->mutex, FuriWaitForever);
+
     FuriString* mineStr;
     FuriString* mineStr;
     FuriString* timeStr;
     FuriString* timeStr;
     mineStr = furi_string_alloc();
     mineStr = furi_string_alloc();
@@ -199,7 +201,6 @@ static void place_flag(Minesweeper* minesweeper_state) {
 
 
 static bool game_lost(Minesweeper* minesweeper_state) {
 static bool game_lost(Minesweeper* minesweeper_state) {
     // returns true if the player wants to restart, otherwise false
     // returns true if the player wants to restart, otherwise false
-
     DialogMessage* message = dialog_message_alloc();
     DialogMessage* message = dialog_message_alloc();
 
 
     dialog_message_set_header(message, "Game Over", 64, 3, AlignCenter, AlignTop);
     dialog_message_set_header(message, "Game Over", 64, 3, AlignCenter, AlignTop);
@@ -237,6 +238,9 @@ static bool game_won(Minesweeper* minesweeper_state) {
         message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter);
         message, furi_string_get_cstr(tempStr), 64, 32, AlignCenter, AlignCenter);
     dialog_message_set_buttons(message, NULL, "Play again", NULL);
     dialog_message_set_buttons(message, NULL, "Play again", NULL);
 
 
+    // Call dolphin deed when we win the game
+    dolphin_deed(DolphinDeedPluginGameWin);
+
     DialogMessageButton choice = dialog_message_show(minesweeper_state->dialogs, message);
     DialogMessageButton choice = dialog_message_show(minesweeper_state->dialogs, message);
     dialog_message_free(message);
     dialog_message_free(message);
     furi_string_free(tempStr);
     furi_string_free(tempStr);
@@ -350,7 +354,6 @@ static void minesweeper_state_init(Minesweeper* const minesweeper_state) {
 
 
 int32_t minesweeper_app(void* p) {
 int32_t minesweeper_app(void* p) {
     UNUSED(p);
     UNUSED(p);
-
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
 
 
     Minesweeper* minesweeper_state = malloc(sizeof(Minesweeper));
     Minesweeper* minesweeper_state = malloc(sizeof(Minesweeper));
@@ -392,6 +395,9 @@ int32_t minesweeper_app(void* p) {
     Gui* gui = furi_record_open(RECORD_GUI);
     Gui* gui = furi_record_open(RECORD_GUI);
     gui_add_view_port(gui, view_port, GuiLayerFullscreen);
     gui_add_view_port(gui, view_port, GuiLayerFullscreen);
 
 
+    // Call dolphin deed on game start
+    dolphin_deed(DolphinDeedPluginGameStart);
+
     PluginEvent event;
     PluginEvent event;
     for(bool processing = true; processing;) {
     for(bool processing = true; processing;) {
         FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
         FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);