/* Yahtze+ by Dave Anderson 12-20-2007 */ Gosub ,InitVariables Gui, Color, 00CCCC Gui,Font,bold, Gui, Add, Picture, x26 y446 w150 h150 vDp1, %D1% ; Dice Dp5help:=Dp4help:=Dp3help:=Dp2help:=Dp1help:=" These are the dice you are rolling" Gui, Add, Picture, x+0 w150 h150 vDp2, %D2% Gui, Add, Picture, x+0 w150 h150 vDp3, %D3% Gui, Add, Picture, x+0 w150 h150 vDp4, %D4% Gui, Add, Picture, x+0 w150 h150 vDp5, %D5% Gui, Add, Text, x26 y26 w100 h30 +Right vTo1, Total of Ones To6help:=To5help:=To4help:=To3help:=To2help:=To1help:="Way this scoring button is scored" Gui, Add, Text, x26 y+0 w100 h30 +Right vTo2, Total of Twos Gui, Add, Text, x26 y+0 w100 h30 +Right vTo3, Total of Threes Gui, Add, Text, x26 y+0 w100 h30 +Right vTo4, Total of Fours Gui, Add, Text, x26 y+0 w100 h30 +Right vTo5, Total of Fives Gui, Add, Text, x26 y+0 w100 h30 +Right vTo6, Total of Sixs Gui, Add, Text, x26 y+0 w100 h30 +Right vTo7, Bonus Points To7help=Left column and Yahtze Bonus scored here Gui, Add, Text, x26 y236 w100 h30 +Right c000000 BackgroundTrans vLCTT1, Left Column Total Gui, Add, Text, xp+2 yp+2 w100 h30 +Right cFFFFFF BackgroundTrans vLCTT2, Left Column Total LC8help:=LCTT1help:=LCTT2help:="Left Column buttons Total" Gui, Add, Text, x466 y26 w100 h30 +Right vRt1, Total of Dice Rt7help:=Rt6help:=Rt5help:=Rt4help:=Rt3help:=Rt2help:=Rt1help:=To1help Gui, Add, Text, x466 y+0 w100 h30 +Right vRt2, Total of Dice Gui, Add, Text, x466 y+0 w100 h30 +Right vRt3, 25 pts Gui, Add, Text, x466 y+0 w100 h30 +Right vRt4, 30 pts Gui, Add, Text, x466 y+0 w100 h30 +Right vRt5, 40 pts Gui, Add, Text, x466 y+0 w100 h30 +Right vRt6, 50 pts Gui, Add, Text, x466 y+0 w100 h30 +Right vRt7, Total of Dice Gui, Add, Text, x456 y236 w115 h30 +Right c000000 BackgroundTrans vRCTT1, Right Column Total Gui, Add, Text, xp+2 yp+2 w115 h30 +Right cFFFFFF BackgroundTrans vRCTT, Right Column Total RC8help:=RCTT1help:=RCTThelp:="Right column buttons total" Gui, Add, Text, x276 y206 w100 h30 +Right c000000 BackgroundTrans vRound1, Round Gui, Add, Text, xp+2 yp+2 w100 h30 +Right cFFFFFF BackgroundTrans vRound2, Round GLhelp:=Round1help:=Round2help:= "Round Being played" Gui, Add, Text, x386 y206 w50 h30 +Right vGL, 0 Gui, Add, Text, x276 y236 w100 h30 +Right c000000 BackgroundTrans vTTS1, Total Score Gui, Add, Text, xp+2 yp+2 w100 h30 +Right cFFFFFF BackgroundTrans vTTS2, Total Score Totalhelp:=TTS1help:=TTS2help:= "Total score of both columns for this player" Gui,Font,w400, Gui, Add, Button, x136 y16 w60 h30 gLC1 vLC1, Ones ; LC=Left Column buttons LC1help = click here to score your ones Gui, Add, Button, x136 y+0 w60 h30 gLC2 vLC2, Twos LC2help = click here to score your twos Gui, Add, Button, x136 y+0 w60 h30 gLC3 vLC3, Threes LC3help = click here to score your threes Gui, Add, Button, x136 y+0 w60 h30 gLC4 vLC4, Fours LC4help = click here to score your fours Gui, Add, Button, x136 y+0 w60 h30 gLC5 vLC5, Fives LC5help = click here to score your fives Gui, Add, Button, x136 y+0 w60 h30 gLC6 vLC6, Sixes LC6help = click here to score your sixes Gui, Add, Button, x136 y+0 w60 h30 vLC7, Bonus LC7help = Only displays Bonus's Gui,Font,bold, Gui, Add, Text, x136 y236 w50 h30 +Right vLC8, 0 ; Left column Total Gui,Font,w400, Gui, Add, Button, x576 y16 w70 h30 gRC1 vRC1, 3 of a Kind ; RC=Right Column Items RC1help = click here to score your 3 of a kind Gui, Add, Button, x576 y+0 w70 h30 gRC2 vRC2, 4 of a Kind RC2help = click here to score your 4 of a kind Gui, Add, Button, x576 y+0 w70 h30 gRC3 vRC3, Full House RC3help = click here to score your full house Gui, Add, Button, x576 y+0 w70 h30 gRC4 vRC4, Sm Straight RC4help = click here to score your sm straight Gui, Add, Button, x576 y+0 w70 h30 gRC5 vRC5, Lg Straight RC5help = click here to score your lg straight Gui, Add, Button, x576 y+0 w70 h30 gRC6 vRC6, Yahtze RC6help = click here to score your Yahtze Gui, Add, Button, x576 y+0 w70 h30 gRC7 vRC7, Chance RC7help = click here to score your chance Gui,Font,bold, Gui, Add, Text, x576 y236 w50 h30 +Right vRC8, 0 ; Right Column Total Gui, Add, Text, x386 y236 w50 h30 +Right vTotal, 0 ; total score Gui,Font,w400, Gui, Add, Button, x76 y276 w100 h30 gVPSB1 vPSB1, Player 1 ;Player Score Buttons c2s= click to start your turn and the first roll of the dice PSB1help = Player 1 %c2s% Gui, Add, Button, x+10 y276 w100 h30 gVPSB2 vPSB2, Player 2 PSB2help = Player 2 %c2s% Gui, Add, Button, x+10 y276 w100 h30 gVPSB3 vPSB3, Player 3 PSB3help = Player 3 %c2s% Gui, Add, Button, x+10 y276 w100 h30 gVPSB4 vPSB4, Player 4 PSB4help = Player 4 %c2s% Gui, Add, Button, x+10 y276 w100 h30 gVPSB5 vPSB5, Player 5 PSB5help = Player 5 %c2s% Gui, Add, Button, x+10 y276 w100 h30 gVPSB6 vPSB6, Player 6 PSB6help = Player 6 %c2s% Gui, Add, Edit, x76 y306 w100 h20 vPNB1 , Computer 1 ;Player Names PNB1help:=PNB2help:=PNB3help:=PNB4help:=PNB5help:=PNB6help:="Type in your Name Here" Gui, Add, Edit, x+10 y306 w100 h20 vPNB2, Computer 2 Gui, Add, Edit, x+10 y306 w100 h20 vPNB3, Computer 3 Gui, Add, Edit, x+10 y306 w100 h20 vPNB4, Computer 4 Gui, Add, Edit, x+10 y306 w100 h20 vPNB5, Computer 5 Gui, Add, Edit, x+10 y306 w100 h20 vPNB6, Computer 6 Gui, Add, Button, x50 y406 w100 h30 gHoldb1 vHold1, Roll ; hold buttons ========= Hold5help:=Hold4help:=Hold3help:=Hold2help:=Hold1help:=" Click to HOLD or Roll this die" Gui, Add, Button, x+50 y406 w100 h30 gHoldb2 vHold2, Roll Gui, Add, Button, x+50 y406 w100 h30 gHoldb3 vHold3, Roll Gui, Add, Button, x+50 y406 w100 h30 gHoldb4 vHold4, Roll Gui, Add, Button, x+50 y406 w100 h30 gHoldb5 vHold5, Roll Gui, Add, Button, x350 y336 w100 h60 gRollDice2 vRollDice, Roll Dice RollDicehelp = click to roll the dice not being held Gui,Font,bold, Gui, Add, Text, x+50 y346 w100 R1.5 +Center c000000 BackgroundTrans vRRM1, Rolls Remaining Gui, Add, Text, xp+2 yp+2 w100 R1.5 +Center cFFFFFF BackgroundTrans vRRM2, Rolls Remaining Gui, Add, Text, xp-2 y370 w100 h20 +Center vRRM, 0 RRM1help:=RRM2help:=RRMhelp:="Shows the number of rolls of dice remaining" Gui,Font,w400, Gui, Add, Picture, x216 y16 w30 h30 vDSP1, %D1% ;ones Gui, Add, Picture, xp+0 y+0 w30 h30 vDSP2 , %D2% ;twos Gui, Add, Picture, xp+0 y+0 w30 h30 vDSP3 , %D3% ;threes Gui, Add, Picture, xp+0 y+0 w30 h30 vDSP4 , %D4% ;fours Gui, Add, Picture, xp+0 y+0 w30 h30 vDSP5 , %D5% ;fives Gui, Add, Picture, xp+0 y+0 w30 h30 vDSP6 , %D6% ;sixes Gui, Add, Picture, x650 y16 w30 h30 vDSP7, %D1% ;3 of a kind Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP8, %D1% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP9, %D1% Gui, Add, Picture, x650 y46 w30 h30 vDSP10 , %D2% ;4 of a kind Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP11 , %D2% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP12 , %D2% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP13 , %D2% Gui, Add, Picture, x650 y76 w30 h30 vDSP14 , %D2% ;full house Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP15 , %D2% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP16 , %D3% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP17 , %D3% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP18 , %D3% Gui, Add, Picture, x650 y106 w30 h30 vDSP22 , %D3% ; sm straight Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP21 , %D4% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP20 , %D5% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP19 , %D6% Gui, Add, Picture, x650 y136 w30 h30 vDSP27 , %D2% ;lg straight Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP26 , %D3% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP25 , %D4% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP24 , %D5% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP23 , %D6% Gui, Add, Picture, x650 y166 w30 h30 vDSP28 , %D6% ;yahtze Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP29 , %D6% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP30 , %D6% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP31 , %D6% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP32 , %D6% Gui, Add, Picture, x650 y196 w30 h30 vDSP33, %D1% ;chance Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP34, %D1% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP35, %D3% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP36, %D5% Gui, Add, Picture, x+0 yp+0 w30 h30 vDSP37, %D6% DSP1help:="Sample of dice needed for this score" loop ,37 { DSP%A_Index%help:=DSP1help } Gui, Add, Button, x346 y16 w100 h30 gRules vRules, Rules Ruleshelp = Click here to get the Yahtze rules for this game Gui, Add, Button, x346 y+0 w100 h30 gDirections vDir, Directions Dirhelp = Click here for directions on how to play Gui, Add, Button, x346 y+30 w100 h30 gNewGame vNewG, New Game NewGhelp = Click here to stop the current game and start a new one Gui, Add, Button, x346 y+0 w100 h30 gStartGame vStartGame, Start Game StartGamehelp = Click here to start the game Gui, Add, DropDownList, x346 y+1 w100 R6 gGetPlayers vNP , 1||2|3|4|5|6 ;number of players NPhelp = select the number of players here Gui,Font,bold, Gui, Add, Text, x286 y606 w180 h30 +Center vHint, Hint ; maybe remove Hinthelp:="Shows a Possible use of the dice rolled and the points total" Gui,Font,w400, Gui, Add, Button, x696 y606 w100 h30 gGuiClose vQuit, Quit Quithelp = Click here to quit the game and close the window Gui, Show, +Theme xCenter yCenter h646 w805, Yahtze+ Return GuiClose: ExitApp InitVariables: ;=========================== initialize variables ========================== Random, NewSeed , 1, 1024 ; set random seed to current clock tic Random, , NewSeed Hand=Chance PL:=NP:=1 NC:=PRD:=DR:=GL:=PS:=0 Yahtze:=Score:=0 D1:=".\Dice\1.png" D2:=".\Dice\2.png" D3:=".\Dice\3.png" D4:=".\Dice\4.png" D5:=".\Dice\5.png" D6:=".\Dice\6.png" Die6:=Die5:=Die4:=Die3:=Die2:=Die1:=0 ;dice Hold1:=Hold2:=Hold3:=Hold4:=Hold5:=1 ;hold button NOT Held LC1:=LC2:=LC3:=LC4:=LC5:=LC6:=LC7:=LC8:=0 RC1:=RC2:=RC3:=RC4:=RC5:=RC6:=RC7:=RC8:=0 PSB1:=PSB2:=PSB3:=PSB4:=PSB5:=PSB6=0 ; scores set 0 Total:=0 msg1=Ones msg2=Twos msg3=Threes msg4=Fours msg5=Fives msg6=Sixes msg7=Bonus msg8=3 of a Kind msg9=4 of a Kind msg10=Full House msg11=Sm Straight msg12=Lg Straight msg13=Yahtze msg14=Chance Loop , 6 { playerSC%A_Index% = 0,0,0,0,0,0,0,0,0,0,0,0,0,0 playerSD%A_Index% = 0,0,0,0,0,0,0,0,0,0,0,0,0,0 } return RollDice: if (PRD=0) return Hold1:=Hold2:=Hold3:=Hold4:=Hold5:=1 Die1:=Die2:=Die3:=Die4:=Die5:=0 Dice= ;msgbox ,A.- %Dice% - %Die1%- %Die2%- %Die3%- %Die4%- %Die5% RollDice2: if (PRD=0) ; player select his button return If (DR=3) ; only 3 rolls return If (GL=14) ; end game is 14 Gosub ,endgame DR+=1 RRM:=3-DR GuiControl,, RRM, %RRM% Loop , 6 ; randomize dice { if (Hold%A_Index% =1) { Random, z , 1, 6 Die%A_Index%:=Mod(z, 6)+1 } } Dice:=Die1 . "," . Die2 . "," . Die3 . "," . Die4 . "," . Die5 ;msgbox ,B.- %Dice% - %Hold1%- %Hold2%- %Hold3%- %Hold4%- %Hold5% Dp1:=D%Die1% Dp2:=D%Die2% Dp3:=D%Die3% Dp4:=D%Die4% Dp5:=D%Die5% SoundPlay, sound\rolldice.wav, wait GuiControl,, DP1, %Dp1% GuiControl,, DP2, %Dp2% GuiControl,, DP3, %Dp3% GuiControl,, DP4, %Dp4% GuiControl,, DP5, %Dp5% Gosub ,SortDice return SortDice: ; sort and prepare for counting and hints Hand=%msg14% DiceS:=Dice Sort DiceS, N D, StringMid, DieS1, DiceS, 1 , 1 , StringMid, DieS2, DiceS, 3 , 1 , StringMid, DieS3, DiceS, 5 , 1 , StringMid, DieS4, DiceS, 7 , 1 , StringMid, DieS5, DiceS, 9 , 1 , DiceCount:=DieS1+DieS2+DieS3+DieS4+DieS5 if (DieS1=DieS2 AND DieS1=DieS3) ; first three of kind FH? { Hand:=(RD1=0) ? msg8 : Hand if (DieS4=DieS5) ; fullhouse Hand:=(RD3=0) ? msg10 : Hand } Hand:=(DieS2=DieS3 AND DieS2=DieS4 AND RD1=0) ? msg8 : Hand ;Mid three of kind NP full house if (DieS3=DieS4 AND DieS3=DieS5) ; Last 3 of Kind FH? { Hand:=(RD1=0) ? msg8 : Hand if (DieS1=DieS2) ;fullhouse Hand:=(RD3=0) ? msg10 : Hand } Hand:=((DieS1=DieS2 AND DieS1=DieS3 AND DieS1=DieS4 AND RD2=0) OR (DieS2=DieS3 AND DieS2=DieS4 AND DieS2=DieS5 AND RD2=0)) ? msg9 : Hand ; 4 0f kind Hand:=((DieS1+1=DieS2 AND DieS2+1=DieS3 AND DieS3+1=DieS4 AND RD4=0) OR (DieS2+1=DieS3 AND DieS3+1=DieS4 AND DieS4+1=DieS5 AND RD4=0)) ? msg11 : Hand ; sm straight Hand:=((DieS1+1=DieS2 AND DieS2=DieS3 AND DieS3+1=DieS4 AND DieS4+1=DieS5 AND RD4=0) OR (DieS1+1=DieS2 AND DieS2+1=DieS3 AND DieS3=DieS4 AND DieS4+1=DieS5 AND RD4=0)) ? msg11 : Hand ;Sm Straight Hand:=(DieS1+1=DieS2 AND DieS2+1=DieS3 AND DieS3+1=DieS4 AND DieS4+1=DieS5 AND RD5=0) ? msg12 : Hand ; lg straight Hand:=(DieS1=DieS2 AND DieS2=DieS3 AND DieS3=DieS4 AND DieS4=DieS5) ? msg13 : Hand ; yahtze if (hand="Chance") { z6=6 z5=5 z4=4 z3=3 z2=2 z1=1 one:=two:=thr:=fou:=fiv:=six:=0 Loop ,5 { six:= (DieS%A_Index%=z6) ? six+=1 : six fiv:= (DieS%A_Index%=z5) ? fiv+=1 : fiv fou:= (DieS%A_Index%=z4) ? fou+=1 : fou thr:= (DieS%A_Index%=z3) ? thr+=1 : thr two:= (DieS%A_Index%=z2) ? two+=1 : two one:= (DieS%A_Index%=z1) ? one+=1 : one } if (RD7=1) hand:="." hand.= (six>=2 AND LD6=0) ? msg6 : "." hand.= (fiv>=2 AND LD5=0) ? msg5 : "." hand.= (fou>=2 AND LD4=0) ? msg4 : "." hand.= (thr>=2 AND LD3=0) ? msg3 : "." hand.= (two>=2 AND LD2=0) ? msg2 : "." hand.= (one>=2 AND LD1=0) ? msg1 : "." } GuiControl,, Hint, %Hand% %DiceCount% if (hand=msg13) SoundPlay, sound\sweet.wav return ; hold dice buttons Holdb1: h=1 Goto ,repeat3 Holdb2: h=2 Goto ,repeat3 Holdb3: h=3 Goto ,repeat3 Holdb4: h=4 Goto ,repeat3 Holdb5: h=5 Goto ,repeat3 repeat3: Hold%h%:=(Hold%h%=0) ? 1 : 0 if (Hold%h%=0) GuiControl,, Hold%h%, HOLD if (Hold%h%=1) GuiControl,, Hold%h%, Roll return GetPlayers: PS:=1 ; indictes players have been setup z:=0 Gui, Submit, NoHide PL:=NP GuiControl,,PSB1,Score Loop, %np% { z+=1 GuiControl,,PSB%z%,%Score% } if (NP<6) { x:=14+np lv:=6-np Loop, %lv% { z+=1 x+=1 Control, Hide ,, Button%x%,Yahtze+ Control, Hide ,, Edit%z%,Yahtze+ } } return ; player Buttons VPSB1: PLI2=1 Goto ,repeat2 VPSB2: PLI2=2 Goto ,repeat2 VPSB3: PLI2=3 Goto ,repeat2 VPSB4: PLI2=4 Goto ,repeat2 VPSB5: PLI2=5 Goto ,repeat2 VPSB6: PLI2=6 Goto ,repeat2 repeat2: if (PLI<>PLI2) ; if not this player return return if (PRD=1) return PRD=1 Gosub, RollDice return NewGame: ; set new game variables LC1:=LC2:=LC3:=LC4:=LC5:=LC6:=LC7:=LC8:=0 ; lt column set 0 RC1:=RC2:=RC3:=RC4:=RC5:=RC6:=RC7:=RC8:=0 ; rt column set 0 PSB1:=PSB2:=PSB3:=PSB4:=PSB5:=PSB6=0 ; scores set 0 Yahtze:=x:=y:=GL:=PS:=0 ; yahtze, game turn, set 0 NC:=0 z=14 Loop, 6 { z+=1 y+=1 x+=1 Control, Show ,, Button%z%,Yahtze+ GuiControl,,PSB%y%,Player%y% Gui, Font,cBlack w400, GuiControl, Font, Edit%y% Control, Show ,, Edit%y%,Yahtze+ GuiControl,,PNB%y%,Computer %y% GuiControl,, Hold%x%, Hold playerSC%x% = 0,0,0,0,0,0,0,0,0,0,0,0,0,0 playerSD%x% = 0,0,0,0,0,0,0,0,0,0,0,0,0,0 } GuiControl, Choose, NP,1 return StartGame: PLI:=1 ; start with player 1 GL+=1 ; start with turn 1 PSB1:=PSB2:=PSB3:=PSB4:=PSB5:=PSB6=0 ; scores set 0 Loop, NP { GuiControl,,PSB%A_Index%,PSB%A_Index% } NextPlayer: ; if (NP>1) Sleep, 2500 if (GL=14) goto , endgame Gui, Submit, NoHide if (PS=0) Gosub, GetPlayers Gui, Font,cRed Bold, GuiControl, Font, Edit%PLI% text:=% PNB%PLI% . " Roll" GuiControl,,Edit%PLI%, %text% Gosub , UpdateScores Loop, 5 { GuiControl,, Hold%A_Index%, Roll Hold%A_Index%=1 } PRD=0 DieS1:=DieS2:=DieS3:=DieS4:=DieS5=0 return ; LC Buttons LC6: NC+=1 LC5: NC+=1 LC4: NC+=1 LC3: NC+=1 LC2: NC+=1 LC1: NC+=1 LCC: if (PRD=0) return Gosub ,repeat1b ; pts for extra yahtze Gosub ,repeat1 NC=0 return ; RC Buttons RC1: ; 3 of a kind ================== if (PRD=0) return RC1:= (hand="3 of a Kind" OR hand="4 of a Kind" OR hand="Full House" OR hand="Yahtze") ? DiceCount : 0 ; pts for extra yahtze Gosub ,repeat1b GuiControl,,RC1, %RC1% RD1:=1 Gosub repeat1a return RC2: ; 4 of a kind ==================== if (PRD=0) return RC2:= (hand="4 of a Kind" OR hand="Yahtze") ? DiceCount : 0 ; pts for extra yahtze Gosub ,repeat1b GuiControl,,RC2, %RC2% RD2:=1 Gosub repeat1a return RC3: ; FullHouse ====================== if (PRD=0) return RC3:= (hand="Full House" OR hand="Yahtze") ? 25 : 0 ; pts for extra yahtze Gosub ,repeat1b GuiControl,,RC3, %RC3% RD3:=1 Gosub ,repeat1a return RC4: ; Sm Straight ==================== if (PRD=0) return RC4:= (hand="Sm Straight" OR hand="Lg Straight") ? 30 : 0 ; no pts for extra yahtze Gosub ,repeat1b GuiControl,,RC4, %RC4% RD4:=1 Gosub ,repeat1a return RC5: ; Lg Straight ==================== if (PRD=0) return RC5:= (hand="Lg Straight") ? 40 : 0 ; no pts for extra yahtze Gosub ,repeat1b GuiControl,,RC5, %RC5% RD5:=1 Gosub ,repeat1a return RC6: ; Yahtze ==================== if (PRD=0) return RC6:=(hand="Yahtze" and Yahtze=0) ? 50 : 0 Yahtze:=(hand="Yahtze" and Yahtze=0) ? 1 : 0 GuiControl,,RC6, %RC6% RD6:=1 Gosub ,repeat1a return RC7: ; Chance ======================= if (PRD=0) return Gosub ,repeat1b RC7:=DiceCount GuiControl,,RC7, %RC7% RD7:=1 Gosub ,repeat1a return repeat1: z:=LC%NC%:=CountDie(NC) LD%NC%:=NC GuiControl,,LC%NC%, %z% repeat1a: Gosub ,UpdateControls Gosub ,PlayerLoop Gosub ,NextPlayer return repeat1b: ; if already have yahtze, multiples get 100 pt bonus if (hand="Yahtze" AND Yahtze>0) { LC7+=100 GuiControl,,LC7, %LC7% } return PlayerLoop: playerSC%PLI%:=LC1 . "," . LC2 . "," . LC3 . "," . LC4 . "," . LC5 . "," . LC6 . "," . LC7 . "," . RC1 . "," . RC2 . "," . RC3 . "," . RC4 . "," . RC5 . "," . RC6 . "," . RC7 playerSD%PLI%:=LD1 . "," . LD2 . "," . LD3 . "," . LD4 . "," . LD5 . "," . LD6 . "," . LD7 . "," . RD1 . "," . RD2 . "," . RD3 . "," . RD4 . "," . RD5 . "," . RD6 . "," . RD7 Gui, Font,cBlack w400, GuiControl, Font, Edit%PLI% text:=% PNB%PLI% GuiControl,,Edit%PLI%, %text% PLI+=1 GL:=(PLI>NP) ? GL+1 : GL PLI:=(PLI>NP) ? 1 : PLI DR:=0 Hand=Chance GuiControl,, Hint, %Hand% %DiceCount% return /* LC RC 1 2 3 4 5 6 7 8 9 10 11 12 13 14 playerSC1:=00,00,00,00,00,00,00,00,00,00,00,00,00,00 scores playerSD1:=00,00,00,00,00,00,00,00,00,00,00,00,00,00 disable=1 */ UpdateScores: Loop, parse, PlayerSC%PLI%, `, { value:=(%A_LoopField%=0) ? msg%A_Index% : A_LoopField ; control text value2:=(%A_LoopField%=0) ? 0 : A_LoopField ; control value ;value3:=(%A_LoopField%=0) ? "Enable" : "Disable" ; show or hide button if (A_Index<8) { GuiControl,,LC%A_Index%, %value% LC%A_Index%=%value2% ;Control, %value3% ,, Button%A_Index%,Yahtze+ Yahtze:= (A_Index=7 AND A_LoopField=>100) ? 1 : 0 } if (A_Index>7) { w:=A_Index-7 GuiControl,,RC%w%, %value% RC%w%=%value2% ;Control, %value3% ,, Button%A_Index%,Yahtze+ } } Loop, parse, PlayerSD%PLI%, `, { value3:=(%A_LoopField%=0) ? "Enable" : "Disable" ; show or hide button if (A_Index<8) Control, %value3% ,, Button%A_Index%,Yahtze+ LD%A_Index%=%A_LoopField% if (A_Index>7) { w:=A_Index-7 RD%w%=%A_LoopField% Control, %value3% ,, Button%A_Index%,Yahtze+ if (w=6) { Yahtze:= (PlayerSD%A_LoopField%<>0) ? A_LoopField : 0 ;MsgBox, Yahtze= %Yahtze% w=%w% } } } UpdateControls: if ((LC1+LC2+LC3+LC4+LC5+LC6>62) AND (LC7=0)) ; add 35 pt bonus if left col > 63 { LC7=35 GuiControl,,LC7,%LC7% } LC8:=LC1+LC2+LC3+LC4+LC5+LC6+LC7 GuiControl,,LC8,%LC8% RC8:=RC1+RC2+RC3+RC4+RC5+RC6+RC7 GuiControl,,RC8,%RC8% Score:=LC8+RC8 PSB%PLI%=%Score% GuiControl,,GL,%GL% GuiControl,,Total,%Score% GuiControl,,PSB%PLI%,%Score% Return CountDie(z) ; count how many dice have same number as z { y:=x:=0 Loop ,5 { if (DieS%A_Index%=z) x+=z ;msgbox ,% DieS%A_Index% . " - " . x } return x } endgame: z:=(PSB1>PSB2) ? PSB1 : PSB2 z:=(PSB3>z) ? PSB3 : z z:=(PSB4>z) ? PSB4 : z z:=(PSB5>z) ? PSB5 : z z:=(PSB6>z) ? PSB6 : z x=0 Loop, 6 { x:=(PSB%A_Index%=z) ? A_Index : x } winner:=PNB%x% SoundPlay, sound\applause1.wav MsgBox ,, Winner Is, Winner is Player %x% %winner% Score %z%,5 Gosub ,InitVariables Goto ,NewGame Rules: FileRead, contents, Rules.txt msgbox,4,Yahtze Rules,%contents%`n`t`t`t`t`tNext Page? IfMsgBox Yes { FileRead, contents, Rules2.txt msgbox,,Yahtze Rules,%contents% } contents= return Directions: FileRead, contents, directions.txt msgbox,,Yahtze Directions,%contents% contents= return ;======== AHK's built-in GUI right-click label GuiContextMenu: If a_GuiControl = help = This is the Main Window help := %a_GuiControl%help ToolTipMon() ToolTip, %help% return ToolTipMon() { HotKey, *~LButton, KillTip HotKey, *~LButton, On return } KillTip: { HotKey, *~LButton, Off ToolTip return }