shithub: tarico

ref: b0f84dfff2d22507165a2c81e4faa094436ca82c
dir: /tarico/

View raw version
#!/bin/rc
# cards by aquirax uno; used without permission
rfork e

url = https://triapul.cz/files/tarico
fn roll{ awk 'BEGIN{ srand(); print int(0 + rand() * 21 ) }' }
fn flip{ awk 'BEGIN{ srand(); print int(1 + rand() * 2 ) }' }

fn caser{
 switch($i){
   case 0 ; echo $1 The Fool
   case 1 ; echo $1 The Magician 
   case 2 ; echo $1 The High Priestess
   case 3 ; echo $1 The Empress
   case 4 ; echo $1 The Emperor
   case 5 ; echo $1 The Hierophant
   case 6 ; echo $1 The Lovers
   case 7 ; echo $1 The Chariot
   case 8 ; echo $1 Strength
   case 9 ; echo $1 Hermit
   case 10 ; echo $1 Wheel of Fortune
   case 11 ; echo $1 Justice
   case 12 ; echo $1 The Hanged Man
   case 13 ; echo $1 Death
   case 14 ; echo $1 Temperance
   case 15 ; echo $1 The Devil
   case 16 ; echo $1 The Tower
   case 17 ; echo $1 The Star
   case 18 ; echo $1 The Moon
   case 19 ; echo $1 The Sun
   case 20 ; echo $1 Judgement
   case 21 ; echo $1 The World
 }
}

#shuffle
cur = 'a'
prev = 'b'
prev2 = 'c'

for (n in one two three) {
  prev2=$prev
  prev=$cur
  $cur=`{roll}
  while ( ~ $cur $prev || ~ $cur $prev2 || ~ $prev $prev2 ) {
  cur=`{roll}
#  echo dupe, reroll
   }
  shuffle = ( $shuffle $cur )
}

# the window `hack' makes sure that page is of the correct size (fit to image).
# page -w only resizes to the image, if it's focused (only the first picture
# would be resized otherwise. bug in page? -
# try ` for ( i in image1 image2 ) { page -w $i & } '

for ( i in $shuffle ) {
  if (~ `{flip} 1) {
    window -dx 445 -dy 745 'hget '^$url^'/'^$i^' | png -c | rotate -r 180 | page -R'
    r=r.
  }
  if not { 
    window -dx 445 -dy 745 'hget '^$url^'/'^$i^' | png -c | page -R'
    r=()
  }
  caser $r
}