Bläddra i källkod

graphic updates
card placing logic

Tibor Tálosi 2 år sedan
förälder
incheckning
c4e04d226f
11 ändrade filer med 182 tillägg och 90 borttagningar
  1. 3 0
      Deck.h
  2. 107 11
      Game.cpp
  3. 2 1
      Game.h
  4. 46 9
      TableauColumn.cpp
  5. 6 2
      TableauColumn.h
  6. 9 9
      assets.h
  7. BIN
      assets/logo.png
  8. 0 56
      defines.h
  9. 1 2
      solitaire.cpp
  10. 7 0
      utils/Card.cpp
  11. 1 0
      utils/Card.h

+ 3 - 0
Deck.h

@@ -1,7 +1,9 @@
 #pragma once
 #pragma once
 
 
+#include <furi_hal_resources.h>
 #include "utils/Card.h"
 #include "utils/Card.h"
 #include "utils/List.h"
 #include "utils/List.h"
+#include "TableauColumn.h"
 
 
 class Deck {
 class Deck {
     List<Card> stock_pile;
     List<Card> stock_pile;
@@ -15,4 +17,5 @@ public:
     Card* GetLastWaste();
     Card* GetLastWaste();
     void AddToWaste(Card* c);
     void AddToWaste(Card* c);
     Card* Extract();
     Card* Extract();
+    void Click(InputKey key, bool isDeck, TableauColumn *hand);
 };
 };

+ 107 - 11
Game.cpp

@@ -1,10 +1,27 @@
 #include "Game.h"
 #include "Game.h"
 #include "assets.h"
 #include "assets.h"
+#include <notification/notification.h>
+#include <notification/notification_messages.h>
 
 
 static Sprite logo = Sprite(sprite_logo, BlackOnly);
 static Sprite logo = Sprite(sprite_logo, BlackOnly);
 static Sprite main_image = Sprite(sprite_main_image, BlackOnly);
 static Sprite main_image = Sprite(sprite_main_image, BlackOnly);
 static Sprite start = Sprite(sprite_start, BlackOnly);
 static Sprite start = Sprite(sprite_start, BlackOnly);
 
 
+static const NotificationSequence sequence_fail = {
+        &message_vibro_on,
+        &message_note_c4,
+        &message_delay_10,
+        &message_vibro_off,
+        &message_sound_off,
+        &message_delay_10,
+
+        &message_vibro_on,
+        &message_note_a3,
+        &message_delay_10,
+        &message_vibro_off,
+        &message_sound_off
+};
+
 Game::~Game() {
 Game::~Game() {
     delete deck;
     delete deck;
     for (int i = 0; i < 4; i++)
     for (int i = 0; i < 4; i++)
@@ -20,7 +37,6 @@ void Game::Render(Canvas *const canvas) {
             buffer->draw(&logo, (Vector) {60, 30}, 0);
             buffer->draw(&logo, (Vector) {60, 30}, 0);
             buffer->draw(&main_image, (Vector) {110, 25}, 0);
             buffer->draw(&main_image, (Vector) {110, 25}, 0);
             buffer->draw(&start, (Vector) {64, 55}, 0);
             buffer->draw(&start, (Vector) {64, 55}, 0);
-
         } else if (state == GameStatePlay) {
         } else if (state == GameStatePlay) {
             buffer->clear();
             buffer->clear();
             if (deck)
             if (deck)
@@ -40,6 +56,8 @@ void Game::Render(Canvas *const canvas) {
                     }
                     }
                 }
                 }
             }
             }
+            if (hand.Count() > 0)
+                hand.Render(current_column * 18 + 10, current_row * 25 + 15, false, 0, buffer);
         }
         }
     }
     }
     had_change = false;
     had_change = false;
@@ -62,6 +80,9 @@ void Game::Reset() {
     current_column = 0;
     current_column = 0;
     current_row = 0;
     current_row = 0;
     column_selection = -1;
     column_selection = -1;
+    hand.Clear();
+    picked_from_column = -1;
+    picked_from_row = -1;
 
 
     deck->Generate();
     deck->Generate();
     //Reset foundations
     //Reset foundations
@@ -85,11 +106,11 @@ void Game::LongPress(InputKey key) {
     UNUSED(key);
     UNUSED(key);
 }
 }
 
 
