juegos

Juegos de terminal de Pancho: Catan (TUI, GUI, web, servidor, PicoCalc), ajedrez, calculadora y minijuegos
git clone https://git.lu3dhn.xyz/juegos.git
Log | Files | Refs

chess_gfx.h (2141B)


      1 /* chess_gfx.h - dibujo del ajedrez en pixeles (GUI de Linux y PicoCalc) y lo que
      2  * comparten los frontends: temas y la "vista" que arma la app para dibujar. */
      3 #ifndef CHESS_GFX_H
      4 #define CHESS_GFX_H
      5 
      6 #include "gfx.h"
      7 #include "../core/chess.h"
      8 #include "../core/ctrl.h"
      9 
     10 /* temas del ajedrez en bash: colores (RGB565) y los mismos en xterm-256 para la TUI */
     11 enum { TH_LIGHT, TH_DARK, TH_FROM, TH_CAPTURE, TH_TARGET, TH_PATH, TH__COUNT };
     12 typedef struct { const char *name; Color c[TH__COUNT]; uint8_t xterm[TH__COUNT]; } Theme;
     13 extern const Theme THEMES[];
     14 enum { NTHEMES = 6 };
     15 
     16 /* sprites: 2 bits por pixel (0 nada, 1 cuerpo, 2 contorno/detalle) */
     17 typedef struct { int size; const uint8_t *img[7]; } PieceSet;
     18 extern const PieceSet PIECES[];
     19 extern const int NPIECESETS;
     20 
     21 /* Lo que la app le pasa al frontend para dibujar una partida. */
     22 typedef struct {
     23     const Game *g;                 /* posicion a mostrar (en el visor puede no ser la actual) */
     24     const Ctrl *c;
     25     const char *names[2];
     26     int32_t     clock[2];          /* ms a mostrar */
     27     bool        has_clock;
     28     int         clock_running;     /* color cuyo reloj corre, -1 ninguno */
     29     const char *status;            /* linea extra: conexion, "pensando..." */
     30     const char *banner;            /* aviso destacado: oferta de tablas, etc */
     31     const char *opening;
     32     bool        show_eval;
     33     int         eval;              /* cp desde blancas */
     34     bool        eval_valid;
     35     int         theme;
     36     int         layout;
     37     bool        show_help;
     38     const char *modal, *modal2;    /* cuadro de confirmacion */
     39     int         view_ply;          /* visor: jugada que se esta mirando (-1 en vivo) */
     40     bool        hide_prompt;       /* visor: sin instrucciones de juego */
     41 } View;
     42 
     43 void chess_screen(Surface *s, const View *v, HitList *hits);
     44 int  chess_form_backdrop(Surface *s, bool compact);
     45 /* capturadas: cuantas piezas de cada tipo le faltan a cada color respecto del inicio */
     46 void captured_pieces(const Game *g, int out[2][7]);
     47 /* reloj "mm:ss" (o "h:mm:ss", o "Nd hh" para correspondencia) */
     48 void fmt_clock(int32_t ms, char *buf, int n);
     49 
     50 #endif