Author Topic: Yahtzee 64!!!  (Read 5239 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Yahtzee 64!!!
« on: November 30, 2019, 12:45:32 pm »
Bit of Preview of Yahtzee I'm working on as a possible net-play game for Steve's server. Still pretty early in development, but the core is there now I'm just working on keeping the score sheets. after that its done until the addition of Steve's server-side code so it can be played over the net, setting it up for a max 255 player game(like that would ever happen but, Hey Optimism!).  See what you guys like about it so far, or what you would suggest I change, but its a pretty simple game, I could have gone completely TEXT only (and made Pete happy) but wanted to give it some Pizazz! Will eventually have simple sound effects and perhaps background music but not yet.

Controls are completely mouse based, save for ESC to quit. not a whole lot to do with this release, you can use the shaker cup and lock the dice you wish to keep, then click on the Upper Score card section. but that is about it so far.

(12/14/2019 update info)
Okay, Major update here, the local High Scores list now functions properly, Added an intro with totally misleading music! :)  Has extra functionality depending on which MFI resource file you have downloaded. Right now this just means a "bubblely" background music if you download the beta MFI file(the one ending in 'b'). The controls are a bit finicky\touchy, if you happen to bump the mouse button over the shaker cup that counts as one roll. so be careful there.

(12/21/2019 update info)
Some Functionality is only implemented when you have the correct MFI file for that option, this mainly pertains to the Back Ground Musics. This is done to keep the resource file size down for people who do not have good internet access, as BGMs tend to be rather bulky even when saved at a fairly low quality rate. Version 'C' gives access to 3 more BGMs to choose from.

(12/22/2019 update info)
Most the major bugs are quashed, Online scores seem to be working, and main audio elements are in place. Version upped to 1.0beta save for a credits screen the only thing I had planned left is the multi player side, but as for the solitaire side its seem good to go. This is the last update of 2019(might whip up a credits screen though). Going to go back to Dragon Warrior for now, at least until QB64 1.4 is out.
Lets see who can get the highest online Score! To be able to add your scores to the online score list you must first view the online scores section. At the moment this connects you to the server.

Note: Requires current Dev. Build of QB64 Can not wait for the 1.4 release! :D

