From 86b0e95b2f4660768a4a44b6d02238e66778aead Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Thu, 11 Apr 2024 02:11:53 +0300 Subject: [PATCH] remove duplicated app (local player only) app got no updates and no online support --- ReadMe.md | 1 - .../flipper-tictactoe-multi/application.fam | 16 - .../assets/tictactoe_10px.png | Bin 1605 -> 0 bytes .../helpers/ttt_multi_game.c | 208 --------- .../helpers/ttt_multi_game.h | 55 --- .../flipper-tictactoe-multi/img/1.png | Bin 1694 -> 0 bytes .../flipper-tictactoe-multi/img/2.png | Bin 1496 -> 0 bytes .../scenes/ttt_multi_scene.c | 30 -- .../scenes/ttt_multi_scene.h | 29 -- .../scenes/ttt_multi_scene_config.h | 2 - .../scenes/ttt_multi_scene_local.c | 57 --- .../scenes/ttt_multi_scene_start.c | 61 --- .../flipper-tictactoe-multi/ttt_multi.c | 87 ---- .../flipper-tictactoe-multi/ttt_multi.h | 36 -- .../ttt_multi_custom_event.h | 6 - .../views/ttt_multi_game_view.c | 416 ------------------ .../views/ttt_multi_game_view.h | 32 -- 17 files changed, 1036 deletions(-) delete mode 100644 apps_source_code/flipper-tictactoe-multi/application.fam delete mode 100644 apps_source_code/flipper-tictactoe-multi/assets/tictactoe_10px.png delete mode 100644 apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.c delete mode 100644 apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.h delete mode 100644 apps_source_code/flipper-tictactoe-multi/img/1.png delete mode 100644 apps_source_code/flipper-tictactoe-multi/img/2.png delete mode 100644 apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.c delete mode 100644 apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.h delete mode 100644 apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_config.h delete mode 100644 apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_local.c delete mode 100644 apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_start.c delete mode 100644 apps_source_code/flipper-tictactoe-multi/ttt_multi.c delete mode 100644 apps_source_code/flipper-tictactoe-multi/ttt_multi.h delete mode 100644 apps_source_code/flipper-tictactoe-multi/ttt_multi_custom_event.h delete mode 100644 apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.c delete mode 100644 apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.h diff --git a/ReadMe.md b/ReadMe.md index 09425c2a244..2b137ecbc5b 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -146,7 +146,6 @@ The Flipper and its community wouldn't be as rich as it is without your contribu | T-rex game | ![Games Badge] | [by Rrycbarm](https://github.com/Rrycbarm/t-rex-runner) | | [![UFW Badge]](https://lab.flipper.net/apps/t_rex_runner) | | TAMA P1 | ![Games Badge] | [by GMMan & DroomOne](https://github.com/GMMan/flipperzero-tamagotch-p1) | requires [this rom](https://tinyurl.com/tamap1) IN `tama_p1` folder on SD renamed as `rom.bin` to make it work. - Modified to allow saving game state by [DroomOne](https://github.com/DroomOne/flipperzero-tamagotch-p1) - Mute mode & settings by [Round-Pi](https://github.com/Round-Pi/flipperzero-tamagotch-p1) | ![None Badge] | | Tanks Game | ![Games Badge] | [by alexgr13](https://github.com/alexgr13/flipperzero-firmware/tree/fork/dev/applications/tanks-game) | Fixes for latest subghz changes **by @Sil333033** | ![None Badge] | -| Tic-Tac-Toe Multi | ![Games Badge] | [by RouNNdeL](https://github.com/RouNNdeL/flipper-tictactoe-multi) | | [![UFW Badge]](https://lab.flipper.net/apps/ttt_multi) | | Video Poker | ![Games Badge] | [by PixlEmly](https://github.com/PixlEmly/flipperzero-firmware-testing/blob/420/applications/VideoPoker/poker.c) | | [![UFW Badge]](https://lab.flipper.net/apps/videopoker) | | Yatzee | ![Games Badge] | [by emfleak](https://github.com/emfleak/flipperzero-yatzee) | | [![UFW Badge]](https://lab.flipper.net/apps/yatzee) | | Secret Toggle | ![Games Badge] | [by nostrumuva](https://github.com/nostrumuva/secret_toggle) | | [![Author Badge]](https://lab.flipper.net/apps/secret_toggle) | diff --git a/apps_source_code/flipper-tictactoe-multi/application.fam b/apps_source_code/flipper-tictactoe-multi/application.fam deleted file mode 100644 index 9065fdb3377..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/application.fam +++ /dev/null @@ -1,16 +0,0 @@ -App( - appid="ttt_multi", - name="Tic-Tac-Toe Multi", - apptype=FlipperAppType.EXTERNAL, - entry_point="ttt_multi_app", - requires=["gui"], - stack_size=1 * 1024, - order=40, - fap_icon="assets/tictactoe_10px.png", - fap_category="Games", - fap_icon_assets="assets", - fap_author="@RouNNdeL", - fap_weburl="https://github.com/RouNNdeL/flipper-tictactoe-multi", - fap_version="1.1", - fap_description="Multiplayer Tic-Tac-Toe game", -) diff --git a/apps_source_code/flipper-tictactoe-multi/assets/tictactoe_10px.png b/apps_source_code/flipper-tictactoe-multi/assets/tictactoe_10px.png deleted file mode 100644 index 41ca1d97344062a9951dc39176de4a94ca051345..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1605 zcmcIk&u`pB6m}X_f}n~+FBQF5vmhui_ITF2Yg;u@nhj(n9HMlkrkohhjCZZ9J;t77 zH#woImmU$~f;b~_;U7Q(AuincFSzs%0I59hdQFAekPDXVd1HU`z3=_-dvbX2(T%M) zwhY6#G1?yP>Yep8UQyn5ux(XpHTH3s7(gX>!7p$-yi_{^lfl+ih zG|O6arT5OjOQZLN#MSt`koJ+R)M?4(-kHpGXYEYz_H1!l&X$o1Zp)d>09Ju8r*&0K zl~&bMy(EtIa~n+&?3R*gRgRUKtqXOyW-%$Xi22TgG#6@K-KiBd2jq}x86v0}#l**s zJEq-$cmeIcN5CK}Xas#Am}XZ4E0HGWSAj-RFv=^15P>KwO-0a?%%M)dhq>c8 znDtzOW7(tFb7QaPyPhj(f2j-34;4SH(^sEgwXIMbINA&aUFv(p;{%*{aSwMLcYtGG z3M`3qJfFo$Ecu%4lQM-rhs~a6tyKwNWZi+65Z}R`U=B{C%dpP|3=b$xoFpE2%mr0~ z2Z<^(27QudY$EL!qxOU-4|1&r6d z9wJ^BSqjv=PG69{tLa?P&ZiPcFDd>CR;fhKSt)lWkm>(yF8gKTD|U9d^s5#Af0W*& zl}}kdkuW%IR0m_%BW6_;```6ietT{lt>G}^YO@`#uxZD$%z?Uu;rs4SPjAEE?u>>z z<6B?zzn(qY-rU^mbUKeWHVW(J=38HUiGIEF)py_jZhZRs?dyO3^5)z1pdalW41c)y H*`vP!1_SN0 diff --git a/apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.c b/apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.c deleted file mode 100644 index 27c72524c44..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.c +++ /dev/null @@ -1,208 +0,0 @@ -#include "ttt_multi_game.h" - -struct TttMultiGame { - TttMultiGameState state; - TttMultiGameResult result; - - uint8_t board[3][3]; -}; - -void ttt_multi_game_move_reset(TttMultiGameMove* move) { - furi_assert(move); - - // make the move invalid - move->player = TttMultiGamePlayerNone; - move->x = 0xff; - move->y = 0xff; -} - -void ttt_multi_game_move_copy(TttMultiGameMove* dst, const TttMultiGameMove* src) { - furi_assert(dst); - furi_assert(src); - - dst->player = src->player; - dst->x = src->x; - dst->y = src->y; -} - -TttMultiGameMove* ttt_multi_game_move_alloc() { - TttMultiGameMove* move = malloc(sizeof(TttMultiGameMove)); - - ttt_multi_game_move_reset(move); - - return move; -} - -void ttt_multi_game_move_free(TttMultiGameMove* move) { - furi_assert(move); - - free(move); -} - -void ttt_multi_game_reset(TttMultiGame* game) { - furi_assert(game); - - game->state = TttMultiGameStateTurnX; - game->result = TttMultiGameResultNone; - - for(uint8_t i = 0; i < 3; i++) { - for(uint8_t j = 0; j < 3; j++) { - game->board[i][j] = TttMultiGamePlayerNone; - } - } -} - -TttMultiGameState ttt_multi_game_get_state(TttMultiGame* game) { - furi_assert(game); - return game->state; -} - -TttMultiGameResult ttt_multi_game_get_result(TttMultiGame* game) { - furi_assert(game); - if(game->state != TttMultiGameStateFinished) { - return TttMultiGameResultNone; - } - - return game->result; -} - -bool ttt_multi_game_is_draw(TttMultiGame* game) { - furi_assert(game); - - for(uint8_t i = 0; i < 3; i++) { - for(uint8_t j = 0; j < 3; j++) { - if(game->board[i][j] == TttMultiGamePlayerNone) { - return false; - } - } - } - - return true; -} - -TttMultiGamePlayer ttt_multi_game_get_winner(TttMultiGame* game) { - furi_assert(game); - - // Check rows - for(uint8_t i = 0; i < 3; i++) { - if(game->board[i][0] != TttMultiGamePlayerNone && game->board[i][0] == game->board[i][1] && - game->board[i][1] == game->board[i][2]) { - return (TttMultiGamePlayer)game->board[i][0]; - } - } - - // Check columns - for(uint8_t i = 0; i < 3; i++) { - if(game->board[0][i] != TttMultiGamePlayerNone && game->board[0][i] == game->board[1][i] && - game->board[1][i] == game->board[2][i]) { - return (TttMultiGamePlayer)game->board[0][i]; - } - } - - // Check diagonals - if(game->board[0][0] == game->board[1][1] && game->board[1][1] == game->board[2][2]) { - return (TttMultiGamePlayer)game->board[0][0]; - } - if(game->board[0][2] == game->board[1][1] && game->board[1][1] == game->board[2][0]) { - return (TttMultiGamePlayer)game->board[0][2]; - } - - return TttMultiGamePlayerNone; -} - -static void ttt_multi_game_update_result(TttMultiGame* game) { - furi_assert(game); - - if(game->state == TttMultiGameStateFinished) { - return; - } - - TttMultiGamePlayer winner = ttt_multi_game_get_winner(game); - if(winner != TttMultiGamePlayerNone) { - game->state = TttMultiGameStateFinished; - if(winner == TttMultiGamePlayerX) { - game->result = TttMultiGameResultXWin; - } else if(winner == TttMultiGamePlayerO) { - game->result = TttMultiGameResultOWin; - } - - return; - } - - if(ttt_multi_game_is_draw(game)) { - game->result = TttMultiGameResultDraw; - game->state = TttMultiGameStateFinished; - } -} - -bool ttt_multi_game_is_move_valid(TttMultiGame* game, TttMultiGameMove* move) { - furi_assert(game); - furi_assert(move); - - if(move->x > 2 || move->y > 2) { - return false; - } - - if(move->player != ttt_multi_game_current_player(game)) { - return false; - } - - if(game->board[move->x][move->y] != TttMultiGamePlayerNone) { - return false; - } - - return true; -} - -TttMultiGamePlayer ttt_multi_game_current_player(TttMultiGame* game) { - furi_assert(game); - - if(game->state == TttMultiGameStateTurnX) { - return TttMultiGamePlayerX; - } else if(game->state == TttMultiGameStateTurnO) { - return TttMultiGamePlayerO; - } - - return TttMultiGamePlayerNone; -} - -void ttt_multi_game_swap_player(TttMultiGame* game) { - furi_assert(game); - - if(game->state == TttMultiGameStateTurnX) { - game->state = TttMultiGameStateTurnO; - } else if(game->state == TttMultiGameStateTurnO) { - game->state = TttMultiGameStateTurnX; - } -} - -void ttt_multi_game_make_move(TttMultiGame* game, TttMultiGameMove* move) { - furi_assert(game); - furi_assert(move); - furi_assert(ttt_multi_game_is_move_valid(game, move)); - - game->board[move->x][move->y] = (uint8_t)move->player; - ttt_multi_game_swap_player(game); - ttt_multi_game_update_result(game); -} - -TttMultiGamePlayer ttt_multi_game_player_at(TttMultiGame* game, uint8_t x, uint8_t y) { - furi_assert(game); - furi_assert(x < 3); - furi_assert(y < 3); - - return (TttMultiGamePlayer)game->board[x][y]; -} - -TttMultiGame* ttt_multi_game_alloc() { - TttMultiGame* game = malloc(sizeof(TttMultiGame)); - ttt_multi_game_reset(game); - - return game; -} - -void ttt_multi_game_free(TttMultiGame* game) { - furi_assert(game); - - free(game); -} diff --git a/apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.h b/apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.h deleted file mode 100644 index 101eb74710e..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/helpers/ttt_multi_game.h +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include - -typedef enum { - TttMultiGamePlayerNone = 0, - TttMultiGamePlayerX = 1, - TttMultiGamePlayerO = 2, -} TttMultiGamePlayer; - -typedef enum { - TttMultiGameStateTurnO, - TttMultiGameStateTurnX, - TttMultiGameStateFinished -} TttMultiGameState; - -typedef enum { - TttMultiGameResultXWin, - TttMultiGameResultOWin, - TttMultiGameResultDraw, - TttMultiGameResultNone -} TttMultiGameResult; - -typedef struct TttMultiGame TttMultiGame; - -typedef struct { - TttMultiGamePlayer player; - uint8_t x; - uint8_t y; -} TttMultiGameMove; - -TttMultiGameMove* ttt_multi_game_move_alloc(); - -void ttt_multi_game_move_free(TttMultiGameMove* move); - -void ttt_multi_game_move_copy(TttMultiGameMove* dst, const TttMultiGameMove* src); - -TttMultiGame* ttt_multi_game_alloc(); - -void ttt_multi_game_free(TttMultiGame* game); - -void ttt_multi_game_reset(TttMultiGame* game); - -void ttt_multi_game_swap_player(TttMultiGame* game); - -void ttt_multi_game_make_move(TttMultiGame* game, TttMultiGameMove* move); - -bool ttt_multi_game_is_move_valid(TttMultiGame* game, TttMultiGameMove* move); - -TttMultiGameState ttt_multi_game_get_state(TttMultiGame* game); - -TttMultiGameResult ttt_multi_game_get_result(TttMultiGame* game); - -TttMultiGamePlayer ttt_multi_game_player_at(TttMultiGame* game, uint8_t x, uint8_t y); - -TttMultiGamePlayer ttt_multi_game_current_player(TttMultiGame* game); \ No newline at end of file diff --git a/apps_source_code/flipper-tictactoe-multi/img/1.png b/apps_source_code/flipper-tictactoe-multi/img/1.png deleted file mode 100644 index d9ca42f7ca1e59721ffad7515076339a827a1fcd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1694 zcmb7FdrVVj6hEaKkvHX{NPXfZ%RP_GkNwUt(cQfyP$C6@59EX(%C&3A9U^PO{kzw`Tj z_f$;O7P1r72>{63wubHiu)$vm;4rs@zhU{}i(~3mRtA8x>)bOQMWbdV z#_`B#Wx(Kh0Eblon;bzLV*{QA|NJSOEbghl8+t~&B2=2BtBZbc+AQ3lv{i6P;1UjS z?0tZ;IEm^&R$M!0<(Oz6-@A^25utQ`uh|T{U$6s{S;N`)nSuP!k7JBcI3JML8duM1*cO~E@Y$13J0bDeGbg`S4kmxf|II5tV zZhm>Gzj%jpPGBM7T_<>0ML7@XE!7zSEkZva=?>ze|4HIHv5s4W zu7$DpwGW(Vc*(ZEmAoW1UyBVsOVJ0Ch;p;F@4g16n3ZJm3bOUW+Fn^6XXQx}?(unQ z#Rk#y+0Bm~W**o>Z~#7;Id-n7?CXB366Fs0$<(U0&;5UR@>N*P7urXaON}khSRwvG zfDf#L7#obeVZrg5J*$uf@^<1+5uuB_(oJ|F1;U^m~;)OPOFA?!QGa7RFM_X6kw zs(j_IG)iHZiH}mzDR>4-|0F#PWqs%fjSsp5h+uCBU6+Z2(0)vKYD9u-aG)o8abiNO z2ARa==}%m+8y>&pCI!T~R?o?*DW#3x(qTGbku%O|h;=&3>p~`gla&`~Ci!V|a%Sv4 zZEa0PY)x-^x0~01J}65y?qdv0Usso}!Ah>S6Xf3WJhxDTJ4H+{!Aw_kf}Zj9H32=H z=3}_HRO!)Fg63tD#lnWZm0}Bu3+MR>d1L1@-2_Dv}1a~D0_Sh#% zkHkfIs?;^*0XBm<$f@fj-yGv;&T5ng-rsoYTg+p{Va%4qjmFtp<6!jx6JHTGhkJnh z51ic?7wa8?Ghc>`v;dE9U4+O4yrf9Si+XqdI%LY%DeyEEsne&Ti?z-Dv7IebpDM;= zQD-h-nmLjyOE&uMF{E^$QkAmFrSY6=n!xIS;=qH?ZzbeOjBgv3ug9lx4#AIyap_ux z@p3GUut>~lbkLV!t&-!y7l_0ocp%e@IRih3O_g(my0u<+Gt~@1x9Lal{RzoxsP}GJ zZE=#XMViOeef3+;3jT*EKoX=f5dVdf@rw_+*i6o?!>m;);&u!E!+~v^qe5#oadZCy DPasaZ diff --git a/apps_source_code/flipper-tictactoe-multi/img/2.png b/apps_source_code/flipper-tictactoe-multi/img/2.png deleted file mode 100644 index a04c8093a258a87a4e746fd2927523f48b148dad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1496 zcmeAS@N?(olHy`uVBq!ia0y~yU;;8388|?c*QZDWAjMhW5n0T@z%2~Ij105pNH8$4 zc6quuhE&XXd)GSePK1EN#fcA|R@BC|Tz~#mLf9hEX+d=Ve5Lo64;_>z`suw2o&5LX z_wVQbGrah@=NA*hjy47c7fuF;EB)bhFFs$Nzj!^fUb?(nFDHY77X!m07If;>(&r4@ zY`zv>jy`X@<9_;w816sGObi`D3=JBL_^GHWae+PAPi<}dYt02?jiGO?{r=;24A*8Nob!g^#@U(AKYe4|a1Om$+;zTU+AK*0SC^PJy@ z_n|12$;+1C@Tt1u?(W@_r^a^Mp4~eG*$);|ixX!YM)m*$|MyeXGr#?M^Z#0X{rCL6 zpZ@1X{`@H=%-}Eu8cUb>5}xkWD}PeAbGP!oo6Ii0I2D}%6ql(_Qwqw!6^b{t`_~BwPfKlQj`$h#p=I-)%=dwozpApnbNeSDNpEDn@%m2Lp`Y(t zzOS19vpgGBdRGp6!I7PBTRy*7e{PT5ckVr>5#dn!if_TUpI_GZ?U={;ee2S){RQrb z2wicwoI&_p?))wMGYbB`Uv*diPAkF>Sx3GzPT5;z_ist@hg*LSr69CvST{IkJ%6zE zcWWj}6g6M56OZ2=KjRp}`c(FUjp65Z&o8ly14^7hNRi-9 z(27{381<{=dvNCSoy_M)-DA!_`TP+mEsKiy!WoX;<5* diff --git a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.c b/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.c deleted file mode 100644 index ea82a508042..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "ttt_multi_scene.h" - -// Generate scene on_enter handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, -void (*const ttt_multi_on_enter_handlers[])(void*) = { -#include "ttt_multi_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_event handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, -bool (*const ttt_multi_on_event_handlers[])(void* context, SceneManagerEvent event) = { -#include "ttt_multi_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_exit handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, -void (*const ttt_multi_on_exit_handlers[])(void* context) = { -#include "ttt_multi_scene_config.h" -}; -#undef ADD_SCENE - -// Initialize scene handlers configuration structure -const SceneManagerHandlers ttt_multi_scene_handlers = { - .on_enter_handlers = ttt_multi_on_enter_handlers, - .on_event_handlers = ttt_multi_on_event_handlers, - .on_exit_handlers = ttt_multi_on_exit_handlers, - .scene_num = TttMultiSceneNum, -}; diff --git a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.h b/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.h deleted file mode 100644 index 13a9360a5dd..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -// Generate scene id and total number -#define ADD_SCENE(prefix, name, id) TttMultiScene##id, -typedef enum { -#include "ttt_multi_scene_config.h" - TttMultiSceneNum, -} TttMultiScene; -#undef ADD_SCENE - -extern const SceneManagerHandlers ttt_multi_scene_handlers; - -// Generate scene on_enter handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); -#include "ttt_multi_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_event handlers declaration -#define ADD_SCENE(prefix, name, id) \ - bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); -#include "ttt_multi_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_exit handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); -#include "ttt_multi_scene_config.h" -#undef ADD_SCENE diff --git a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_config.h b/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_config.h deleted file mode 100644 index fb753cc3a8c..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_config.h +++ /dev/null @@ -1,2 +0,0 @@ -ADD_SCENE(ttt_multi, start, Start) -ADD_SCENE(ttt_multi, local, Local) \ No newline at end of file diff --git a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_local.c b/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_local.c deleted file mode 100644 index a127df841df..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_local.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "../ttt_multi.h" - -static void ttt_multi_scene_local_callback(void* context, TttMultiCustomEvent event) { - furi_assert(context); - - TttMultiApp* ttt_multi = context; - - view_dispatcher_send_custom_event(ttt_multi->view_dispatcher, event); -} - -void ttt_multi_scene_local_on_enter(void* context) { - furi_assert(context); - - TttMultiApp* ttt_multi = context; - TttMultiGameView* view = ttt_multi->game_view; - - ttt_multi_game_view_set_callback(view, ttt_multi_scene_local_callback, ttt_multi); - ttt_multi_game_view_set_local_play(view); - view_dispatcher_switch_to_view(ttt_multi->view_dispatcher, TttMultiViewGame); -} - -void ttt_multi_scene_local_on_exit(void* context) { - furi_assert(context); - TttMultiApp* ttt_multi = context; - - ttt_multi_game_view_reset(ttt_multi->game_view); -} - -bool ttt_multi_scene_local_on_event(void* context, SceneManagerEvent event) { - furi_assert(context); - TttMultiApp* ttt_multi = context; - - if(event.type == SceneManagerEventTypeCustom) { - TttMultiCustomEvent custom_event = event.event; - switch(custom_event) { - case TttMultiCustomEventGameMove: { - TttMultiGameMove last_move = {}; - ttt_multi_game_view_get_last_move(ttt_multi->game_view, &last_move); - ttt_multi_game_view_move(ttt_multi->game_view, &last_move); - return true; - } - case TttMultiCustomEventGameFinish: { - TttMultiGameResult result = ttt_multi_game_view_get_result(ttt_multi->game_view); - if(result == TttMultiGameResultDraw) { - notification_message(ttt_multi->notifications, &sequence_error); - } else { - notification_message(ttt_multi->notifications, &sequence_success); - } - return true; - } - default: - break; - } - } - - return false; -} \ No newline at end of file diff --git a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_start.c b/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_start.c deleted file mode 100644 index 8a5d00df4a1..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/scenes/ttt_multi_scene_start.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "../ttt_multi.h" - -enum SubmenuIndex { SubmenuIndexCreate, SubmenuIndexJoin, SubmenuIndexLocal }; - -void ttt_multi_scene_start_submenu_callback(void* context, uint32_t index) { - TttMultiApp* ttt_multi = context; - view_dispatcher_send_custom_event(ttt_multi->view_dispatcher, index); -} - -void ttt_multi_scene_start_on_enter(void* context) { - TttMultiApp* ttt_multi = context; - - Submenu* submenu = ttt_multi->submenu; - submenu_add_item( - submenu, - "Create game", - SubmenuIndexCreate, - ttt_multi_scene_start_submenu_callback, - ttt_multi); - submenu_add_item( - submenu, "Join game", SubmenuIndexJoin, ttt_multi_scene_start_submenu_callback, ttt_multi); - - submenu_add_item( - submenu, - "Local game", - SubmenuIndexLocal, - ttt_multi_scene_start_submenu_callback, - ttt_multi); - - submenu_set_header(submenu, "Tic-Tac-Toe"); - - submenu_set_selected_item( - submenu, scene_manager_get_scene_state(ttt_multi->scene_manager, TttMultiSceneStart)); - view_dispatcher_switch_to_view(ttt_multi->view_dispatcher, TttMultiViewMenu); -} - -bool ttt_multi_scene_start_on_event(void* context, SceneManagerEvent event) { - TttMultiApp* ttt_multi = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexCreate) { - // TODO: implement - consumed = true; - } else if(event.event == SubmenuIndexJoin) { - // TODO: implement - consumed = true; - } else if(event.event == SubmenuIndexLocal) { - scene_manager_next_scene(ttt_multi->scene_manager, TttMultiSceneLocal); - consumed = true; - } - scene_manager_set_scene_state(ttt_multi->scene_manager, TttMultiSceneStart, event.event); - } - - return consumed; -} - -void ttt_multi_scene_start_on_exit(void* context) { - TttMultiApp* ttt_multi = context; - submenu_reset(ttt_multi->submenu); -} diff --git a/apps_source_code/flipper-tictactoe-multi/ttt_multi.c b/apps_source_code/flipper-tictactoe-multi/ttt_multi.c deleted file mode 100644 index 12daa913e2d..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/ttt_multi.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "ttt_multi.h" - -bool ttt_multi_custom_event_callback(void* context, uint32_t event) { - furi_assert(context); - TttMultiApp* ttt_multi = context; - return scene_manager_handle_custom_event(ttt_multi->scene_manager, event); -} - -bool ttt_multi_back_event_callback(void* context) { - furi_assert(context); - TttMultiApp* ttt_multi = context; - return scene_manager_handle_back_event(ttt_multi->scene_manager); -} - -void ttt_multi_tick_event_callback(void* context) { - furi_assert(context); - TttMultiApp* ttt_multi = context; - scene_manager_handle_tick_event(ttt_multi->scene_manager); -} - -TttMultiApp* ttt_multi_alloc() { - TttMultiApp* ttt_multi = malloc(sizeof(TttMultiApp)); - - ttt_multi->view_dispatcher = view_dispatcher_alloc(); - ttt_multi->scene_manager = scene_manager_alloc(&ttt_multi_scene_handlers, ttt_multi); - - view_dispatcher_enable_queue(ttt_multi->view_dispatcher); - view_dispatcher_set_event_callback_context(ttt_multi->view_dispatcher, ttt_multi); - view_dispatcher_set_custom_event_callback( - ttt_multi->view_dispatcher, ttt_multi_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - ttt_multi->view_dispatcher, ttt_multi_back_event_callback); - view_dispatcher_set_tick_event_callback( - ttt_multi->view_dispatcher, ttt_multi_tick_event_callback, 100); - - ttt_multi->gui = furi_record_open(RECORD_GUI); - view_dispatcher_attach_to_gui( - ttt_multi->view_dispatcher, ttt_multi->gui, ViewDispatcherTypeFullscreen); - - ttt_multi->notifications = furi_record_open(RECORD_NOTIFICATION); - - ttt_multi->game_view = ttt_multi_game_view_alloc(); - view_dispatcher_add_view( - ttt_multi->view_dispatcher, - TttMultiViewGame, - ttt_multi_game_get_view(ttt_multi->game_view)); - - ttt_multi->submenu = submenu_alloc(); - view_dispatcher_add_view( - ttt_multi->view_dispatcher, TttMultiViewMenu, submenu_get_view(ttt_multi->submenu)); - - return ttt_multi; -} - -void ttt_multi_free(TttMultiApp* ttt_multi) { - furi_assert(ttt_multi); - - notification_message(ttt_multi->notifications, &sequence_blink_stop); - furi_record_close(RECORD_NOTIFICATION); - ttt_multi->notifications = NULL; - - view_dispatcher_remove_view(ttt_multi->view_dispatcher, TttMultiViewGame); - ttt_multi_game_view_free(ttt_multi->game_view); - - view_dispatcher_remove_view(ttt_multi->view_dispatcher, TttMultiViewMenu); - submenu_free(ttt_multi->submenu); - - scene_manager_free(ttt_multi->scene_manager); - view_dispatcher_free(ttt_multi->view_dispatcher); - - furi_record_close(RECORD_GUI); - ttt_multi->gui = NULL; - - free(ttt_multi); -} - -int32_t ttt_multi_app(void* p) { - UNUSED(p); - TttMultiApp* ttt_multi = ttt_multi_alloc(); - - scene_manager_next_scene(ttt_multi->scene_manager, TttMultiSceneStart); - view_dispatcher_run(ttt_multi->view_dispatcher); - - ttt_multi_free(ttt_multi); - - return 0; -} \ No newline at end of file diff --git a/apps_source_code/flipper-tictactoe-multi/ttt_multi.h b/apps_source_code/flipper-tictactoe-multi/ttt_multi.h deleted file mode 100644 index 695020a4b0e..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/ttt_multi.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "scenes/ttt_multi_scene.h" -#include "views/ttt_multi_game_view.h" - -#include "ttt_multi_icons.h" - -typedef struct { - Gui* gui; - NotificationApp* notifications; - ViewDispatcher* view_dispatcher; - SceneManager* scene_manager; - - // Common views - Submenu* submenu; - TttMultiGameView* game_view; -} TttMultiApp; - -typedef enum { - TttMultiViewMenu, - TttMultiViewGame, -} TttMultiView; \ No newline at end of file diff --git a/apps_source_code/flipper-tictactoe-multi/ttt_multi_custom_event.h b/apps_source_code/flipper-tictactoe-multi/ttt_multi_custom_event.h deleted file mode 100644 index c65cbc7ca64..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/ttt_multi_custom_event.h +++ /dev/null @@ -1,6 +0,0 @@ -typedef enum { - TttMultiCustomEventReserved = 100, - - TttMultiCustomEventGameMove, - TttMultiCustomEventGameFinish, -} TttMultiCustomEvent; diff --git a/apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.c b/apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.c deleted file mode 100644 index c71e5400607..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.c +++ /dev/null @@ -1,416 +0,0 @@ -#include "ttt_multi_game_view.h" - -struct TttMultiGameView { - View* view; -}; - -typedef struct { - TttMultiGame* game; - uint8_t position_x; - uint8_t position_y; - - TttMultiGamePlayer local_player; - bool is_local; - - TttMultiGameViewCallback callback; - void* context; - - TttMultiGameMove* last_move; - TttMultiGameResult result; -} TttMultiGameViewModel; - -void ttt_multi_game_view_draw_callback(Canvas* canvas, void* _model) { - TttMultiGameViewModel* model = _model; - - canvas_clear(canvas); - const uint8_t top = 2; - const uint8_t left = 4; - const uint8_t cell_size = 20; - const uint8_t padding = 4; - - canvas_draw_frame(canvas, left - 1, top - 1, 3 * cell_size + 2, 3 * cell_size + 2); - - for(uint8_t i = 0; i < 3; i++) { - for(uint8_t j = 0; j < 3; j++) { - canvas_draw_frame( - canvas, left + i * cell_size, top + j * cell_size, cell_size, cell_size); - } - } - - for(uint8_t i = 0; i < 3; i++) { - for(uint8_t j = 0; j < 3; j++) { - bool is_selected = model->position_x == i && model->position_y == j && - ttt_multi_game_get_state(model->game) != TttMultiGameStateFinished; - - if(ttt_multi_game_player_at(model->game, i, j) == TttMultiGamePlayerX) { - canvas_draw_line( - canvas, - left + i * cell_size + padding, - top + j * cell_size + padding, - left + i * cell_size + cell_size - padding, - top + j * cell_size + cell_size - padding); - canvas_draw_line( - canvas, - left + i * cell_size + cell_size - padding, - top + j * cell_size + padding, - left + i * cell_size + padding, - top + j * cell_size + cell_size - padding); - } else if(ttt_multi_game_player_at(model->game, i, j) == TttMultiGamePlayerO) { - canvas_draw_circle( - canvas, - left + i * cell_size + cell_size / 2, - top + j * cell_size + cell_size / 2, - cell_size / 2 - padding); - } - - if(is_selected) { - canvas_draw_frame( - canvas, - left + i * cell_size + 1, - top + j * cell_size + 1, - cell_size - 2, - cell_size - 2); - } - } - } - - char* status_str = ""; - // TODO: Rewrite this - if(model->is_local) { - if(ttt_multi_game_get_state(model->game) == TttMultiGameStateFinished) { - if(ttt_multi_game_get_result(model->game) == TttMultiGameResultXWin) { - status_str = "X win"; - } else if(ttt_multi_game_get_result(model->game) == TttMultiGameResultOWin) { - status_str = "O win"; - } else if(ttt_multi_game_get_result(model->game) == TttMultiGameResultDraw) { - status_str = "Draw"; - } - } else { - if(ttt_multi_game_current_player(model->game) == TttMultiGamePlayerX) { - status_str = "X turn"; - } else { - status_str = "O turn"; - } - } - } else { - if(ttt_multi_game_get_state(model->game) == TttMultiGameStateFinished) { - if(model->local_player == TttMultiGamePlayerX) { - if(ttt_multi_game_get_result(model->game) == TttMultiGameResultXWin) { - status_str = "You win"; - } else if(ttt_multi_game_get_result(model->game) == TttMultiGameResultOWin) { - status_str = "You lose"; - } else if(ttt_multi_game_get_result(model->game) == TttMultiGameResultDraw) { - status_str = "Draw"; - } - } else { - if(ttt_multi_game_get_result(model->game) == TttMultiGameResultXWin) { - status_str = "You lose"; - } else if(ttt_multi_game_get_result(model->game) == TttMultiGameResultOWin) { - status_str = "You win"; - } else if(ttt_multi_game_get_result(model->game) == TttMultiGameResultDraw) { - status_str = "Draw"; - } - } - } else { - if(model->local_player == TttMultiGamePlayerX) { - if(ttt_multi_game_get_state(model->game) == TttMultiGameStateTurnX) { - status_str = "Your turn"; - } else { - status_str = "Opponent turn"; - } - } else { - if(ttt_multi_game_get_state(model->game) == TttMultiGameStateTurnO) { - status_str = "Your turn"; - } else { - status_str = "Opponent turn"; - } - } - } - } - - elements_text_box(canvas, 64, 16, 64, 16, AlignCenter, AlignCenter, status_str, false); - if(ttt_multi_game_get_state(model->game) == TttMultiGameStateFinished) { - elements_multiline_text_aligned( - canvas, 100, 32, AlignCenter, AlignTop, "Press OK\nto restart"); - } -} - -static void ttt_multi_game_view_process_left(TttMultiGameView* view); -static void ttt_multi_game_view_process_right(TttMultiGameView* view); -static void ttt_multi_game_view_process_up(TttMultiGameView* view); -static void ttt_multi_game_view_process_down(TttMultiGameView* view); -static void ttt_multi_game_view_process_ok(TttMultiGameView* view); - -static bool ttt_multi_game_view_input_callback(InputEvent* event, void* context) { - furi_assert(context); - - TttMultiGameView* game_view = context; - bool consumed = false; - - if(event->type == InputTypeShort) { - switch(event->key) { - case InputKeyLeft: - ttt_multi_game_view_process_left(game_view); - consumed = true; - break; - case InputKeyRight: - ttt_multi_game_view_process_right(game_view); - consumed = true; - break; - case InputKeyUp: - ttt_multi_game_view_process_up(game_view); - consumed = true; - break; - case InputKeyDown: - ttt_multi_game_view_process_down(game_view); - consumed = true; - break; - case InputKeyOk: - ttt_multi_game_view_process_ok(game_view); - consumed = true; - break; - default: - break; - } - } - - return consumed; -} - -void ttt_multi_game_view_model_reset(TttMultiGameViewModel* model) { - furi_assert(model); - furi_assert(model->game); - - model->position_x = 1; - model->position_y = 1; - ttt_multi_game_reset(model->game); -} - -TttMultiGameView* ttt_multi_game_view_alloc() { - TttMultiGameView* game_view = malloc(sizeof(TttMultiGameView)); - game_view->view = view_alloc(); - view_set_context(game_view->view, game_view); - view_allocate_model(game_view->view, ViewModelTypeLocking, sizeof(TttMultiGameViewModel)); - view_set_draw_callback(game_view->view, (ViewDrawCallback)ttt_multi_game_view_draw_callback); - view_set_input_callback(game_view->view, ttt_multi_game_view_input_callback); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - model->game = ttt_multi_game_alloc(); - model->last_move = ttt_multi_game_move_alloc(); - ttt_multi_game_view_model_reset(model); - }, - true); - - return game_view; -} - -void ttt_multi_game_view_free(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - ttt_multi_game_free(model->game); - ttt_multi_game_move_free(model->last_move); - }, - true); - - view_free(game_view->view); - free(game_view); -} - -View* ttt_multi_game_get_view(TttMultiGameView* game_view) { - furi_assert(game_view); - - return game_view->view; -} - -void ttt_multi_game_view_process_up(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - if(model->position_y > 0) { - model->position_y--; - } - }, - true); -} - -void ttt_multi_game_view_process_down(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - if(model->position_y < 2) { - model->position_y++; - } - }, - true); -} - -void ttt_multi_game_view_process_left(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - if(model->position_x > 0) { - model->position_x--; - } - }, - true); -} - -void ttt_multi_game_view_process_right(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - if(model->position_x < 2) { - model->position_x++; - } - }, - true); -} - -void ttt_multi_game_view_process_ok(TttMultiGameView* game_view) { - furi_assert(game_view); - TttMultiGameViewCallback callback = NULL; - void* context = NULL; - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - if(ttt_multi_game_get_state(model->game) == TttMultiGameStateFinished) { - ttt_multi_game_view_model_reset(model); - } else { - model->last_move->player = ttt_multi_game_current_player(model->game); - model->last_move->x = model->position_x; - model->last_move->y = model->position_y; - - if(ttt_multi_game_is_move_valid(model->game, model->last_move)) { - callback = model->callback; - context = model->context; - } - } - }, - true); - - if(callback) { - callback(context, TttMultiCustomEventGameMove); - } -} - -void ttt_multi_game_view_move(TttMultiGameView* game_view, TttMultiGameMove* move) { - furi_assert(game_view); - furi_assert(move); - - TttMultiGameResult result; - TttMultiGameViewCallback callback = NULL; - void* context = NULL; - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - ttt_multi_game_make_move(model->game, move); - result = ttt_multi_game_get_result(model->game); - if(result != TttMultiGameResultNone) { - callback = model->callback; - context = model->context; - } - }, - true); - - if(callback) { - callback(context, TttMultiCustomEventGameFinish); - } -} - -void ttt_multi_game_view_set_callback( - TttMultiGameView* game_view, - TttMultiGameViewCallback callback, - void* context) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - model->callback = callback; - model->context = context; - }, - true); -} - -void ttt_multi_game_view_set_remote_play(TttMultiGameView* game_view, TttMultiGamePlayer player) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - model->local_player = player; - model->is_local = false; - }, - true); -} - -void ttt_multi_game_view_set_local_play(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, TttMultiGameViewModel * model, { model->is_local = true; }, true); -} - -void ttt_multi_game_view_get_last_move(TttMultiGameView* game_view, TttMultiGameMove* move) { - furi_assert(game_view); - furi_assert(move); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { - if(model->last_move->player != TttMultiGamePlayerNone) { - ttt_multi_game_move_copy(move, model->last_move); - } - }, - true); -} - -TttMultiGameResult ttt_multi_game_view_get_result(TttMultiGameView* game_view) { - furi_assert(game_view); - - TttMultiGameResult result = TttMultiGameResultNone; - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { result = ttt_multi_game_get_result(model->game); }, - true); - - return result; -} - -void ttt_multi_game_view_reset(TttMultiGameView* game_view) { - furi_assert(game_view); - - with_view_model( - game_view->view, - TttMultiGameViewModel * model, - { ttt_multi_game_view_model_reset(model); }, - true); -} \ No newline at end of file diff --git a/apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.h b/apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.h deleted file mode 100644 index 3773405ce67..00000000000 --- a/apps_source_code/flipper-tictactoe-multi/views/ttt_multi_game_view.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include -#include "../ttt_multi_custom_event.h" -#include "../helpers/ttt_multi_game.h" - -typedef void (*TttMultiGameViewCallback)(void* context, TttMultiCustomEvent event); -typedef struct TttMultiGameView TttMultiGameView; - -TttMultiGameView* ttt_multi_game_view_alloc(); - -void ttt_multi_game_view_free(TttMultiGameView* game_view); - -View* ttt_multi_game_get_view(TttMultiGameView* game_view); - -void ttt_multi_game_view_move(TttMultiGameView* game_view, TttMultiGameMove* move); - -void ttt_multi_game_view_set_callback( - TttMultiGameView* game_view, - TttMultiGameViewCallback callback, - void* context); - -void ttt_multi_game_view_set_remote_play(TttMultiGameView* game_view, TttMultiGamePlayer player); - -void ttt_multi_game_view_set_local_play(TttMultiGameView* game_view); - -void ttt_multi_game_view_get_last_move(TttMultiGameView* game_view, TttMultiGameMove* move); - -TttMultiGameResult ttt_multi_game_view_get_result(TttMultiGameView* game_view); - -void ttt_multi_game_view_reset(TttMultiGameView* game_view); \ No newline at end of file