Une version rudimentaire de Slay The Spire dans le terminal - retour accueil
git clone git://bebou.netlib.re/sts-term
Log | Files | Refs |
commit f9b4bad4fc03b7cf245f7bf5f6a5538d25d1db6c parent 397ece31da777247149a315cf50d76886ef42cd1 Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Wed, 19 Jun 2024 11:07:06 +0200 Ajout des utils Banque de fonction qui font tout un tas de truc jouer une carte modifier une stat etc Diffstat:
A | utils | | | 61 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 61 insertions(+), 0 deletions(-)
diff --git a/utils b/utils @@ -0,0 +1,61 @@ +#! /bin/sh + +setstat() { + target="$1" + stat="$2" + value="$3" + sed -i -E "/$stat/ s/ .*/ $value/" "$target" +} + +setstatus() { + target="$1" + stat="$2" + value="$3" + sed -i -E "/$stat/ s/ / $value,/" "$target" +} + +attack() { + damage="$1" + target="$2" + targethealth=$(grep health "$target" | cut -f2) + newhealth=$(( $targethealth - "$damage" )) + setstat "$target" health "$newhealth" +} + +defend() { + block="$1" + target="$2" + targetblock=$(grep block "$target" | cut -f2) + newblock=$(( $targetblock + "$block" )) + setstat "$target" block "$newblock" +} + +hasstatus() { + echo +} + +cost() { + printf "minus $1 energy" + cost="$1" + currentenergy=$(grep energy player | cut -f2) + newenergy=$(( $currentenergy - $cost )) + setstat player energy "$newenergy" +} + +discardcard() { + card="$1" + dest=$(echo "$card" | sed 's/stack/discard/') + mv "$card" "$dest" +} + +playcard() { + card="$1" + target="$2" + eval $(cat "$card" | sed "s,$, $target," | paste -s -d ';') + discardcard "$1" +} + +draw() { + echo +} +