-void Game::Update(NotificationApp *app) {
-    UNUSED(app);
+void Game::Update() {
 }
 }
 
 
 void Game::Press(InputKey key) {
 void Game::Press(InputKey key) {
+//region Navigation
     if (key == InputKeyOk && state == GameStateStart) {
     if (key == InputKeyOk && state == GameStateStart) {
         Reset();
         Reset();
         NewRound();
         NewRound();
@@ -103,11 +124,6 @@ void Game::Press(InputKey key) {
         return;
         return;
     }
     }
 
 
-    if(key == InputKeyOk && current_column == 0 && current_row == 0){
-        deck->Cycle();
-        had_change = true;
-    }
-
     if (key == InputKeyLeft && current_column > 0) {
     if (key == InputKeyLeft && current_column > 0) {
         current_column--;
         current_column--;
         had_change = true;
         had_change = true;
@@ -118,9 +134,9 @@ void Game::Press(InputKey key) {
     }
     }
 
 
     if (key == InputKeyUp && current_row == 1) {
     if (key == InputKeyUp && current_row == 1) {
-        uint8_t count = tableau[current_column].Count() - 1;
+        uint8_t count = tableau[current_column].Count()-1;
         uint8_t first_non_flipped = tableau[current_column].FirstNonFlipped();
         uint8_t first_non_flipped = tableau[current_column].FirstNonFlipped();
-        if (count > first_non_flipped && (column_selection + 1) > count) {
+        if (count > first_non_flipped && (column_selection) < count) {
             column_selection++;
             column_selection++;
         } else
         } else
             current_row--;
             current_row--;
@@ -130,11 +146,91 @@ void Game::Press(InputKey key) {
         current_row++;
         current_row++;
         column_selection = 0;
         column_selection = 0;
         had_change = true;
         had_change = true;
+    } else if (key == InputKeyDown && current_row == 1 && column_selection > 0) {
+        column_selection--;
+        had_change = true;
     }
     }
 
 
     //disable empty space selection
     //disable empty space selection
     if (current_row == 0 && current_column == 2) {
     if (current_row == 0 && current_column == 2) {
         current_column--;
         current_column--;
+        column_selection = 0;
         had_change = true;
         had_change = true;
     }
     }
-}
+//endregion
+
+    //Pick/cycle logic
+    if (hand.Count() == 0) {
+        if (key == InputKeyOk) {
+            if (current_row == 0) {
+                //cycle deck
+                if (current_column == 0) {
+                    deck->Cycle();
+                    had_change = true;
+                } else if (current_column == 1) {
+                    //pick from deck
+                    Card *c = deck->GetLastWaste();
+                    if (c) {
+                        hand.AddCard(c);
+                        picked_from_column = current_column;
+                        picked_from_row = current_row;
+                        had_change = true;
+                    }
+                }
+                return;
+            } else {
+                //Tableau logic
+                auto *column = &tableau[current_column];
+                //Flip last card if it is not exposed
+                if (column->Count() > 0) {
+                    if (!column->LastCard()->exposed) {
+                        column->Reveal();
+                        had_change = true;
+                    } else {
+                        //Pick selection
+                        hand.AddCard(column->Pop());
+                        had_change = true;
+                        picked_from_row = current_row;
+                        picked_from_column = current_column;
+                    }
+                } else {
+                    ErrorMessage();
+                }
+                return;
+            }
+        }
+    } else {
+        //Place logic
+        if (key == InputKeyOk) {
+            if (current_column == picked_from_column && current_row == picked_from_row) {
+                //add back to tableau
+                if (picked_from_row == 0) {
+                    had_change = true;
+                    deck->AddToWaste(hand.Pop());
+                }
+            } else if (hand.Count() == 1 && current_row == 0 && current_column > 1) {
+                Card *current = piles[current_column - 3];
+                if (Card::CanPlace(current, hand.TopCard())) {
+                    piles[current_column - 3] = hand.Pop();
+                    had_change = true;
+                } else {
+                    ErrorMessage();
+                }
+            } else if (current_row == 1) {
+                auto *column = &tableau[current_column];
+                if ((current_row == picked_from_row && current_column == picked_from_column) ||
+                    column->CanPlace(&hand)) {
+                    column->Merge(&hand);
+                    had_change = true;
+                }
+            } else {
+                ErrorMessage();
+            }
+            return;
+        }
+    }
+}
+
+void Game::ErrorMessage() {
+
+}

+ 2 - 1
Game.h

@@ -43,7 +43,8 @@ public:
 
 
     void LongPress(InputKey key);
     void LongPress(InputKey key);
     void Press(InputKey key);
     void Press(InputKey key);
-    void Update(NotificationApp *app);
+    void Update();
+    void ErrorMessage();
 
 
     ~Game();
     ~Game();
 };
 };

+ 46 - 9
TableauColumn.cpp

@@ -22,7 +22,7 @@ void TableauColumn::Render(uint8_t x, uint8_t y, bool selected, uint8_t selectio
     if (cards->count == 0) {
     if (cards->count == 0) {
         Card::RenderEmptyCard(x, y, buffer);
         Card::RenderEmptyCard(x, y, buffer);
         if (selected)
         if (selected)
-            buffer->draw_rbox(x, y, x + 16, y + 22, Flip);
+            buffer->draw_rbox(x+1, y+1, x + 16, y + 22, Flip);
         return;
         return;
     }
     }
     uint8_t selection = cards->count - selection_from_end;
     uint8_t selection = cards->count - selection_from_end;
@@ -38,14 +38,15 @@ void TableauColumn::Render(uint8_t x, uint8_t y, bool selected, uint8_t selectio
     if (first_non_flipped <= loop_start && selection != first_non_flipped) {
     if (first_non_flipped <= loop_start && selection != first_non_flipped) {
         // Draw a card back if it is not the first card
         // Draw a card back if it is not the first card
         if (first_non_flipped > 0) {
         if (first_non_flipped > 0) {
-            Card::RenderBack(x, y + position, selection == first_non_flipped, buffer, 4);
+            Card::RenderBack(x, y + position, selection == first_non_flipped, buffer, 5);
             // Increment loop start index and position
             // Increment loop start index and position
             position += 4;
             position += 4;
             loop_start++;
             loop_start++;
             had_top = true;
             had_top = true;
         }
         }
         // Draw the front side of the first non-flipped card
         // Draw the front side of the first non-flipped card
-        (*cards)[first_non_flipped]->Render(x, y + position, selection == first_non_flipped, buffer, cards->count == 1 ? 22 : 8);
+        (*cards)[first_non_flipped]->Render(x, y + position, selection == first_non_flipped, buffer,
+                                            cards->count == 1 ? 22 : 9);
         position += 8;
         position += 8;
         loop_start++; // Increment loop start index
         loop_start++; // Increment loop start index
     }
     }
@@ -53,19 +54,23 @@ void TableauColumn::Render(uint8_t x, uint8_t y, bool selected, uint8_t selectio
     // Draw the selected card with adjusted visibility
     // Draw the selected card with adjusted visibility
     if (loop_start > selection) {
     if (loop_start > selection) {
         if (!had_top && first_non_flipped > 0) {
         if (!had_top && first_non_flipped > 0) {
-            Card::RenderBack(x, y + position, selection == first_non_flipped, buffer,4);
+            Card::RenderBack(x, y + position, selection == first_non_flipped, buffer, 5);
             position += 2;
             position += 2;
             loop_start++;
             loop_start++;
         }
         }
         // Draw the front side of the selected card
         // Draw the front side of the selected card
-        (*cards)[selection]->Render(x, y + position, true, buffer, 8);
+        (*cards)[selection]->Render(x, y + position, true, buffer, 9);
         position += 8;
         position += 8;
         loop_start++; // Increment loop start index
         loop_start++; // Increment loop start index
     }
     }
 
 
     //Draw the rest
     //Draw the rest
     for (uint8_t i = loop_start; i < loop_end; i++, position += 4) {
     for (uint8_t i = loop_start; i < loop_end; i++, position += 4) {
-        (*cards)[i]->Render(x, y + position, i == selection, buffer, (i+1)==loop_end ? 22 : 4);
+        int height = 5;
+        if((i + 1) == loop_end) height = 22;
+        else if(i == first_non_flipped) height = 9;
+
+        (*cards)[i]->Render(x, y + position, i == selection, buffer, height);
 
 
         if (i == selection || i == first_non_flipped) position += 4;
         if (i == selection || i == first_non_flipped) position += 4;
     }
     }
@@ -92,10 +97,11 @@ TableauColumn::~TableauColumn() {
     delete cards;
     delete cards;
 }
 }
 
 
-void TableauColumn::AddTo(TableauColumn *other) {
+void TableauColumn::Merge(TableauColumn *other) {
     for (auto *item: *(other->cards)) {
     for (auto *item: *(other->cards)) {
         cards->add(item);
         cards->add(item);
     }
     }
+    other->cards->soft_clear();
 }
 }
 
 
 Card *TableauColumn::TopCard() {
 Card *TableauColumn::TopCard() {
@@ -106,6 +112,37 @@ uint8_t TableauColumn::Count() {
     return cards->count;
     return cards->count;
 }
 }
 
 
-List<Card>* TableauColumn::ExtractEnd(uint8_t count) {
-    return cards->splice(cards->count - count, count);
+Card *TableauColumn::Pop() {
+    return cards->pop();
+}
+
+void TableauColumn::Reveal() {
+    (*cards)[cards->count - 1]->exposed = true;
+}
+
+Card *TableauColumn::LastCard() {
+    if (cards->count > 0) {
+        return (*cards)[cards->count - 1];
+    }
+    return nullptr;
+}
+
+void TableauColumn::Clear() {
+    cards->soft_clear();
+}
+
+bool TableauColumn::CanPlace(TableauColumn *other) {
+    if (cards->count == 0) {
+        if(other->TopCard()->value == 11) FURI_LOG_D("TBLC", "placing first");
+        return other->TopCard()->value == 11;
+    }
+    Card *last = LastCard();
+    Card *top = other->TopCard();
+    int current_suit = last->suit / 2;
+    int other_suit = top->suit / 2;
+    if((current_suit + 1) % 2 == other_suit && (last->value + 1) % 13 == (top->value + 2) % 13) FURI_LOG_D("TBLC", "Adding at end");
+    else
+        FURI_LOG_D("TBLC", "CANT ADD, suit check %i, label check %i", (current_suit + 1) % 2 == other_suit, (last->value + 1) % 13 == (top->value + 2) % 13);
+
+    return (current_suit + 1) % 2 == other_suit && (last->value + 1) % 13 == (top->value + 2) % 13;
 }
 }

+ 6 - 2
TableauColumn.h

@@ -12,12 +12,16 @@ public:
     ~TableauColumn();
     ~TableauColumn();
     void Reset();
     void Reset();
     void AddCard(Card *c);
     void AddCard(Card *c);
+    void Clear();
     void AddRange(List<Card> *hand);
     void AddRange(List<Card> *hand);
-    void AddTo(TableauColumn *other);
-    List<Card>* ExtractEnd(uint8_t count);
+    void Merge(TableauColumn *other);
     void Render(uint8_t x, uint8_t y, bool selected, uint8_t selection, RenderBuffer *buffer);
     void Render(uint8_t x, uint8_t y, bool selected, uint8_t selection, RenderBuffer *buffer);
     Card* TopCard();
     Card* TopCard();
+    Card* LastCard();
 
 
     int8_t FirstNonFlipped();
     int8_t FirstNonFlipped();
     uint8_t Count();
     uint8_t Count();
+    Card* Pop();
+    void Reveal();
+    bool CanPlace(TableauColumn *other);
 };
 };

+ 9 - 9
assets.h

@@ -307,18 +307,18 @@ const SpriteData sprite_clubs = (SpriteData) {.width=7, .height=7, .data=(uint8_
 ███                                                                                                                                                                                                            ███
 ███                                                                                                                                                                                                            ███
 ██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
 ██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
                                                                                                       ███                                                                                          ███            
                                                                                                       ███                                                                                          ███            
-                                                                                                      ███                                                                        ███               ███            
-                                                                                                      ███   ███                        █████████                              ███                  ███            
-                                                                                                      ███   ██████      ███   ███      ███      ███      ███         ███   █████████   ███   ███   ███            
-                                                                                                      ███   ███   ███   ███   ███      ███      ███   ███   ███   ███   ███   ███      ███   ███   ███            
-                                                                                                      ███   ███   ███      ███         ███      ███   ███   ███   ███   ███   ███         ███      ███            
-                                                                                                      ███   ██████         ███         █████████         ███         ███      ███         ███      ███            
-                                                                                                      ███                                                                                          ███            
+      ███         ███               ███                     ███                  █████████            ███                                                                        ███               ███            
+   ███   ███   ███   ███         ███   ███               █████████               █████████            ███   ███                        █████████                              ███                  ███            
+   ███      ███      ███      ███         ███         ███████████████      ██████   ███   ██████      ███   ██████      ███   ███      ███      ███      ███         ███   █████████   ███   ███   ███            
+   ███               ███   ███               ███   █████████████████████   █████████████████████      ███   ███   ███   ███   ███      ███      ███   ███   ███   ███   ███   ███      ███   ███   ███            
+      ███         ███         ███         ███      ██████   ███   ██████   ██████   ███   ██████      ███   ███   ███      ███         ███      ███   ███   ███   ███   ███   ███         ███      ███            
+         ███   ███               ███   ███                  ███                     ███               ███   ██████         ███         █████████         ███         ███      ███         ███      ███            
+            ███                     ███                  █████████               █████████            ███                                                                                          ███            
                                                                                                       ████████████████████████████████████████████████████████████████████████████████████████████████            
                                                                                                       ████████████████████████████████████████████████████████████████████████████████████████████████            
 */
 */
 const SpriteData sprite_logo = (SpriteData) {.width=70, .height=29, .data=(uint8_t[]) {
 const SpriteData sprite_logo = (SpriteData) {.width=70, .height=29, .data=(uint8_t[]) {
 		0xff, 0x1, 0x1, 0x1, 0xe1, 0xf1, 0x39, 0x19, 0x19, 0x19, 0x39, 0x71, 0x61, 0x1, 0x1, 0x1, 0x81, 0x81, 0x81, 0x81, 0x1, 0x1, 0x1, 0x1, 0xf9, 0xf9, 0x1, 0x1, 0x1, 0xb9, 0xb9, 0x1, 0x1, 0x81, 0xf1, 0xf9, 0x81, 0x81, 0x1, 0x1, 0x81, 0x81, 0x81, 0x81, 0x81, 0x1, 0x1, 0x1, 0xb9, 0xb9, 0x1, 0x1, 0x1, 0x81, 0x81, 0x1, 0x81, 0x81, 0x1, 0x1, 0x1, 0x81, 0x81, 0x81, 0x1, 0x1, 0x1, 0x1, 0x1, 0xff, 
 		0xff, 0x1, 0x1, 0x1, 0xe1, 0xf1, 0x39, 0x19, 0x19, 0x19, 0x39, 0x71, 0x61, 0x1, 0x1, 0x1, 0x81, 0x81, 0x81, 0x81, 0x1, 0x1, 0x1, 0x1, 0xf9, 0xf9, 0x1, 0x1, 0x1, 0xb9, 0xb9, 0x1, 0x1, 0x81, 0xf1, 0xf9, 0x81, 0x81, 0x1, 0x1, 0x81, 0x81, 0x81, 0x81, 0x81, 0x1, 0x1, 0x1, 0xb9, 0xb9, 0x1, 0x1, 0x1, 0x81, 0x81, 0x1, 0x81, 0x81, 0x1, 0x1, 0x1, 0x81, 0x81, 0x81, 0x1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x16, 0x11, 0x10, 0x10, 0x17, 0x14, 0x14, 0x13, 0x10, 0x13, 0x14, 0x13, 0x10, 0x13, 0x14, 0x13, 0x10, 0x17, 0x10, 0x10, 0x11, 0x16, 0x11, 0x10, 0x1f, 0x0, 0x0, 0x0, 0x0
 }};
 }};

BIN
assets/logo.png


+ 0 - 56
defines.h

@@ -1,56 +0,0 @@
-#pragma once
-#include <furi.h>
-#include <input/input.h>
-#include <gui/elements.h>
-#include <flipper_format/flipper_format.h>
-#include <flipper_format/flipper_format_i.h>
-#include "common/card.h"
-#include "common/queue.h"
-
-#define APP_NAME "Solitaire"
-
-typedef enum {
-    EventTypeTick,
-    EventTypeKey,
-} EventType;
-
-typedef struct {
-    EventType type;
-    InputEvent input;
-} AppEvent;
-
-typedef enum { GameStateGameOver, GameStateStart, GameStatePlay, GameStateAnimate } PlayState;
-typedef struct {
-    uint8_t* buffer;
-    Card card;
-    int8_t deck;
-    int indexes[4];
-    float x;
-    float y;
-    float vx;
-    float vy;
-    bool started;
-} CardAnimation;
-
-typedef struct {
-    Deck deck;
-    Hand bottom_columns[7];
-    Card top_cards[4];
-    bool dragging_deck;
-    uint8_t dragging_column;
-    Hand dragging_hand;
-
-    InputKey input;
-
-    bool started;
-    bool processing;
-    bool longPress;
-    PlayState state;
-    unsigned int last_tick;
-    uint8_t selectRow;
-    uint8_t selectColumn;
-    int8_t selected_card;
-    CardAnimation animation;
-    uint8_t* buffer;
-    FuriMutex* mutex;
-} GameState;

+ 1 - 2
solitaire.cpp

@@ -67,7 +67,6 @@ int32_t solitaire_app(void *p) {
 
 
         AppEvent event;
         AppEvent event;
         game->Reset();
         game->Reset();
-//        game->NewRound();
 
 
         while (processing) {
         while (processing) {
             FuriStatus event_status = furi_message_queue_get(event_queue, &event, FuriWaitForever);
             FuriStatus event_status = furi_message_queue_get(event_queue, &event, FuriWaitForever);
@@ -94,7 +93,7 @@ int32_t solitaire_app(void *p) {
                         game->Press(event.input->key);
                         game->Press(event.input->key);
                     }
                     }
                 } else if (event.type == EventTypeTick) {
                 } else if (event.type == EventTypeTick) {
-                    game->Update(notification);
+                    game->Update();
                 }
                 }
             }
             }
 
 

+ 7 - 0
utils/Card.cpp

@@ -62,3 +62,10 @@ void Card::RenderBack(uint8_t x, uint8_t y, bool selected, RenderBuffer *buffer,
         buffer->draw_box(x + 1, y + 1, x + 16, height, Flip);
         buffer->draw_box(x + 1, y + 1, x + 16, height, Flip);
     }
     }
 }
 }
+
+bool Card::CanPlace(Card *a, Card *b) {
+    if (a == nullptr) {
+        return b->value == 12;
+    }
+    return a->suit == b->suit && ((b->value + 1) % 13 == (a->value + 2) % 13);
+}

+ 1 - 0
utils/Card.h

@@ -14,4 +14,5 @@ struct Card {
     void Render(uint8_t x, uint8_t y, bool selected, RenderBuffer *buffer, uint8_t size_limit);
     void Render(uint8_t x, uint8_t y, bool selected, RenderBuffer *buffer, uint8_t size_limit);
     static void RenderEmptyCard(uint8_t x, uint8_t y, RenderBuffer *buffer);
     static void RenderEmptyCard(uint8_t x, uint8_t y, RenderBuffer *buffer);
     static void RenderBack(uint8_t x, uint8_t y, bool selected, RenderBuffer *buffer, uint8_t size_limit);
     static void RenderBack(uint8_t x, uint8_t y, bool selected, RenderBuffer *buffer, uint8_t size_limit);
+    static bool CanPlace(Card *where, Card *what);
 };
 };