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 7a86cf8f3c5c0445d6d9569ec24be57f4f4cd19c
parent 9cd70968b9ee55fa34cfeabaffb65d8227d03da1
Author: Francisco Armando Rosmino <franciscorosmino@rosmino.com.ar>
Date:   Sat,  3 Oct 2026 11:34:29 -0300

Catan: descargas y leeme en el menu de la web, make release/publish

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
M.gitignore | 1+
Mcatan/Makefile | 13+++++++++++++
Mcatan/linux/app.c | 41++++++++++++++++++++++++++++++++++++++---
Acatan/tools/linux-release.sh | 30++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -27,3 +27,4 @@ __pycache__/ # de terceros / paquetes armados ajedrez/engine/stockfish kit-picocalc.zip +catan/release/ diff --git a/catan/Makefile b/catan/Makefile @@ -62,6 +62,19 @@ catan.exe: $(WIN_SRC) $(HDRS) $(WIN_SDL)/lib/libSDL3.a windows: catan.exe +# Lo que se reparte: catan.exe y el catan de Linux (compilado en un Ubuntu 22.04 con docker +# para que corra en distros no tan nuevas), sueltos, en release/. make publish los sube a +# https://catan.lu3dhn.xyz/descargas/ y empuja el codigo al git (CT111 y espejo publico). +release: catan.exe + mkdir -p release + cp catan.exe release/catan.exe + tools/linux-release.sh "$(VERSION)" release/catan-linux + +publish: release + cd .. && git push origin main --tags && git push publico main --tags + scp release/catan.exe release/catan-linux vps:/var/www/descargas/ + ssh vps 'chmod a+r /var/www/descargas/*' + # Web (PWA para el telefono): el mismo cliente (sin TUI ni red local) compilado a # WebAssembly con emscripten y SDL3 estatico, servido desde web/dist. Necesita emscripten # (pacman -S emscripten; source /etc/profile.d/emscripten.sh) y la fuente de SDL3 (la diff --git a/catan/linux/app.c b/catan/linux/app.c @@ -560,7 +560,7 @@ static bool new_game(Frontend *fe, Settings *st, Session *s) /* ------------------------------------------------------------ menu principal */ -enum { M_QUIT = 0, M_NEW = 1, M_CONTINUE, M_ONLINE, M_LAN_HOST, M_LAN_JOIN, M_COLORS, M_DL_WIN, M_DL_LINUX, +enum { M_QUIT = 0, M_NEW = 1, M_CONTINUE, M_ONLINE, M_LAN_HOST, M_LAN_JOIN, M_COLORS, M_DL_WIN, M_DL_LINUX, M_HOWTO, M_LANG = 50, M_NAME, M_SERVER }; /* ------------------------------------------------------------ colores */ @@ -657,6 +657,39 @@ static bool lan_join_form(Frontend *fe, Settings *st) return lan_join(fe, st, form_get(&f, 1)->text, atoi(form_get(&f, 2)->text)); } +#ifdef __EMSCRIPTEN__ +/* el "leeme" de las descargas */ +static void howto_form(Frontend *fe) +{ + Form f; + bool en = g_lang; + char t[64]; + snprintf(t, sizeof t, "%s %s", en ? "Catan for your computer, version" : "Catan para la compu, versión", APP_VERSION); + form_begin(&f, t); + if (en) { + form_label(&f, "Windows: download catan.exe and double-click it."); + form_label(&f, "If Windows warns: More info > Run anyway."); + form_label(&f, "Linux: download catan-linux, then in a terminal:"); + form_label(&f, " chmod +x catan-linux"); + form_label(&f, " ./catan-linux --gui (window; without --gui: terminal)"); + form_label(&f, "Online uses the same server as this page:"); + form_label(&f, "web, Windows and Linux play together. Use the"); + form_label(&f, "same version (shown in the main menu title)."); + } else { + form_label(&f, "Windows: bajá catan.exe y abrilo con doble click."); + form_label(&f, "Si Windows avisa: Más información > Ejecutar."); + form_label(&f, "Linux: bajá catan-linux y en una terminal:"); + form_label(&f, " chmod +x catan-linux"); + form_label(&f, " ./catan-linux --gui (ventana; sin --gui: terminal)"); + form_label(&f, "Online es el mismo servidor que esta página:"); + form_label(&f, "web, Windows y Linux juegan juntos. Conviene"); + form_label(&f, "la misma versión (está en el título del menú)."); + } + form_button(&f, 0, en ? "Back" : "Volver"); + run_form(fe, &f, 0, 0); +} +#endif + void app_menu(Frontend *fe, Settings *st) { static const char *LANGS[] = { "Español", "English" }; @@ -682,6 +715,7 @@ void app_menu(Frontend *fe, Settings *st) #else /* la web ofrece bajar el juego para la compu */ form_button(&f, M_DL_WIN, en ? "Download for Windows (catan.exe)" : "Descargar para Windows (catan.exe)"); form_button(&f, M_DL_LINUX, en ? "Download for Linux" : "Descargar para Linux"); + form_button(&f, M_HOWTO, en ? "How to install (read me)" : "Cómo instalarlo (leeme)"); #endif int r = run_form(fe, &f, menu_change, st); static Session s; @@ -705,8 +739,9 @@ void app_menu(Frontend *fe, Settings *st) case M_LAN_JOIN: lan_join_form(fe, st); break; case M_QUIT: return; #ifdef __EMSCRIPTEN__ - case M_DL_WIN: emscripten_run_script("window.open('descargas/catan-windows.zip', '_blank')"); break; - case M_DL_LINUX: emscripten_run_script("window.open('descargas/catan-linux.tar.gz', '_blank')"); break; + case M_DL_WIN: emscripten_run_script("window.open('descargas/catan.exe', '_blank')"); break; + case M_DL_LINUX: emscripten_run_script("window.open('descargas/catan-linux', '_blank')"); break; + case M_HOWTO: howto_form(fe); break; #endif case FORM_CANCEL: #ifndef __EMSCRIPTEN__ diff --git a/catan/tools/linux-release.sh b/catan/tools/linux-release.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Compila el catan de Linux para repartir: un solo archivo que corre en la mayoria de las +# distros. Se compila dentro de un Ubuntu 22.04 (docker) porque un binario de Linux solo +# corre en sistemas con una libc igual o mas nueva que la de donde se compilo; la de esta +# compu es muy nueva. SDL3 y ncurses van adentro (estaticos); lo grafico (X11/Wayland, audio) +# SDL lo busca al arrancar en la compu de cada uno. +# Uso: tools/linux-release.sh <version> <salida> (lo llama make release) +set -e +VERSION=$1; OUT=$2 +SDL_SRC=${WIN_SDL_SRC:-$HOME/.local/opt/src/SDL3-3.4.16} +ROOT=$(cd "$(dirname "$0")/../.." && pwd) +docker run --rm -v "$ROOT":/src:ro -v "$SDL_SRC":/sdl:ro -v "$(dirname "$(realpath -m "$OUT")")":/out \ + -e VERSION="$VERSION" -e OUTNAME="$(basename "$OUT")" -e HUID="$(id -u)" ubuntu:22.04 sh -ec ' + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq >/dev/null + apt-get install -y -qq build-essential cmake ninja-build pkg-config libncurses-dev \ + libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxfixes-dev \ + libwayland-dev libxkbcommon-dev wayland-protocols libegl-dev libgl-dev libdecor-0-dev \ + libasound2-dev libpulse-dev libdrm-dev libgbm-dev >/dev/null + cmake -S /sdl -B /tmp/sdl -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/sdl \ + -DSDL_SHARED=OFF -DSDL_STATIC=ON -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF >/dev/null + cmake --build /tmp/sdl >/dev/null && cmake --install /tmp/sdl >/dev/null + cp -r /src /tmp/j && cd /tmp/j/catan && rm -f catan + make catan VERSION="$VERSION" CFLAGS="-O2" \ + SDL="$(PKG_CONFIG_PATH=/opt/sdl/lib/pkgconfig pkg-config --cflags --static --libs sdl3)" \ + NCURSES="-Wl,-Bstatic -lncursesw -ltinfo -Wl,-Bdynamic" >/dev/null + strip catan + cp catan /out/$OUTNAME && chown $HUID /out/$OUTNAME + ldd /out/$OUTNAME | sed "s/^/ /" +'