Une version rudimentaire de Slay The Spire dans le terminal - retour accueil
git clone git://bebou.netlib.re/sts-term
Log | Files | Refs |
commit 2436c7670797c927b145ed70d33a06fd69e24089 parent 0b2b39c6ff7c5fb32ce0a78d1213d61a0a6cb226 Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Wed, 19 Jun 2024 12:12:23 +0200 Ajout main et mécanismes de tir et défausse Diffstat:
M | .gitignore | | | 1 | + |
M | makeplayer | | | 2 | +- |
M | reset | | | 2 | +- |
M | utils | | | 34 | ++++++++++++++++++++++++++++++++-- |
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -5,3 +5,4 @@ map relics UI player +hand diff --git a/makeplayer b/makeplayer @@ -13,7 +13,7 @@ addrelic() { cp bdd/relics/$1 relic/$1 } -mkdir -p deck relics discard stack +mkdir -p deck relics discard stack hand c=$(./pickrandom characters) < $c grep -Ev "(deck|relic)" > player diff --git a/reset b/reset @@ -1,3 +1,3 @@ #! /bin/sh -rm -rf player relics deck discard stack map +rm -rf player relics deck discard stack map hand diff --git a/utils b/utils @@ -7,7 +7,7 @@ setstat() { sed -i -E "/$stat/ s/ .*/ $value/" "$target" } -setstatus() { +status() { target="$1" stat="$2" value="$3" @@ -42,9 +42,39 @@ cost() { setstat player energy "$newenergy" } +shufflediscard() { + mv discard/* stack +} + +endturn() { + find hand -type f | + while read card;do + discardcard $card + done +} + +_drawcard() { + [ "$(find stack -type f | wc -l)" = "0" ] && shufflediscard + card=$(find stack -type f | + shuf | + head -n 1) + mv "$card" hand +} + +drawcards() { + nbtodraw="$1" + for nb in $(seq $nbtodraw);do + _drawcard + done +} + +newhand() { + drawcards 5 +} + discardcard() { card="$1" - dest=$(echo "$card" | sed 's/stack/discard/') + dest=$(echo "$card" | sed 's/hand/discard/') mv "$card" "$dest" }