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 | README |

commit f13fef5d5f5145268e76b55d038df12e077520f0
parent c2dbea250ffd996aefe148bc0493e4a4ef696816
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Thu, 20 Jun 2024 22:00:43 +0200

power-through et gestion de cartes qui font rien

par contre bug sur l'exec des cartes, à corriger

Diffstat:
Abdd/cards/power-through | 3+++
Abdd/cards/wounds | 0
Mutils | 56++++++++++++++++++++++++++++++++------------------------
3 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/bdd/cards/power-through b/bdd/cards/power-through @@ -0,0 +1,3 @@ +_cost 1 +_defend 15 +_addcard 2 wounds fight/hand diff --git a/bdd/cards/wounds b/bdd/cards/wounds diff --git a/utils b/utils @@ -22,11 +22,12 @@ _makeui() { tree --noreport fight/discard > $tmpdir/discard tree --noreport fight/exhaust > $tmpdir/exhaust - cat $tmpdir/nonexeccards | - xargs -r -n1 basename | - while read card;do - sed -i -E "/$card/ s/^/$grayed/;/$card/ s/$/$norm/" $tmpdir/hand - done + 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 <<-. cat Floor : $(cat fight/floor) @@ -75,9 +76,9 @@ _makefight() { done ln -rs -f player fight/player - _setstat fight/player energy 3 _setstat fight/player block 0 _newhand + _setstat fight/player energy 3 _nextmove _refreshUI } @@ -88,19 +89,26 @@ _exhaust() { } _addcard() { + howmuch="$1" + name="$2" + dest="${3:-deck}" nbcard=$(find deck -name "$2-*" | wc -l) - for i in $(seq $(( $nbcard + 1 )) $(( $nbcard + $1 )));do - <<-. cat > A - . ./utils - $(cat bdd/cards/$2 | - sed -E '/^_(cost|defend) / s/$/ player/; - /^_(attack|status) / s/$/ "${1:?need a target}" fight\/player/; - /^_exhaust$/ s/$/ "$0"/' | - sort) - _discard "\$0" - _refreshUI - . - mv A deck/$2-$i + for i in $(seq $(( $nbcard + 1 )) $(( $nbcard + $howmuch )));do + if [ "$name" = "wounds" ];then + cp bdd/cards/$name $dest/$name-$i + else + <<-. cat > $tmpdir/A + . ./utils + $(cat bdd/cards/$name | + sed -E '/^_(cost|defend) / s/$/ player/; + /^_(attack|status) / s/$/ "${1:?need a target}" fight\/player/; + /^_exhaust$/ s/$/ "$0"/' | + sort) + _discard "\$0" + _refreshUI + . + mv $tmpdir/A $dest/$name-$i + fi done } @@ -197,16 +205,16 @@ _defend() { _updatecardexecutability() { currentenergy=$(_getstat "$target" energy) grep -H cost fight/hand/* | - awk "\$2>$currentenergy{print}" | - cut -d':' -f1 > $tmpdir/nonexeccards + awk "\$2<=$currentenergy{print}" | + cut -d':' -f1 > $tmpdir/execcards - for card in $(cat $tmpdir/nonexeccards);do - chmod -x "$card" + for card in $(cat $tmpdir/execcards);do + chmod +x "$card" done - for card in $(find fight/hand/* -type f | grep -v -f $tmpdir/nonexeccards) + for card in $(find fight/hand/* -type f | grep -v -f $tmpdir/execcards) do - chmod +x "$card" + chmod -x "$card" done }