/*+JMJ
 * aceyducy.c - Acey Deucey card game
 *
 * Ported from Creative Computing BASIC Games Collection
 *
 * 2015 David Meyer <papa@sdf.org>
 */

#include <stdio.h>
#include "krcompat.h"

int main ()
{

}

/*
  10 rem Portability enhancement by David Meyer (2012/2/3)
  20 def FNA(P,Q)=-1*P*Q
  30 def FNO(P,Q)=SGN(P+Q)
  40 def FNN(P)=-1*P-1
  50 def FNI(P,A,B)=ABS(P)*A+ABS(FNN(P))*B
  60 def FNI$(P,A$,B$)=LEFT$(A$,ABS(P)*LEN(A$))+LEFT$(B$,ABS(FNN(P))*LEN(B$))
  70 def FNY(A$,Q)=FNI(LEN(A$)=0,Q,FNO(LEFT$(A$,1)="Y",LEFT$(A$,1)="y"))
  80 
  90 print tab(26);"ACEY DUCEY CARD GAME"
 100 print tab(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
 110 print
 120 print
 130 print "ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER "
 140 print "THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP"
 150 print "YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING"
 160 print "ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE"
 170 print "A VALUE BETWEEN THE FIRST TWO."
 180 print "IF YOU DO NOT WANT TO BET, INPUT A 0"
 190 N=100
 200 Q=100
 210 print "YOU NOW HAVE";Q;" DOLLARS."
 220 print
 230 goto 280
 240 Q=Q+M
 250 goto 210
 260 Q=Q-M
 270 goto 210
 280 print "HERE ARE YOUR NEXT TWO CARDS: "
 290 A=INT(14*RND(1))+2
 300 if A<2 then goto 290
 310 if A>14 then goto 290
 320 B=INT(14*RND(1))+2
 330 if B<2 then goto 320
 340 if B>14 then goto 320
 350 if A>=B then goto 290
 360 if A<11 then goto 410
 370 if A=11 then goto 430
 380 if A=12 then goto 450
 390 if A=13 then goto 470
 400 if A=14 then goto 490
 410 print A
 420 goto 500
 430 print "JACK"
 440 goto 500
 450 print "QUEEN"
 460 goto 500
 470 print "KING"
 480 goto 500
 490 print "ACE"
 500 if B<11 then goto 550
 510 if B=11 then goto 570
 520 if B=12 then goto 590
 530 if B=13 then goto 610
 540 if B=14 then goto 630
 550 print B
 560 goto 650
 570 print "JACK"
 580 goto 650
 590 print "QUEEN"
 600 goto 650
 610 print "KING"
 620 goto 650
 630 print "ACE"
 640 print
 650 print
 660 input "WHAT IS YOUR BET";M
 670 if M<>0 then goto 710
 680 print "CHICKEN!!"
 690 print
 700 goto 280
 710 if M<=Q then goto 750
 720 print "SORRY, MY FRIEND, BUT YOU BET TOO MUCH."
 730 print "YOU HAVE ONLY ";Q;" DOLLARS TO BET."
 740 goto 650
 750 C=INT(14*RND(1))+2
 760 if C<2 then goto 750
 770 if C>14 then goto 750
 780 if C<11 then goto 830
 790 if C=11 then goto 850
 800 if C=12 then goto 870
 810 if C=13 then goto 890
 820 if C=14 then goto 910
 830 print C
 840 goto 930
 850 print "JACK"
 860 goto 930
 870 print "QUEEN"
 880 goto 930
 890 print "KING"
 900 goto 930
 910 print "ACE"
 920 print
 930 if C>A then goto 950
 940 goto 980
 950 if C>=B then goto 980
 960 print "YOU WIN!!!"
 970 goto 240
 980 print "SORRY, YOU LOSE"
 990 if M<Q then goto 260
1000 print
1010 print
1020 print "SORRY, FRIEND, BUT YOU BLEW YOUR WAD."
1030 print : print
1040 input "TRY AGAIN (YES OR NO)";A$
1050 print : print
1060 if FNY(A$,0) then goto 200
1070 print "O.K., HOPE YOU HAD FUN!"
1080 end
*/

/*
Acey Deucy:

- 3rd card between 1st & 2nd: Player wins bet
- 3rd card outside 1st & 2nd: Player loses bet
- 3rd card matches 1st or 2nd ("hit the post"): 
  Player loses double bet

If 1st & 2nd cards same value, player guesses whether 3rd card 
higher or lower.
- Correct guess: Player wins bet
- Incorrect guess: Player loses bet
- 3rd card matches 1st & 2nd ("hit the post"): 
  Player loses triple bet

-- summarized from Wikipedia
*/