sts-term

Une version rudimentaire de Slay The Spire dans le terminal - retour accueil

git clone git://bebou.netlib.re/sts-term
Log | Files | Refs |

commit 32042c892705fb5b66326ec6dafe1279bc6e092a
parent a586fa3a6c60327def8eb8f1276e42ee53dcc080
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 19 Jun 2024 13:27:34 +0200

Meilleure UI

makeui intégré dans utils
génère un fichier UI qu'on cat avec watch (pour le moment)
l'UI met le jouer et les ennemis ainsi que les différents tas de cartes
sur des colonnes plutôt qu'à la suite verticalement

Diffstat:
Dmakeui | 18------------------
Mreset | 2+-
Mutils | 45++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/makeui b/makeui @@ -1,18 +0,0 @@ -#! /bin/sh - -[ ! -e "player" ] && { printf "player doesn't exist\n"; exit 1; } - -showstat() { - [ "$2" = "name" ] && { basename $1; return; } - grep "$2" "$1" | sed 's/\t/ : /' -} -echo "Player\n" -showstat player gold -showstat player health -showstat player energy -echo -echo "Ennemies\n" -showstat map/1/* name -showstat map/1/* health -echo -tree --noreport stack hand discard diff --git a/reset b/reset @@ -1,3 +1,3 @@ #! /bin/sh -rm -rf player relics deck discard stack map hand +rm -rf player relics deck discard stack map hand UI diff --git a/utils b/utils @@ -1,10 +1,46 @@ #! /bin/sh +tmpdir=$(mktemp -d) + +showstat() { + [ "$2" = "name" ] && { basename $1; return; } + grep "$2" "$1" | sed 's/\t/ : /' +} + +makeui() { + [ ! -e "player" ] && { printf "player doesn't exist\n"; exit 1; } + tree --noreport stack > $tmpdir/stack + tree --noreport hand > $tmpdir/hand + tree --noreport discard > $tmpdir/discard + + <<-. cat > $tmpdir/player + Player + + $(showstat player gold) + $(showstat player health) + $(showstat player block) + $(showstat player energy) + . + <<-. cat > $tmpdir/en + Ennemies + + $(showstat map/1/* name) + $(showstat map/1/* health) + . + + paste $tmpdir/player $tmpdir/en | + column -ts ' ' -o ' ' + printf '\n\n' + paste $tmpdir/stack $tmpdir/hand $tmpdir/discard | + column -ts ' ' -o ' ' +} + setstat() { target="$1" stat="$2" value="$3" sed -i -E "/$stat/ s/ .*/ $value/" "$target" + refreshUI } status() { @@ -26,7 +62,7 @@ defend() { block="$1" target="$2" targetblock=$(grep block "$target" | cut -f2) - newblock=$(( $targetblock + "$block" )) + newblock=$(( $targetblock + $block )) setstat "$target" block "$newblock" } @@ -59,6 +95,7 @@ _drawcard() { shuf | head -n 1) mv "$card" hand + refreshUI } drawcards() { @@ -76,6 +113,7 @@ discardcard() { card="$1" dest=$(echo "$card" | sed 's/hand/discard/') mv "$card" "$dest" + refreshUI } playcard() { @@ -83,9 +121,10 @@ playcard() { target="$2" eval $(cat "$card" | sed "s,$, $target," | paste -s -d ';') discardcard "$1" + refreshUI } -draw() { - echo +refreshUI() { + makeui > UI }