mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 22:38:36 -07:00
Temporarily backport app updates from apps repo
This commit is contained in:
@@ -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",
|
||||
)
|
||||
)
|
||||
18
applications/external/blackjack/blackjack.c
vendored
18
applications/external/blackjack/blackjack.c
vendored
@@ -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);
|
||||
|
||||
@@ -350,4 +350,4 @@ void add_hand_region(Hand* to, Hand* from) {
|
||||
add_to_hand(to, from->cards[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
applications/external/blackjack/defines.h
vendored
2
applications/external/blackjack/defines.h
vendored
@@ -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;
|
||||
|
||||
2
applications/external/blackjack/ui.c
vendored
2
applications/external/blackjack/ui.c
vendored
@@ -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);
|
||||
|
||||
2
applications/external/blackjack/util.c
vendored
2
applications/external/blackjack/util.c
vendored
@@ -121,4 +121,4 @@ Settings load_settings() {
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user