Une version rudimentaire de Slay The Spire dans le terminal - retour accueil
git clone git://bebou.netlib.re/sts-term
Log | Files | Refs | README |
commit fb24a4e24678780408a5aad742f8e97d229abee0 parent 1347d895897ba14a4100e5e0e4a7816bd5fbe5df Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Sat, 22 Jun 2024 17:49:53 +0200 Nouvelle UI Eh beh c'est pas rien Des trucs vraiment crado genre le fait de retirer le doublon de gold parce que je sais pas utiliser awk Diffstat:
M | utils | | | 109 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- |
1 file changed, 83 insertions(+), 26 deletions(-)
diff --git a/utils b/utils @@ -10,6 +10,64 @@ _getstat() { grep -wF "$2" "$target" | cut -f2 } +##### +# UI +##### + +_greyoutnonplayablecards() { + find fight/hand -type f | + grep -v -f $tmpdir/execcards | + xargs -r -n1 basename | sed -E 's/-[0-9]+$//' | + while read card;do + sed -i -E "/$card/ s/^/$grayed/;/$card/ s/$/$norm/" $tmpdir/hand + done +} + +_createdisplaycard(){ + local card name + card="$1";name="$(basename $card)" + + <<-. cat > $tmpdir/disp-$name + $name + + $(cat $card | + grep -Ev "moves|bufs" | + sed -E 's/ / : /') + + $(_dispbufsanddebufs $card) + . +} + +_dispbufsanddebufs() { + local target type + target="$1" + + for type in bufs debufs;do + echo "$type" + grep -E "^$type" target | + cut -sf2- | + tr '\t' '\n' | + sed 's/ / : /' | + column -ts',' + done +} + +_showplayerstats() { + head player -n5 | + sed 's/ / : /' | + awk '{printf $0"\t";getline;printf $0"\t";getline;printf $0"\t\n"}' | + sed -E 's/(gold : [0-9]+).*/\1/' | + column -ts' ' +} + +_showpileofcards() { + local pile + pile="$1" + tree --noreport fight/$pile | + sed -E 's/-[0-9]+$//g; + s,fight/,,g' +} + _makeui() { # Pour savoir combien de fois l'ui est rafraichie # Clairement pas optimal mais drĂ´le @@ -19,17 +77,16 @@ _makeui() { currentenergy=$(_getstat player energy) _updatecardexecutability - tree --noreport fight/stack > $tmpdir/stack - tree --noreport fight/hand > $tmpdir/hand - tree --noreport fight/discard > $tmpdir/discard - tree --noreport fight/exhaust > $tmpdir/exhaust + _showpileofcards stack > $tmpdir/stack + _showpileofcards hand > $tmpdir/hand + _showpileofcards discard > $tmpdir/discard + _showpileofcards exhaust > $tmpdir/exhaust - find fight/hand -type f | - grep -v -f $tmpdir/execcards | - xargs -r -n1 basename | - while read card;do - sed -i -E "/$card/ s/^/$grayed/;/$card/ s/$/$norm/" $tmpdir/hand - done + _greyoutnonplayablecards + + for c in fight/ennemies/* ;do + _createdisplaycard "$c" + done <<-. cat Floor : $(cat fight/floor) @@ -37,28 +94,28 @@ _makeui() { . - <<-. cat > $tmpdir/player - Player + <<-. cat > $tmpdir/left-pane + $(_showplayerstats) + + $(_dispbufsanddebufs player) - $(cat player | sed 's/ / : /') - . - <<-. cat > $tmpdir/en - Ennemies + $(paste $tmpdir/disp-* | column -ts' ') + + Next move - $(basename fight/ennemies/*) - $(cat fight/ennemies/* | grep -v moves | sed 's/ / : /') - $(echo "\nNext move :\n") $(cat $tmpdir/nextmove | tr -d '_') + + $(paste $tmpdir/stack $tmpdir/discard $tmpdir/exhaust | column -ts' ') . - - paste $tmpdir/player $tmpdir/en | - column -ts ' ' -o ' ' - printf '\n\n' - paste $tmpdir/stack $tmpdir/hand $tmpdir/discard $tmpdir/exhaust | - column -ts ' ' -o ' ' | - sed -E 's/-[0-9]/ /g;s,fight/([^ ]*),\1 ,g' + + paste $tmpdir/left-pane $tmpdir/hand | + column -ts' ' } +##### +# +#### + _makefight() { rm -rf fight