@@ -211,7 +211,7 @@ QUERY$=""$9B
211211JSON$=" /tables"
212212dummy$=" "
213213' Initialize strings and Arrays - this reserves their space in memory so NInput can write to them
214- Dim TableCurrentPlayers (6 ),TableMaxPlayers (6 ),TableStatus (6 ),PlayerStatus (5 ),PlayerHandCount (5 ),PlayerWhiteTokens (5 ),PlayerBlackTokens (5 ),PlayerScore (5 ),PlayerRoundScore (5 ),GameStatus (5 )
214+ Dim TableCurrentPlayers (6 ),TableMaxPlayers (6 ),TableStatus (6 ),PlayerStatus (5 ),PlayerHandCount (5 ),PlayerWhiteTokens (5 ),PlayerBlackTokens (5 ),PlayerScore (5 ),PlayerRoundScore (5 ),GameStatus (5 ), xStart ( 5 ), yStart ( 5 )
215215for i =0 to 6
216216 TableID$(i )=" "
217217 TableName$(i )=" "
290290 ENDIF
291291 if playerStatus (PlayerIndex )<>1
292292 @readGameState
293+ if LastMovePlayed$<>PreviousLastMovePlayed $ then @MoveAnimation
293294 @DrawGameState
294295 ENDIF
295296 @ReadKeyPresses
@@ -304,6 +305,52 @@ LOOP
304305
305306' MY ROUTINES
306307
308+ PROC MoveAnimation
309+ dummy$=lastMovePlayed $[1 ,len (playerName $(playerIndex ))]
310+ if dummy$=playerName $(playerIndex ) then exit
311+ for a =0 to 5
312+ dummy$=lastMovePlayed $[1 ,len (playerName $(a ))]
313+ if dummy$=playerName $(a ) then exit
314+ next a
315+ if dummy$=" " then exit
316+ dummy$=lastMovePlayed $[len (playerName $(a ))+2 ,4 ]
317+ @POS 1 ,1
318+ @POS 1 ,2 : @PrintUpper &PlayerName $(a ):@printUpper &" is:"
319+ if dummy$=" drew"
320+ @POS 1 ,3 : @PrintUpper &" Drawing"
321+ @UpdateScreenBuffer
322+ @DrawCardFromDeck xStart (a ),yStart (a ),9
323+ elif dummy$=" play"
324+ @POS 1 ,3 : @PrintUpper &" Discarding"
325+ @PlayCard a
326+ elif dummy$=" fold"
327+ @POS 1 ,3 : @PrintUpper &" Folding"
328+ get K
329+ Endif
330+ EndProc
331+
332+ PROC ClearState
333+ Drawdeck =0
334+ DiscardTop =0
335+ LastMovePlayed$=" "
336+ PreviousLastMovePlayed$=" "
337+ for i =0 to 5
338+ playerName$(i )=" "
339+ PlayerStatus (i )=0
340+ PlayerHandCount (i )=0
341+ PlayerWhiteTokens (i )=0
342+ PlayerBlackTokens (i )=0
343+ PlayerScore (i )=0
344+ PlayerHand$(i )=" "
345+ PlayerValidMoves$(i )=" "
346+ PlayerRoundScore (i )=0
347+ GameStatus (i )=0
348+ next i
349+ move$=" "
350+ PlayerIndex =0
351+ dealt =0
352+ EndProc
353+
307354PROC TitleScreen
308355 @ClearKeyQueue
309356 @EnableDoubleBuffer
@@ -353,6 +400,7 @@ ENDPROC
353400
354401PROC TableSelection
355402 ' This procedure draws the table selection screen and displays the tables available to join
403+ @ClearState
356404 @ClearKeyQueue
357405 @EnableDoubleBuffer
358406 @ResetScreen
@@ -432,7 +480,7 @@ PROC TableSelection
432480 JSON$=+" &player="
433481 JSON$=+MyName $
434482 @POS 5 ,22 : @Print & " CONNECTING TO TABLE "
435- @POS 3 ,25 : @Print & " PLEASE WAIT THIS MAY TAKE A MOMENT "
483+ @POS 1 ,25 : @Print & " PLEASE WAIT THIS MAY TAKE A MOMENT "
436484 @CallFujiNet ' Call the FujiNet API to join the table
437485 @NInputInit UNIT, &responseBuffer ' Initialize reading the api response
438486 @NInput &dummy $ ' Read the response from the FujiNet API
@@ -489,35 +537,56 @@ PROC CheckVaildMove _move
489537 Next a
490538 if Move$<>" "
491539 @GoodBeep
492- @POS 1 ,24 : @Print &" "
493- @POS 1 ,24 : @Print &PlayerName $(PlayerIndex )
494- @POS Len (PlayerName $(PlayerIndex ))+1 ,24 :@Print &" PLAYED A "
495- if move$=" 1"
496- @Print &" ONE"
497- elif move$=" 2"
498- @Print &" TWO"
499- elif move$=" 3"
500- @Print &" THREE"
501- elif move$=" 4"
502- @Print &" FOUR"
503- elif move$=" 5"
504- @Print &" FIVE"
505- elif move$=" 6"
506- @Print &" SIX"
507- elif move$=" 7"
508- @Print &" LLAMA"
509- elif move$=" D"
510- @POS Len (PlayerName $(PlayerIndex ))+1 ,24 :@PrintUpper &" drew a card from the deck"
511- elif move$=" F"
512- @POS Len (PlayerName $(PlayerIndex ))+1 ,24 :@Print &" FOLDED "
513- ENDIF
540+ @DoMainPlayerAnimation
514541 @PlayMove
515542 playerStatus (PlayerIndex )=0
516543 ELSE
517544 @BadBeep
518545 ENDIF
519546ENDPROC
520547
548+ Proc DoMainPlayerAnimation
549+ if move$=" D" then @DrawCardFromDeck xStart (PlayerIndex ),yStart (PlayerIndex ),8
550+ if move$>=" 1" and move$<=" 7" then @PlayCardMain val (move $)
551+ EndProc
552+
553+ Proc PlayCardMain _card
554+ C =_card
555+ SOUND 0 ,121 ,1 ,8
556+ mset &screenBuffer +(40 *19 ), 40 *5 ,0 ' Clear area above deck
557+ if len (PlayerHand $(PlayerIndex ))>1
558+ ' Remove the played card from the hand
559+ for a =1 to len (PlayerHand $(PlayerIndex ))
560+ dummy$=PlayerHand $(PlayerIndex )[a,1 ]
561+ if dummy$=STR $(C )
562+ if a =len (PlayerHand $(PlayerIndex ))
563+ dummy$=PlayerHand $(PlayerIndex )[1 ,len (PlayerHand $(PlayerIndex ))-1 ]
564+ else
565+ dummy$=PlayerHand $(PlayerIndex )[1 ,a -1 ]
566+ value$=PlayerHand $(PlayerIndex )[a +1 ,len (PlayerHand $(PlayerIndex ))]
567+ dummy$=+value $
568+ Endif
569+ exit
570+ ENDIF
571+ NEXT A
572+ PlayerHand$(PlayerIndex )=dummy $
573+ @DrawMainPlayerHand playerIndex
574+ ENDIF
575+ card =C
576+ @UpdateScreenBuffer
577+ endx =20 :endy =9
578+ dx =36 :dy =20
579+ xchange =-1 :ychange =-1
580+ repeat
581+ @DrawBuffer
582+ if dx <>endx then DX =DX +xchange
583+ if dy <>endy then DY =DY +ychange
584+ @DrawCard dx,dy ,card
585+ until dx =endx and dy =endy
586+ @UpdateScreenBuffer
587+ sound
588+ ENDPROC
589+
521590PROC ShowResults
522591 dealt =0
523592 @EnableDoubleBuffer
@@ -802,6 +871,21 @@ PROC ReadGameState
802871 loop
803872ENDPROC
804873
874+ proc SetPlayerSlots
875+ data xS ()=2 ,1 ,1 ,13 ,26 ,26
876+ data yS ()=19 ,14 ,8 ,3 ,8 ,14
877+ xstart (PlayerIndex )=xS (0 )
878+ ystart (PlayerIndex )=yS (0 )
879+ i =1
880+ for a =0 to 5
881+ if a <>PlayerIndex
882+ xStart (a )=xs (i )
883+ yStart (a )=ys (i )
884+ inc i
885+ Endif
886+ next a
887+ endproc
888+
805889PROC PlayMove
806890 JSON$=" /move?table="
807891 JSON$=+TableID $(TableNumber )
@@ -838,6 +922,7 @@ Proc DealCards
838922 next cardnumber
839923 @DrawCardFromDeck 20 ,9 ,DiscardTop
840924 dealt =1
925+ @SetPlayerSlots
841926ENDPROC
842927
843928PROC CheckErrors
@@ -899,6 +984,51 @@ PROC BadBeep
899984 SOUND
900985ENDPROC
901986
987+ Proc DrawCardFromDeck _endX _endY _card
988+ SOUND 0 ,121 ,1 ,8
989+ dx =18 :dy =10 : endX =_endX : endY =_endY : card =_card
990+ xchange =-1 :ychange =-1
991+ if endX >dx then xchange =1
992+ if endy >dy then ychange =1
993+ repeat
994+ @DrawBuffer
995+ if dx <>endx then DX =DX +xchange
996+ if dy <>endy then DY =DY +ychange
997+ if card =9
998+ @POS dx,dy :@PrintByte 13 :@PrintByte 14
999+ @POS dx,dy +1 :@PrintByte 15 :@PrintByte 27
1000+ else
1001+ @DrawCard dx,dy ,card
1002+ endif
1003+ until dx =endx and dy =endy
1004+ dec Drawdeck
1005+ @POS 19 ,13 : @PrintVal Drawdeck
1006+ @UpdateScreenBuffer
1007+ sound
1008+ ENDPROC
1009+
1010+ Proc PlayCard _PlayerIndex
1011+ index =_PlayerIndex
1012+ SOUND 0 ,121 ,1 ,8
1013+ endx =20 :endy =10
1014+ dx =xStart (index ):dy =yStart (index )
1015+ xchange =-1 :ychange =-1
1016+ if endX >dx then xchange =1
1017+ if endy >dy then ychange =1
1018+ @POS dx,dy : @Print &" "
1019+ @POS dx,dy +1 : @Print &" "
1020+ @DrawPlayerHand dx,dy , PlayerHandCount (index ), 0
1021+ @UpdateScreenBuffer
1022+ repeat
1023+ @DrawBuffer
1024+ if dx <>endx then DX =DX +xchange
1025+ if dy <>endy then DY =DY +ychange
1026+ @POS dx,dy :@PrintByte 13 :@PrintByte 14
1027+ @POS dx,dy +1 :@PrintByte 15 :@PrintByte 27
1028+ until dx =endx and dy =endy
1029+ @UpdateScreenBuffer
1030+ sound
1031+ ENDPROC
9021032
9031033' ============================================================================
9041034' Drawing ROUTINES
@@ -922,6 +1052,7 @@ ENDPROC
9221052
9231053PROC DrawGameState
9241054 ' Draw the current game state on the screen
1055+ if GameStatus (tablenumber )=5 then Exit ' if game over do not redraw screen
9251056 @EnableDoubleBuffer
9261057 @ResetScreen
9271058 @POS 0 ,5 : @PrintINV &" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
@@ -959,13 +1090,14 @@ PROC DrawGameState
9591090 @EnableDoubleBuffer
9601091 Endif
9611092 @DrawCard 20 ,9 ,DiscardTop ' Discard Pile
962- @POS 1 ,24 : @PrintUpper & LastMovePlayed $[1 ,38 ]
1093+ ' @POS 1,24: @PrintUpper & LastMovePlayed$[1,38]
9631094 @POS 5 ,25 :@Print &" H-HELP C-COLOR E-EXIT Q-QUIT"
9641095 if PlayerStatus (PlayerIndex )=1
965- @POS 1 ,24 : @PrintUpper & LastMovePlayed $[1 ,23 ]
966- @Print &" , YOUR TURN NOW"
1096+ @POS 13 ,24 : @Print &" YOUR TURN NOW"
9671097 @DrawDrawButton 2 ,20
9681098 @DrawFoldButton 37 ,20
1099+ else
1100+ @POS 7 ,24 : @Print &" WAITING FOR OTHERS TO PLAY"
9691101 ENDIF
9701102 @DrawBufferEnd
9711103 @ShowScreen
@@ -1287,29 +1419,6 @@ PROC DrawResultHands _Index _Xoffset _Yoffset
12871419 next a
12881420ENDPROC
12891421
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-
13131422Proc UpdateScreenBuffer
13141423 move &screenBuffer ,&screenBuffer +1040 , 1040
13151424 @DrawBuffer
0 commit comments