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 9587d58a2ed1a8e9f265ef5c7d8dfde714da2595 parent 070c1c4db34ef6357bfba341bf0e18fab3a8bf4d Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Wed, 19 Jun 2024 18:21:00 +0200 Les combats se passent dans fight Dans fight sont fait des liens symboliques vers les fichiers ennemis et player qui existent dans leurs dossiers respectifs stack hand et discard sont créés pour l'occasion Diffstat:
M | .gitignore | | | 1 | + |
A | makefight | | | 15 | +++++++++++++++ |
M | makegame | | | 3 | +-- |
M | reset | | | 2 | +- |
M | utils | | | 50 | +++++++++++++++++++++++++------------------------- |
5 files changed, 43 insertions(+), 28 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -6,3 +6,4 @@ relics UI player hand +fight diff --git a/makefight b/makefight @@ -0,0 +1,15 @@ +#! /bin/sh + +mkdir -p fight/ennemies +mkdir -p fight/stack +mkdir -p fight/hand +mkdir -p fight/discard + +cp deck/* fight/stack + +for en in $(find "$1" -type f);do + ln "$en" fight/ennemies/$(basename "$en") +done + +ln player fight/player + diff --git a/makegame b/makegame @@ -15,7 +15,6 @@ addcard() { refreshUI . mv A deck/$2-$i - cp deck/$2-$i stack done } @@ -32,7 +31,7 @@ for floor in $(seq 1 10);do done } -mkdir -p deck relics discard stack hand +mkdir -p deck relics 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 hand UI +rm -rf player relics deck discard stack map hand UI fight diff --git a/utils b/utils @@ -14,12 +14,12 @@ makeui() { [ ! -e "player" ] && { printf "player doesn't exist\n"; exit 1; } currentenergy=$(grep energy player | cut -f2) - grep cost hand/* | + grep cost fight/hand/* | awk "\$2>$currentenergy{print}" | cut -d':' -f1 | xargs -r -n1 basename > $tmpdir/nonexeccards - tree --noreport stack > $tmpdir/stack - tree --noreport hand > $tmpdir/hand - tree --noreport discard > $tmpdir/discard + tree --noreport fight/stack > $tmpdir/stack + tree --noreport fight/hand > $tmpdir/hand + tree --noreport fight/discard > $tmpdir/discard while read card;do sed -i -E "/$card/ s/^/$grayed/;/$card/ s/$/$norm/" $tmpdir/hand @@ -36,9 +36,9 @@ makeui() { <<-. cat > $tmpdir/en Ennemies - $(showstat map/1/* name) - $(showstat map/1/* health) - $(showstat map/1/* block) + $(showstat fight/ennemies/* name) + $(showstat fight/ennemies/* health) + $(showstat fight/ennemies/* block) $(echo "\nNext move :\n") $(cat $tmpdir/nextmove) . @@ -48,7 +48,7 @@ makeui() { printf '\n\n' paste $tmpdir/stack $tmpdir/hand $tmpdir/discard | column -ts ' ' -o ' ' | - sed -E 's/-[0-9]/ /g' + sed -E 's/-[0-9]/ /g;s,fight/([^ ]*),\1 ,g' } setstat() { @@ -92,13 +92,13 @@ hasstatus() { _updatecardexecutability() { currentenergy=$(grep energy player | cut -f2) - grep cost hand/* | + grep cost fight/hand/* | awk "\$2<=$currentenergy{print}" | cut -d':' -f1 | while read card;do chmod +x "$card" done - grep cost hand/* | + grep cost fight/hand/* | awk "\$2>$currentenergy{print}" | cut -d':' -f1 | while read card;do @@ -113,24 +113,24 @@ cost() { setstat player energy "$newenergy" } -shufflediscard() { - mv discard/* stack +shufflefight/discard() { + mv fight/discard/* fight/stack } endturn() { - find hand -type f | + find fight/hand -type f | while read card;do - discard $card + fight/discard $card done } _draw() { - [ "$(find stack -type f | wc -l)" = "0" ] && shufflediscard - card=$(find stack -type f | + [ "$(find fight/stack -type f | wc -l)" = "0" ] && shufflefight/discard + card=$(find fight/stack -type f | shuf | head -n 1) chmod +x "$card" - mv "$card" hand + mv "$card" fight/hand _updatecardexecutability refreshUI } @@ -142,18 +142,18 @@ draw() { done } -newhand() { - find hand -type f | +newfight/hand() { + find fight/hand -type f | while read card;do - discard "$card" + fight/discard "$card" done draw 5 } -discard() { +fight/discard() { card="$1" chmod -x "$card" - mv "$card" discard + mv "$card" fight/discard refreshUI } @@ -161,7 +161,7 @@ playcard() { card="$1" target="$2" eval $(cat "$card" | sed "s,$, $target," | paste -s -d ';') - discard "$1" + fight/discard "$1" refreshUI } @@ -174,7 +174,7 @@ refreshUI() { ##### nextmove() { - cat map/1/* | + cat fight/ennemies/* | grep moves | cut -f2- | tr ' ' '\n' | @@ -182,7 +182,7 @@ nextmove() { tr ',' ' ' | tr ';' '\n' > $tmpdir/nextmove <<-. cat > $tmpdir/executablenextmove . ./utils - $(< $tmpdir/nextmove sed -E '/attack/ s/$/ player/;/defend/ s,$, map/1/*,') + $(< $tmpdir/nextmove sed -E '/attack/ s/$/ player/;/defend/ s,$, fight/ennemies/*,') refreshUI . chmod +x $tmpdir/executablenextmove