223223' Player and table selection variables
224224TableNumber =0
225225myName$=" TESTER" ' Default name will get this from App key when I learn how to do that
226- gameover =0
227- shown =0
228226
229227' Game state variables
230228Drawdeck =0
@@ -245,8 +243,8 @@ for i=0 to 5
245243next i
246244move$=" "
247245PlayerIndex =0
248- ' Game Result variables
249- MessageLine1$= " "
246+ dealt = 0
247+
250248' Error variable
251249_ERR =0
252250' Index variable for reading FujiNet JSON data
305303' --------- End of Main program ----------------------
306304
307305' MY ROUTINES
306+
308307PROC TitleScreen
309308 @ClearKeyQueue
310309 @EnableDoubleBuffer
@@ -520,6 +519,7 @@ PROC CheckVaildMove _move
520519ENDPROC
521520
522521PROC ShowResults
522+ dealt =0
523523 @EnableDoubleBuffer
524524 @ResetScreen
525525 @POS 2 ,0 : @Print &" ROUND OVER - PLAYERS HANDS AND SCORES"
@@ -818,6 +818,28 @@ PROC StartGame
818818 @CallFujiNet
819819ENDPROC
820820
821+ Proc DealCards
822+ data yend ()=19 ,14 ,8 ,3 ,8 ,14
823+ data xend0 ()=8 ,12 ,16 ,20 ,24 ,28
824+ data xend1 ()=1 ,3 ,5 ,7 ,9 ,11
825+ data xend2 ()=1 ,3 ,5 ,7 ,9 ,11
826+ data xend3 ()=14 ,16 ,18 ,20 ,22 ,24
827+ data xend4 ()=38 ,36 ,34 ,32 ,30 ,28
828+ data xend5 ()=38 ,36 ,34 ,32 ,30 ,28
829+ for cardnumber =1 to 6
830+ for player =0 to 5
831+ if player =0 and playerName$(player )<>" " then @DrawCardFromDeck xend0 (cardnumber -1 ),yend (player ),VAL (PlayerHand $(player )[cardnumber,1 ])
832+ if player =1 and playerName$(player )<>" " then @DrawCardFromDeck xend1 (cardnumber -1 ),yend (player ),9
833+ if player =2 and playerName$(player )<>" " then @DrawCardFromDeck xend2 (cardnumber -1 ),yend (player ),9
834+ if player =3 and playerName$(player )<>" " then @DrawCardFromDeck xend3 (cardnumber -1 ),yend (player ),9
835+ if player =4 and playerName$(player )<>" " then @DrawCardFromDeck xend4 (cardnumber -1 ),yend (player ),9
836+ if player =5 and playerName$(player )<>" " then @DrawCardFromDeck xend5 (cardnumber -1 ),yend (player ),9
837+ next player
838+ next cardnumber
839+ @DrawCardFromDeck 20 ,9 ,DiscardTop
840+ dealt =1
841+ ENDPROC
842+
821843PROC CheckErrors
822844 ' Check data returned from FujiNet to see if it was successful or not
823845 ' and display appropriate message
@@ -914,10 +936,10 @@ PROC DrawGameState
914936 @POS 15 ,16 : @PrintByte 254 :@POS 23 ,16 : @PrintByte 254
915937 @DrawPlayers
916938 if LastMovePlayed$=" Waiting for players to join"
917- @POS 2 ,2 : @Print &" PLEASE WAIT FOR OTHER PLAYERS TO JOIN"
918- @POS 3 ,3 : @Print &" OR PRESS S TO START WITH AI PLAYERS"
939+ @POS 2 ,3 : @Print &" PLEASE WAIT FOR OTHER PLAYERS TO JOIN"
940+ @POS 3 ,4 : @Print &" OR PRESS S TO START WITH AI PLAYERS"
919941 @DrawCard 17 ,9 ,8 ' Draw Deck
920- @DrawCard 20 ,9 ,0 ' Discard Pile
942+ ' @DrawCard 20,9,0 ' Discard Pile
921943 @DrawBufferEnd
922944 @ShowScreen
923945 exit
@@ -928,6 +950,14 @@ PROC DrawGameState
928950 else
929951 @DrawCard 17 ,9 ,0 ' Empty Draw Deck
930952 endif
953+ if dealt =0
954+ DrawDeck =56
955+ @POS 19 ,13 : @PrintVal Drawdeck
956+ @DrawBufferEnd
957+ @ShowScreen
958+ @DealCards
959+ @EnableDoubleBuffer
960+ Endif
931961 @DrawCard 20 ,9 ,DiscardTop ' Discard Pile
932962 @POS 1 ,24 : @PrintUpper & LastMovePlayed $[1 ,38 ]
933963 @POS 5 ,25 :@Print &" H-HELP C-COLOR E-EXIT Q-QUIT"
@@ -1129,35 +1159,37 @@ PROC DrawPlayers
11291159 @POS X +Xoffset ,Y : @Print &" :"
11301160 @POS X +Xoffset +1 ,Y : @PrintVal PlayerStatus (PlayerIndex )
11311161 @DrawPlayerScore X +Xoffset +2 ,17 ,PlayerBlackTokens (PlayerIndex ),PlayerWhiteTokens (PlayerIndex )
1162+ if PlayerHandCount (playerIndex )>0 and dealt =1 then @DrawMainPlayerHand Playerindex
11321163 DATA XPOS ()=1 ,1 ,0 ,25 ,25
11331164 DATA HPOS ()=1 ,1 ,13 ,26 ,26
11341165 DATA YPOS ()=12 ,6 ,1 ,6 ,12
11351166 slot =0
11361167 For a =0 to 5
1137- if a <>PlayerIndex
1138- if PlayerName$(a )<>" "
1139- Xoffset =len (PlayerName $(a ))
1140- if Xoffset >8 and slot <>2 then Xoffset =8
1141- if Xoffset >12 and slot =2 then Xoffset =12
1142- X =(14 -(Xoffset +6 ))/2
1143- if slot =2 then X =((36 -(Xoffset +6 ))/2 )+2
1144- X =X +XPOS (SLOT )
1145- @POS X,YPOS (SLOT ): @PrintUpper &PlayerName $(a )[1 ,Xoffset ]
1146- @POS X +Xoffset ,YPOS (SLOT ): @Print &" :"
1147- @POS X +Xoffset +1 ,YPOS (SLOT ): @PrintVal PlayerStatus (a )
1148- @DrawPlayerScore X +Xoffset +2 ,YPOS (SLOT ),PlayerBlackTokens (a ),PlayerWhiteTokens (a )
1149- folded =0
1150- if playerStatus (a )=2 then folded =128
1151- if slot =2
1152- @DrawPlayerHand XPOS (SLOT )+((38 -(PlayerHandCount (a )+2 ))/2 ),YPOS (SLOT )+2 ,PlayerHandCount (a ),folded
1153- else
1154- @DrawPlayerHand XPOS (SLOT )+((14 -(PlayerHandCount (a )+2 ))/2 ),YPOS (SLOT )+2 ,PlayerHandCount (a ),folded
1155- ENDIF
1156- endif
1157- inc SLOT
1158- endif
1159- Next a
1160- if PlayerHandCount (playerIndex )>0 then @DrawMainPlayerHand Playerindex
1168+ if a <>PlayerIndex
1169+ if PlayerName$(a )<>" "
1170+ Xoffset =len (PlayerName $(a ))
1171+ if Xoffset >8 and slot <>2 then Xoffset =8
1172+ if Xoffset >12 and slot =2 then Xoffset =12
1173+ X =(14 -(Xoffset +6 ))/2
1174+ if slot =2 then X =((36 -(Xoffset +6 ))/2 )+2
1175+ X =X +XPOS (SLOT )
1176+ @POS X,YPOS (SLOT ): @PrintUpper &PlayerName $(a )[1 ,Xoffset ]
1177+ @POS X +Xoffset ,YPOS (SLOT ): @Print &" :"
1178+ @POS X +Xoffset +1 ,YPOS (SLOT ): @PrintVal PlayerStatus (a )
1179+ @DrawPlayerScore X +Xoffset +2 ,YPOS (SLOT ),PlayerBlackTokens (a ),PlayerWhiteTokens (a )
1180+ folded =0
1181+ if playerStatus (a )=2 then folded =128
1182+ if dealt =1
1183+ if slot =2
1184+ @DrawPlayerHand XPOS (SLOT )+((38 -(PlayerHandCount (a )+2 ))/2 ),YPOS (SLOT )+2 ,PlayerHandCount (a ),folded
1185+ else
1186+ @DrawPlayerHand XPOS (SLOT )+((14 -(PlayerHandCount (a )+2 ))/2 ),YPOS (SLOT )+2 ,PlayerHandCount (a ),folded
1187+ ENDIF
1188+ endif
1189+ inc SLOT
1190+ Endif
1191+ Endif
1192+ Next a
11611193ENDPROC
11621194
11631195PROC DrawPlayerHand _col _row _numCards _folded
@@ -1255,6 +1287,34 @@ PROC DrawResultHands _Index _Xoffset _Yoffset
12551287 next a
12561288ENDPROC
12571289
1290+ Proc DrawCardFromDeck _endX _endY _card
1291+ SOUND 0 ,121 ,1 ,8
1292+ dx =18 :dy =10 : endX =_endX : endY =_endY : card =_card
1293+ xchange =-1 :ychange =-1
1294+ if endX >dx then xchange =1
1295+ if endy >dy then ychange =1
1296+ repeat
1297+ @DrawBuffer
1298+ if dx <>endx then DX =DX +xchange
1299+ if dy <>endy then DY =DY +ychange
1300+ if card =9
1301+ @POS dx,dy :@PrintByte 13 :@PrintByte 14
1302+ @POS dx,dy +1 :@PrintByte 15 :@PrintByte 27
1303+ else
1304+ @DrawCard dx,dy ,card
1305+ endif
1306+ until dx =endx and dy =endy
1307+ dec Drawdeck
1308+ @POS 19 ,13 : @PrintVal Drawdeck
1309+ @UpdateScreenBuffer
1310+ sound
1311+ ENDPROC
1312+
1313+ Proc UpdateScreenBuffer
1314+ move &screenBuffer ,&screenBuffer +1040 , 1040
1315+ @DrawBuffer
1316+ ENDPROC
1317+
12581318' -------------------------------------------------------------
12591319' PROCEDURES to get Json data and load into the Var Result
12601320' open the API connect and setup for Read JSON file
0 commit comments