Temporarily backport app updates from apps repo

This commit is contained in:
Willy-JL
2023-11-12 11:06:02 +00:00
parent 79e7f491fe
commit e309fa8a88
1498 changed files with 1325977 additions and 20227 deletions

View File

@@ -3,12 +3,13 @@ App(
name="BlackJack",
apptype=FlipperAppType.EXTERNAL,
entry_point="blackjack_app",
requires=["gui", "storage", "canvas"],
requires=["gui","storage","canvas"],
stack_size=2 * 1024,
order=30,
fap_icon="blackjack_10px.png",
fap_category="Games",
fap_icon_assets="assets",
fap_author="@teeebor",
fap_version="1.0",
fap_version="1.1",
fap_description="Blackjack Game",
)
)

View File

@@ -15,7 +15,6 @@
#include "ui.h"
#include "blackjack_icons.h"
#include <assets_icons.h>
#define DEALER_MAX 17
@@ -34,9 +33,12 @@ static void draw_ui(Canvas* const canvas, const GameState* game_state) {
}
static void render_callback(Canvas* const canvas, void* ctx) {
furi_assert(ctx);
const GameState* game_state = ctx;
furi_mutex_acquire(game_state->mutex, FuriWaitForever);
furi_mutex_acquire(game_state->mutex, 25);
if(game_state == NULL) {
return;
}
canvas_set_color(canvas, ColorBlack);
canvas_draw_frame(canvas, 0, 0, 128, 64);
@@ -177,6 +179,7 @@ void lose(void* ctx) {
}
void win(void* ctx) {
dolphin_deed(DolphinDeedPluginGameWin);
GameState* game_state = ctx;
game_state->state = GameStatePlay;
game_state->player_score += game_state->bet * 2;
@@ -277,7 +280,6 @@ void dealer_tick(GameState* game_state) {
if(dealer_score >= DEALER_MAX) {
if(dealer_score > 21 || dealer_score < player_score) {
dolphin_deed(DolphinDeedPluginGameWin);
enqueue(
&(game_state->queue_state),
game_state,
@@ -540,7 +542,7 @@ int32_t blackjack_app(void* p) {
int32_t return_code = 0;
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(AppEvent));
dolphin_deed(DolphinDeedPluginGameStart);
GameState* game_state = malloc(sizeof(GameState));
game_state->menu = malloc(sizeof(Menu));
game_state->menu->menu_width = 40;
@@ -571,9 +573,6 @@ int32_t blackjack_app(void* p) {
AppEvent event;
// Call dolphin deed on game start
dolphin_deed(DolphinDeedPluginGameStart);
for(bool processing = true; processing;) {
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
furi_mutex_acquire(game_state->mutex, FuriWaitForever);
@@ -612,8 +611,9 @@ int32_t blackjack_app(void* p) {
processing = game_state->processing;
}
}
view_port_update(view_port);
furi_mutex_release(game_state->mutex);
view_port_update(view_port);
}
furi_timer_free(timer);

View File

@@ -350,4 +350,4 @@ void add_hand_region(Hand* to, Hand* from) {
add_to_hand(to, from->cards[i]);
}
}
}
}

View File

@@ -54,7 +54,6 @@ typedef enum {
} Direction;
typedef struct {
FuriMutex* mutex;
Card player_cards[21];
Card dealer_cards[21];
uint8_t player_card_count;
@@ -74,4 +73,5 @@ typedef struct {
QueueState queue_state;
Menu* menu;
unsigned int last_tick;
FuriMutex* mutex;
} GameState;

View File

@@ -81,7 +81,7 @@ void draw_score(Canvas* const canvas, bool top, uint8_t amount) {
void draw_money(Canvas* const canvas, uint32_t score) {
canvas_set_font(canvas, FontSecondary);
char drawChar[11];
char drawChar[10];
uint32_t currAmount = score;
if(currAmount < 1000) {
snprintf(drawChar, sizeof(drawChar), "$%lu", currAmount);

View File

@@ -121,4 +121,4 @@ Settings load_settings() {
flipper_format_free(file);
furi_record_close(RECORD_STORAGE);
return settings;
}
}