shithub: andre_quest

ref: ae91e5f2e84bac93f7135a5d59a9c80ba2e57226
dir: /ac/

View raw version
#!/bin/rc
#ANDRE QUEST 9 COMBAT DEMO BLOCKCHAIN PREQUEL AI GENERATED
# controls y/n
# a - attack , p - pure psychic automatism , h - help , q - quit

fn clear { echo >/dev/text }
fn dice { awk 'BEGIN{ srand(); print int(1 + rand() * '$1^' ) }' }
fn ln { awk 'END{print NR}' $1 }
fn rand_w { dice `{ ln $1 } }
fn sortr { sed -n `{rand_w $1}^p $1 }

fn inp {
  >[3]/dev/consctl{
     echo rawon >[1=3]
     echo -n '> '
     inp = `{read -c 1 /dev/cons}
     if (~ $inp q) exit
  }
}

fn hud {
cat <<eof >/dev/text
Andre
 hp: $hp
wep: $wep
psa: $psa

 ~VERSUS~

$enemy
 hp: $e_hp
wep: $e_wep

eof
}

fn prep {
  switch ($1) {
    case [aeiou]* ; echo -n an
    case * ; echo -n a
  }
}

fn caser {
 switch($inp) {
  case h 
echo
cat <<eof
a - attack with the $wep
p - use pure psychic automatism
h - this help
q - quit

Enter to cont.
eof
read
  case a
 attack
  case p
 psa
 }
}

fn banter {
cat <<eof
I. AM. SURREALISM!
DIE!
Take this, Andre!
Take this!
Chew on my $e_wep !
Andre, my name is $enemy , you killed my father. Prepare to die.
You cannot block my style.
Prepare to be punished.
I will pour molten ink down your throat!
I hope this doesn't hurt too much!
eof
}

fn banter_hurt {
cat <<eof
Bastard!
That barely hurt.
Ouch.
That tickles, Andre.
Andre! That hurt!
How dare you!
I will get you for this!
eof
}

fn type_sim {
 for (i) { for (ii in `{echo $i | sed 's,.,& ,g'} ) {
            sleep .05 #^`{dice 2}
            echo -n $ii
      }
  echo -n ' '
 }
echo
}

fn psa {

 if (test $psa -gt 0 ) {
 echo >/dev/text
 type_sim `{ sed 10q /dev/random | tr -dc aeiouyhckrdtn}
 echo
 
 type_sim $enemy : " wtf? "
 type_sim Andre : " I dunno. Computer speak. "
 sleep 2

 psa = `{ echo $psa - 1 | bc } 
 }
 if not echo Andre is out of pure psychic surrealism.
}

fn e_gen {

  fn e_chars {
 cat << eof
Phillip Soupalt
Toyen
Jacquelin Lamba
Nadja
Kay Sage
Paul Eluard
Yves Tanguy
Man Ray
Salvador Dali
eof
  }

 fn e_weps {
 cat << eof
wet fish
sharpened paintbrush
manifesto of surrealism
first edition of the book of C
packet filter
phone protective screen
box of parentheses
interlisp t-shirt
machine gun
cracked thinkpad
rob pike
rabbit hat
beer can
corn on the cob
hentai calendar
pirate hook
macaroni picture
sickly dog
eof
  }

 e_l = `{e_chars | ln }
 enemy = `{e_chars | sed -n `{dice $e_l}^p}
 e_l = `{e_weps | ln }
 e_wep =`{e_weps | sed -n `{dice $e_l}^p}
 wep = `{e_weps | sed -n `{dice $e_l}^p}
 e_hp = 10
 hp = 10
 psa = 3

}

fn verbs {
cat <<eof
readies
flicks
licks
pongs
pings
pats
cocks
fondles
eof
}

fn hp_ck {
if ( test $hp -le 0 ) hp = 0
if ( test $e_hp -le 0 ) e_hp = 0
switch ($hp) {
 case 0 ; echo Andre is dead. ; exit
 }
switch ($e_hp) {
 case 0 ; echo Andre defeated $enemy . ; exit
 }
}

fn battle {
 if ( ~ $turn 1 ) {
 verb_l = `{verbs | ln }
 verb = `{ verbs | sed -n `{dice $verb_l}^p }
 banter_l = `{ banter | ln }
 banter = `{ banter | sed -n `{ dice $banter_l}^p }
 dmg = `{ dice 6 }

 echo $enemy $verb the $e_wep .
 type_sim $enemy : $banter
 echo Andre is damaged for $dmg points.

 hp = `{ echo $hp - $dmg | bc }
 turn = 0
 hp_ck
 echo Cont.
 read
 }

}

fn attack {
 verb_l = `{verbs | ln }
 verb = `{ verbs | sed -n `{dice $verb_l}^p }
 dmg = `{ dice 6 }
 banter_l = `{ banter_hurt | ln }
 banter = `{ banter_hurt | sed -n `{ dice $banter_l}^p }

 echo Andre $verb the $"wep .
 echo $"enemy is damaged for $dmg points.
 type_sim $enemy : " $banter "
 e_hp = `{ echo $e_hp - $dmg | bc }
 turn = 1
 hp_ck
 echo Cont.
 read

}

e_gen
#echo >/dev/text
type_sim Andre comes across $enemy armed with `{prep $"e_wep} $e_wep .
type_sim $enemy : "Andre! Fight me!"
type_sim Andre must fight $enemy .
echo
ok=1; n=1
while (~ $ok 1) {

type_sim Fight $enemy '?'
inp
switch ($inp) {
 case [yY]   
     type_sim Perfect. Andre readies his $wep .
     sleep .3
     ok=0 
 case [nN] 
     if (~ $n 3 ) { echo Fine, you chicken. ; exit }
     type_sim You must fight $enemy ...
     n = `{ echo $n +1 | bc }
  }
}

flip = `{ dice 2 }
turn = 1
if ( ~ $flip 1 ) turn = 0

while (test $hp -gt 0 || test $e_hp -gt 0) {

 hud
 battle
 hud
 inp
 caser

}