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 5fe30427ad38cefee3fd12097f504996f3df992f
parent 1c571a723a5705704097e479da8990d91818c583
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 19 Jun 2024 14:04:20 +0200

Diverses améliorations

Renommage de quelques fonction
Les scripts ne sont exec que lorsqu'ils sont dans la main
Correction bug de calcul de la vie après attaque

Diffstat:
Mmakegame | 3+--
Mutils | 22+++++++++++-----------
2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/makegame b/makegame @@ -6,11 +6,10 @@ addcard() { for i in $(seq $count $(( $count + $1 - 1)));do <<-. cat > A . ./utils - $(cat bdd/cards/$2 | sed -E '/(cost|defend)/ s/$/ player/;/attack/ s/$/ "$1"/') + $(cat bdd/cards/$2 | sed -E '/(cost|defend)/ s/$/ player/;/attack/ s/$/ "${1:?need a target}"/') discard "\$0" refreshUI . - chmod +x A mv A deck/$2-$i cp deck/$2-$i stack done diff --git a/utils b/utils @@ -54,7 +54,7 @@ attack() { damage="$1" target="$2" targethealth=$(grep health "$target" | cut -f2) - newhealth=$(( $targethealth - "$damage" )) + newhealth=$(( $targethealth - $damage )) setstat "$target" health "$newhealth" } @@ -71,7 +71,6 @@ hasstatus() { } cost() { - printf "minus $1 energy" cost="$1" currentenergy=$(grep energy player | cut -f2) newenergy=$(( $currentenergy - $cost )) @@ -85,34 +84,35 @@ shufflediscard() { endturn() { find hand -type f | while read card;do - discardcard $card + discard $card done } -_drawcard() { +_draw() { [ "$(find stack -type f | wc -l)" = "0" ] && shufflediscard card=$(find stack -type f | shuf | head -n 1) + chmod +x "$card" mv "$card" hand refreshUI } -drawcards() { +draw() { nbtodraw="$1" for nb in $(seq $nbtodraw);do - _drawcard + _draw done } newhand() { - drawcards 5 + draw 5 } -discardcard() { +discard() { card="$1" - dest=$(echo "$card" | sed 's/hand/discard/') - mv "$card" "$dest" + chmod -x "$card" + mv "$card" discard refreshUI } @@ -120,7 +120,7 @@ playcard() { card="$1" target="$2" eval $(cat "$card" | sed "s,$, $target," | paste -s -d ';') - discardcard "$1" + discard "$1" refreshUI }