10K DICE GAME

Post your working scripts, libraries and tools
Hellbent
Posts: 716
Joined: 23 Sep 2017, 13:34

10K DICE GAME

05 Jan 2019, 08:26

Here is the classic dice game 10,000 converted into a computer game written in AHK.

When I was about to write out the rules for the game I decided to look online to see if the rules were posted somewhere, and sure enough there is a wiki page on the game.

https://en.wikipedia.org/wiki/Dice_10000

There are a few minor differences in the rules, here are the main ones I saw.

1. Each player starts each round with a fresh set of dice (you can't play off the last players hand)
2. You don't lose points for scoreless streaks.

I left a exploit in, use it or don't. Cheaters are going to cheat.
(I left a bit of the sorting code to the end and i'm feeling to lazy to add it in seeing as I don't know many people who would actually play the game so spending more time on a bit of code that no one is every going to see the fruits of seems a bit of a waste of time, and i'm ready to move onto something new.) If you do play, just don't cheat (just the same as with the real game.)

Here is what the main game window looks like.

Image

***Seems as though the image isn't showing up. so here are the links
https://imgur.com/0MabRPy
https://imgur.com/a0lmMmr


Here is the script

Code: Select all

#SINGLEINSTANCE , FORCE
SETBATCHLINES , -1
LISTLINES , OFF
#NoEnv
PBUTTON_STARTUP() 
GLOBAL PRESS_ACTIVE := 0 , HOVER_ON := 0 , ACTIVE_BUTTON , PBUTTON := {} , GAME := {} 
GAME := NEW 10K()
RETURN
GUICLOSE:
IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
	RETURN
	EXITAPP
WIN_MOVE() {
	POSTMESSAGE , 0XA1 , 2
	SETTIMER , WATCH_HOVER , OFF
	WHILE( GETKEYSTATE( "LBUTTON" ) )
		SLEEP , 10
	SETTIMER , WATCH_HOVER , ON
}
WIN_MIN() {
	IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
		RETURN
	GUI , 1: MINIMIZE
}
NEWGAME() {
	IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
		RETURN
	RELOAD
	RETURN
}
SUBMITNEWNAMES() {
	GUI , 9: SUBMIT , NOHIDE
	LOOP, % GAME.NUMBEROFPLAYERS
		GAME.NAMELIST2[ A_INDEX ] := NAME_EDIT_%A_INDEX%
	GAME.ADDGAMEWINDOWS()
	GUI , 9: HIDE
}
NEWGAMEOKBUTTON(){
	IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
		RETURN
	GAME.CREATEPLAYERS()
	IF( GAME.USECUSTOMNAMES = 1 )
		GAME.CREATENAMESLISTWINDOW()
	ELSE
		GAME.ADDGAMEWINDOWS()
	GUI , 6: HIDE
}
ROLLDICE() {
	IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
		RETURN
	GAME.ROLLBUTTON()
}
ENDTURN() {
	IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
		RETURN
	GAME.ENDTURN()
}
SWAP(){
	IF( !PBUTTON[ A_GUICONTROL ].BUTTON_PRESS() ) 
		RETURN
	IF( A_GUICONTROL = 4 ) 
		PBUTTON[ 4 ].TOP_COLOR_1 := "224466" , PBUTTON[ 4 ].TOP_COLOR_2 := "224466" , PBUTTON[ 4 ].TOP_COLOR_3 := "224466"
		, PBUTTON[ 5 ].TOP_COLOR_1 := "882222" , PBUTTON[ 5 ].TOP_COLOR_2 := "882222" , PBUTTON[ 5 ].TOP_COLOR_3 := "882222"
		, PBUTTON[ 5 ].BUTTON_HOVER_OFF() , PBUTTON[ 4 ].BUTTON_HOVER_OFF()
		, GAME.USECUSTOMNAMES := FALSE
	ELSE
		PBUTTON[ 4 ].TOP_COLOR_1 := "882222" , PBUTTON[ 4 ].TOP_COLOR_2 := "882222" , PBUTTON[ 4 ].TOP_COLOR_3 := "882222"
		, PBUTTON[ 5 ].TOP_COLOR_1 := "224466" , PBUTTON[ 5 ].TOP_COLOR_2 := "224466" , PBUTTON[ 5 ].TOP_COLOR_3 := "224466"
		, PBUTTON[ 4 ].BUTTON_HOVER_OFF() , PBUTTON[ 5 ].BUTTON_HOVER_OFF()
		, GAME.USECUSTOMNAMES := TRUE
	GAME.NAMELIST2 := [ "PLAYER 1" , "PLAYER 2" , "PLAYER 3" , "PLAYER 4" , "PLAYER 5" , "PLAYER 6" , "PLAYER 7" , "PLAYER 8" ]
}
MOVESLIDER() {
	COORDMODE , MOUSE , CLIENT
	WHILE( GETKEYSTATE( "LBUTTON" ) ) {
		MOUSEGETPOS , TTX
		IF( TTX > 110 && TTX < 245 ) {
			GUI , 8: SHOW , % "X" TTX - 15 " Y87 NA"
			GAME.NUMBEROFPLAYERS := FLOOR( ( TTX - ( 110 ) ) / 20 + 2 )
		}ELSE IF( TTX <= 110 ) {
			GUI , 8: SHOW , % "X" 110 - 15 " Y87 NA"
			GAME.NUMBEROFPLAYERS := 2
		}ELSE IF( TTX >= 240 ) {
			GUI , 8: SHOW , % "X" 240 - 15 " Y87 NA"
			GAME.NUMBEROFPLAYERS := 8
		}
		GUICONTROL , 7: , NUMBEROFPLAYEREDIT , % GAME.NUMBEROFPLAYERS
	}
}
DRAW_OUTLINE( GUI_NAME , X , Y , W , H , COLOR1 :="BLACK", COLOR2 := "BLACK" , THICKNESS := 1 ) {
	GUI , % GUI_NAME ": ADD" , PROGRESS , % "X" X " Y" Y " W" W " H" THICKNESS " BACKGROUND" COLOR1 
	GUI , % GUI_NAME ": ADD" , PROGRESS , % "X" X " Y" Y " W" THICKNESS " H" H " BACKGROUND" COLOR1 
	GUI , % GUI_NAME ": ADD" , PROGRESS , % "X" X " Y" Y+H-THICKNESS " W" W " H" THICKNESS " BACKGROUND" COLOR2 
	GUI , % GUI_NAME ": ADD" , PROGRESS , % "X" X+W-THICKNESS " Y" Y " W" THICKNESS " H" H " BACKGROUND" COLOR2 	
}
DRAW_LINE( GUI_NAME , X , Y , W , H , COLOR ) {
	GUI , % GUI_NAME ": ADD" , PROGRESS , % "X" X " Y" Y " W" W " H" H " BACKGROUND" COLOR 
}
PBUTTON_STARTUP() {
	SETTIMER , WATCH_HOVER , 10
}
WATCH_HOVER() {
	GLOBAL
	IF( PRESS_ACTIVE = 0 ) {
		IF( HOVER_ON = 0 ) {
			MOUSEGETPOS , , , , CTRL , 2
			LOOP , % PBUTTON.LENGTH()	{
				GUICONTROLGET , CNAME , % PBUTTON[ A_INDEX ].WINDOW_NAME ": NAME" , % CTRL
				CUT := STRLEN( CNAME )
				STRINGLEFT , BNAME , CNAME , CUT - 2
					IF( BNAME = PBUTTON[ A_INDEX ].BUTTON_NAME) {
						PBUTTON[ A_INDEX ].BUTTON_HOVER_ON()
						HOVER_ON := 1 , ACTIVE_BUTTON := BNAME , WIN := PBUTTON[ A_INDEX ].WINDOW_NAME
						RETURN
					}
			}
		}ELSE IF( HOVER_ON = 1 ) {
			MOUSEGETPOS , , , , CTRL , 2
			GUICONTROLGET , CNAME , %WIN%: NAME , % CTRL
			CUT := STRLEN( CNAME )
			STRINGLEFT , NBNAME , CNAME , CUT - 2
			IF( NBNAME != ACTIVE_BUTTON ) 
				PBUTTON[ ACTIVE_BUTTON ].BUTTON_HOVER_OFF()
				, HOVER_ON := 0 , ACTIVE_BUTTON := ""
		}
	}
}	
CLASS 10K	{
	__NEW()	{
		THIS.NAMELIST := [ "PLAYER_1" , "PLAYER_2" , "PLAYER_3" , "PLAYER_4" , "PLAYER_5" , "PLAYER_6" , "PLAYER_7" , "PLAYER_8" ]
		THIS.NAMELIST2 := [ "PLAYER 1" , "PLAYER 2" , "PLAYER 3" , "PLAYER 4" , "PLAYER 5" , "PLAYER 6" , "PLAYER 7" , "PLAYER 8" ]
		THIS.NUMBEROFPLAYERS := 2 , THIS.CURRENTPLAYER := 1 , THIS.TURNSCORE := 0 , THIS.ROUNDSCORE := 0 , THIS.LAST_SCORE := 0
		THIS.FIRSTTURN := 1 , THIS.CREATEPLAYERS() , THIS.ENDTURNBUTTONDISABLED := 1 , THIS.REMAINING_DICE := 0
		THIS.FREE_DICE_SET := [] , THIS.HELD_DICE_SET := [] , THIS.SORTING_HELD_DICE_SET := []
		THIS.FREEDIECOLOR1 := "WHITE" , THIS.FREEDIECOLOR2 := "BLACK" , THIS.TRIMONCOLOR := "RED" , THIS.TRIMOFFCOLOR := "222222"
		THIS.HELDCOLOR1	:= "AAAAAA" , THIS.HELDCOLOR2 := "BLACK"
		THIS.CREATEGAMEOPENINGWINDOW()
	}
	ADDGAMEWINDOWS() {
		THIS.CREATE_MAIN_WINDOW()
		THIS.CREATE_FREE_DICE_WINDOW()
		THIS.CREATE_HELD_DICE_WINDOW()
		THIS.CREATEPLAYERCARD()
		THIS.CREATEENDTURNGUI()
	}
	CREATEPLAYERS() {
		THIS.PLAYER := {}
		LOOP , % THIS.NUMBEROFPLAYERS	{
			THIS.PLAYER[ A_INDEX ] := { SCORE : 0 , TURN : 1 , NAME : THIS.NAMELIST2[ A_INDEX ], FIRSTTURN : 1 }
		}
	}
	CREATEGAMEOVERWINDOW() {
		GUI , 11: DESTROY
		GUI , 12: DESTROY
		GUI , 11: +ALWAYSONTOP -CAPTION -DPISCALE
		GUI , 12: +PARENT11 -CAPTION -DPISCALE
		GUI , 11: COLOR , 222222 , 222222
		GUI , 12: COLOR , 333333 , 222222
		GUI , 11: FONT , CAAAAAA S12 W600 , SEGOE UI
		GUI , 12: FONT , C005599 S10 W600 , SEGOE UI
		DRAW_OUTLINE( 11 , 0 , 0 , 250 , 150 , "AAAAAA" , "BLACK" , 1 ) , DRAW_OUTLINE( 11 , 1 , 1 , 248 , 148 , "777777" , "111111" , 1 ) 
		DRAW_OUTLINE( 12 , 0 , 0 , 230 , 110 , "AAAAAA" , "BLACK" , 1 ) , DRAW_OUTLINE( 12 , 1 , 1 , 228 , 108 , "777777" , "111111" , 1 )
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "11" , PBUTTON.LENGTH() + 1 , "WIN_MOVE" , 75 , 3 , 100 , 25 , "222222" , "222222" , "222222" , "333333" , "BLACK" , "GAME OVER" , 1 ) )
		GUI , 12: ADD , TEXT , X10 Y10 W210 H50 BACKGROUNDTRANS CENTER 0X200 , % THIS.NAMELIST2[ THIS.CURRENTPLAYER ] " WINS"
		GUI , 12: FONT , CAAAAAA S10 W600 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "12" , PBUTTON.LENGTH() + 1 , "NEWGAME" , 10 , 75 , 100 , 25 , "BLACK" , "AAAAAA" , "222222" , "882222" , "BLACK" , "NEW GAME" , 3 ) )
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "12" , PBUTTON.LENGTH() + 1 , "GUICLOSE" , 120 , 75 , 100 , 25 , "BLACK" , "AAAAAA" , "222222" , "882222" , "880000" , "EXIT" , 3 ) )
		DRAW_LINE( 12 , 11 , 100 , 100 , 1 , "222222" ) , DRAW_LINE( 12 , 110 , 76 , 1 , 25 , "222222" )
		DRAW_LINE( 12 , 121 , 100 , 100 , 1 , "222222" ) , DRAW_LINE( 12 , 220 , 76 , 1 , 25 , "222222" )
		GUI , 12: SHOW , X10 Y30 W230 H110
		GUI , 11: SHOW , W250 H150
	}
	CREATENAMESLISTWINDOW() {
		GLOBAL
		GUI , 9: DESTROY
		GUI , 10: DESTROY
		GUI , 9: +ALWAYSONTOP -CAPTION -DPISCALE
		GUI , 10: +PARENT9 -CAPTION -DPISCALE
		GUI , 9: COLOR , 222222 , 222222
		GUI , 10: COLOR , 333333 , 222222
		GUI , 9: FONT , CAAAAAA S12 W600 , SEGOE UI
		GUI, 10: FONT , CAAAAAA S10 W600 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "9" , PBUTTON.LENGTH() + 1 , "WIN_MOVE" , 55 , 5 , 200 , 20 , "222222" , "222222" , "222222" , "226699" , "BLACK" , "PLAYER NAMES" , 1 ) )
		GUI, 9: FONT , C222222 S12 W600 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "9" , PBUTTON.LENGTH() + 1 , "GUICLOSE" , 280 , 0 , 30 , 25 , "222222" , "222222" , "222222" , "882222" , "BLACK" , "X" , 1 ) )
		GUI , 9: FONT , C0099AA S10 W600 , SEGOE UI
		Y := 10
		LOOP , % THIS.NUMBEROFPLAYERS	{
			GUI , 10: ADD , PROGRESS , X20 Y%Y% W250 H25 BACKGROUND222222
			DRAW_OUTLINE( 10 , 19 , Y-1 , 252 , 27 , "555555" , "111111" , 1 )
			GUI , 9: ADD , EDIT , % "X40 Y" Y + 3 + 30 " W210 H19 CENTER LIMIT15 UPPERCASE -E0X200 VNAME_EDIT_" A_INDEX , % THIS.NAMELIST2[ A_INDEX ]
			Y += 30
		}
		GUI, 10: FONT , CAAAA00 S8 W600 , SEGOE UI
		Y -= 0
		GUI , 10: ADD , TEXT , X10 Y%Y% W290 H20 CENTER BACKGROUNDTRANS , USE TAB TO CYCLE NAMES
		H := THIS.NUMBEROFPLAYERS * 30 + 30
		DRAW_OUTLINE( 9 , 0 , 0 , 310 , H + 90 , "777777" , "BLACK" , 1 ) , DRAW_OUTLINE( 9 , 1 , 1 , 308 , H + 88 , "555555" , "111111" , 1 )
		DRAW_OUTLINE( 10 , 0 , 0 , 290 , H , "777777" , "BLACK" , 1 ) , DRAW_OUTLINE( 10 , 1 , 1 , 288 , H - 2 , "555555" , "111111" , 1 )
		GUI , 9: FONT , CAAAAAA S12 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "9" , PBUTTON.LENGTH() + 1 , "SUBMITNEWNAMES" , 115 , H + 70 - 33 , 80 , 25 , "BLACK" , "444444" , "222222" , "226699" , "226699" , "OK" , 0 ) )
		GUI , 10: SHOW , X10 Y30 W290 H%H%
		GUI , 9: SHOW , % "W310 H" H + 70
	}
	CREATEGAMEOPENINGWINDOW() {
		GLOBAL 
		GUI , 6: DESTROY
		GUI , 7: DESTROY
		GUI , 8: DESTROY
		GUI , 6: +ALWAYSONTOP  -DPISCALE -CAPTION 
		GUI , 7: +PARENT6  -DPISCALE -CAPTION
		GUI , 8: +PARENT7  -DPISCALE -CAPTION +ALWAYSONTOP
		GUI , 6: COLOR , 222222
		GUI , 7: COLOR , 333333
		GUI , 8: COLOR , 222222
		DRAW_OUTLINE( 6 , 0 , 0 , 350 , 200 , "555555" , "BLACK" , 1 ) , DRAW_OUTLINE( 6 , 1 , 1 , 348 , 198 , "444444" , "111111" , 1 )
		DRAW_OUTLINE( 7 , 0 , 0 , 330 , 160 , "BLACK" , "555555" , 1 ) , DRAW_OUTLINE( 7 , 1 , 1 , 328 , 158 , "111111" , "444444" , 1 )
		GUI , 6: FONT , C222222 S8 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "6" , PBUTTON.LENGTH() + 1 , "WIN_MOVE" , 5 , 5 , 60 , 20 , "222222" , "222222" , "222222" , "00BB00" , "BLACK" , "HB             " , 3 ) )
		GUI , 6: FONT , C888888 S12 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "6" , PBUTTON.LENGTH() + 1 , "WIN_MOVE" , 100 , 3 , 150 , 25 , "222222" , "222222" , "222222" , "226699" , "BLACK" , "10K" , 1 ) )
		GUI , 6: FONT , C888888 S10 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "6" , PBUTTON.LENGTH() + 1 , "GUICLOSE" , 294 , 2 , 55 , 26 , "222222" , "222222" , "222222" , "882222" , "BLACK" , "`          X" , -3 ) )
		GUI , 7: FONT , CBLACK S8 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "7" , PBUTTON.LENGTH() + 1 , "SWAP" , 20 , 10 , 290 , 25 , "333333" , "333333" , "224466" , "224466" , "224466" , "USE DEFAULT NAMES" , 6 ) )
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "7" , PBUTTON.LENGTH() + 1 , "SWAP" , 20 , 40 , 290 , 25 , "333333" , "333333" , "882222" , "882222" , "882222" , "USE CUSTOM NAMES" , 6 ) )
		DRAW_OUTLINE( 7 , 15 , 75 , 300 , 50 , "444444" , "222222" , 1 )
		GUI , 7: FONT , C999999 S8 , SEGOE UI
		GUI , 7: ADD , TEXT , X20 Y75 H20 BACKGROUNDTRANS 0X200 , PLAYERS
		GUI , 7: ADD , TEXT , X90 Y80 H40 W150 BACKGROUNDTRANS GMOVESLIDER
		GUI , 7: ADD , PROGRESS , X90 Y98 W150 H3 BACKGROUND222222
		GUI , 7: FONT , CFFFFFF S14 , SEGOE UI
		GUI , 7: ADD , EDIT , X270 Y85 W20 H20 VNUMBEROFPLAYEREDIT DISABLED -E0X200 , % THIS.NUMBEROFPLAYERS
		GUI , 7: FONT , C888888 S10 , SEGOE UI
		GUI , 8: SHOW , X95 Y87 W10 H25
		GUI , 8: ADD , TEXT , X0 Y0 W10 H25 BACKGROUNDTRANS CENTER 0X200 GMOVESLIDER
		GUI , 7: FONT , CBCBCBC S10 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "7" , PBUTTON.LENGTH() + 1 , "NEWGAMEOKBUTTON" , 125 , 132 , 80 , 20 , "BLACK" , "666666" , "222222" , "444444" , "555555" , "OK" , 1 ) )
		DRAW_LINE( 7 , 126 , 152 , 80 , 1 , "222222" ) , DRAW_LINE( 7 , 205 , 132 , 1 , 20 , "222222" )
		GUI , 6: SHOW , W350 H200 ,10K GAME SETTINGS
		GUI , 7: SHOW , X10 Y30  W330 H160
	}
	CREATE_MAIN_WINDOW() {
		GLOBAL
		LOOP , % THIS.NUMBEROFPLAYERS
			THIS.PLAYER[ A_INDEX ] := { SCORE : 0 , TURN : 1 , NAME : THIS.NAMELIST2[ A_INDEX ] , FIRSTTURN : 1 }
		GUI , 1: DESTROY
		GUI , 1: +ALWAYSONTOP -DPISCALE -CAPTION +OWNER
		GUI , 1: COLOR , 222222 , 226699
		H := 300 + ( THIS.NUMBEROFPLAYERS * 42 ) + 60 
		DRAW_OUTLINE( 1 , 0 , 0 , 380 , H , "999999" , "BLACK" , 1 ) , DRAW_OUTLINE( 1 , 1 , 1 , 378 , H - 2 , "555555" , "111111" , 1 )
		DRAW_OUTLINE( 1 , 5 , 42 , 370 , H - 48 , "BLACK" , "444444" , 1 ) , DRAW_OUTLINE( 1 , 6 , 43 , 368 , H - 50 , "111111" , "333333" , 1 )
		GUI , 1: FONT , C999999 S16 W600 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "1" , PBUTTON.LENGTH() + 1 , "WIN_MOVE" , 90 , 7 , 200 , 30 , "111111" , "333333" , "222222" , "2F3768" , "BLACK" , "10K" , -1 ) )
		GUI , 1: FONT , C777777 S16 W600 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "1" , PBUTTON.LENGTH() + 1 , "WIN_MIN" , 330 , 7 , 20 , 20 , "111111" , "333333" , "222222" , "2F3768" , "3F4778" , "-" , -3 ) )
		GUI , 1: FONT ,
		GUI , 1: FONT , C777777 S14 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "1" , PBUTTON.LENGTH() + 1 , "GUICLOSE" , 355 , 7 , 20 , 20 , "111111" , "333333" , "222222" , "880000" , "AA0000" , "X" , -5 ) )
		GUI , 1: FONT ,
		GUI , 1: FONT , C777777 S12 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "1" , PBUTTON.LENGTH() + 1 , "ROLLDICE" , 190 , 220 , 150 , 50 , "BLACK" , "333333" , "182233" , "182543" , "182853" , "ROLL DICE" , 14 ) )
		DRAW_LINE( 1 , 191 , 270 , 150 , 1 , "111111" ) , DRAW_LINE( 1 , 340 , 221 , 1 , 50 , "111111" )
		GUI , 1: FONT ,
		GUI , 1: FONT , C777777 S14 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "1" , PBUTTON.LENGTH() + 1 , "NEWGAME" , 115 , H - 45 , 150 , 30 , "BLACK" , "333333" , "181818" , "660000" , "AA0000" , "NEW GAME" , 1 ) )
		DRAW_LINE( 1 , 116 , H - 15 , 150 , 1 , "111111" ) , DRAW_LINE( 1 , 265 , H - 44 , 1 , 30 , "111111" )
		GUI , 1: FONT ,
		GUI , 1: FONT , C888888 S12 , SEGOE UI
		GUI , 1: ADD , EDIT , X250 Y173 W110 H29 -E0X200 BORDER CENTER DISABLED VEDITBOXFORSCORE ,
		GUI , 1: ADD , EDIT , X14  Y52 W180 H27 -E0X200 CENTER DISABLED VEDITBOXFORPLAYERTURNNUMBER , % THIS.PLAYER[ 1 ].NAME
		DRAW_OUTLINE( 1 , 13 , 49 , 182 , 31 , "333333" , "111111" , 1 )
		GUI , 1: FONT ,
		GUI , 1: FONT , CAAAAAA S10 , SEGOE UI
		GUI , 1: ADD , TEXT , C777777 X20 Y280 W340 H20 CENTER BACKGROUNDTRANS 0X200 , NAME                                     SCORE             `
		GUI , 1: SHOW , W380 H%H% , 10K
	}
	CREATE_FREE_DICE_WINDOW() {
		GLOBAL
		GUI , 2: DESTROY
		GUI , 2: +PARENT1 -CAPTION -DPISCALE
		GUI , 2: COLOR , 223040
		DRAW_OUTLINE( 2 , 0 , 0 , 360 , 80 , "555555" , "111111" , 1 )
		THIS.CREATE_RANDOM_DICE( THIS.REMAINING_DICE )
		GUI , 2: FONT , CAA0000 S24 , SEGOE UI
		GUI , 2: ADD , TEXT ,X10 Y10 W360 H300 CENTER BACKGROUNDTRANS HIDDEN VMESSAGETEXT , BUST
		GUI , 2: SHOW , X10 Y83 W360 H80 ,
	}
	CREATE_HELD_DICE_WINDOW() {
		GUI , 3: DESTROY
		GUI , 3: +PARENT1 -CAPTION -DPISCALE
		GUI , 3: COLOR , 332222
		DRAW_OUTLINE( 3 , 0 , 0 , 230 , 45 , "444444" , "111111" , 1 )
		GUI , 3: SHOW , X15 Y165 W230 H45 ,
	}
	CREATEPLAYERCARD() {
		GLOBAL
		GUI , 4: DESTROY
		GUI , 4: +PARENT1 -CAPTION -DPISCALE
		GUI , 4: COLOR , 191919
		H := THIS.NUMBEROFPLAYERS * 42 + 10
		DRAW_OUTLINE( 4 , 0 , 0 , 360 , H , "444444" , "BLACK" , 1 ) , DRAW_OUTLINE( 4 , 1 , 1 , 358 , H - 2 , "333333" , "111111" , 1 )
		X := 10 , Y := 10
		LOOP , % THIS.NUMBEROFPLAYERS	{
			GUI , 4: ADD , PROGRESS , X10 Y%Y% W340 H32 BACKGROUND2F3768
			DRAW_OUTLINE( 4 , 10 , Y , 340 , 32 , "777777" , "BLACK" , 1 )
			GUI , 4: FONT , CAAAAAA S12 Q4 W650 , SEGOE UI
			GUI , 4: ADD , TEXT , % "X20 Y" Y + 5 " W155 H22 BACKGROUNDTRANS 0X200 " , % THIS.PLAYER[ A_INDEX ].NAME
			GUI , 4: ADD , EDIT , % " CWHITE X180 Y" Y + 5 " W155 H22 BORDER CENTER -E0X200 CENTER DISABLED V" THIS.NAMELIST[ A_INDEX ] , % THIS.PLAYER[ A_INDEX ].SCORE
			Y += 42
		}
		H := THIS.NUMBEROFPLAYERS * 42 + 10
		GUI , 4: SHOW , X10 Y300 W360 H%H% 
	}
	CREATEENDTURNGUI() {
		GLOBAL
		GUI , 5: DESTROY
		GUI , 5: +PARENT1 -CAPTION -DPISCALE
		GUI , 5: COLOR , 222222
		GUI , 5: FONT , C666666 S10 , SEGOE UI
		PBUTTON.PUSH( NEW PROGRESS_BUTTON( "5" , PBUTTON.LENGTH() + 1 , "ENDTURN" , 5 , 5 , 100 , 30 , "BLACK" , "333333" , "331111" , "661111" , "771111" , "END TURN" , 6 ) )
		DRAW_LINE( 5 , 6 , 35 , 100 , 1 , "111111" ) , DRAW_LINE( 5 , 105 , 6 , 1 , 30 , "111111" )
		GUI , 5: SHOW , X45 Y225 W110 H40
		GUI , 5: HIDE
	}
	ENDTURN() {
		GUI , 5: HIDE
		THIS.HELD_DICE_SET := "" , THIS.HELD_DICE_SET := []
		THIS.FREE_DICE_SET := "" , THIS.FREE_DICE_SET := []
		THIS.FIRSTTURN := 1 , THIS.CREATE_HELD_DICE_WINDOW()
		THIS.REMAINING_DICE := 0 , THIS.CREATE_FREE_DICE_WINDOW() , THIS.REMAINING_DICE := 6
		IF( THIS.TURNSCORE > 0 ) {
			IF( THIS.PLAYER[ THIS.CURRENTPLAYER ].FIRSTTURN = 1 ){
				IF( ( THIS.ROUNDSCORE + THIS.TURNSCORE ) >= 1000 )
					THIS.PLAYER[ THIS.CURRENTPLAYER ].SCORE += THIS.ROUNDSCORE + THIS.TURNSCORE , THIS.PLAYER[ THIS.CURRENTPLAYER ].FIRSTTURN := 0
			}ELSE IF( ( THIS.ROUNDSCORE + THIS.TURNSCORE ) >= 300 )
				THIS.PLAYER[ THIS.CURRENTPLAYER ].SCORE += THIS.ROUNDSCORE + THIS.TURNSCORE
		}
		THIS.TURNSCORE := 0 , THIS.ROUNDSCORE := 0
		GUICONTROL , 1: , EDITBOXFORSCORE , % THIS.ROUNDSCORE
		GUICONTROL , 4: , % THIS.NAMELIST[ THIS.CURRENTPLAYER ] , % THIS.PLAYER[ THIS.CURRENTPLAYER ].SCORE
		IF( THIS.PLAYER[ THIS.CURRENTPLAYER ].SCORE >= 10000 ){
			GUI , 1: HIDE
			THIS.CREATEGAMEOVERWINDOW()
		}
		THIS.CURRENTPLAYER++
		IF( THIS.CURRENTPLAYER > THIS.NUMBEROFPLAYERS )
			THIS.CURRENTPLAYER := 1
		GUICONTROL , 1: , EDITBOXFORPLAYERTURNNUMBER , % THIS.PLAYER[ THIS.CURRENTPLAYER ].NAME
		GUICONTROL , 2: SHOW , MESSAGETEXT , 
		GUICONTROL , 2: , MESSAGETEXT , % THIS.PLAYER[ THIS.CURRENTPLAYER ].NAME
	}
	ROLLBUTTON() {
		GUI , 5: SHOW
		IF( THIS.TURNSCORE > 0 || THIS.FIRSTTURN = 1 ) {
			THIS.FIRSTTURN := 0 , THIS.FREE_DICE_SET := "" , THIS.FREE_DICE_SET := []
			IF( THIS.REMAINING_DICE = 0 ) {
				THIS.HELD_DICE_SET := "" , THIS.HELD_DICE_SET := []
				THIS.CREATE_HELD_DICE_WINDOW() , THIS.REMAINING_DICE := 6
			}
			THIS.ROUNDSCORE += THIS.TURNSCORE , THIS.TURNSCORE := 0 , THIS.CREATE_FREE_DICE_WINDOW()
		}ELSE	{
			GUICONTROL , 1: , EDITBOXFORSCORE , BUST
			SOUNDBEEP , 450 , 300
		}
	}
	ADDPOINTSTOSCORE( FREESET ) {
		1S := 0 , 2S := 0 , 3S := 0 , 4S := 0 , 5S := 0 , 6S := 0 , POINTS_ARRAY := [] , THIS.TURNSCORE := 0
		LOOP , % FREESET.LENGTH()
			IF( FREESET[ A_INDEX ].STATE = 1 )
				 ( FREESET[ A_INDEX ].VALUE = 1 ) ? ( 1S++ ) : ( FREESET[ A_INDEX ].VALUE = 2 ) ? ( 2S++ ) : ( FREESET[ A_INDEX ].VALUE = 3 ) ? ( 3S++ ) : ( FREESET[ A_INDEX ].VALUE = 4 ) ? ( 4S++ ) : ( FREESET[ A_INDEX ].VALUE = 5 ) ? ( 5S++ ) : ( FREESET[ A_INDEX ].VALUE = 6 ) ? ( 6S++ )
		IF( 1S = 1 && 2S = 1 && 3S = 1 && 4S = 1 && 5S = 1 && 6S = 1 ) 
			THIS.TURNSCORE += 2000
		ELSE	{
			( 1S = 6 ) ? ( THIS.TURNSCORE += 8000 ) : ( 1S = 5 ) ? ( THIS.TURNSCORE += 4000 ) : ( 1S = 4 ) ? ( THIS.TURNSCORE += 2000):(1S=3)?(THIS.TURNSCORE += 1000):(1S=2)?(THIS.TURNSCORE += 200):(1S=1)?(THIS.TURNSCORE += 100)
			( 2S = 6 ) ? ( THIS.TURNSCORE += 1600 ) : ( 2S = 5 ) ? ( THIS.TURNSCORE += 800 ) : ( 2S = 4 ) ? ( THIS.TURNSCORE += 400 ) : ( 2S = 3 ) ? ( THIS.TURNSCORE += 200 ) : ( 2S < 3 ) ? ( THIS.TURNSCORE += 0 )
			( 3S = 6 ) ? ( THIS.TURNSCORE += 2400 ) : ( 3S = 5 ) ? ( THIS.TURNSCORE += 1200 ) : ( 3S = 4 ) ? ( THIS.TURNSCORE += 600 ) : ( 3S = 3 ) ? ( THIS.TURNSCORE += 300 ) : ( 3S < 3 ) ? ( THIS.TURNSCORE += 0 )
			( 4S = 6 ) ? ( THIS.TURNSCORE += 3200 ) : ( 4S = 5 ) ? ( THIS.TURNSCORE += 1600 ) : ( 4S = 4 ) ? ( THIS.TURNSCORE += 800 ) : ( 4S = 3 ) ? ( THIS.TURNSCORE += 400 ) : ( 4S < 3 ) ? ( THIS.TURNSCORE += 0 )
			( 5S = 6 ) ? ( THIS.TURNSCORE += 4000 ) : ( 5S = 5 ) ? ( THIS.TURNSCORE += 2000 ) : ( 5S = 4 ) ? ( THIS.TURNSCORE += 1000 ) : ( 5S = 3 ) ? ( THIS.TURNSCORE += 500 ) : ( 5S = 2 ) ? ( THIS.TURNSCORE += 100 ) : ( 5S = 1 ) ? ( THIS.TURNSCORE += 50 )
			( 6S = 6 ) ? ( THIS.TURNSCORE += 4800 ) : ( 6S = 5 ) ? ( THIS.TURNSCORE += 2400 ) : ( 6S = 4 ) ? ( THIS.TURNSCORE += 1200 ) : ( 6S = 3 ) ? ( THIS.TURNSCORE += 600 ) : ( 6S < 3 ) ? ( THIS.TURNSCORE += 0 )
		}
		GUICONTROL , 1: , EDITBOXFORSCORE , % THIS.ROUNDSCORE + THIS.TURNSCORE
	}
	HOLDDICE() {
		LOOP, % THIS.FREE_DICE_SET.LENGTH() {
			IF( A_INDEX = A_GUICONTROL ) {
				IF( THIS.FREE_DICE_SET[ A_INDEX ].STATE := ! THIS.FREE_DICE_SET[ A_INDEX ].STATE ) 
					THIS.ADDHELDDICETOLIST()
				ELSE 
					THIS.CREATE_HELD_DICE_WINDOW() , THIS.HIGHLIGHT_SELECTED_DICE_OFF( THIS.FREE_DICE_SET[ A_INDEX ] )
					, THIS.REMOVEHELDFROMLIST() , THIS.UPDATEHELDLIST() , THIS.ADD_HELD_DICE()
			}
		}
		THIS.ADDPOINTSTOSCORE( THIS.FREE_DICE_SET ) , THIS.CREATE_HELD_DICE_WINDOW() , THIS.SORTHELDDICE() , THIS.ADD_HELD_DICE()
	}
	CREATE_RANDOM_DICE(AMOUNT) {
		THIS.FREE_DICE_SET := "" , THIS.FREE_DICE_SET := []
		LOOP , % AMOUNT	{
			Y := 20 , W := 35 , H := W , X := ( W * ( A_INDEX - 1 ) + ( 21 * A_INDEX ) )
			THIS.FREE_DICE_SET[ A_INDEX ] := { X : X , Y : Y , W : W , H : H , COLOR1 : THIS.FREEDIECOLOR1 , COLOR2 : THIS.FREEDIECOLOR2 , NAME : "2" , FREEORDERPOSITION : A_INDEX }
			THIS.DRAW_RANDOM_DICE( THIS.FREE_DICE_SET[ A_INDEX ] , A_INDEX ) , THIS.ADDTRIM( THIS.FREE_DICE_SET[ A_INDEX ] )
		}
	}
	DRAW_RANDOM_DICE( RANDOMDIE , INDEX ) {
		GLOBAL
		GUI , % RANDOMDIE.NAME " : ADD" , TEXT , % "X" RANDOMDIE.X " Y" RANDOMDIE.Y " W" RANDOMDIE.W " H" RANDOMDIE.H " HWNDHWND V" INDEX , % INDEX
		RDB := THIS.HOLDDICE.BIND( THIS ) 
		GUICONTROL +G , %HWND% , % RDB
		GUI , % RANDOMDIE.NAME " : ADD" , PROGRESS , % "X" RANDOMDIE.X - 1 " Y" RANDOMDIE.Y - 1 " W" RANDOMDIE.W + 2 " H" RANDOMDIE.H + 2 " BACKGROUNDWHITE C" RANDOMDIE.COLOR1 , 100
		GUI , % RANDOMDIE.NAME " : ADD" , PROGRESS , % "X" RANDOMDIE.X " Y" RANDOMDIE.Y " W" RANDOMDIE.W " H" RANDOMDIE.H " BACKGROUNDBLACK C" RANDOMDIE.COLOR1 , 100
		THIS.READY_DOTS( THIS.RANDOM( 1 ,6 ) , RANDOMDIE )
	}
	ADDHELDDICETOLIST()	{
		THIS.REMAINING_DICE--
		THIS.HIGHLIGHT_SELECTED_DICE_ON( THIS.FREE_DICE_SET[ A_INDEX ] )
		Y := 10 , W := 25 , H := W , X := ( W * ( THIS.HELD_DICE_SET.LENGTH() - 1 ) + ( 11 * THIS.HELD_DICE_SET.LENGTH() -1  ) ) , NAME := "3" , VALUE := THIS.FREE_DICE_SET[ A_INDEX ].VALUE
		THIS.HELD_DICE_SET[ THIS.HELD_DICE_SET.LENGTH() + 1 ] := { X : X , Y : Y , W : W , H : H , NAME : NAME , VALUE : VALUE }
		THIS.HELD_DICE_SET[ THIS.HELD_DICE_SET.LENGTH() ].X := ( W * ( THIS.HELD_DICE_SET.LENGTH() - 1 ) + ( 11 * THIS.HELD_DICE_SET.LENGTH() +1 ) )
		THIS.ADD_HELD_DICE()
	}
	REMOVEHELDFROMLIST() {
		THIS.REMAINING_DICE++ , THIS.SORTING_HELD_DICE_SET := "" , THIS.SORTING_HELD_DICE_SET := [] , K := 1 , I := 1
		LOOP, % THIS.HELD_DICE_SET.LENGTH()	{
			IF( THIS.HELD_DICE_SET[ A_INDEX ].VALUE = THIS.FREE_DICE_SET[ A_GUICONTROL ].VALUE ) {
				IF( ++I > 2 )	
					THIS.SORTING_HELD_DICE_SET[ K ] := THIS.HELD_DICE_SET[ A_INDEX ] , K++
			}ELSE
				THIS.SORTING_HELD_DICE_SET[ K ] := THIS.HELD_DICE_SET[ A_INDEX ] , K++
		}
	}
	UPDATEHELDLIST() {
		THIS.HELD_DICE_SET := "" , THIS.HELD_DICE_SET := []
		LOOP, % THIS.SORTING_HELD_DICE_SET.LENGTH()	{
			Y := 10 , W := 25 , H := W , X := ( W * ( A_INDEX - 1 ) + ( 11 * A_INDEX + 1 ) )
			THIS.HELD_DICE_SET[ A_INDEX ] := { X : X , Y : Y , W : W , H : H , COLOR1 : "RED" , COLOR2 : "BLACK" , NAME : "3" , VALUE : THIS.SORTING_HELD_DICE_SET[ A_INDEX ].VALUE }
		}
	}
	SORTHELDDICE() {
		TEMP := ""
		LOOP , % THIS.HELD_DICE_SET.LENGTH() - 1	{
			LOOP , % THIS.HELD_DICE_SET.LENGTH() - 1	{
				IF( THIS.HELD_DICE_SET[ A_INDEX ].VALUE < THIS.HELD_DICE_SET[ A_INDEX + 1 ].VALUE) {
					TEMP := THIS.HELD_DICE_SET[ A_INDEX ].VALUE
					THIS.HELD_DICE_SET[ A_INDEX ].VALUE := THIS.HELD_DICE_SET[ A_INDEX + 1 ].VALUE
					THIS.HELD_DICE_SET[ A_INDEX + 1 ].VALUE := TEMP
				}
			}
		}	
	}
	ADD_HELD_DICE() {
		LOOP , % THIS.HELD_DICE_SET.LENGTH()	{
			THIS.DRAW_HELD_DICE( THIS.HELD_DICE_SET[ A_INDEX ] )
			THIS.READY_HELD_DOTS( THIS.HELD_DICE_SET[ A_INDEX ] , THIS.HELD_DICE_SET[ A_INDEX ].VALUE )
		}
	}
	READY_HELD_DOTS(HELDOBJECT,VALUE) {
		THIS.LOAD_DICE_TEMPLATE(HELDOBJECT)
		 ( VALUE = 1 ) ? ( THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 4 ] ) )
		:( VALUE = 2 ) ? ( THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 1 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 7 ] ) )
		:( VALUE = 3 ) ? ( THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 1 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 4 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 7 ] ) )
		:( VALUE = 4 ) ? ( THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 1 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 2 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 6 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 7 ] ) )
		:( VALUE = 5 ) ? ( THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 1 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 2 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 4 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 6 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 7 ] ) )
		:( VALUE = 6 ) ? ( THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 1 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 2 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 3 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 5 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 6 ] ) , THIS.DRAW_HELD_DOTS( HELDOBJECT.POSITIONS[ 7 ] ) )
	}
	DRAW_HELD_DOTS(VALUE) {
		GUI , 3: ADD , PROGRESS , % "X" VALUE.X " Y" VALUE.Y " W" VALUE.W " H" VALUE.H " BACKGROUND" THIS.HELDCOLOR2
	}
	DRAW_HELD_DICE(HELDOBJECT) {
		GUI, % HELDOBJECT.NAME " : ADD" , PROGRESS , % "X" HELDOBJECT.X " Y" HELDOBJECT.Y " W" HELDOBJECT.W " H" HELDOBJECT.H " BACKGROUNDBLACK C" THIS.HELDCOLOR1 , 100
		DRAW_OUTLINE( 3 , HELDOBJECT.X - 1 , HELDOBJECT.Y - 1 , HELDOBJECT.W + 2 , HELDOBJECT.H + 2 , "WHITE" , "WHITE" , 1 )
	}
	ADDTRIM( TRIMOBJECT ) {
		GLOBAL
		TRIMOBJECT.TTRIM_ := "TTRIM_" TRIMOBJECT.FREEORDERPOSITION , TRIMOBJECT.BTRIM_ := "BTRIM_" TRIMOBJECT.FREEORDERPOSITION , TRIMOBJECT.RTRIM_ := "RTRIM_" TRIMOBJECT.FREEORDERPOSITION , TRIMOBJECT.LTRIM_ := "LTRIM_" TRIMOBJECT.FREEORDERPOSITION
		GUI , % TRIMOBJECT.NAME " : ADD" , PROGRESS , % "X" TRIMOBJECT.X - 4 " Y" TRIMOBJECT.Y - 4 " W" TRIMOBJECT.W + 6 " H" 3 " BACKGROUND" THIS.TRIMOFFCOLOR " V" TRIMOBJECT.TTRIM_
		GUI , % TRIMOBJECT.NAME " : ADD" , PROGRESS , % "X" TRIMOBJECT.X - 4 " Y" TRIMOBJECT.Y - 4 " W" 3 " H" TRIMOBJECT.H + 6 " BACKGROUND" THIS.TRIMOFFCOLOR " V" TRIMOBJECT.LTRIM_
		GUI , % TRIMOBJECT.NAME " : ADD" , PROGRESS , % "X" TRIMOBJECT.X - 4 " Y" TRIMOBJECT.Y - 4 + TRIMOBJECT.H + 5 " W" TRIMOBJECT.W + 6 " H" 3 " BACKGROUND" THIS.TRIMOFFCOLOR " V" TRIMOBJECT.BTRIM_
		GUI , % TRIMOBJECT.NAME " : ADD" , PROGRESS , % "X" TRIMOBJECT.X - 4 + TRIMOBJECT.W + 5 " Y" TRIMOBJECT.Y - 4 " W" 3 " H" TRIMOBJECT.H + 8 " BACKGROUND" THIS.TRIMOFFCOLOR " V" TRIMOBJECT.RTRIM_ 
	}
	HIGHLIGHT_SELECTED_DICE_ON( THEDIE ) {
		FOR K , V IN [ THEDIE.TTRIM_ , THEDIE.BTRIM_ , THEDIE.RTRIM_ , THEDIE.LTRIM_ ]
			GUICONTROL , % THEDIE.NAME ": +BACKGROUND" THIS.TRIMONCOLOR , % V
	}
	HIGHLIGHT_SELECTED_DICE_OFF( THEDIE ) {
		FOR K , V IN [ THEDIE.TTRIM_ , THEDIE.BTRIM_ , THEDIE.RTRIM_ , THEDIE.LTRIM_ ]
			GUICONTROL , % THEDIE.NAME ": +BACKGROUND" THIS.TRIMOFFCOLOR , % V
	}
	READY_DOTS( RANDOMNUMBER , DIEOBJECT ) {
		DIEOBJECT.VALUE := RANDOMNUMBER
		THIS.LOAD_DICE_TEMPLATE(DIEOBJECT)
		  ( RANDOMNUMBER = 1 ) ? ( THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 4 ] ) )
		: ( RANDOMNUMBER = 2 ) ? ( THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 1 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 7 ] ) )
		: ( RANDOMNUMBER = 3 ) ? ( THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 1 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 4 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 7 ] ) )
		: ( RANDOMNUMBER = 4 ) ? ( THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 1 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 2 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 6 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 7 ] ) )
		: ( RANDOMNUMBER = 5 ) ? ( THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 1 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 2 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 4 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 6 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 7 ] ) )
		: ( RANDOMNUMBER = 6 ) ? ( THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 1 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 2 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 3 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 5 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 6 ] ) , THIS.DRAWDOT( DIEOBJECT.POSITIONS[ 7 ] ) )
	}
	DRAWDOT( VALUE ) {
		GUI , 2: ADD , PROGRESS , % "X" VALUE.X " Y" VALUE.Y " W" VALUE.W " H" VALUE.H " BACKGROUND" THIS.FREEDIECOLOR2
	}
	LOAD_DICE_TEMPLATE( DICEOBJECT ) {
		DICEOBJECT.POSITIONS := []
		DICEOBJECT.POSITIONS[ 1 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 7 ) 									, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 7 ) 						  		 	, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
		DICEOBJECT.POSITIONS[ 2 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 1.5 )    							, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 7 ) 						   		 	, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
		DICEOBJECT.POSITIONS[ 3 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 7 )        							, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 2 ) - ( ( DICEOBJECT.H / 5 ) / 2 ) 	, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
		DICEOBJECT.POSITIONS[ 4 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 2 ) - ( ( DICEOBJECT.W / 5 ) / 2 ) 	, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 2 ) - ( ( DICEOBJECT.H / 5 ) / 2 ) 	, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
		DICEOBJECT.POSITIONS[ 5 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 1.5 )                        		, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 2 ) - ( ( DICEOBJECT.H / 5 ) / 2 ) 	, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
		DICEOBJECT.POSITIONS[ 6 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 7 )                        			, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 1.5 ) 					   			, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
		DICEOBJECT.POSITIONS[ 7 ] := { X : DICEOBJECT.X + ( DICEOBJECT.W / 1.5 )                        		, Y : DICEOBJECT.Y + ( DICEOBJECT.H / 1.5 ) 					   			, W : ( DICEOBJECT.W / 5 ) , H : ( DICEOBJECT.H / 5 ) }
	}
	RANDOM( MIN , MAX )	{
		RANDOM , OUTPUT , MIN , MAX
		RETURN OUTPUT
	}
}
CLASS PROGRESS_BUTTON	{
		__NEW( WINDOW_NAME , BUTTON_NAME , LABEL , X , Y , W , H , BC , TRC , TC1 , TC2 , TC3 , BUTTON_TEXT , TEXT_OFFSET := 0 ) {
			THIS.TEXT_OFFSET := TEXT_OFFSET , THIS.WINDOW_NAME := WINDOW_NAME , THIS.BUTTON_NAME := BUTTON_NAME
			THIS.LABEL := LABEL , THIS.BUTTON_ID1 := BUTTON_NAME "_1" , THIS.BUTTON_ID2 := BUTTON_NAME "_2"
			THIS.BUTTON_ID3 := BUTTON_NAME "_3" , THIS.BUTTON_ID4 := BUTTON_NAME "_4" , THIS.BUTTON_TEXT := BUTTON_TEXT
			THIS.X := X , THIS.Y := Y , THIS.W := W , THIS.H := H
			THIS.BOTTOM_COLOR := BC , THIS.TRIM_COLOR := TRC ,THIS.TOP_COLOR_1 := TC1
			THIS.TOP_COLOR_2 := TC2 , THIS.TOP_COLOR_3 := TC3
			THIS.ADD_BUTTON()
		}
		ADD_BUTTON() {
			GLOBAL
			GUI , % THIS.WINDOW_NAME ": ADD" , TEXT , % "X" THIS.X " Y" THIS.Y " W" THIS.W " H" THIS.H " V" THIS.BUTTON_NAME " G" THIS.LABEL
			GUI , % THIS.WINDOW_NAME ": ADD" , PROGRESS , % "X" THIS.X " Y" THIS.Y " W" THIS.W " H" THIS.H " BACKGROUND" THIS.BOTTOM_COLOR " V" THIS.BUTTON_ID1
			GUI , % THIS.WINDOW_NAME ": ADD" , PROGRESS , % "X" THIS.X " Y" THIS.Y " W" THIS.W - 1 " H" THIS.H - 1 " BACKGROUND" THIS.TRIM_COLOR " V" THIS.BUTTON_ID2
			GUI , % THIS.WINDOW_NAME ": ADD" , PROGRESS , % "X" THIS.X + 1 " Y" THIS.Y + 1 " W" THIS.W - 2 " H" THIS.H - 2 " BACKGROUND" THIS.TOP_COLOR_1 " V" THIS.BUTTON_ID3
			GUI , % THIS.WINDOW_NAME ": ADD" , TEXT , % "X" THIS.X + 1 " Y" THIS.Y + THIS.TEXT_OFFSET " W" THIS.W - 2 " R1 CENTER BACKGROUNDTRANS V" THIS.BUTTON_ID4 , % THIS.BUTTON_TEXT
		}
		BUTTON_PRESS() {
			GLOBAL
			PRESS_ACTIVE := 1
			GUICONTROL , % THIS.WINDOW_NAME ": MOVE" , % THIS.BUTTON_ID4 , % "X" THIS.X + 1 " Y" THIS.Y + 1 + THIS.TEXT_OFFSET
			SLEEP , -1
			GUICONTROL , % THIS.WINDOW_NAME ": HIDE" , THIS.BUTTON_ID2
			GUICONTROL , % THIS.WINDOW_NAME ": +BACKGROUND" THIS.TOP_COLOR_3 , % THIS.BUTTON_ID3
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID1
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID3
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID4
			WHILE( GETKEYSTATE( "LBUTTON" ) )
				SLEEP , 10
			MOUSEGETPOS , , , , CTRL , 2
			GUICONTROLGET , CNAME , % WIN ": NAME" , % CTRL
			CUT := STRLEN( CNAME )
			STRINGLEFT , BNAME , CNAME , CUT - 2
			IF( BNAME = THIS.BUTTON_NAME ) {
				GUICONTROL , % THIS.WINDOW_NAME ": SHOW" , THIS.BUTTON_ID2
				GUICONTROL , % THIS.WINDOW_NAME ": +BACKGROUND" THIS.TOP_COLOR_1 , % THIS.BUTTON_ID3
				GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID1
				GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID2
				GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID3
				GUICONTROL , % THIS.WINDOW_NAME ": MOVE" , % THIS.BUTTON_ID4 , % "X" THIS.X " Y" THIS.Y + THIS.TEXT_OFFSET
				GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID4
				%BNAME%.BUTTON_HOVER_ON()
				HOVER_ON := 0 , ACTIVE_BUTTON := BNAME , PRESS_ACTIVE := 0
				SLEEP , 10
				RETURN TRUE
			}
			GUICONTROL , % THIS.WINDOW_NAME ": SHOW" , THIS.BUTTON_ID2
			GUICONTROL , % THIS.WINDOW_NAME ": MOVE" , % THIS.BUTTON_ID4 , % "X" THIS.X " Y" THIS.Y + THIS.TEXT_OFFSET
			GUICONTROL , % THIS.WINDOW_NAME ": +BACKGROUND" THIS.TOP_COLOR_1 , % THIS.BUTTON_ID3
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID1
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID2
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID3
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID4
			HOVER_ON := 0 , PRESS_ACTIVE := 0
				SLEEP , 10
				RETURN FALSE
		}
		BUTTON_HOVER_ON(){
			GLOBAL
			GUICONTROL , % THIS.WINDOW_NAME ": +BACKGROUND" THIS.TOP_COLOR_2 , % THIS.BUTTON_ID3
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID4
		}
		BUTTON_HOVER_OFF() {
			GLOBAL
			GUICONTROL , % THIS.WINDOW_NAME ": +BACKGROUND" THIS.TOP_COLOR_1 , % THIS.BUTTON_ID3
			GUICONTROL , % THIS.WINDOW_NAME ": +REDRAW" , % THIS.BUTTON_ID4
		}
	}
Helgef
Posts: 3981
Joined: 17 Jul 2016, 01:02
Contact:

Re: 10K DICE GAME

09 Jan 2019, 04:01

Looks good, well done :thumbup:.

Thanks for sharing, cheers.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: DigiDon, Gh0sTG0, hasantr and 43 guests