/**

@desc shows the result of the dice (only works with three dices)
@form dice_result


**/


dice_result:-
	free(@dice1),
	free(@dice2),
	free(@dice3),
	send(@playground,display,new(@dice1,box(50,50)),point(570,570)),
	send(@dice1,colour,black),
	send(@dice1,fill_pattern,colour(white)),
	send(@dice1,shadow,3),
	send(@dice1,pen,20),
	send(@playground,display,new(@dice2,box(50,50)),point(655,570)),
	send(@dice2,colour,black),
	send(@dice2,fill_pattern,colour(white)),
	send(@dice2,shadow,3),
	send(@dice2,pen,20),
	send(@playground,display,new(@dice3,box(50,50)),point(613,650)),
	send(@dice3,colour,black),
	send(@dice3,fill_pattern,colour(white)),
	send(@dice3,shadow,3),
	send(@dice3,pen,20).

roll_the_dice(LogicList) :-
	dice_colour_wrapper(LogicList,0,ColourList),
	dice_colour_all(ColourList).

dice_colour(Dice,Colour):-
	free(Dice),
	dice(Dice,X,Y),
	send(@playground,display,new(Dice,circle(40)),point(X,Y)),
	send(Dice,pen,1),
	send(Dice,fill_pattern,colour(Colour)),
	send(Dice,colour,black).

dice_colour_all([Colour1,Colour2,Colour3]):-
	dice_result,
	dice_colour(@dice_circle1,Colour1),
	dice_colour(@dice_circle2,Colour2),
	dice_colour(@dice_circle3,Colour3).

hide_dice:-
	free(@dice1),
	free(@dice2),
	free(@dice3),
	free(@dice_circle1),
	free(@dice_circle2),
	free(@dice_circle3).

dice_colour_wrapper([],_,[]).

dice_colour_wrapper([X|R],Acc,[Color|ColorRest]) :-
	X > 0,
	XN is X - 1,
	int2colour(Acc,Color),
	dice_colour_wrapper([XN|R],Acc,ColorRest).

dice_colour_wrapper([0|R],Acc,L) :-
	AccN is Acc + 1,
	dice_colour_wrapper(R,AccN,L).



	