Todo List: Finish Sound control menu Done 12/21/2019
              : Fix Scoring bug, odd behavior: sometimes game quits before all scores are filled in other times it wont quit even with all
                scores filled in!?(with Yahtzee dice(5 of kind) clicking Large Straight then cancel then choosing yathzee with all
                other scores done has reproduced this error.)[/color] Done 12/22/2019
              : Implement On-Line score keeping Done 12/22/2019
              :Implement game sound effects(they are already in the MFIs and loaded just not coded in) Done 12/21/2019
              :confirm fix for multiple Yahtzee scoring.[only managed to pull this off once and it didn't track the score properly :( ]Done 12/21/2019 Best score yet 351!
              : Implement multi player games( this will be a big deal as it will require actual re-coding of some functions and a 'master host'
                program.
              :Add a credits screen

Code: QB64: [Select]
  1. REM'$Include:'YahtzeeTypes.BI'
  2. TYPE Upper_Card 'max score 125('base' shown),140('lite')
  3.  Aces AS _BYTE '  4
  4.  Duces AS _BYTE ' 8
  5.  Trips AS _BYTE ' 12
  6.  Quads AS _BYTE ' 16
  7.  Quinc AS _BYTE ' 20
  8.  Sexte AS _BYTE ' 24
  9.  Bonus AS _BYTE ' 35 if all values added >= 63
  10.  Total AS _UNSIGNED _BYTE 'base rules allow for only 125 max, but lite rules allow for 140
  11.  
  12. TYPE Lower_Card
  13.  ThreeOfKind AS _BYTE 'total all dice, max 28(3x6+2x5 not using full house/30 with yahtzee bonus)
  14.  FourOfKind AS _BYTE ' total all dice, max 29(4x6+1x5/30 with yahtzee bonus)
  15.  FullHouse AS _BYTE '  25
  16.  SmStraight AS _BYTE ' 30
  17.  LgStraight AS _BYTE ' 40
  18.  Chance AS _BYTE '     29 max(30 if not using yahtzee\'base' rules or yahtzee+bonus taken)
  19.  Yahtzee AS _BYTE '    50 points(+100 per bonus yahtzee)
  20.  Bonus AS _BYTE '      only 1 allowed in 'base' rules but multiple in 'lite' rules
  21.  Total AS INTEGER 'Max:'base' rules-332: 'lite' rules- 650+185 and + 600 for upper_card(1435)
  22. 'Absolute MAXIMUM high score is 1575 using 'lite' rules which allow for up to 13 yahtzees
  23. 'first yahtzee being 50 points then 12 extra yahtzee at 100 points placing max numbers in
  24. 'all 12 non yahtzee boxes, this would be a 'GOD'game where player rolled nothing but 5 of
  25. 'a kind including 1 for each of the upper card scores and nothing but 6s for lower.
  26. 'Odds are astronomical, but not technically impossible!
  27.  
  28. TYPE Game_Data
  29.  Players AS _UNSIGNED _BYTE 'odds of 255 players for 1 game also ASTRONOMICAL!
  30.  Whos_Turn AS _UNSIGNED _BYTE
  31.  Current_Roll AS _BYTE 'each player gets up to 3 rolls for max score
  32.  Upper_Filled AS _BYTE 'flag if all upper stats are filled in
  33.  Lower_Filled AS _BYTE 'flag if all lower stats are filled in
  34.  Rule_Set AS _BYTE 'using base rules or lite rules
  35.  SetValues AS INTEGER ' flags for 13 values
  36.  GameOver AS _BYTE 'when all 13 flags are set game is over
  37.  FirstGame AS _BYTE 'if there is no score file then this is first game
  38.  Connected AS _BYTE
  39.  MFIVerB AS _BYTE 'does user have the B version MFI file?(extra BGM)
  40.  MFIVerC AS _BYTE 'does user have Full BGM list MFI file?
  41.  BGMVol AS _BYTE 'volume level of Background music
  42.  SFXVol AS _BYTE 'volume level of Sound effects
  43.  Current_BGM AS _BYTE 'which type of BGM is playing
  44.  Loaded AS _BYTE 'are online high scores already loaded?
  45.  
  46. TYPE Die_Data
  47.  Value AS _BYTE
  48.  Locked AS _BYTE
  49.  
  50. TYPE Scores
  51.  Who AS STRING * 16
  52.  Score AS INTEGER
  53.  Rules AS _BYTE
  54.  
  55. CONST TRUE = -1, FALSE = NOT TRUE
  56. CONST STANDARD = 1, LITE = 2, LOWER = -1, UPPER = -2
  57. CONST ACES = 1, DUCES = 2, TRIPS = 3, QUADS = 4, QUINC = 5, SEXTE = 6
  58. CONST THREEOFKIND = 7, CHANCE = 13, FULLHOUSE = 9, FOUROFKIND = 8, YAHTZEE = 12, SMSTRAIGHT = 10, LGSTRAIGHT = 11
  59. DIM SHARED PCU(255) AS Upper_Card, PCL(255) AS Lower_Card, G AS Game_Data, Layer(13) AS LONG
  60. DIM SHARED DieArray(5) AS Die_Data '5 dice results
  61. DIM SHARED Nick(255) AS STRING, Local(100) AS Scores, Online(255) AS Scores
  62. DIM SHARED FFX&, FFX2&, BGM(6) AS LONG, SFX(8) AS LONG, D1 AS STRING, C2 AS STRING, T$(1)
  63.  
  64. DIM SHARED Host, Client '<--server needs
  65.  
  66. REM _DEFINE A-Z AS _INTEGER64  'we're going to send/recieve int64s usually (8 bytes).  Deal with it.
  67.  
  68. 'Graphic stuff setup---------------------------------------
  69. SCREEN _NEWIMAGE(640, 480, 32)
  70. Layer(0) = _DISPLAY
  71. Layer(1) = _NEWIMAGE(640, 480, 32) 'Mixing layer
  72. Layer(4) = _NEWIMAGE(640, 480, 32) 'click boxes
  73. Layer(10) = _NEWIMAGE(640, 480, 32) 'Temp Layer
  74. Layer(11) = _NEWIMAGE(640, 480, 32) 'green mat layer
  75. Layer(13) = _NEWIMAGE(297, 608, 32) 'final score temp layer
  76. '----------------Special Resource file check--------------------------
  77. DATA 9,80,104,97,125,115,108,108,86,56,8,89,125,97,107,99,87,97,124
  78. IF _FILEEXISTS("YahtzeeV1_2c.MFI") THEN
  79.  G.MFIVerC = TRUE
  80.  G.Current_BGM = 2
  81.  MFI_Loader "YahtzeeV1_2c.MFI" 'load graphics and fonts (and sounds) B version
  82. ELSEIF _FILEEXISTS("YahtzeeV1_2b.MFI") THEN
  83.  G.MFIVerB = TRUE
  84.  G.Current_BGM = 2
  85.  MFI_Loader "YahtzeeV1_2b.MFI" 'load graphics and fonts (and sounds) B version
  86.  G.MFIVerB = FALSE
  87.  G.MFIVerC = FALSE
  88.  MFI_Loader "YahtzeeV1_2.MFI" 'load graphics and fonts (and sounds)
  89. '-----------------------------------------------------------------------
  90. '-------------Final GFX setup-----------------------------
  91. _CLEARCOLOR _RGB32(0, 0, 0), Layer(8)
  92. _CLEARCOLOR _RGB32(0, 0, 0), Layer(9)
  93. _FONT FFX&, Layer(10)
  94. _TITLE "Yahtzee64 by Unikorn Produckions @2019 Ver 1.0b Build 011"
  95. Draw_GameMat Layer(11)
  96. _SOURCE Layer(4) 'source for mouse click detection
  97. '----------------------------------------------------------
  98.  
  99. '---------Inital Sound level setup-----------------------
  100. G.BGMVol = 10
  101. G.SFXVol = 10
  102. FOR i%% = 1 TO 5
  103.  _SNDVOL BGM(i%%), .1
  104.  _SNDVOL SFX(i%%), .1
  105. NEXT i%%
  106. '----------------------------------------------------------
  107. '---------Some inital setup values------------
  108. Init_Scores 0
  109. G.Rule_Set = STANDARD
  110. Die_Shaker 'pre-shake dice
  111. '---------------------------------------------
  112.  
  113. '--------intro screens-------
  114. Intro
  115. '-------------------------------------------------
  116.  
  117. IF G.MFIVerB OR G.MFIVerC THEN _SNDLOOP BGM(G.Current_BGM)
  118. Load_Local_HiScore
  119. Menu
  120. IF G.MFIVerB OR G.MFIVerC THEN _SNDSTOP BGM(G.Current_BGM)
  121.  
  122.  
  123. SUB Menu
  124.  Create_ClickLayer 3
  125.  DO
  126.   _PUTIMAGE (0, 0), Layer(7), Layer(1)
  127.   _PUTIMAGE , Layer(1), Layer(0)
  128.  
  129.   Selection%% = Check_ClickBox(_MOUSEX, _MOUSEY)
  130.   LOCATE 1, 1: PRINT Selection%%
  131.  
  132.    SELECT CASE Selection%%
  133.     CASE 1
  134.      ClearLayer Layer(1)
  135.      Pick_Nick 0
  136.      Create_ClickLayer 0
  137.      Init_Scores 0
  138.      Main_Game_Loop
  139.      Create_ClickLayer 3
  140.      End_Score 0
  141.      Save_Local_Score
  142.      IF G.Connected THEN Save_Online_Score: Sort_Online_Scores
  143.      G.GameOver = FALSE
  144.      G.SetValues = 0
  145.     CASE 2 'multiplayer game
  146.     CASE 3 'local high scores
  147.      ClearLayer Layer(1)
  148.      ClearLayer Layer(10)
  149.      Load_Local_HiScore
  150.      Local_Scores
  151.     CASE 4 'online high scores
  152.      ClearLayer Layer(1)
  153.      ClearLayer Layer(10)
  154.      IF NOT G.Loaded THEN
  155.       Load_Online_HiScore
  156.       Sort_Online_Scores
  157.       G.Loaded = TRUE
  158.      END IF
  159.      Online_Scores
  160.     CASE 5 'Sound control
  161.      Sound_Controls
  162.     CASE 6 'QUIT game
  163.      ExitFlag%% = TRUE
  164.    END SELECT
  165.   END IF
  166.   _LIMIT 30
  167.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  168.  LOOP UNTIL ExitFlag%%
  169.  
  170.  
  171. SUB Pick_Nick (Who~%%)
  172.  Create_ClickLayer 4
  173.  _DEST Layer(1)
  174.  _FONT FFX2&, Layer(1)
  175.  _PRINTSTRING (85, 160), "A B C D E F G H I J K L M", Layer(1)
  176.  _PRINTSTRING (85, 210), "N O P Q R S T U V W X Y Z", Layer(1)
  177.  _PRINTSTRING (85, 260), "0 1 2 3 4 5 6 7 8 9   .", Layer(1)
  178.  _PRINTSTRING (85, 310), "      BACK      DONE     ", Layer(1)
  179.  FOR i%% = 0 TO 15
  180.   LINE (64 + 32 * i%%, 64)-STEP(24, 4), _RGB32(192, 192, 192), BF
  181.  NEXT i%%
  182.  _PUTIMAGE , Layer(1), Layer(10)
  183.  
  184.  DO
  185.   SELECT CASE Selection%%
  186.    CASE 0 TO 13
  187.     i%% = 0
  188.     j%% = (Selection%% MOD 14) - 1
  189.    CASE 14 TO 26
  190.     i%% = 1
  191.     j%% = (Selection%% MOD 14)
  192.    CASE 27 TO 38
  193.     i%% = 2
  194.     j%% = (Selection%% MOD 13) - 1
  195.   _PUTIMAGE , Layer(10), Layer(1)
  196.   IF Selection%% < 63 THEN
  197.    IF Selection%% <> 0 THEN 'hi-lite current letter mouse is over
  198.     LINE (85 + 35 * j%% + j%%, 158 + 50 * i%%)-STEP(19, 25), _RGB32(224, 204, 16), B
  199.    END IF
  200.   ELSEIF Selection%% = 63 THEN
  201.    LINE (190, 308)-STEP(80, 25), _RGB32(224, 204, 16), B
  202.  
  203.   ELSEIF Selection%% = 64 THEN
  204.    LINE (370, 308)-STEP(80, 25), _RGB32(224, 204, 16), B
  205.   ELSE
  206.   END IF
  207.  
  208.   FOR k%% = 1 TO LEN(Nick$) 'Print name
  209.    _PRINTSTRING (64 + 32 * (k%% - 1), 32), MID$(Nick$, k%%, 1), Layer(1)
  210.   NEXT k%%
  211.  
  212.   'hi-lite current Character
  213.   IF lit%% AND LEN(Nick$) < 16 THEN LINE (64 + 32 * LEN(Nick$), 64)-STEP(24, 4), _RGB32(224, 224, 64), BF
  214.  
  215.   _PUTIMAGE , Layer(1), Layer(0) 'move image to screen
  216.  
  217.   Selection%% = Check_ClickBox(_MOUSEX, _MOUSEY)
  218.   _PRINTSTRING (0, 0), STR$(Selection%%) + STR$(j%%) + STR$(i%%), Layer(0)
  219.    IF LEN(Nick$) < 16 THEN
  220.     SELECT CASE Selection%%
  221.      CASE 1 TO 26
  222.       Nick$ = Nick$ + CHR$(64 + Selection%%)
  223.      CASE 27 TO 36
  224.       Nick$ = Nick$ + CHR$(48 + (Selection%% - 27))
  225.      CASE 37 '32
  226.       Nick$ = Nick$ + " "
  227.      CASE 38 '46
  228.       Nick$ = Nick$ + "."
  229.      CASE 63 'back space
  230.       IF LEN(RTRIM$(Nick$)) > 0 THEN Nick$ = LEFT$(Nick$, LEN(Nick$) - 1)
  231.      CASE 64 'accept nick
  232.       Exitflag%% = TRUE
  233.     END SELECT
  234.    END IF
  235.    Button_Down_Lock
  236.   END IF
  237.  
  238.  
  239.   _LIMIT 30
  240.   ClearLayer Layer(1)
  241.   IF INKEY$ = CHR$(27) THEN Exitflag%% = TRUE
  242.   tim%% = tim%% + 1
  243.   IF tim%% = 15 AND lit%% = FALSE THEN lit%% = TRUE: tim%% = 0
  244.   IF tim%% = 15 AND lit%% THEN lit%% = FALSE: tim%% = 0
  245.  LOOP UNTIL Exitflag%%
  246.  
  247.  _DEST Layer(0)
  248.  _FONT 16, Layer(1)
  249.  Nick(Who~%%) = Nick$
  250.  
  251.  
  252. SUB Main_Game_Loop
  253.  DO
  254.   _PUTIMAGE , Layer(11), Layer(1)
  255.   Place_ShakerCup 500, 20
  256.   IF G.Current_Roll > 0 THEN
  257.    Display_Dice 50, 50
  258.    IF G.Current_Roll < 3 THEN
  259.     _PRINTSTRING (30, 409), "Click on Dice to keep then click shaker cup,", Layer(1)
  260.     _PRINTSTRING (30, 426), "to reroll remaining dice, or click on score ", Layer(1)
  261.     _PRINTSTRING (30, 443), "card to record score.", Layer(1)
  262.    ELSE
  263.     _PRINTSTRING (30, 409), "Out of Rolls, select score card to save ", Layer(1)
  264.     _PRINTSTRING (30, 426), "Dice score.", Layer(1)
  265.    END IF
  266.   ELSE
  267.    _PRINTSTRING (30, 425), "Click on shaker cup.", Layer(1)
  268.   END IF
  269.   Display_UpperCard 400, 140, .33, 0
  270.   Display_LowerCard 400, 295, .33, 0
  271.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  272.   Selection%% = Check_ClickBox(_MOUSEX, _MOUSEY)
  273.  
  274.   Top~%% = _SHL(G.SetValues, 2)
  275.   Bot~%% = _SHR(G.SetValues, 6)
  276.   LOCATE 1, 1: PRINT Selection%%; G.Current_Roll; Die_Check; G.Upper_Filled; Top~%%; Bot~%%; G.SetValues
  277.  
  278.    SELECT CASE Selection%%
  279.     CASE 1
  280.      IF G.Current_Roll < 3 THEN
  281.       Die_Shaker
  282.       Shaking%% = TRUE
  283.      END IF
  284.     CASE 2, 3 'view score card
  285.      DO: nul = _MOUSEINPUT: LOOP WHILE _MOUSEBUTTON(1)
  286.      View_Score_Card Selection%%, 0
  287.     CASE 4 TO 8 'dice
  288.      IF DieArray(Selection%% - 3).Locked THEN DieArray(Selection%% - 3).Locked = FALSE ELSE DieArray(Selection%% - 3).Locked = TRUE
  289.    END SELECT
  290.    IF Selection%% > 1 THEN DO: nul = _MOUSEINPUT: LOOP WHILE _MOUSEBUTTON(1) 'wait while button is down unless shaking dice
  291.   END IF
  292.   'player gets 3 rolls, count roll when mouse button released
  293.   IF Shaking%% AND NOT _MOUSEBUTTON(1) THEN G.Current_Roll = G.Current_Roll + 1: Shaking%% = FALSE: _SNDPLAY SFX(5)
  294.  
  295.   IF Shaking%% AND Soundplaying%% = FALSE THEN
  296.    SELECT CASE Die_In_Cup
  297.     CASE 4 OR 5
  298.      _SNDPLAY SFX(1)
  299.      Soundplaying%% = 1
  300.     CASE 3
  301.      _SNDPLAY SFX(2)
  302.      Soundplaying%% = 2
  303.     CASE 2
  304.      _SNDPLAY SFX(3)
  305.      Soundplaying%% = 3
  306.     CASE 1
  307.      _SNDPLAY SFX(4)
  308.      Soundplaying%% = 4
  309.    END SELECT
  310.   ELSEIF NOT Shaking%% THEN
  311.    _SNDSTOP SFX(Soundplaying%%)
  312.    Soundplaying%% = 0
  313.   END IF
  314.  
  315.   _LIMIT 30
  316.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  317.  LOOP UNTIL ExitFlag%% OR G.GameOver
  318.  
  319. SUB View_Score_Card (UL%%, Who~%%)
  320.  DO
  321.   SELECT CASE UL%%
  322.    CASE 2 'upper
  323.     Result%% = Show_Upper_Card(Who~%%)
  324.    CASE 3 'lower
  325.     Result%% = Show_Lower_Card(Who~%%)
  326.   IF Result%% = -1 THEN ExitFlag%% = TRUE
  327.   IF Result%% = -2 THEN G.Current_Roll = 0: ExitFlag%% = TRUE
  328.   IF Result%% = 1 THEN UL%% = 3
  329.   IF Result%% = 2 THEN UL%% = 2
  330.   PRINT Result%%; UL%%
  331.   _DELAY .05
  332.  LOOP UNTIL ExitFlag%%
  333.  UL%% = 0
  334.  Top~%% = _SHL(G.SetValues, 2)
  335.  Bot~%% = _SHR(G.SetValues, 6)
  336.  IF Top~%% = 252 THEN G.Upper_Filled = TRUE
  337.  IF Bot~%% = 254 THEN G.Lower_Filled = TRUE
  338.  IF Top~%% = 252 AND Bot~%% = 254 THEN G.GameOver = TRUE
  339.  Button_Down_Lock
  340.  
  341.  
  342.  
  343. SUB MFI_Loader (FN$)
  344.  DIM Size(64) AS LONG, FOffset(64) AS LONG
  345.  GET #1, , c~%% 'retrieve number of files
  346.  FOR I~%% = 1 TO c~%%
  347.   GET #1, , FOffset(I~%%)
  348.   GET #1, , Size(I~%%)
  349.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  350.  NEXT I~%%
  351.  FOR d%% = 0 TO 1: READ C%%
  352.   FOR i%% = 1 TO C%%
  353.    READ T%%: T%% = T%% XOR C%%: T$(d%%) = T$(d%%) + CHR$(T%%)
  354.  NEXT i%%, d%%
  355.  'load the files where they go here----------
  356.  Layer(2) = LoadGFX(FOffset(1), Size(1)) '_LOADIMAGE("Upper_Card.png", 32) 'upper score card
  357.  Layer(3) = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("Lower_Card.png", 32) 'Lower score card
  358.  Layer(5) = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("UPsplash6x4.BMP", 32) 'flash Screen
  359.  Layer(6) = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("Yahtzeeflash.BMP", 32)
  360.  Layer(7) = LoadGFX(FOffset(5), Size(5)) '_LOADIMAGE("Yahtzee-logo.BMP", 32)
  361.  Layer(8) = LoadGFX(FOffset(6), Size(6)) '_LOADIMAGE("SizedDiceRedDot.BMP", 32)
  362.  Layer(9) = LoadGFX(FOffset(7), Size(7)) '_LOADIMAGE("ShakerCup.BMP", 32)
  363.  FFX& = LoadFFX(FOffset(8), Size(8), 24) '_LOADFONT("OBGB.ttf", 24, "MONOSPACE")
  364.  FFX2& = LoadFFX(FOffset(8), Size(8), 24) '_LOADFONT("OBGB.ttf", 24, "MONOSPACE")
  365.  Layer(12) = LoadGFX(FOffset(15), Size(15)) '_LOADIMAGE("ShakerCup.BMP", 32)
  366.  BGM(1) = LoadSFX(FOffset(16), Size(16))
  367.  
  368.  SFX(1) = LoadSFX(FOffset(9), Size(9)) 'die shake 4 or 5 dice
  369.  SFX(2) = LoadSFX(FOffset(10), Size(10)) 'die shake 3 dice
  370.  SFX(3) = LoadSFX(FOffset(11), Size(11)) 'die shake 2 dice
  371.  SFX(4) = LoadSFX(FOffset(12), Size(12)) 'single die shake
  372.  SFX(5) = LoadSFX(FOffset(13), Size(13)) 'rolling dice
  373.  
  374.  IF G.MFIVerB OR G.MFIVerC THEN BGM(2) = LoadSFX(FOffset(17), Size(17))
  375.  IF G.MFIVerC THEN BGM(3) = LoadSFX(FOffset(18), Size(18))
  376.  IF G.MFIVerC THEN BGM(4) = LoadSFX(FOffset(19), Size(19))
  377.  IF G.MFIVerC THEN BGM(5) = LoadSFX(FOffset(20), Size(20))
  378.  
  379.  '-------------------------------------------
  380.  CLOSE #1
  381.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  382.  
  383.  
  384. REM'$include:'Core_Funcitons.BAS'
  385. REM'$include:'GFX_Functions.BAS'
  386. REM'$include:'MFI_Functions.BAS'
  387. REM'$include:'ServerCode.BAS'
  388.  
  389. SUB Button_Down_Lock
  390.  
  391. FUNCTION Check_ClickBox%% (X%, Y%)
  392.  Result%% = 0
  393.  R%% = _RED32(POINT(X%, Y%))
  394.  Result%% = R%%
  395.  Check_ClickBox = Result%%
  396.  
  397. SUB ClearLayer (L&)
  398.  old& = _DEST
  399.  _DEST L&
  400.  CLS
  401.  _DEST old&
  402.  
  403. SUB Clear_Scores
  404.  FOR i%% = 1 TO 99
  405.   Local(i%%).Who = ""
  406.   Local(i%%).Score = 0
  407.   Local(i%%).Rules = 0
  408.  NEXT i%%
  409.  
  410. FUNCTION Count_Dice%% (DV%%)
  411.  Result%% = 0 'initalize value
  412.  FOR i%% = 1 TO 5
  413.   IF DieArray(i%%).Value = DV%% THEN Result%% = Result%% + DV%%
  414.  NEXT i%%
  415.  Count_Dice = Result%%
  416.  
  417. FUNCTION Die_Check%%
  418.  'Steves Dice Status checking routine
  419.  DIM Count(7)
  420.  
  421.  FOR i%% = 1 TO 5
  422.   Count(DieArray(i%%).Value) = Count(DieArray(i%%).Value) + 1
  423.  NEXT i%%
  424.  
  425.  FOR i%% = 1 TO 6
  426.   IF Count(i%%) >= 2 THEN
  427.    Result%% = Result%% + Count(i%%)
  428.    IF Count(i%%) > 3 THEN Result%% = Result%% + 2
  429.   END IF
  430.  NEXT i%%
  431.  
  432.  'check for long straight------
  433.  FOR i%% = 1 TO 5
  434.   IF Count(i%%) = 1 THEN LS%% = LS%% + 1
  435.   IF Count(i%% + 1) = 1 THEN LS2%% = LS2%% + 1
  436.  NEXT i%%
  437.  '-----------------------------
  438.  
  439.  'check for short straight------
  440.  FOR x%% = 0 TO 2
  441.   FOR i%% = 1 TO 4
  442.    IF Count(i%% + x%%) = 1 OR Count(i%% + x%%) = 2 THEN SS%% = SS%% + 1
  443.   NEXT i%%
  444.   IF SS%% = 4 THEN x%% = 3 ELSE SS%% = 0
  445.  NEXT x%%
  446.  '------------------------------
  447.  IF SS%% = 4 THEN Result%% = 9
  448.  
  449.  IF LS%% = 5 OR LS2%% = 5 THEN Result%% = 8 'comes after short straight cause a long trumps a short.
  450.  
  451.  ' IF Result = 3 THEN PRINT "Three of Kind"
  452.  ' IF Result = 5 THEN PRINT "Full House"
  453.  ' IF Result = 6 THEN PRINT "Four of Kind"
  454.  ' IF Result = 7 THEN PRINT "Yahtzee"
  455.  ' IF Result = 8 THEN PRINT "Large Straight"
  456.  ' IF Result = 9 THEN PRINT "Short Straight"
  457.  Die_Check = Result%%
  458.  
  459. FUNCTION Die_In_Cup%%
  460.  Result%% = 5
  461.  FOR i%% = 1 TO 5 'check if any dice are locked, then they are not in the shaker cup.
  462.   IF DieArray(i%%).Locked THEN Result%% = Result%% - 1
  463.  NEXT i%%
  464.  Die_In_Cup = Result%%
  465.  
  466. FUNCTION Die_Roll%%
  467.  Die_Roll = INT(RND * 6) + 1 'very, very simple
  468.  
  469. SUB Die_Shaker
  470.  FOR i%% = 1 TO 5
  471.   IF G.Current_Roll = 0 THEN DieArray(i%%).Locked = FALSE
  472.   IF DieArray(i%%).Locked = FALSE THEN DieArray(i%%).Value = Die_Roll
  473.  NEXT i%%
  474.  
  475. SUB Init_Scores (who~%%)
  476.  'set all values at -1 to show not filled in, as you can score 0
  477.  PCU(who~%%).Aces = -1
  478.  PCU(who~%%).Duces = -1
  479.  PCU(who~%%).Trips = -1
  480.  PCU(who~%%).Quads = -1
  481.  PCU(who~%%).Quinc = -1
  482.  PCU(who~%%).Sexte = -1
  483.  PCU(who~%%).Total = -1
  484.  PCL(who~%%).ThreeOfKind = -1
  485.  PCL(who~%%).FourOfKind = -1
  486.  PCL(who~%%).FullHouse = -1
  487.  PCL(who~%%).SmStraight = -1
  488.  PCL(who~%%).LgStraight = -1
  489.  PCL(who~%%).Chance = -1
  490.  PCL(who~%%).Yahtzee = -1
  491.  PCL(who~%%).Bonus = 0 'save for bonus Yahtzees which starts at 0
  492.  PCL(who~%%).Total = -1
  493.  
  494. SUB Load_Local_HiScore
  495.  IF _FILEEXISTS("LocalYahtzee.SCR") THEN
  496.   'load high scores
  497.   OPEN "LocalYahtzee.SCR" FOR BINARY AS #1
  498.   GET #1, , Local()
  499.   G.FirstGame = TRUE
  500.   'use defult names
  501.   Local(1).Who = "COBALT": Local(1).Score = 390: Local(1).Rules = 0
  502.   Local(2).Who = "SMcNeill": Local(2).Score = 300: Local(2).Rules = 0
  503.   Local(3).Who = "Fellippe": Local(3).Score = 290: Local(3).Rules = 0
  504.   Local(4).Who = "Pete": Local(4).Score = 280: Local(4).Rules = 0
  505.   Local(5).Who = "STaXaTIC": Local(5).Score = 270: Local(5).Rules = 0
  506.   Local(6).Who = "Luke": Local(6).Score = 260: Local(6).Rules = 0
  507.   Local(7).Who = "[banned user]": Local(7).Score = 250: Local(7).Rules = 0
  508.   Local(8).Who = "Keybone": Local(8).Score = 240: Local(8).Rules = 0
  509.   Local(9).Who = "Catherine": Local(9).Score = 230: Local(9).Rules = 0
  510.   Local(10).Who = "Clippy": Local(10).Score = 220: Local(10).Rules = 0
  511.   Local(11).Who = "Narika": Local(11).Score = 210: Local(11).Rules = 0
  512.   Local(12).Who = "Galleon": Local(12).Score = 20: Local(12).Rules = 0
  513.  
  514. SUB Load_Online_HiScore
  515.  DIM M AS _MEM
  516.  M = _MEM(Online())
  517.  
  518.  LOCATE 20, 1: PRINT "Logging on to server"
  519.  DO
  520.   count = count + 1: C2 = T$(1)
  521.   Client = _OPENCLIENT("TCP/IP:7993:172.93.60.23") 'attempt to join as client
  522.   _LIMIT 10
  523.  LOOP UNTIL Client <> 0 OR count > 100
  524.  D1 = T$(0)
  525.  OK$ = Verify$
  526.  IF LEFT$(OK$, 4) <> "[OK]" THEN
  527.   Detail$ = "[ERROR]Host not responding."
  528.   END
  529.   G.Connected = TRUE
  530.  _DELAY .25
  531.  
  532.  PRINT "logging in to scores"
  533.  IF G.Connected THEN
  534.   N$ = D1: P$ = C2
  535.   Send Client, "[LOG IN]" + N$ + "," + P$ 'Register a new account
  536.   OK$ = Verify$
  537.   _TITLE OK$
  538.   Detail$ = OK$
  539.   IF LEFT$(OK$, 4) = "[OK]" THEN
  540.    _DELAY .15
  541.    DO
  542.     Send Client, "[GAME SET]Yahtzee" 'Let the server know what game we're playing.
  543.     OK$ = Verify$
  544.     IF LEFT$(OK$, 4) = "[OK]" THEN
  545.      ExitFlag%% = TRUE
  546.     ELSE
  547.      DisplayError OK$
  548.      CLOSE
  549.      END
  550.     END IF
  551.    LOOP UNTIL ExitFlag%%
  552.    _DELAY .25
  553.    PRINT "Requesting score file"
  554.  
  555.  
  556.    Send Client, "[GAME GET]TestScores.txt" 'the command to get the data back from the server.
  557.    OK$ = Verify$
  558.    IF LEFT$(OK$, 4) = "[OK]" THEN
  559.     'All is good
  560.     DataWeGot$ = MID$(OK$, 5) 'the data is attached after the [OK].  Like this, we got it.
  561.    ELSE
  562.     DisplayError OK$ 'pop up an error message telling us what went wrong.
  563.     END 'However we want to handle an error when trying to put data to the server.
  564.    END IF
  565.  
  566.    _MEMPUT M, M.OFFSET, DataWeGot$
  567.  
  568.   ELSE
  569.    PRINT OK$
  570.    CLOSE
  571.    END
  572.   END IF
  573.  
  574.   Online(1).Who = "Not Connected"
  575.  
  576. FUNCTION LowerTotal% (Who~%%)
  577.  IF PCL(Who~%%).ThreeOfKind >= 0 THEN Result% = PCL(Who~%%).ThreeOfKind
  578.  IF PCL(Who~%%).FourOfKind >= 0 THEN Result% = Result% + PCL(Who~%%).FourOfKind
  579.  IF PCL(Who~%%).FullHouse >= 0 THEN Result% = Result% + PCL(Who~%%).FullHouse
  580.  IF PCL(Who~%%).SmStraight >= 0 THEN Result% = Result% + PCL(Who~%%).SmStraight
  581.  IF PCL(Who~%%).LgStraight >= 0 THEN Result% = Result% + PCL(Who~%%).LgStraight
  582.  IF PCL(Who~%%).Chance >= 0 THEN Result% = Result% + PCL(Who~%%).Chance
  583.  IF PCL(Who~%%).Yahtzee >= 0 THEN Result% = Result% + PCL(Who~%%).Yahtzee
  584.  'go ahead and calculate grand total for lower as we go.-------------
  585.  PCL(Who~%%).Total = Result%
  586.  IF PCL(Who~%%).Bonus THEN
  587.   FOR i%% = 1 TO PCL(Who~%%).Bonus
  588.    PCL(Who~%%).Total = PCL(Who~%%).Total + 100
  589.    Result% = Result% + 100
  590.   NEXT i%%
  591.  '-------------------------------------------------------------------
  592.  LowerTotal = Result%
  593.  
  594. SUB Reset_SelectedScore (Selected%%, Who~%%, Rules%%)
  595.  SELECT CASE Rules%%
  596.   CASE STANDARD
  597.    SELECT CASE Selected%%
  598.     CASE 1 'aces
  599.      PCU(Who~%%).Aces = -1
  600.     CASE 2 'Duces
  601.      PCU(Who~%%).Duces = -1
  602.     CASE 3 'Trips
  603.      PCU(Who~%%).Trips = -1
  604.     CASE 4 'quads
  605.      PCU(Who~%%).Quads = -1
  606.     CASE 5 'quinc
  607.      PCU(Who~%%).Quinc = -1
  608.     CASE 6 'sexte
  609.      PCU(Who~%%).Sexte = -1
  610.     CASE 7 '3 of kind
  611.      PCL(Who~%%).ThreeOfKind = -1
  612.     CASE 8 '4 of kind
  613.      PCL(Who~%%).FourOfKind = -1
  614.     CASE 9 'full house
  615.      PCL(Who~%%).FullHouse = -1
  616.     CASE 10 'Small Straight
  617.      PCL(Who~%%).SmStraight = -1
  618.     CASE 11 'Large Straight
  619.      PCL(Who~%%).LgStraight = -1
  620.     CASE 12 'Yahtzee
  621.      PCL(Who~%%).Yahtzee = -1
  622.     CASE 13 'Chance
  623.      PCL(Who~%%).Chance = -1
  624.    END SELECT
  625.  
  626. FUNCTION Return_Local_Rank%% (Score%)
  627.  DO
  628.   i%% = i%% + 1
  629.   IF Local(i%%).Score < Score% THEN Found%% = TRUE: Result%% = i%%
  630.  LOOP UNTIL Found%%
  631.  Return_Local_Rank = Result%%
  632.  
  633. FUNCTION Return_Online_Rank~%% (Score%)
  634.  DO
  635.   i~%% = i~%% + 1
  636.   IF Online(i~%%).Score < Score% THEN Found~%% = TRUE: Result~%% = i~%%
  637.  LOOP UNTIL Found~%%
  638.  Return_Online_Rank = Result~%%
  639.  
  640. FUNCTION Set_SelectedScore%% (Selected%%, Who~%%, Rules%%)
  641.  Result%% = FALSE
  642.  SELECT CASE Rules%%
  643.   CASE STANDARD
  644.    SELECT CASE Selected%%
  645.     CASE 1 'aces
  646.      IF PCU(Who~%%).Aces = -1 THEN
  647.       PCU(Who~%%).Aces = Count_Dice%%(ACES)
  648.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN 'the bonus Yahtzee check
  649.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  650.         PCL(Who~%%).Bonus = 1
  651.        ELSEIF G.Rule_Set = LITE THEN
  652.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  653.        END IF
  654.       END IF
  655.       Result%% = TRUE
  656.      END IF
  657.     CASE 2 'Duces
  658.      IF PCU(Who~%%).Duces = -1 THEN
  659.       PCU(Who~%%).Duces = Count_Dice%%(DUCES)
  660.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN 'the bonus Yahtzee check
  661.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  662.         PCL(Who~%%).Bonus = 1
  663.        ELSEIF G.Rule_Set = LITE THEN
  664.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  665.        END IF
  666.       END IF
  667.       Result%% = TRUE
  668.      END IF
  669.     CASE 3 'Trips
  670.      IF PCU(Who~%%).Trips = -1 THEN
  671.       PCU(Who~%%).Trips = Count_Dice%%(TRIPS)
  672.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN 'the bonus Yahtzee check
  673.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  674.         PCL(Who~%%).Bonus = 1
  675.        ELSEIF G.Rule_Set = LITE THEN
  676.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  677.        END IF
  678.       END IF
  679.       Result%% = TRUE
  680.      END IF
  681.     CASE 4 'quads
  682.      IF PCU(Who~%%).Quads = -1 THEN
  683.       PCU(Who~%%).Quads = Count_Dice%%(QUADS)
  684.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN 'the bonus Yahtzee check
  685.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  686.         PCL(Who~%%).Bonus = 1
  687.        ELSEIF G.Rule_Set = LITE THEN
  688.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  689.        END IF
  690.       END IF
  691.       Result%% = TRUE
  692.      END IF
  693.     CASE 5 'quinc
  694.      IF PCU(Who~%%).Quinc = -1 THEN
  695.       PCU(Who~%%).Quinc = Count_Dice%%(QUINC)
  696.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN 'the bonus Yahtzee check
  697.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  698.         PCL(Who~%%).Bonus = 1
  699.        ELSEIF G.Rule_Set = LITE THEN
  700.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  701.        END IF
  702.       END IF
  703.       Result%% = TRUE
  704.      END IF
  705.     CASE 6 'sexte
  706.      IF PCU(Who~%%).Sexte = -1 THEN
  707.       PCU(Who~%%).Sexte = Count_Dice%%(SEXTE)
  708.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN 'the bonus Yahtzee check
  709.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  710.         PCL(Who~%%).Bonus = 1
  711.        ELSEIF G.Rule_Set = LITE THEN
  712.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  713.        END IF
  714.       END IF
  715.       Result%% = TRUE
  716.      END IF
  717.  
  718.     CASE 7 '3 of kind
  719.      'condition is met 4 ways, 3 of kind, 4 of kind, full house and yahtzee
  720.      IF PCL(Who~%%).ThreeOfKind = -1 THEN
  721.       IF Die_Check >= 3 AND Die_Check <= 6 THEN
  722.        Result%% = TRUE
  723.        PCL(Who~%%).ThreeOfKind = 0
  724.        FOR i%% = 1 TO 5
  725.         PCL(Who~%%).ThreeOfKind = PCL(Who~%%).ThreeOfKind + DieArray(i%%).Value
  726.        NEXT i%%
  727.       ELSEIF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN
  728.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  729.         Result%% = TRUE
  730.         PCL(Who~%%).ThreeOfKind = 0
  731.         FOR i%% = 1 TO 5
  732.          PCL(Who~%%).ThreeOfKind = PCL(Who~%%).ThreeOfKind + DieArray(i%%).Value
  733.         NEXT i%%
  734.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  735.        ELSEIF G.Rule_Set = LITE THEN
  736.         Result%% = TRUE
  737.         PCL(Who~%%).ThreeOfKind = 0
  738.         FOR i%% = 1 TO 5
  739.          PCL(Who~%%).ThreeOfKind = PCL(Who~%%).ThreeOfKind + DieArray(i%%).Value
  740.         NEXT i%%
  741.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  742.        END IF
  743.       ELSE
  744.        Result%% = TRUE
  745.        PCL(Who~%%).ThreeOfKind = 0
  746.       END IF
  747.      END IF
  748.  
  749.     CASE 8 '4 of kind
  750.      'condition is met with 4 of a kind or yahtzee
  751.      IF PCL(Who~%%).FourOfKind = -1 THEN
  752.       IF Die_Check = 6 THEN
  753.        Result%% = TRUE
  754.        PCL(Who~%%).FourOfKind = 0
  755.        FOR i%% = 1 TO 5
  756.         PCL(Who~%%).FourOfKind = PCL(Who~%%).FourOfKind + DieArray(i%%).Value
  757.        NEXT i%%
  758.       ELSEIF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN
  759.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  760.         Result%% = TRUE
  761.         PCL(Who~%%).FourOfKind = 0
  762.         FOR i%% = 1 TO 5
  763.          PCL(Who~%%).FourOfKind = PCL(Who~%%).FourOfKind + DieArray(i%%).Value
  764.         NEXT i%%
  765.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  766.        ELSEIF G.Rule_Set = LITE THEN
  767.         Result%% = TRUE
  768.         PCL(Who~%%).FourOfKind = 0
  769.         FOR i%% = 1 TO 5
  770.          PCL(Who~%%).FourOfKind = PCL(Who~%%).FourOfKind + DieArray(i%%).Value
  771.         NEXT i%%
  772.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  773.        END IF
  774.       ELSE
  775.        Result%% = TRUE
  776.        PCL(Who~%%).FourOfKind = 0
  777.       END IF
  778.      END IF
  779.  
  780.     CASE 9 'full house
  781.      IF PCL(Who~%%).FullHouse = -1 THEN
  782.       IF Die_Check = 5 THEN
  783.        Result%% = TRUE
  784.        PCL(Who~%%).FullHouse = 25
  785.       ELSEIF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN
  786.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  787.         Result%% = TRUE
  788.         PCL(Who~%%).FullHouse = 25
  789.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  790.        ELSEIF G.Rule_Set = LITE THEN
  791.         Result%% = TRUE
  792.         PCL(Who~%%).FullHouse = 25
  793.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  794.        END IF
  795.       ELSE
  796.        Result%% = TRUE
  797.        PCL(Who~%%).FullHouse = 0
  798.       END IF
  799.      END IF
  800.  
  801.     CASE 10 'Small Straight
  802.      IF PCL(Who~%%).SmStraight = -1 THEN
  803.       IF Die_Check = 9 OR Die_Check = 8 THEN 'check for long as well, if you have a long straight automatically have a short.
  804.        Result%% = TRUE
  805.        PCL(Who~%%).SmStraight = 30
  806.       ELSEIF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN
  807.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  808.         Result%% = TRUE
  809.         PCL(Who~%%).SmStraight = 30
  810.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  811.        ELSEIF G.Rule_Set = LITE THEN
  812.         Result%% = TRUE
  813.         PCL(Who~%%).SmStraight = 30
  814.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  815.        END IF
  816.       ELSE
  817.        Result%% = TRUE
  818.        PCL(Who~%%).SmStraight = 0
  819.       END IF
  820.      END IF
  821.  
  822.     CASE 11 'Large Straight
  823.      IF PCL(Who~%%).LgStraight THEN
  824.       IF Die_Check = 8 THEN
  825.        Result%% = TRUE
  826.        PCL(Who~%%).LgStraight = 40
  827.       ELSEIF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN
  828.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  829.         Result%% = TRUE
  830.         PCL(Who~%%).LgStraight = 40
  831.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  832.        ELSEIF G.Rule_Set = LITE THEN
  833.         Result%% = TRUE
  834.         PCL(Who~%%).LgStraight = 40
  835.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  836.        END IF
  837.       ELSE
  838.        Result%% = TRUE
  839.        PCL(Who~%%).LgStraight = 0
  840.       END IF
  841.      END IF
  842.  
  843.     CASE 12 'Yahtzee
  844.      IF PCL(Who~%%).Yahtzee = -1 THEN
  845.       IF Die_Check = 7 THEN
  846.        Result%% = TRUE
  847.        PCL(Who~%%).Yahtzee = 50
  848.       ELSE
  849.        Result%% = TRUE
  850.        PCL(Who~%%).Yahtzee = 0
  851.       END IF
  852.      END IF
  853.  
  854.     CASE 13 'Chance
  855.      IF PCL(Who~%%).Chance = -1 THEN
  856.       Result%% = TRUE
  857.       PCL(Who~%%).Chance = 0
  858.       FOR i%% = 1 TO 6
  859.        PCL(Who~%%).Chance = PCL(Who~%%).Chance + Count_Dice%%(i%%)
  860.       NEXT
  861.       IF Die_Check = 7 AND PCL(Who~%%).Yahtzee > 0 THEN
  862.        IF G.Rule_Set = STANDARD AND PCL(Who~%%).Bonus = 0 THEN
  863.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  864.        ELSEIF G.Rule_Set = LITE THEN
  865.         PCL(Who~%%).Bonus = PCL(Who~%%).Bonus + 1
  866.        END IF
  867.       END IF
  868.      END IF
  869.    END SELECT
  870.  Set_SelectedScore = Result%%
  871.  
  872. FUNCTION UpperTotal~%% (Who~%%)
  873.  IF PCU(Who~%%).Aces >= 0 THEN Result~%% = PCU(Who~%%).Aces
  874.  IF PCU(Who~%%).Duces >= 0 THEN Result~%% = Result~%% + PCU(Who~%%).Duces
  875.  IF PCU(Who~%%).Trips >= 0 THEN Result~%% = Result~%% + PCU(Who~%%).Trips
  876.  IF PCU(Who~%%).Quads >= 0 THEN Result~%% = Result~%% + PCU(Who~%%).Quads
  877.  IF PCU(Who~%%).Quinc >= 0 THEN Result~%% = Result~%% + PCU(Who~%%).Quinc
  878.  IF PCU(Who~%%).Sexte >= 0 THEN Result~%% = Result~%% + PCU(Who~%%).Sexte
  879.  'go ahead and calculate grand total for upper as we go.-------------
  880.  PCU(Who~%%).Total = Result~%%
  881.  IF Result~%% >= 63 THEN PCU(Who~%%).Total = PCU(Who~%%).Total + 35
  882.  '-------------------------------------------------------------------
  883.  UpperTotal = Result~%%
  884.  
  885. FUNCTION Show_Upper_Card%% (Who~%%)
  886.  SELECT CASE G.Rule_Set
  887.   CASE STANDARD
  888.    Create_ClickLayer 1
  889.  
  890.    DO
  891.     Display_UpperCard 0, 0, 1, Who~%%
  892.     _PUTIMAGE , Layer(1), Layer(0)
  893.     Selection%% = Check_ClickBox(_MOUSEX, _MOUSEY)
  894.     LOCATE 1, 1: PRINT Selection%%; Clicked%%
  895.      IF Clicked%% = 0 THEN
  896.       SELECT CASE Selection%%
  897.        CASE 1
  898.         IF Set_SelectedScore(ACES, Who~%%, G.Rule_Set) THEN Clicked%% = 1: G.SetValues = _SETBIT(G.SetValues, 0)
  899.        CASE 2
  900.         IF Set_SelectedScore(DUCES, Who~%%, G.Rule_Set) THEN Clicked%% = 2: G.SetValues = _SETBIT(G.SetValues, 1)
  901.        CASE 3
  902.         IF Set_SelectedScore(TRIPS, Who~%%, G.Rule_Set) THEN Clicked%% = 3: G.SetValues = _SETBIT(G.SetValues, 2)
  903.        CASE 4
  904.         IF Set_SelectedScore(QUADS, Who~%%, G.Rule_Set) THEN Clicked%% = 4: G.SetValues = _SETBIT(G.SetValues, 3)
  905.        CASE 5
  906.         IF Set_SelectedScore(QUINC, Who~%%, G.Rule_Set) THEN Clicked%% = 5: G.SetValues = _SETBIT(G.SetValues, 4)
  907.        CASE 6
  908.         IF Set_SelectedScore(SEXTE, Who~%%, G.Rule_Set) THEN Clicked%% = 6: G.SetValues = _SETBIT(G.SetValues, 5)
  909.       END SELECT
  910.      END IF
  911.      'if player clicks accept make sure they have selected a scoring location
  912.      IF Selection%% = 7 AND Clicked%% > 0 THEN Result%% = -2: ExitFlag%% = TRUE
  913.      IF Selection%% = 8 THEN 'resets selection
  914.       Reset_SelectedScore Clicked%%, Who~%%, G.Rule_Set
  915.       G.SetValues = _RESETBIT(G.SetValues, Clicked%% - 1)
  916.       Clicked%% = FALSE
  917.      END IF
  918.      IF Selection%% = 9 THEN
  919.       Result%% = TRUE: ExitFlag%% = TRUE 'hits cancel
  920.       Reset_SelectedScore Clicked%%, Who~%%, G.Rule_Set
  921.       G.SetValues = _RESETBIT(G.SetValues, Clicked%% - 1)
  922.       Clicked%% = FALSE
  923.      END IF
  924.      IF Selection%% = 10 THEN
  925.       Result%% = 1: ExitFlag%% = TRUE 'switch to lower card
  926.       Reset_SelectedScore Clicked%%, Who~%%, G.Rule_Set
  927.       G.SetValues = _RESETBIT(G.SetValues, Clicked%% - 1)
  928.       Clicked%% = FALSE
  929.      END IF
  930.      Button_Down_Lock 'hold program while button is down to help prevent 'skipping'
  931.     END IF
  932.  
  933.     _LIMIT 30
  934.     IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE: Result%% = TRUE
  935.    LOOP UNTIL ExitFlag%%
  936.  Create_ClickLayer 0
  937.  Show_Upper_Card = Result%%
  938.  ClearLayer Layer(1)
  939.  
  940. FUNCTION Show_Lower_Card%% (Who~%%)
  941.  SELECT CASE G.Rule_Set
  942.   CASE STANDARD
  943.    Create_ClickLayer 2
  944.    DO
  945.     Display_LowerCard 0, 0, 1, Who~%%
  946.     _PUTIMAGE , Layer(1), Layer(0)
  947.     Selection%% = Check_ClickBox(_MOUSEX, _MOUSEY)
  948.     LOCATE 1, 1: PRINT Selection%%; Clicked%%
  949.      IF Clicked%% = 0 AND G.Current_Roll > 0 THEN
  950.       SELECT CASE Selection%%
  951.        CASE 1
  952.         IF Set_SelectedScore(THREEOFKIND, Who~%%, G.Rule_Set) THEN Clicked%% = 7: G.SetValues = _SETBIT(G.SetValues, 7)
  953.        CASE 2
  954.         IF Set_SelectedScore(FOUROFKIND, Who~%%, G.Rule_Set) THEN Clicked%% = 8: G.SetValues = _SETBIT(G.SetValues, 8)
  955.        CASE 3
  956.         IF Set_SelectedScore(FULLHOUSE, Who~%%, G.Rule_Set) THEN Clicked%% = 9: G.SetValues = _SETBIT(G.SetValues, 9)
  957.        CASE 4
  958.         IF Set_SelectedScore(SMSTRAIGHT, Who~%%, G.Rule_Set) THEN Clicked%% = 10: G.SetValues = _SETBIT(G.SetValues, 10)
  959.        CASE 5
  960.         IF Set_SelectedScore(LGSTRAIGHT, Who~%%, G.Rule_Set) THEN Clicked%% = 11: G.SetValues = _SETBIT(G.SetValues, 11)
  961.        CASE 6
  962.         IF Set_SelectedScore(YAHTZEE, Who~%%, G.Rule_Set) THEN Clicked%% = 12: G.SetValues = _SETBIT(G.SetValues, 12)
  963.        CASE 7
  964.         IF Set_SelectedScore(CHANCE, Who~%%, G.Rule_Set) THEN Clicked%% = 13: G.SetValues = _SETBIT(G.SetValues, 13)
  965.       END SELECT
  966.      END IF
  967.      'if player clicks accept make sure they have selected a scoring location
  968.      IF Selection%% = 8 AND Clicked%% > 0 THEN Result%% = -2: ExitFlag%% = TRUE
  969.      IF Selection%% = 9 THEN
  970.       Reset_SelectedScore Clicked%%, Who~%%, G.Rule_Set
  971.       G.SetValues = _RESETBIT(G.SetValues, Clicked%%)
  972.       Clicked%% = 0
  973.      END IF
  974.      IF Selection%% = 10 THEN
  975.       ExitFlag%% = TRUE: Result%% = TRUE 'cancel
  976.       Reset_SelectedScore Clicked%%, Who~%%, G.Rule_Set
  977.       G.SetValues = _RESETBIT(G.SetValues, Clicked%%)
  978.      END IF
  979.      IF Selection%% = 11 THEN
  980.       Result%% = 2: ExitFlag%% = TRUE 'switch to upper card
  981.       Reset_SelectedScore Clicked%%, Who~%%, G.Rule_Set
  982.       G.SetValues = _RESETBIT(G.SetValues, Clicked%%)
  983.       Clicked%% = FALSE
  984.      END IF
  985.      Button_Down_Lock 'hold program while button is down to help prevent 'skipping'
  986.     END IF
  987.     _LIMIT 30
  988.     IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE: Result%% = TRUE
  989.    LOOP UNTIL ExitFlag%%
  990.  Create_ClickLayer 0
  991.  Show_Lower_Card = Result%%
  992.  ClearLayer Layer(1)
  993.  
  994. SUB Save_Local_Score
  995.  F1 = FREEFILE
  996.  OPEN "LocalYahtzee.SCR" FOR BINARY AS #F1
  997.  GrandTotal% = PCU(Who~%%).Total + PCL(who%%).Total
  998.  
  999.  IF G.FirstGame THEN
  1000.   Clear_Scores
  1001.   Local(1).Who = Nick(0)
  1002.   Local(1).Score = GrandTotal%
  1003.   Local(1).Rules = G.Rule_Set
  1004.  
  1005.   PUT #F1, , Local()
  1006.   G.FirstGame = 0
  1007.   Start%% = Return_Local_Rank(GrandTotal%) 'where is player being placed in score list
  1008.   FOR i%% = 99 TO Start%% STEP -1
  1009.    Local(i%% + 1) = Local(i%%)
  1010.   NEXT i%%
  1011.   Local(Start%%).Who = Nick(0)
  1012.   Local(Start%%).Rules = G.Rule_Set
  1013.   Local(Start%%).Score = GrandTotal%
  1014.   PUT #F1, , Local()
  1015.  CLOSE #F1
  1016.  
  1017. SUB Sort_Online_Scores
  1018.  'simple but slow sort
  1019.   FOR i~%% = 1 TO 255
  1020.   FOR j~%% = i%% + 1 TO 255
  1021.    IF Online(j~%%).Score < Online(i~%%).Score THEN SWAP Online(j~%%), Online(i~%%)
  1022.   NEXT j~%%
  1023.  NEXT i~%%
  1024.  
  1025. SUB Save_Online_Score
  1026.  DIM M AS _MEM
  1027.  M = _MEM(Online())
  1028.  
  1029.  Send Client, "[GAME GET]TestScores.txt" 'the command to get the data back from the server.
  1030.  OK$ = Verify$
  1031.  IF LEFT$(OK$, 4) = "[OK]" THEN
  1032.   'All is good
  1033.   DataWeGot$ = MID$(OK$, 5) 'the data is attached after the [OK].  Like this, we got it.
  1034.   DisplayError OK$ 'pop up an error message telling us what went wrong.
  1035.   END 'However we want to handle an error when trying to put data to the server.
  1036.  
  1037.  _MEMPUT M, M.OFFSET, DataWeGot$
  1038.  Online(0).Who = Nick$(0)
  1039.  Online(0).Rules = 0
  1040.  Online(0).Score = PCU(Who~%%).Total + PCL(who%%).Total
  1041.  'bump scores down, oldest score falls off. not too keen on this maybe some day
  1042.  'I could adjust the score file to handle a larger number of scores.
  1043.  FOR i~%% = 254 TO 0 STEP -1
  1044.   Online(i~%% + 1) = Online(i~%%)
  1045.  NEXT i~%%
  1046.  Online(0).Who = ""
  1047.  Online(0).Rules = 0
  1048.  Online(0).Score = 0
  1049.  
  1050.  Temp$ = SPACE$(19 * 255)
  1051.  _MEMGET M, M.OFFSET, Temp$
  1052.  
  1053.  DataToPut$ = Temp$
  1054.  'TO PUT INFORMATION TO THE SERVER:
  1055.  Send Client, "[GAME PUT]TestScores.TXT" + CHR$(0) + DataToPut$ 'put the data to filename.ext on the server
  1056.  OK$ = Verify$
  1057.  IF LEFT$(OK$, 4) = "[OK]" THEN
  1058.   'All is good
  1059.   DisplayError OK$ 'pop up an error message telling us what went wrong.
  1060.   END 'However we want to handle an error when trying to put data to the server.
  1061.  _DELAY .25
  1062.  
  1063.  
  1064. SUB Create_ClickLayer (Scren%%)
  1065.  _DEST Layer(4)
  1066.  CLS , 0
  1067.  SELECT CASE Scren%%
  1068.   CASE 0 'main game wscreen
  1069.    'shaker cup
  1070.    LINE (500, 20)-STEP(90, 118), _RGB32(1, 0, 0), BF
  1071.    'upper score card
  1072.    LINE (400, 140)-STEP(210, 154), _RGB32(2, 0, 0), BF
  1073.    'lower score card
  1074.    LINE (400, 295)-STEP(210, 155), _RGB32(3, 0, 0), BF
  1075.    'dice
  1076.    FOR i%% = 0 TO 4
  1077.     LINE (50 + i%% * 60, 50)-STEP(52, 50), _RGB32(4 + i%%, 0, 0), BF
  1078.    NEXT i%%
  1079.   CASE 1 'upper score card screen
  1080.    FOR i%% = 0 TO 5
  1081.     LINE (230, 150 + (32 * i%%) + i%%)-STEP(63, 31), _RGB32(1 + i%%, 0, 0), BF
  1082.    NEXT i%%
  1083.    LINE (465, 128)-STEP(129, 31), _RGB32(7, 0, 0), BF
  1084.    LINE (465, 175)-STEP(129, 31), _RGB32(8, 0, 0), BF
  1085.    LINE (465, 220)-STEP(129, 31), _RGB32(10, 0, 0), BF
  1086.    LINE (465, 264)-STEP(129, 31), _RGB32(9, 0, 0), BF
  1087.  
  1088.   CASE 2 'lower score card screen
  1089.    FOR i%% = 0 TO 6
  1090.     LINE (230, 28 + (32 * i%%))-STEP(63, 31), _RGB32(1 + i%%, 0, 0), BF
  1091.    NEXT i%%
  1092.    LINE (475, 38)-STEP(129, 31), _RGB32(8, 0, 0), BF
  1093.    LINE (475, 85)-STEP(129, 31), _RGB32(9, 0, 0), BF
  1094.    LINE (475, 130)-STEP(129, 31), _RGB32(11, 0, 0), BF
  1095.    LINE (475, 174)-STEP(129, 31), _RGB32(10, 0, 0), BF
  1096.   CASE 3 'main menu
  1097.    LINE (220, 336)-STEP(180, 20), _RGB32(1, 0, 0), BF
  1098.    LINE (220, 357)-STEP(180, 22), _RGB32(2, 0, 0), BF
  1099.    LINE (220, 380)-STEP(180, 21), _RGB32(3, 0, 0), BF
  1100.    LINE (220, 403)-STEP(180, 21), _RGB32(4, 0, 0), BF
  1101.    LINE (220, 426)-STEP(180, 22), _RGB32(5, 0, 0), BF
  1102.    LINE (220, 450)-STEP(180, 28), _RGB32(6, 0, 0), BF
  1103.   CASE 4 'Nick name selection screen
  1104.    FOR i%% = 0 TO 1
  1105.     FOR j%% = 0 TO 12
  1106.      C%% = C%% + 1
  1107.      LINE (85 + 35 * j%% + j%%, 158 + 50 * i%%)-STEP(19, 25), _RGB32(C%%, 0, 0), BF
  1108.     NEXT j%%
  1109.    NEXT i%%
  1110.    FOR j%% = 0 TO 11
  1111.     C%% = C%% + 1
  1112.     LINE (85 + 35 * j%% + j%%, 158 + 50 * i%%)-STEP(19, 25), _RGB32(C%%, 0, 0), BF
  1113.    NEXT j%%
  1114.    LINE (190, 308)-STEP(80, 25), _RGB32(63, 0, 0), BF
  1115.    LINE (370, 308)-STEP(80, 25), _RGB32(64, 0, 0), BF
  1116.  
  1117.  _DEST Layer(0)
  1118.  
  1119. SUB Display_Dice (X%, Y%)
  1120.  FOR i%% = 0 TO 4
  1121.   IF DieArray(i%% + 1).Locked = FALSE THEN
  1122.    _PUTIMAGE (X% + i%% * 60, Y%)-STEP(52, 50), Layer(8), Layer(1), (23 + DieArray(i%% + 1).Value * 54, 0)-STEP(52, 50)
  1123.   ELSE
  1124.    _PUTIMAGE (X% + i%% * 60, Y%)-STEP(52, 50), Layer(8), Layer(1), (23 + DieArray(i%% + 1).Value * 54, 55)-STEP(52, 50)
  1125.   END IF
  1126.  NEXT i%%
  1127.  
  1128. SUB Draw_GameMat (L&)
  1129.  _DEST L&
  1130.  LINE (18, 22)-STEP(604, 436), _RGB32(8, 72, 32), BF
  1131.  LINE (22, 18)-STEP(596, 444), _RGB32(8, 72, 32), BF
  1132.  LINE (19, 21)-STEP(602, 438), _RGB32(16, 96, 40), BF
  1133.  LINE (21, 19)-STEP(598, 442), _RGB32(16, 96, 40), BF
  1134.  LINE (20, 20)-STEP(600, 440), _RGB32(24, 128, 52), BF
  1135.  _DEST Layer(0)
  1136.  
  1137. SUB Display_UpperCard (X%, Y%, Scale!, Who~%%)
  1138.  _DEST Layer(10)
  1139.  COLOR _RGB32(0, 0, 0)
  1140.  _PUTIMAGE , Layer(2), Layer(10)
  1141.  Display_UpperScores Layer(10), Who~%%
  1142.  _PUTIMAGE (X%, Y%)-STEP(639 * Scale!, 474 * Scale!), Layer(10), Layer(1)
  1143.  COLOR _RGB32(255, 255, 255)
  1144.  _DEST Layer(0)
  1145.  
  1146. SUB Display_LowerCard (X%, Y%, Scale!, Who~%%)
  1147.  _DEST Layer(10)
  1148.  COLOR _RGB32(0, 0, 0)
  1149.  _PUTIMAGE , Layer(3), Layer(10)
  1150.  Display_LowerScores Layer(10), Who~%%
  1151.  _PUTIMAGE (X%, Y%)-STEP(639 * Scale!, 474 * Scale!), Layer(10), Layer(1)
  1152.  COLOR _RGB32(255, 255, 255)
  1153.  _DEST Layer(0)
  1154.  
  1155. SUB Display_UpperScores (L&, Who~%%)
  1156.  SELECT CASE G.Rule_Set
  1157.   CASE STANDARD
  1158.    _PRINTSTRING (363, 15), Nick(Who~%%), L&
  1159.    IF PCU(Who~%%).Aces >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Aces))) / 1.6), 157), LTRIM$(STR$(PCU(Who~%%).Aces)), L&
  1160.    IF PCU(Who~%%).Duces >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Duces))) / 1.6), 190), LTRIM$(STR$(PCU(Who~%%).Duces)), L&
  1161.    IF PCU(Who~%%).Trips >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Trips))) / 1.6), 223), LTRIM$(STR$(PCU(Who~%%).Trips)), L&
  1162.    IF PCU(Who~%%).Quads >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Quads))) / 1.6), 258), LTRIM$(STR$(PCU(Who~%%).Quads)), L&
  1163.    IF PCU(Who~%%).Quinc >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Quinc))) / 1.6), 291), LTRIM$(STR$(PCU(Who~%%).Quinc)), L&
  1164.    IF PCU(Who~%%).Sexte >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Sexte))) / 1.6), 326), LTRIM$(STR$(PCU(Who~%%).Sexte)), L&
  1165.    _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(UpperTotal(Who~%%)))) / 1.6), 370), LTRIM$(STR$(UpperTotal(Who~%%))), L&
  1166.    IF UpperTotal(Who~%%) >= 63 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(35))) / 1.6), 405), LTRIM$(STR$(35)), L&
  1167.    IF G.Upper_Filled THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Total))) / 1.6), 438), LTRIM$(STR$(PCU(Who~%%).Total)), L&
  1168.  
  1169. SUB Display_LowerScores (L&, Who~%%)
  1170.  SELECT CASE G.Rule_Set
  1171.   CASE STANDARD
  1172.    IF PCL(Who~%%).ThreeOfKind >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).ThreeOfKind))) / 1.6), 34), LTRIM$(STR$(PCL(Who~%%).ThreeOfKind)), L&
  1173.    IF PCL(Who~%%).FourOfKind >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).FourOfKind))) / 1.6), 67), LTRIM$(STR$(PCL(Who~%%).FourOfKind)), L&
  1174.    IF PCL(Who~%%).FullHouse >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).FullHouse))) / 1.6), 101), LTRIM$(STR$(PCL(Who~%%).FullHouse)), L&
  1175.    IF PCL(Who~%%).SmStraight >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).SmStraight))) / 1.6), 134), LTRIM$(STR$(PCL(Who~%%).SmStraight)), L&
  1176.    IF PCL(Who~%%).LgStraight >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).LgStraight))) / 1.6), 165), LTRIM$(STR$(PCL(Who~%%).LgStraight)), L&
  1177.    IF PCL(Who~%%).Yahtzee >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).Yahtzee))) / 1.6), 199), LTRIM$(STR$(PCL(Who~%%).Yahtzee)), L&
  1178.    IF PCL(Who~%%).Chance >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).Chance))) / 1.6), 232), LTRIM$(STR$(PCL(Who~%%).Chance)), L&
  1179.    IF PCL(Who~%%).Bonus > 0 THEN _PRINTSTRING (300, 199), "100x" + LTRIM$(STR$(PCL(Who~%%).Bonus)), L&
  1180.    _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(LowerTotal(Who~%%)))) / 1.6), 265), LTRIM$(STR$(LowerTotal(Who~%%))), L&
  1181.    '   _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(UpperTotal(Who~%%)))) / 1.6), 298), LTRIM$(STR$(UpperTotal(Who~%%))), L&
  1182.    _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Total))) / 1.6), 298), LTRIM$(STR$(PCU(Who~%%).Total)), L&
  1183.    GrandTotal% = PCU(Who~%%).Total + PCL(who%%).Total
  1184.    IF GrandTotal% > 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(GrandTotal%))) / 1.6), 330), LTRIM$(STR$(GrandTotal%)), L&
  1185.  
  1186. SUB End_Score (Who~%%)
  1187.  CLS
  1188.  _PUTIMAGE , Layer(12), Layer(13)
  1189.  'fill in card
  1190.  _FONT FFX&, Layer(13)
  1191.  _DEST Layer(13)
  1192.  _DEST Layer(0)
  1193.  IF PCU(Who~%%).Aces >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Aces))) / 1.6), 16), LTRIM$(STR$(PCU(Who~%%).Aces)), Layer(13)
  1194.  IF PCU(Who~%%).Duces >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Duces))) / 1.6), 50), LTRIM$(STR$(PCU(Who~%%).Duces)), Layer(13)
  1195.  IF PCU(Who~%%).Trips >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Trips))) / 1.6), 84), LTRIM$(STR$(PCU(Who~%%).Trips)), Layer(13)
  1196.  IF PCU(Who~%%).Quads >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Quads))) / 1.6), 118), LTRIM$(STR$(PCU(Who~%%).Quads)), Layer(13)
  1197.  IF PCU(Who~%%).Quinc >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Quinc))) / 1.6), 152), LTRIM$(STR$(PCU(Who~%%).Quinc)), Layer(13)
  1198.  IF PCU(Who~%%).Sexte >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Sexte))) / 1.6), 186), LTRIM$(STR$(PCU(Who~%%).Sexte)), Layer(13)
  1199.  IF UpperTotal(Who~%%) >= 63 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(35))) / 1.6), 221), LTRIM$(STR$(35)), Layer(13)
  1200.  
  1201.  IF PCL(Who~%%).ThreeOfKind >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).ThreeOfKind))) / 1.6), 254), LTRIM$(STR$(PCL(Who~%%).ThreeOfKind)), Layer(13)
  1202.  IF PCL(Who~%%).FourOfKind >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).FourOfKind))) / 1.6), 288), LTRIM$(STR$(PCL(Who~%%).FourOfKind)), Layer(13)
  1203.  IF PCL(Who~%%).FullHouse >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).FullHouse))) / 1.6), 320), LTRIM$(STR$(PCL(Who~%%).FullHouse)), Layer(13)
  1204.  IF PCL(Who~%%).SmStraight >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).SmStraight))) / 1.6), 354), LTRIM$(STR$(PCL(Who~%%).SmStraight)), Layer(13)
  1205.  IF PCL(Who~%%).LgStraight >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).LgStraight))) / 1.6), 386), LTRIM$(STR$(PCL(Who~%%).LgStraight)), Layer(13)
  1206.  IF PCL(Who~%%).Yahtzee >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).Yahtzee))) / 1.6), 418), LTRIM$(STR$(PCL(Who~%%).Yahtzee)), Layer(13)
  1207.  IF PCL(Who~%%).Chance >= 0 THEN _PRINTSTRING (260 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).Chance))) / 1.6), 450), LTRIM$(STR$(PCL(Who~%%).Chance)), Layer(13)
  1208.  
  1209.  IF PCL(Who~%%).Bonus > 0 THEN _PRINTSTRING (165, 482), LTRIM$(STR$(PCL(Who~%%).Bonus)), Layer(13): _PRINTSTRING (250 - 12 * (LEN(LTRIM$(STR$(PCL(Who~%%).Bonus * 100))) / 1.6), 482), LTRIM$(STR$(PCL(Who~%%).Bonus * 100)), Layer(13)
  1210.  
  1211.  _PRINTSTRING (254 - 12 * (LEN(LTRIM$(STR$(LowerTotal(Who~%%)))) / 1.6), 517), LTRIM$(STR$(LowerTotal(Who~%%))), Layer(13)
  1212.  _PRINTSTRING (258 - 12 * (LEN(LTRIM$(STR$(PCU(Who~%%).Total))) / 1.6), 549), LTRIM$(STR$(PCU(Who~%%).Total)), Layer(13)
  1213.  GrandTotal% = PCU(Who~%%).Total + PCL(who%%).Total
  1214.  _PRINTSTRING (254 - 12 * (LEN(LTRIM$(STR$(GrandTotal%))) / 1.6), 581), LTRIM$(STR$(GrandTotal%)), Layer(13)
  1215.  
  1216.  _PUTIMAGE (0, 0)-STEP(296, 479), Layer(13), Layer(0)
  1217.  
  1218.  _FONT 16
  1219.  ' COLOR _RGB32(255)
  1220.  'display top 5 scores
  1221.  IF NOT G.FirstGame THEN _PRINTSTRING (360, 0), "Gameover, Good Job." ELSE _PRINTSTRING (300, 0), "Congradulations on playing the first Game!"
  1222.  COLOR _RGB32(160, 124, 32)
  1223.  _PRINTSTRING (400, 20), "Top 5 Local"
  1224.  COLOR _RGB32(255)
  1225.  _PRINTSTRING (310, 38), "   Name                Rules      Score"
  1226.  
  1227.  LINE (305, 54)-STEP(320, 3), _RGB32(212, 212, 60), BF
  1228.  
  1229.  FOR i%% = 1 TO 5
  1230.   _PRINTSTRING (310, 44 + 18 * i%%), "#" + LTRIM$(STR$(i%%)) + "-" + RTRIM$(Local(i%%).Who) + SPACE$(32 - LEN(RTRIM$(Local(i%%).Who))) + LTRIM$(STR$(Local(i%%).Score))
  1231.   IF Local(i%%).Rules = 2 THEN _PRINTSTRING (500, 44 + 18 * i%%), "Lite" ELSE _PRINTSTRING (500, 44 + 18 * i%%), "Base"
  1232.  
  1233.  NEXT i%%
  1234.  COLOR _RGB32(212, 200, 48)
  1235.  _PRINTSTRING (400, 48 + 18 * i%%), "Your Ranking"
  1236.  COLOR _RGB32(255)
  1237.  
  1238.  IF G.FirstGame THEN
  1239.   _PRINTSTRING (310, 48 + 18 * (i%% + 1)), "#1-" + RTRIM$(Nick(Who~%%)) + SPACE$(32 - LEN(RTRIM$(Nick(Who~%%)))) + LTRIM$(STR$(GrandTotal%))
  1240.   IF Local(i%%).Rules = 2 THEN _PRINTSTRING (500, 48 + 18 * (i%% + 1)), "Lite" ELSE _PRINTSTRING (500, 48 + 18 * (i%% + 1)), "Base"
  1241.   _PRINTSTRING (310, 48 + 18 * (i%% + 1)), "#" + LTRIM$(STR$(Return_Local_Rank(GrandTotal%))) + "-" + RTRIM$(Nick(Who~%%)) + SPACE$(32 - LEN(RTRIM$(Nick(Who~%%)))) + LTRIM$(STR$(GrandTotal%))
  1242.   IF Local(i%%).Rules = 2 THEN _PRINTSTRING (500, 48 + 18 * (i%% + 1)), "Lite" ELSE _PRINTSTRING (500, 48 + 18 * (i%% + 1)), "Base"
  1243.  
  1244.  COLOR _RGB32(60, 192, 32)
  1245.  IF G.Connected THEN
  1246.   _PRINTSTRING (400, 216), "Top 5 Online"
  1247.   COLOR _RGB32(255)
  1248.   FOR i%% = 1 TO 5
  1249.    _PRINTSTRING (310, 224 + 18 * i%%), "#" + LTRIM$(STR$(i%%)) + "-" + RTRIM$(Online(i%%).Who) + SPACE$(32 - LEN(RTRIM$(Online(i%%).Who))) + LTRIM$(STR$(Online(i%%).Score))
  1250.    IF Online(i%%).Rules = 2 THEN _PRINTSTRING (500, 224 + 18 * i%%), "Lite" ELSE _PRINTSTRING (500, 224 + 18 * i%%), "Base"
  1251.   NEXT i%%
  1252.  
  1253.   COLOR _RGB32(144, 240, 64)
  1254.   _PRINTSTRING (380, 228 + 18 * i%%), "Your Ranking Online"
  1255.   COLOR _RGB32(255)
  1256.   _PRINTSTRING (310, 228 + 18 * (i%% + 1)), "#" + LTRIM$(STR$(Return_Online_Rank(GrandTotal%))) + "-" + RTRIM$(Nick(Who~%%)) + SPACE$(32 - LEN(RTRIM$(Nick(Who~%%)))) + LTRIM$(STR$(GrandTotal%))
  1257.   IF Local(i%%).Rules = 2 THEN _PRINTSTRING (500, 228 + 18 * (i%% + 1)), "Lite" ELSE _PRINTSTRING (500, 228 + 18 * (i%% + 1)), "Base"
  1258.   _PRINTSTRING (350, 216), "Top 5 Online (not connected)"
  1259.  COLOR _RGB32(255)
  1260.  _PRINTSTRING (350, 450), "Press any key to return to menu"
  1261.  DO: LOOP UNTIL INKEY$ <> ""
  1262.  
  1263. SUB FlashScreen (L&)
  1264.  _PUTIMAGE (0, 0), L&, Layer(0)
  1265.  
  1266. SUB Place_ShakerCup (X%, Y%)
  1267.  _PUTIMAGE (X%, Y%), Layer(9), Layer(1)
  1268.  
  1269. SUB DarkenImage (Image AS LONG, Value_From_0_To_1 AS SINGLE)
  1270.  'Taken from the QB64 Wiki.
  1271.  IF Value_From_0_To_1 <= 0 OR Value_From_0_To_1 >= 1 OR _PIXELSIZE(Image) <> 4 THEN EXIT SUB
  1272.  DIM Buffer AS _MEM: Buffer = _MEMIMAGE(Image) 'Get a memory reference to our image
  1273.  DIM Frac_Value AS LONG: Frac_Value = Value_From_0_To_1 * 65536 'Used to avoid slow floating point calculations
  1274.  DIM O AS _OFFSET, O_Last AS _OFFSET
  1275.  O = Buffer.OFFSET 'We start at this offset
  1276.  O_Last = Buffer.OFFSET + _WIDTH(Image) * _HEIGHT(Image) * 4 'We stop when we get to this offset
  1277.  'use on error free code ONLY!
  1278.  DO
  1279.   _MEMPUT Buffer, O, _MEMGET(Buffer, O, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  1280.   _MEMPUT Buffer, O + 1, _MEMGET(Buffer, O + 1, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  1281.   _MEMPUT Buffer, O + 2, _MEMGET(Buffer, O + 2, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  1282.   O = O + 4
  1283.  LOOP UNTIL O = O_Last
  1284.  'turn checking back on when done!
  1285.  _MEMFREE Buffer
  1286.  
  1287. SUB Intro
  1288.  _SNDPLAY BGM(1)
  1289.  FOR n! = 0.01 TO 1 STEP 0.01
  1290.   tmp& = _COPYIMAGE(Layer(5))
  1291.   DarkenImage tmp&, n!
  1292.   _PUTIMAGE (0, 0), tmp&
  1293.   _FREEIMAGE tmp&
  1294.   _DELAY .025
  1295.  _DELAY 3
  1296.  FOR n! = 1 TO 0.01 STEP -0.01
  1297.   tmp& = _COPYIMAGE(Layer(5))
  1298.   DarkenImage tmp&, n!
  1299.   _PUTIMAGE (0, 0), tmp&
  1300.   _FREEIMAGE tmp&
  1301.   _DELAY .025
  1302.  FOR n! = 0.01 TO 1 STEP 0.01
  1303.   tmp& = _COPYIMAGE(Layer(6))
  1304.   DarkenImage tmp&, n!
  1305.   _PUTIMAGE (5, 0), tmp&
  1306.   _FREEIMAGE tmp&
  1307.   _DELAY .025
  1308.  _DELAY 2.5
  1309.  FOR n! = 1 TO 0.01 STEP -0.01
  1310.   tmp& = _COPYIMAGE(Layer(6))
  1311.   DarkenImage tmp&, n!
  1312.   _PUTIMAGE (5, 0), tmp&
  1313.   _FREEIMAGE tmp&
  1314.   _DELAY .025
  1315.  
  1316. SUB Local_Scores
  1317.  Display_Offset%% = 0
  1318.  'setup the static parts of high score list on layer 10---------
  1319.  _DEST Layer(10)
  1320.  _FONT 16
  1321.  _PRINTSTRING (320 - (39 * 4), 38), "   Name                Rules      Score", Layer(10)
  1322.  LINE (320 - 39 * 4, 54)-STEP(320, 3), _RGB32(212, 212, 60), BF
  1323.  LINE (500, 60)-STEP(16, 360), _RGB32(24, 24, 24), BF
  1324.  LINE (610, 60)-STEP(20, 60), _RGBA32(192, 192, 192, 96), BF
  1325.  FOR i%% = 1 TO 40 STEP 5
  1326.   LINE (615, 70 + i%%)-STEP(10, 2), _RGBA32(224, 224, 224, 192), BF
  1327.  NEXT i%%
  1328.  LINE (60, 20)-STEP(60, 20), _RGB32(92, 112, 16), BF
  1329.  _PRINTSTRING (74, 23), "Exit", Layer(10)
  1330.  LINE (540, 20)-STEP(60, 20), _RGB32(92, 112, 16), BF
  1331.  _PRINTSTRING (552, 23), "Reset", Layer(10)
  1332.  _DEST Layer(0)
  1333.  '---------------------------------------------------------------
  1334.  
  1335.  DO
  1336.   _PUTIMAGE (0, 0), Layer(10), Layer(1), (0, 0)-STEP(600, 479)
  1337.   _PUTIMAGE (498, 60 + Display_Offset%% * 3.8), Layer(10), Layer(1), (610, 60)-STEP(20, 60)
  1338.   FOR j%% = 1 TO 20
  1339.    i%% = j%% + Display_Offset%%
  1340.    N$ = LTRIM$(STR$(i%%))
  1341.    N$ = LEFT$("00", 2 - LEN(N$)) + N$
  1342.    NickString$ = "#" + N$ + "-" + RTRIM$(Local(i%%).Who)
  1343.    ScoreString$ = LTRIM$(STR$(Local(i%%).Score))
  1344.    _PRINTSTRING (320 - 39 * 4, 44 + 18 * j%%), NickString$, Layer(1)
  1345.    _PRINTSTRING (472 - 8 * LEN(ScoreString$), 44 + 18 * j%%), ScoreString$, Layer(1)
  1346.    IF Local(i%%).Rules = 2 THEN _PRINTSTRING (350, 44 + 18 * j%%), "Lite", Layer(1) ELSE _PRINTSTRING (350, 44 + 18 * j%%), "Base", Layer(1)
  1347.   NEXT j%%
  1348.   IF _MOUSEX >= 60 AND _MOUSEX <= 120 AND _MOUSEY >= 20 AND _MOUSEY <= 40 THEN
  1349.    _DEST Layer(1): COLOR _RGB32(212, 64, 64)
  1350.    _PRINTSTRING (74, 23), "Exit", Layer(1)
  1351.    COLOR _RGB32(255): _DEST Layer(0)
  1352.   END IF
  1353.   IF _MOUSEX >= 540 AND _MOUSEX <= 600 AND _MOUSEY >= 20 AND _MOUSEY <= 40 THEN
  1354.    _DEST Layer(1): COLOR _RGB32(212, 64, 64)
  1355.    _PRINTSTRING (552, 23), "Reset", Layer(1)
  1356.    COLOR _RGB32(255): _DEST Layer(0)
  1357.   END IF
  1358.   _PUTIMAGE , Layer(1), Layer(0)
  1359.   ClearLayer Layer(1)
  1360.   _LIMIT 30
  1361.  
  1362.    IF _MOUSEX >= 498 AND _MOUSEX <= 524 THEN
  1363.     Display_Offset%% = INT(_MOUSEY - starty%) / 4
  1364.    END IF
  1365.    IF _MOUSEX >= 60 AND _MOUSEX <= 120 AND _MOUSEY >= 20 AND _MOUSEY <= 40 THEN ExitFlag%% = TRUE: Button_Down_Lock
  1366.    IF _MOUSEX >= 540 AND _MOUSEX <= 600 AND _MOUSEY >= 20 AND _MOUSEY <= 40 THEN
  1367.     IF _FILEEXISTS("LocalYahtzee.SCR") THEN KILL "LocalYahtzee.SCR": G.FirstGame = TRUE
  1368.     Button_Down_Lock
  1369.    END IF
  1370.   ELSE
  1371.    starty% = _MOUSEY
  1372.   END IF
  1373.  
  1374.  
  1375.  
  1376.    CASE 27
  1377.     ExitFlag%% = TRUE
  1378.    CASE 18432
  1379.     Display_Offset%% = Display_Offset%% - 1
  1380.    CASE 20480
  1381.     Display_Offset%% = Display_Offset%% + 1
  1382.   IF Display_Offset%% > 80 THEN Display_Offset%% = 80
  1383.   IF Display_Offset%% < 0 THEN Display_Offset%% = 0
  1384.  
  1385.  LOOP UNTIL ExitFlag%%
  1386.  _FONT FFX&, Layer(10) 'restore font to layer 10
  1387.  ClearLayer Layer(10) 'clean layer 10 up
  1388.  
  1389. SUB Online_Scores
  1390.  Display_Offset% = 0
  1391.  'setup the static parts of high score list on layer 10---------
  1392.  _DEST Layer(10)
  1393.  _FONT 16
  1394.  _PRINTSTRING (320 - (39 * 4), 38), "   Name                Rules      Score", Layer(10)
  1395.  LINE (320 - 39 * 4, 54)-STEP(320, 3), _RGB32(212, 212, 60), BF
  1396.  LINE (500, 60)-STEP(16, 360), _RGB32(24, 24, 24), BF
  1397.  LINE (610, 60)-STEP(20, 60), _RGBA32(192, 192, 192, 96), BF
  1398.  FOR i%% = 1 TO 40 STEP 5
  1399.   LINE (615, 70 + i%%)-STEP(10, 2), _RGBA32(224, 224, 224, 192), BF
  1400.  NEXT i%%
  1401.  LINE (60, 20)-STEP(60, 20), _RGB32(92, 112, 16), BF
  1402.  _PRINTSTRING (74, 23), "Exit", Layer(10)
  1403.  _DEST Layer(0)
  1404.  '---------------------------------------------------------------
  1405.  
  1406.  DO
  1407.   _PUTIMAGE (0, 0), Layer(10), Layer(1), (0, 0)-STEP(600, 479)
  1408.   _PUTIMAGE (498, 60 + Display_Offset% * 1.3), Layer(10), Layer(1), (610, 60)-STEP(20, 60)
  1409.   FOR J~%% = 1 TO 20
  1410.    I~%% = J~%% + Display_Offset%
  1411.    N$ = LTRIM$(STR$(I~%%))
  1412.    N$ = LEFT$("00", 2 - LEN(N$)) + N$
  1413.    NickString$ = "#" + N$ + "-" + RTRIM$(Online(I~%%).Who)
  1414.    ScoreString$ = LTRIM$(STR$(Online(I~%%).Score))
  1415.    _PRINTSTRING (320 - 39 * 4, 44 + 18 * J~%%), NickString$, Layer(1)
  1416.    _PRINTSTRING (472 - 8 * LEN(ScoreString$), 44 + 18 * J~%%), ScoreString$, Layer(1)
  1417.    IF Online(I~%%).Rules = 2 THEN _PRINTSTRING (350, 44 + 18 * J~%%), "Lite", Layer(1) ELSE _PRINTSTRING (350, 44 + 18 * J~%%), "Base", Layer(1)
  1418.   NEXT J~%%
  1419.   IF _MOUSEX >= 60 AND _MOUSEX <= 120 AND _MOUSEY >= 20 AND _MOUSEY <= 40 THEN
  1420.    _DEST Layer(1): COLOR _RGB32(212, 64, 64)
  1421.    _PRINTSTRING (74, 23), "Exit", Layer(1)
  1422.    COLOR _RGB32(255): _DEST Layer(0)
  1423.   END IF
  1424.   _PUTIMAGE , Layer(1), Layer(0)
  1425.   ClearLayer Layer(1)
  1426.   _LIMIT 30
  1427.  
  1428.    IF _MOUSEX >= 498 AND _MOUSEX <= 524 THEN
  1429.     Display_Offset% = INT(_MOUSEY - starty%) / 1.4
  1430.    END IF
  1431.    IF _MOUSEX >= 60 AND _MOUSEX <= 120 AND _MOUSEY >= 20 AND _MOUSEY <= 40 THEN ExitFlag%% = TRUE: Button_Down_Lock
  1432.   ELSE
  1433.    starty% = _MOUSEY
  1434.   END IF
  1435.  
  1436.  
  1437.  
  1438.    CASE 27
  1439.     ExitFlag%% = TRUE
  1440.    CASE 18432
  1441.     Display_Offset% = Display_Offset% - 1
  1442.    CASE 20480
  1443.     Display_Offset% = Display_Offset% + 1
  1444.   IF Display_Offset% > 235 THEN Display_Offset% = 235
  1445.   IF Display_Offset% < 0 THEN Display_Offset% = 0
  1446.  
  1447.  LOOP UNTIL ExitFlag%%
  1448.  _FONT FFX&, Layer(10) 'restore font to layer 10
  1449.  ClearLayer Layer(10) 'clean layer 10 up
  1450.  
  1451. SUB Sound_Controls
  1452.  _DEST Layer(10)
  1453.  LINE (610, 60)-STEP(20, 60), _RGBA32(192, 192, 192, 160), BF
  1454.  FOR i%% = 1 TO 40 STEP 5
  1455.   LINE (615, 70 + i%%)-STEP(10, 2), _RGBA32(224, 224, 224, 224), BF
  1456.  NEXT i%%
  1457.  _DEST Layer(1)
  1458.  
  1459.  DO
  1460.   C1~%% = 2.55 * G.BGMVol
  1461.   C2~%% = 2.55 * G.SFXVol
  1462.   _FONT FFX2&, Layer(1)
  1463.   _PUTIMAGE , Layer(11), Layer(1)
  1464.   LINE (60, 136)-STEP(309, 43), _RGB32(C1~%%, 255 - C1~%%, 0), BF
  1465.   LINE (60, 328)-STEP(309, 43), _RGB32(C2~%%, 255 - C2~%%, 0), BF
  1466.   _PRINTSTRING (64, 64), "Music", Layer(1)
  1467.   _PRINTSTRING (64, 256), "Sound FX", Layer(1)
  1468.   '-----------Background Music selection---------------
  1469.   IF G.MFIVerB OR G.MFIVerC THEN
  1470.    _PRINTSTRING (424, 128), "Bubblely", Layer(1)
  1471.    IF G.MFIVerC THEN
  1472.     _PRINTSTRING (424, 172), "Aggresive", Layer(1)
  1473.     _PRINTSTRING (424, 216), "Creepy", Layer(1)
  1474.     _PRINTSTRING (424, 260), "Up Beat", Layer(1)
  1475.    END IF
  1476.    COLOR _RGB32(160, 16, 16)
  1477.    SELECT CASE G.Current_BGM
  1478.     CASE 2
  1479.      _PRINTSTRING (424, 128), "Bubblely", Layer(1)
  1480.     CASE 3
  1481.      _PRINTSTRING (424, 172), "Aggresive", Layer(1)
  1482.     CASE 4
  1483.      _PRINTSTRING (424, 216), "Creepy", Layer(1)
  1484.     CASE 5
  1485.      _PRINTSTRING (424, 260), "Up Beat", Layer(1)
  1486.    END SELECT
  1487.    COLOR _RGB32(255)
  1488.   END IF
  1489.   '-----------------------------------------------------
  1490.   '-------------Hi_lite done button---------------------
  1491.   IF _MOUSEX > 500 AND _MOUSEX < 575 AND _MOUSEY > 48 AND _MOUSEY < 72 THEN
  1492.    COLOR _RGB32(212, 224, 16)
  1493.    _PRINTSTRING (500, 48), "Done", Layer(1)
  1494.    COLOR _RGB32(255)
  1495.   ELSE
  1496.    _PRINTSTRING (500, 48), "Done", Layer(1)
  1497.   END IF
  1498.   '-----------------------------------------------------
  1499.   _PUTIMAGE (60 + (3 * G.BGMVol), 128), Layer(10), Layer(1), (610, 60)-STEP(20, 60)
  1500.   _PUTIMAGE (60 + (3 * G.SFXVol), 320), Layer(10), Layer(1), (610, 60)-STEP(20, 60)
  1501.   _PUTIMAGE , Layer(1), Layer(0)
  1502.   _PRINTSTRING (0, 0), STR$(G.BGMVol) + STR$(G.SFXVol) + STR$(_MOUSEX) + STR$(_MOUSEY), Layer(0)
  1503.  
  1504.    IF _MOUSEX > 60 AND _MOUSEX < 360 THEN
  1505.     IF _MOUSEY > 128 AND _MOUSEY < 188 THEN 'music vol slider
  1506.      G.BGMVol = (_MOUSEX - 60) \ 3
  1507.      Sound_Adjust%% = TRUE
  1508.     END IF
  1509.     IF _MOUSEY > 320 AND _MOUSEY < 380 THEN 'sound fx vol slider
  1510.      G.SFXVol = (_MOUSEX - 60) \ 3
  1511.      Sound_Adjust%% = -2
  1512.     END IF
  1513.    END IF
  1514.    IF _MOUSEX > 500 AND _MOUSEX < 575 AND _MOUSEY > 48 AND _MOUSEY < 72 THEN 'done button
  1515.     ExitFlag%% = TRUE
  1516.    END IF
  1517.    IF _MOUSEX > 424 AND _MOUSEX < 560 AND (G.MFIVerB OR G.MFIVerC) THEN 'BGM selection
  1518.      CASE 128 TO 152 'Bubblely
  1519.       IF G.Current_BGM <> 2 THEN
  1520.        _SNDSTOP BGM(G.Current_BGM)
  1521.        G.Current_BGM = 2
  1522.        _SNDLOOP BGM(G.Current_BGM)
  1523.       END IF
  1524.      CASE 172 TO 196 'Agressive
  1525.       IF G.Current_BGM <> 3 AND G.MFIVerC THEN
  1526.        _SNDSTOP BGM(G.Current_BGM)
  1527.        G.Current_BGM = 3
  1528.        _SNDLOOP BGM(G.Current_BGM)
  1529.       END IF
  1530.      CASE 216 TO 240 'Creepy
  1531.       IF G.Current_BGM <> 4 AND G.MFIVerC THEN
  1532.        _SNDSTOP BGM(G.Current_BGM)
  1533.        G.Current_BGM = 4
  1534.        _SNDLOOP BGM(G.Current_BGM)
  1535.       END IF
  1536.      CASE 260 TO 284 'up beat
  1537.       IF G.Current_BGM <> 5 AND G.MFIVerC THEN
  1538.        _SNDSTOP BGM(G.Current_BGM)
  1539.        G.Current_BGM = 5
  1540.        _SNDLOOP BGM(G.Current_BGM)
  1541.       END IF
  1542.     END SELECT
  1543.    END IF
  1544.   END IF
  1545.  
  1546.   IF NOT _MOUSEBUTTON(1) AND Sound_Adjust%% THEN
  1547.    FOR i%% = 1 TO 5
  1548.     _SNDVOL BGM(i%%), G.BGMVol / 100
  1549.    NEXT i%%
  1550.    FOR i%% = 1 TO 5
  1551.     _SNDVOL SFX(i%%), G.SFXVol / 100
  1552.    NEXT i%%
  1553.    IF Sound_Adjust%% = -2 THEN _SNDPLAY SFX(5)
  1554.    Sound_Adjust%% = FALSE
  1555.   END IF
  1556.  
  1557.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  1558.   _LIMIT 30
  1559.   ClearLayer Layer(1)
  1560.  LOOP UNTIL ExitFlag%%
  1561.  
  1562.  FOR i%% = 1 TO 2
  1563.   _SNDVOL BGM(i%%), G.BGMVol / 100
  1564.  NEXT i%%
  1565.  
  1566.  FOR i%% = 1 TO 5
  1567.   _SNDVOL SFX(i%%), G.SFXVol / 100
  1568.  NEXT i%%
  1569.  
  1570.  _FONT 16, Layer(1)
  1571.  _DEST Layer(0)
  1572.  
  1573. FUNCTION LoadGFX& (Foff&, Size&)
  1574.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1575.  OPEN "temp.dat" FOR BINARY AS #3
  1576.  dat$ = SPACE$(Size&)
  1577.  GET #1, Foff&, dat$
  1578.  PUT #3, , dat$
  1579.  CLOSE #3
  1580.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  1581.  
  1582. FUNCTION LoadFFX& (Foff&, Size&, Fize%%)
  1583.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1584.  OPEN "temp.dat" FOR BINARY AS #3
  1585.  dat$ = SPACE$(Size&)
  1586.  GET #1, Foff&, dat$
  1587.  PUT #3, , dat$
  1588.  CLOSE #3
  1589.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, "monospace")
  1590.  
  1591. FUNCTION LoadSFX& (Foff&, Size&)
  1592.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1593.  OPEN "temp.dat" FOR BINARY AS #3
  1594.  dat$ = SPACE$(Size&)
  1595.  GET #1, Foff&, dat$
  1596.  PUT #3, , dat$
  1597.  CLOSE #3
  1598.  LoadSFX& = _SNDOPEN("temp.dat")
  1599.  
  1600. SUB LoadData (Foff&, Size&)
  1601.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1602.  OPEN "temp.dat" FOR BINARY AS #3
  1603.  dat$ = SPACE$(Size&)
  1604.  GET #1, Foff&, dat$
  1605.  PUT #3, , dat$
  1606.  CLOSE #3
  1607.  
  1608.  F1 = FREEFILE
  1609.  OPEN "temp.dat" FOR BINARY AS #F1
  1610.  CLOSE #F1
  1611.  
  1612. SUB DisplayError (ErrorMessage$)
  1613.  D = _DEST: Disp = _AUTODISPLAY
  1614.  BG = _COPYIMAGE(D)
  1615.  E$ = ErrorMessage$ 'back up the string so we don't corrupt it any way.
  1616.  
  1617.  LogInScreen = _NEWIMAGE(200, 240, 32)
  1618.  _DEST LogInScreen
  1619.  _KEYCLEAR 'clear the buffer before we start accepting stray input as being part of our login
  1620.  Xoffset = (_WIDTH(D) - _WIDTH(LogInScreen)) / 2
  1621.  Yoffset = (_HEIGHT(D) - _HEIGHT(LogInScreen)) / 2
  1622.  
  1623.  CLS , DarkGray
  1624.  LINE (3, 3)-(_WIDTH - 4, _HEIGHT - 4), LightGray, BF
  1625.  LINE (5, 5)-(_WIDTH - 6, 27), DarkGray, BF
  1626.  LINE (6, 6)-(_WIDTH - 7, 26), White, BF
  1627.  LINE (5, 30)-(_WIDTH - 6, 180), DarkGray, BF
  1628.  LINE (6, 31)-(_WIDTH - 7, 179), Black, BF
  1629.  LINE (30, 190)-(90, 225), DarkGray, BF
  1630.  LINE (33, 193)-(87, 222), Green, BF
  1631.  LINE (111, 190)-(170, 225), DarkGray, BF
  1632.  LINE (113, 193)-(167, 222), Red, BF
  1633.  
  1634.  ViewWidth = _WIDTH - 13 - _FONTWIDTH '(_WIDTH -7, -6 from above for our print box area)
  1635.  ViewHeight = 179 - 31 '(again, from the 179, 31 above)
  1636.  
  1637.  U = ViewHeight \ _FONTHEIGHT - 1
  1638.  IF U < 0 THEN U = 0 'we can't have negative lines to print to!
  1639.  DIM A(U) AS STRING 'the most lines we can print too
  1640.  
  1641.  COLOR Red, 0
  1642.  
  1643.  i = 0: OUT$ = ""
  1644.  FOR j = 1 TO LEN(E$)
  1645.   OUT$ = OUT$ + MID$(E$, j, 1)
  1646.   IF _PRINTWIDTH(OUT$) >= ViewWidth THEN 'we're printing off the screen
  1647.    j1 = 0 'back up to our next valid breakpoint.
  1648.    DO
  1649.     j = j - 1: j1 = j1 + 1
  1650.     SELECT CASE MID$(OUT$, LEN(OUT$) - j1, 1)
  1651.      CASE " ", ".", ";", "-", "!", "?": EXIT DO 'valid end of line breaks.
  1652.     END SELECT
  1653.    LOOP UNTIL j1 >= ViewWidth
  1654.    IF j1 >= ViewWidth THEN j = j + j1: j1 = 0
  1655.    'if we have such a long word that we can't break it
  1656.    '(perhaps like a html link), then print as much of it on one line as we can and carry on
  1657.    'with business like usual.
  1658.    A(i) = _TRIM$(LEFT$(OUT$, LEN(OUT$) - j1))
  1659.    OUT$ = ""
  1660.    i = i + 1
  1661.    IF i > U THEN EXIT FOR
  1662.   END IF
  1663.  IF i < U AND OUT$ <> "" THEN A(i) = OUT$
  1664.  
  1665.  p1 = (U - i) / 2
  1666.  FOR p = 0 TO U 'center the text as much as possible inside our error box
  1667.   _PRINTSTRING (100 - _PRINTWIDTH(A(p)) / 2, 33 + _FONTHEIGHT * (p + p1)), A(p)
  1668.  
  1669.  COLOR White, 0
  1670.  _PRINTSTRING (60 - _PRINTWIDTH("OK") / 2, 200), "OK"
  1671.  COLOR Black, 0
  1672.  _PRINTSTRING (140 - _PRINTWIDTH("QUIT") / 2, 200), "QUIT"
  1673.  DO
  1674.   count = (count + 1) MOD 2
  1675.   IF count MOD 2 = 0 THEN blink = NOT blink
  1676.   IF blink THEN COLOR Red, 0 ELSE COLOR Black, 0
  1677.   _PRINTSTRING (100 - _PRINTWIDTH("WARNING: ERROR") / 2, 10), "WARNING: ERROR"
  1678.   k = _KEYHIT
  1679.    CASE 13: EXIT DO 'Enter for "OK"
  1680.    CASE 27: SYSTEM 'ESC for "QUIT"
  1681.  
  1682.   mb = _MOUSEBUTTON(1): mx = _MOUSEX - Xoffset: my = _MOUSEY - Yoffset
  1683.   IF mb = -1 AND oldmouse = 0 THEN
  1684.    IF my >= 190 AND my <= 225 THEN
  1685.     IF mx >= 30 AND mx <= 90 THEN
  1686.      EXIT DO 'we clicked our "OK"
  1687.     ELSEIF mx >= 111 AND mx <= 170 THEN
  1688.      SYSTEM 'we clicked the "QUIT"
  1689.     END IF
  1690.    END IF
  1691.   END IF
  1692.   oldmouse = mb
  1693.   _PUTIMAGE (Xoffset, Yoffset), LogInScreen, D
  1694.   _LIMIT 10
  1695.  
  1696.  _DEST D
  1697.  COLOR DC, BGC
  1698.  _PUTIMAGE , BG, D 'restore the background
  1699.  
  1700.  
  1701. FUNCTION LogIn (Detail$)
  1702.  D = _DEST: Disp = _AUTODISPLAY
  1703.  BG = _COPYIMAGE(D)
  1704.  
  1705.  DO
  1706.   count = count + 1
  1707.   Client = _OPENCLIENT("TCP/IP:7993:172.93.60.23") 'attempt to join as client
  1708.   _LIMIT 10
  1709.  LOOP UNTIL Client <> 0 OR count > 100
  1710.  OK$ = Verify$
  1711.  IF LEFT$(OK$, 4) <> "[OK]" THEN
  1712.   Detail$ = "[ERROR]Host not responding."
  1713.   LogIn = 0
  1714.  
  1715.  LogInScreen = _NEWIMAGE(200, 240, 32)
  1716.  _DEST LogInScreen
  1717.  _KEYCLEAR 'clear the buffer before we start accepting stray input as being part of our login
  1718.  Xoffset = (_WIDTH(D) - _WIDTH(LogInScreen)) / 2
  1719.  Yoffset = (_HEIGHT(D) - _HEIGHT(LogInScreen)) / 2
  1720.  DO
  1721.   CLS , DarkGray
  1722.   LINE (3, 3)-(_WIDTH - 4, _HEIGHT - 4), LightGray, BF
  1723.   LINE (20, 40)-(180, 200), DarkGray, BF
  1724.   LINE (23, 68)-(177, 92), DarkGray, BF
  1725.   LINE (23, 128)-(172, 152), DarkGray, BF
  1726.   LINE (25, 70)-(175, 90), Black, BF
  1727.   LINE (25, 130)-(175, 150), Black, BF
  1728.   LINE (20, 210)-(100, 230), DarkGray, BF
  1729.   LINE (22, 212)-(98, 228), Green, BF
  1730.   LINE (101, 210)-(180, 230), DarkGray, BF
  1731.   LINE (103, 212)-(178, 228), Red, BF
  1732.  
  1733.   COLOR DarkBlue, 0
  1734.   _PRINTSTRING (100 - _PRINTWIDTH("CHECKERS") / 2, 15), "CHECKERS"
  1735.   _PRINTSTRING (100 - _PRINTWIDTH("User Name") / 2, 95), "User Name"
  1736.   _PRINTSTRING (100 - _PRINTWIDTH("Password") / 2, 155), "Password"
  1737.   COLOR Yellow
  1738.   _PRINTSTRING (60 - _PRINTWIDTH("LOG IN") / 2, 212), "LOG IN"
  1739.   _PRINTSTRING (141 - _PRINTWIDTH("REGISTER") / 2, 212), "REGISTER"
  1740.   count = (count + 1) MOD 30
  1741.   IF count MOD 15 = 0 THEN blink = NOT blink
  1742.   k = _KEYHIT
  1743.    CASE 9, 13 'tab or enter to toggle between the two fields.
  1744.     S = NOT S
  1745.    CASE 8 'backspace
  1746.     IF S THEN p$ = LEFT$(p$, LEN(p$) - 1) ELSE n$ = LEFT$(n$, LEN(n$) - 1)
  1747.    CASE 27 'Escape quits before we login
  1748.     Detail$ = "[ERROR]User Exited Log In Manually"
  1749.     GOTO function_exit
  1750.    CASE 32 TO 255 'visable characters
  1751.     IF S THEN p$ = p$ + CHR$(k) ELSE n$ = n$ + CHR$(k)
  1752.   COLOR White
  1753.   _PRINTSTRING (27, 72), RIGHT$(n$, 18): _PRINTSTRING (27, 132), RIGHT$(p$, 18)
  1754.   IF blink THEN
  1755.    IF S THEN l = _PRINTWIDTH(p$) ELSE l = _PRINTWIDTH(n$)
  1756.    _PRINTSTRING (27 + l, 72 - 60 * S), "_"
  1757.   END IF
  1758.   _PUTIMAGE (Xoffset, Yoffset), LogInScreen, D
  1759.  
  1760.   mb = _MOUSEBUTTON(1): mx = _MOUSEX - Xoffset: my = _MOUSEY - Yoffset
  1761.   IF mb = TRUE AND oldmouse = FALSE THEN
  1762.    IF my >= 210 AND my <= 230 THEN 'we're in the right X/Y position
  1763.     IF mx >= 20 AND mx <= 100 THEN
  1764.      'Run log in code
  1765.      _TITLE n$ + "," + p$
  1766.      Send Client, "[LOG IN]" + n$ + "," + p$ 'Register a new account
  1767.      OK$ = Verify$
  1768.      _TITLE OK$
  1769.      Detail$ = OK$
  1770.      IF LEFT$(OK$, 4) = "[OK]" THEN LogIn = -1: GOTO function_exit 'Success
  1771.      GOTO function_exit 'Failure
  1772.     END IF
  1773.     IF mx >= 101 AND mx <= 180 THEN
  1774.      'Run register code
  1775.      Send Client, "[REGISTER]" + n$ + "," + p$ 'Login from an existing account
  1776.      OK$ = Verify$
  1777.      Detail$ = OK$
  1778.      IF LEFT$(OK$, 4) = "[OK]" THEN LogIn = -1: GOTO function_exit
  1779.      GOTO function_exit
  1780.     ELSEIF my >= 70 AND my <= 90 AND mx >= 20 AND mx <= 180 THEN
  1781.      S = 0
  1782.     ELSEIF my >= 130 AND my <= 150 AND mx >= 20 AND mx <= 180 THEN
  1783.      S = -1
  1784.     END IF
  1785.    END IF
  1786.   END IF
  1787.   _LIMIT 30
  1788.   oldmouse = mb
  1789.  
  1790.  function_exit: 'Safely restore our settings.
  1791.  PlayerName$ = n$
  1792.  _DEST D
  1793.  COLOR DC, BGC
  1794.  _PUTIMAGE , BG, D 'restore the background
  1795.  
  1796. SUB Send (Who, What$)
  1797.  IF Client = 0 OR What$ = "" THEN EXIT SUB
  1798.  OUT$ = CHR$(2) 'an initial byte to say, "We're sending data."
  1799.  OUT$ = OUT$ + _MK$(_INTEGER64, LEN(What$) + 8) '8 bytes to store the length of the data we're sending.
  1800.  OUT$ = OUT$ + What$
  1801.  PUT Client, , OUT$
  1802.  
  1803. SUB Receive (Who, What$)
  1804.  IF Client = 0 THEN EXIT SUB
  1805.  IF In = "" THEN
  1806.   GET Client, , B
  1807.   B = ASC(In)
  1808.   r$ = r$ + In
  1809.   In = "" 'Is there a message waiting for us, after we processed one message?
  1810.  IF B = 2 THEN
  1811.   DO
  1812.    GET Client, , a$
  1813.    IF a$ <> "" THEN r$ = r$ + a$
  1814.    IF LEN(r$) > 8 THEN length = _CV(_INTEGER64, LEFT$(r$, 8))
  1815.    _LIMIT 10
  1816.   LOOP UNTIL LEN(r$) >= length AND length <> 0
  1817.   What$ = MID$(r$, 9) '8 bytes for the length
  1818.   In = MID$(r$, length + 1)
  1819.  
  1820. FUNCTION Verify$
  1821.  DO
  1822.   Receive Client, OK$ 'Get the confirmation message.
  1823.   _LIMIT 10 'Use low CPU while waiting.  No need for a high number here... Be patient and let the server have time to respond.  Checking 10 times a second is more than enough to get an [OK] or [ERROR] message.
  1824.  LOOP UNTIL OK$ <> ""
  1825.  Verify$ = OK$
  1826.  

Updated 12/3/2019: Playable!
Updated 12/14/2019: Intro with music, and 'Bubblely' BGM game music added, Local High Scores functionality added
Updated 12/21/2019: 3 more musics added, sound control menu added. C version MFI file added
Updated 12/22/2019: Online Score keeping activated.
* YahtzeeV1_2.MFI (Filesize: 1.92 MB, Downloads: 186)
* YahtzeeV1_2b.MFI (Filesize: 2.65 MB, Downloads: 188)
* YahtzeeV1_2c.MFI (Filesize: 5.13 MB, Downloads: 184)
« Last Edit: December 22, 2019, 03:07:48 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Yahtzee 64 (development)
« Reply #1 on: November 30, 2019, 02:28:45 pm »
Hi Cobalt,

Check line 530. I pointed out to Steve, in your other post, that that his FOR/NEXT loop needed to be 1 TO 6, not 1 to 5. He edited his reply, accordingly. As is, if you haven't modified his code since my post, your loop will only analyze die rolls of 1 to 5, and not include any sixes. You'll also have to increase dim count to: DIM COUNT(7)

To check this try...

Code: QB64: [Select]
  1. DIM Count(6)
  2. DieArray(1) = 6
  3. DieArray(2) = 6
  4. DieArray(3) = 6
  5. DieArray(4) = 6
  6. DieArray(5) = 6
  7.  
  8. FOR i% = 1 TO 5
  9.     Count(DieArray(i%)) = Count(DieArray(i%)) + 1
  10. NEXT i%
  11.  
  12. FOR i% = 1 TO 5
  13.     IF Count(i%) > 2 THEN
  14.         Result% = Result% + Count(i%)
  15.         IF Count(i%) > 3 THEN Result% = Result% + 2
  16.     END IF
  17.     PRINT i, Result%
  18.     'check for long straight------
  19.     IF Count(i%) = 1 THEN LS% = LS% + 1
  20.     IF Count(i% + 1) = 1 THEN LS2% = LS2% + 1
  21.     '-----------------------------
  22. NEXT i%
  23.  

See? The sixes were not counted. Now increase DIM by one, because you added  IF Count(i% + 1) = 1 THEN LS2% = LS2% + 1 to the mix, and make the FOR loop 1 TO 6...


Code: QB64: [Select]
  1. DIM Count(7)
  2. DieArray(1) = 6
  3. DieArray(2) = 6
  4. DieArray(3) = 6
  5. DieArray(4) = 6
  6. DieArray(5) = 6
  7.  
  8. FOR i% = 1 TO 5
  9.     Count(DieArray(i%)) = Count(DieArray(i%)) + 1
  10. NEXT i%
  11.  
  12. FOR i% = 1 TO 6
  13.     IF Count(i%) > 2 THEN
  14.         Result% = Result% + Count(i%)
  15.         IF Count(i%) > 3 THEN Result% = Result% + 2
  16.     END IF
  17.     PRINT i, Result%
  18.     'check for long straight------
  19.     IF Count(i%) = 1 THEN LS% = LS% + 1
  20.     IF Count(i% + 1) = 1 THEN LS2% = LS2% + 1
  21.     '-----------------------------
  22. NEXT i%
  23.  

See? it now includes a six roll. Please note I took out the double % and got rid of .value, to make it easy code for me to use, so don't copy paste this code, edit your own as needed.

The game looks great. I look forward to giving it a roll, later today.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Yahtzee 64 (development)
« Reply #2 on: November 30, 2019, 03:10:40 pm »
Wrong loop, Pete.   You wanted to increase this one instead:

Code: [Select]
FOR i% = 1 TO 5
    Count(DieArray(i%)) = Count(DieArray(i%)) + 1
NEXT i%

Make that 5 a 6 and all is good.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Yahtzee 64 (development)
« Reply #3 on: November 30, 2019, 05:16:54 pm »
I don't think so, Tim...

So, let's back up the truck, and try this...

Code: QB64: [Select]
  1. LOCATE 25, 1: PRINT "Press Enter to continue or Esc to quit...";
  2. LOCATE 1, 1
  3.     REDIM Count(7)
  4.     ' Roll 5 6-sided dice.
  5.     FOR i% = 1 TO 5
  6.         DieArray(i%) = INT(RND * 6 + 1)
  7.         PRINT DieArray(i%);
  8.     NEXT
  9.  
  10.     FOR i% = 1 TO 5
  11.         Count(DieArray(i%)) = Count(DieArray(i%)) + 1
  12.     NEXT i%
  13.  
  14.  ' SIX is required in the loop below to count the instances of die showing the number 6. Each Count() variable has recorded the number of instances of each die value from 1 to 6.
  15.  
  16.     FOR i% = 1 TO 6
  17.         IF Count(i%) > 2 THEN
  18.             Result% = Result% + Count(i%)
  19.             IF Count(i%) > 3 THEN Result% = Result% + 2
  20.             PRINT "Result ="; Result%,
  21.         END IF
  22.  
  23.         '-----------------------------
  24.     NEXT i%
  25.  
  26.     IF Result% = 3 THEN PRINT "Three of Kind";
  27.     IF Result% = 5 THEN PRINT "Full House";
  28.     IF Result% = 6 THEN PRINT "Four of Kind";
  29.     IF Result% = 7 THEN PRINT "Yahtzee";
  30.  
  31.     DO
  32.         _LIMIT 30
  33.         b$ = INKEY$
  34.         IF LEN(b$) THEN
  35.             IF b$ = CHR$(13) THEN EXIT DO
  36.             IF b$ = CHR$(27) THEN SYSTEM
  37.         END IF
  38.     LOOP
  39.     Result% = 0
  40.     PRINT
  41.  

Do 6 turns and you should get these results:

 
Yahtzee-test.jpg


If you don't go through 6 loops of the RESULTS FOR/NEXT, you cannot get the number of 6 instances from each turn. Try it this way, then switch it around so the line you posted is 6 and mine is 5 and you will not get accurate results when the three sixes appear in the 4th turn.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Yahtzee 64 (Beta)
« Reply #4 on: December 03, 2019, 10:01:20 am »
It's PLAYABLE!!! now. Make your rolls, save the dice you wish to keep between rolls, and make up to 3 rolls trying to get that perfect Yahtzee!. No sounds yet I'm afraid, but do not be afraid to make your own sounds(go ahead, do it, no body is watching!). My best score by chance '301'. Standard rules set at the moment, 2 Yahtzees allowed, +50 for first one +100 for second. though I have yet to pull this off so I do not know if the code works correctly when scoring such an event.

Working on the menu now, hopefully be able to have it save(and even play across the net) with Steve's server.
GoodGame.jpg
* GoodGame.jpg (Filesize: 137.54 KB, Dimensions: 644x487, Views: 196)
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Yahtzee 64 (Beta release 2)
« Reply #5 on: December 14, 2019, 11:30:19 pm »
Next release! once the sound menu is done, and sounds added will start implementing on-line score keeping thanks to, and with, Steve's server!
Granted after becoming radioactive I only have a half-life!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Yahtzee 64 (Beta release 2)
« Reply #6 on: December 17, 2019, 06:07:39 am »
Just downloaded Yahtzee (and the YahtzeeV1_2.MFI and YahtzeeV1_2b.MFI file).

Ran it and received the following error message...

 
Screenshot at 2019-12-17 22-01-22.png


Running QB64 v1.3 on 64 bit Linux Mint 19.2
Logic is the beginning of wisdom.

FellippeHeitor

  • Guest
Re: Yahtzee 64 (Beta release 2)
« Reply #7 on: December 17, 2019, 06:35:35 am »
_SETBIT is only available in the development build of QB64 for now. Intended to be released with upcoming v.1.4

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Yahtzee 64 (Beta release 2)
« Reply #8 on: December 17, 2019, 07:36:26 am »
Ok. Good to know. Thank you.
Logic is the beginning of wisdom.

Offline AndyA

  • Newbie
  • Posts: 73
    • View Profile
Re: Yahtzee 64 (Beta release 2)
« Reply #9 on: December 17, 2019, 09:30:28 pm »
johnno56,

If you don't want to download the latest dev build you could use these home rolled functions.

Code: [Select]
_TITLE "Bit Changing Functions"


'Populate powers of 2 array
DIM SHARED pow2~&(31)
FOR i% = 0 TO 31: pow2~&(i%) = 2 ^ i%: NEXT

PRINT "Decimal number to binary number"
PRINT "123456789 = "
PRINT dec2bin$(123456789)
PRINT
PRINT "Set bit 5"
PRINT dec2bin$(setBit~&(123456789, 5))
PRINT setBit~&(123456789, 5)
SLEEP
SYSTEM



FUNCTION setBit~& (iVal~&, bitPos%)
    setBit~& = iVal~& OR pow2~&(bitPos%)
END FUNCTION

FUNCTION clearBit~& (iVal~&, bitPos%)
    clearBit~& = iVal~& AND (iVal~& XOR pow2~&(bitPos%))
END FUNCTION

FUNCTION toggleBit~& (iVal~&, bitPos%)
    toggleBit~& = iVal~& XOR pow2~&(bitPos%)
END FUNCTION

FUNCTION readBit~& (iVal~&, bitPos%)
    readBit~& = iVal~& AND pow2~&(bitPos%)
END FUNCTION

FUNCTION dec2bin$ (iVal~&)
    FOR i% = 31 TO 0 STEP -1
        b$ = b$ + _TRIM$(STR$(ABS((iVal~& AND pow2~&(i%)) > 0)))
    NEXT
    dec2bin$ = b$
END FUNCTION

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Yahtzee 64!!!
« Reply #10 on: December 22, 2019, 02:37:11 pm »
Ready to GO! you will need the latest development build.  Lets see who can get the highest online Score! To be able to add your scores to the online score list you must first view the online scores section. At the moment this connects you to the server.
Granted after becoming radioactive I only have a half-life!