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

commit 2c19c1f08abb3a6b3d91ac8b203fd315583ef770
parent 81d7034e427025f3924725bc6da2f30cab8b11d2
Author: Francisco Armando Rosmino <franciscorosmino@rosmino.com.ar>
Date:   Sat,  3 Oct 2026 15:13:09 -0300

El costo al lado de cada accion de construir

En tu turno la lista de acciones reemplazaba la tabla de costos, justo cuando
hacen falta: ahora Ruta, Pueblo, Ciudad, Carta y Barco llevan sus cuadraditos
de recursos a la derecha, en el panel ancho y en el vertical.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Diffstat:
Mcatan/gfx/screen.c | 35+++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/catan/gfx/screen.c b/catan/gfx/screen.c @@ -41,6 +41,31 @@ static void res_card(Surface *s, int x, int y, int w, int h, int r, int n, HitLi /* ------------------------------------------------------------ piezas comunes */ +/* costo de una accion de construir (NULL si no construye nada) */ +static const uint8_t *action_cost(int action) +{ + switch (action) { + case A_ROAD: return COST_ROAD; + case A_SETTLE: return COST_SETTLE; + case A_CITY: return COST_CITY; + case A_BUYDEV: return COST_DEV; + case A_SHIP: return COST_SHIP; + } + return 0; +} + +/* los cuadraditos del costo, alineados a la derecha (termina en x1); devuelve el ancho */ +static int cost_squares(Surface *s, int x1, int y, const uint8_t *cost, int sq) +{ + int n = 0; + for (int r = 0; r < NRES; r++) n += cost[r]; + int w = n * (sq + 2) - 2, x = x1 - w; + if (s) + for (int r = 0; r < NRES; r++) + for (int k = 0; k < cost[r]; k++) { gfx_rect(s, x, y, sq, sq + 1, TERRAIN_COLOR[r]); gfx_frame(s, x, y, sq, sq + 1, C_OUTLINE); x += sq + 2; } + return w; +} + static void top_bar(Surface *s, const Game *g, const UiInfo *ui, int w, int h, bool compact, HitList *hits) { gfx_rect(s, 0, 0, w, h, C_ACCENT); @@ -599,7 +624,10 @@ static void screen_wide(Surface *s, const Game *g, const Ctrl *c, const UiInfo * else if (ui->touch) gfx_frame(s, ax, ay - 1, colw - 2, ah, C_PANEL2); char k[2] = { it->key, 0 }; gfx_text(s, &font_bold, ax + 4, ty, k, sel ? C_OUTLINE : C_ACCENT); - gfx_text_fit(s, &font_normal, ax + 16, ty, colw - 20, it->label, sel ? C_OUTLINE : it->enabled ? C_TEXT : C_DIM); + const uint8_t *cost = action_cost(it->action); /* lo que cuesta, a la derecha: se ve cuando hace falta */ + int sq = colw >= 150 ? 8 : 6; /* en columnas angostas, mas chicos */ + int cw2 = cost ? cost_squares(s, ax + colw - 6, ay + (ah - sq - 3) / 2, cost, sq) + 4 : 0; + gfx_text_fit(s, &font_normal, ax + 16, ty, colw - 20 - cw2, it->label, sel ? C_OUTLINE : it->enabled ? C_TEXT : C_DIM); hit_add(hits, ax, ay - 1, colw - 2, ah, PK_ACTION, i); } y += rows * ah; @@ -793,7 +821,10 @@ static void screen_tall(Surface *s, const Game *g, const Ctrl *c, const UiInfo * box(s, ax, ay - 1, colw - 2, ah, sel ? C_ACCENT : C_PANEL2, sel ? C_ACCENT : C_DIM); char k[2] = { it->key, 0 }; gfx_text(s, &font_bold, ax + 4, ty, k, sel ? C_OUTLINE : C_ACCENT); - gfx_text_fit(s, &font_normal, ax + 16, ty, colw - 20, it->label, sel ? C_OUTLINE : it->enabled ? C_TEXT : C_DIM); + const uint8_t *cost = action_cost(it->action); + int sq = colw >= 150 ? 8 : 6; /* en columnas angostas, mas chicos */ + int cw2 = cost ? cost_squares(s, ax + colw - 6, ay + (ah - sq - 3) / 2, cost, sq) + 4 : 0; + gfx_text_fit(s, &font_normal, ax + 16, ty, colw - 20 - cw2, it->label, sel ? C_OUTLINE : it->enabled ? C_TEXT : C_DIM); hit_add(hits, ax, ay - 1, colw - 2, ah, PK_ACTION, i); } y += arows * ah;