Start New Discussion Reply to this Discussion Yahtzee type game
I'm programming a Yahtzee type game, but I have a problem checking for the different scoring types. So far I have everything but Full House, Small Straight and Large straight. It works like this: There are 5 variables (the dice) that are randomized to something between 1 and 6 every roll. I need to figure out a way to check if 1) Two of the variables are the same and three of the variables are also the same but a different number (Full House). Then I need to check if there are 4 variables in sequence (1,2,3,4 for example)(small Straight). Finally I need to check if all 5 are in sequence (large straight). How would I do this? Each of those have their own procedure, I just need to know what to put in there because after struggling a bit I can't seem to figure it out.
Thanks for any help.
Fireprufe15
Light Poster
46 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
For the straight, I got this code, but it doesn't work. Can somebody tell me what's wrong?
var
counter, min, look, K : integer;
temp, iSequence : integer;
for counter:=1 to Top do begin
min:=counter;
for look:=counter+1 to top do
if aDiceScores[look]<aDiceScores[min] then min:=look;
temp:= aDiceScores[min];
aDiceScores[min]:=aDiceScores[counter];
aDiceScores[counter]:=temp;
end;
iSequence := 0;
for K := 1 to 5 do
if aDiceScores[K] + 1 = aDiceScores[K + 1]
then inc(iSequence);
if iSequence = 5 then
iScoreLarge := 40;
Fireprufe15
Light Poster
46 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0591 seconds
using 2.65MB