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 f7c512fa438779031150dad5829c6b5d12598ef0
parent db02257c24ab018172d72a4f740317b14e14f4e6
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 19 Jun 2024 21:00:39 +0200

Gestion mort d'un ennemie et fin de combat

Aussi correction de bug pour les chmod des cartes

Bug connus : passage d'un comabt à l'autre ne fonctionne pas bien, nrj
pas reset à 3, parfois une carte reste dans la défausse

Diffstat:
Mutils | 27++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/utils b/utils @@ -14,7 +14,7 @@ _makeui() { [ ! -e "player" ] && printf "No current game\n" currentenergy=$(grep energy fight/player | cut -f2) - grep cost fight/hand/* | + grep -H cost fight/hand/* | awk "\$2>$currentenergy{print}" | cut -d':' -f1 | xargs -r -n1 basename > $tmpdir/nonexeccards tree --noreport fight/stack > $tmpdir/stack @@ -75,16 +75,27 @@ _makefight() { done ln -rs -f player fight/player + _setstat fight/player energy 3 _newhand _nextmove } +_killennemie() { + rm -rf "$(readlink -e $target)" + if [ $(find fight/ennemies -type f | wc -l) = '0' ];then + _makefight map/$(( $(cat fight/floor) + 1 )) + fi +} + _setstat() { target="$1" stat="$2" value="$3" - if [ "$stat" = "health" -a "$target" = "fight/player" -a "$value" -le '0' ];then - _gameover + if [ "$stat" = "health" -a "$value" -le '0' ];then + case "$target" in + ("*player*") _gameover;; + (*) _killennemie "$target";; + esac else sed -i --follow-symlinks -E "/$stat/ s/ .*/ $value/" "$target" fi @@ -130,13 +141,13 @@ _hasstatus() { _updatecardexecutability() { currentenergy=$(grep energy fight/player | cut -f2) - grep cost fight/hand/* | + grep -H cost fight/hand/* | awk "\$2<=$currentenergy{print}" | cut -d':' -f1 | while read card;do chmod +x "$card" done - grep cost fight/hand/* | + grep -H cost fight/hand/* | awk "\$2>$currentenergy{print}" | cut -d':' -f1 | while read card;do @@ -148,7 +159,7 @@ _cost() { cost="$1" currentenergy=$(grep energy fight/player | cut -f2) newenergy=$(( $currentenergy - $cost )) - setstat fight/player energy "$newenergy" + _setstat fight/player energy "$newenergy" } _shufflediscard() { @@ -158,10 +169,12 @@ _shufflediscard() { endturn() { _setstat fight/ennemies/* block 0 _execnextmove - _newhand _setstat fight/player block 0 + _setstat fight/player energy 3 _nextmove + _newhand echo "$(( $(cat fight/turn) + 1 ))" > fight/turn + _refreshUI } _draw() {