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 df79c8f78dfa08be2c3c8c9fb32d0057e696b239 parent e7efe9ad0a9a497b6c9fb140301861ea22c600a5 Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Thu, 20 Jun 2024 20:59:42 +0200 Gestion de weakness (uppercut pour test) Diffstat:
A | bdd/cards/uppercut | | | 4 | ++++ |
M | utils | | | 18 | +++++++++++------- |
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/bdd/cards/uppercut b/bdd/cards/uppercut @@ -0,0 +1,4 @@ +_cost 2 +_attack 13 1 +_status vulnerable 1 +_status weak 1 diff --git a/utils b/utils @@ -94,7 +94,7 @@ _addcard() { . ./utils $(cat bdd/cards/$2 | sed -E '/^_(cost|defend) / s/$/ player/; - /^_(attack|status) / s/$/ "${1:?need a target}"/; + /^_(attack|status) / s/$/ "${1:?need a target}" fight\/player/; /^_exhaust$/ s/$/ "$0"/' | sort) _discard "\$0" @@ -160,9 +160,10 @@ _gameover() { _dodamage() { ffplay -nodisp -autoexit -loglevel panic -i sounds/hit.ogg - damage="$1";target="$2" + damage="$1";target="$2";hitter="$3" targethealth=$(_getstat "$target" health);targetblock=$(_getstat "$target" block) - _hasstatus "$target" vulnerable && multiplier=1.5 || multiplier=1 + _hasstatus "$hitter" weak && multiplier=0.75 || multiplier=1 + _hasstatus "$target" vulnerable && multiplier=$(echo "$multiplier*1.5" | bc -l) newblock=$(echo "($targetblock - $damage*$multiplier)/1" | bc) # Si la quantité de block qui reste est négative c'est qu'on prend cette # quantité de dégât @@ -175,8 +176,10 @@ _attack() { damage="$1" times="$2" target="$3" + hitter="$4" for i in $(seq $times);do - _dodamage "$damage" "$target" + echo _dodamage "$damage" "$target" "$hitter" + _dodamage "$damage" "$target" "$hitter" done; } @@ -325,14 +328,15 @@ _decreasestatuses() { while read ennemy;do statuses=$(_getstatuses "$ennemy") [ -z "$statuses" ] && continue - for stat in "$statuses";do + echo "$statuses" | + while read stat;do _status "$stat" -1 "$ennemy" done done } _hasstatus() { - target="${1:?need target}" + local target="${1:?need target}" stat="$2" grep -Eq "^(de)?bufs.*$stat,[0-9]+" "$target" } @@ -361,7 +365,7 @@ _nextmove() { tr ',' ' ' | tr ';' '\n' > $tmpdir/nextmove <<-. cat > $tmpdir/executablenextmove . ./utils - $(< $tmpdir/nextmove sed -E '/attack/ s/$/ fight\/player/;/defend/ s,$, fight/ennemies/*,') + $(< $tmpdir/nextmove sed -E "/attack/ s,$, fight/player fight/ennemies/*,;/defend/ s,$, fight/ennemies/*,") . chmod +x $tmpdir/executablenextmove }