var dice_to_reroll : string := "string"
var roll : array 1 .. 5 of int
var deroll : int
var dice : int
var dice_roll : array 1 .. 5 of int
var count, name, game : int := 0
var numply : int
var players : array 1 .. 4 of string
var answer : string (1)
var score : array 1 .. 4 of int
var font2, numroll : int
font2 := Font.New ("sans serif:18:bold")
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.Box (0, 0, 100, 100, black)
Draw.Box (100, 0, 200, 100, black)
Draw.Box (200, 0, 300, 100, black)
Draw.Box (300, 0, 400, 100, black)
Draw.Box (400, 0, 500, 100, black)
for i : 1 .. 4
score (i) := 0
end for
%%%%%%%%%DICE%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure one_on_face (di : int)
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.FillOval (di, 50, 6, 6, black)
end one_on_face
procedure two_on_face (di : int)
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.FillOval (di - 20, 50, 6, 6, black)
Draw.FillOval (di + 20, 50, 6, 6, black)
end two_on_face
procedure three_on_face (di : int)
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.FillOval (di, 50, 6, 6, black)
Draw.FillOval (di - 20, 20, 6, 6, black)
Draw.FillOval (di + 20, 80, 6, 6, black)
end three_on_face
procedure four_on_face (di : int)
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.FillOval (di - 20, 20, 6, 6, black)
Draw.FillOval (di + 20, 20, 6, 6, black)
Draw.FillOval (di - 20, 80, 6, 6, black)
Draw.FillOval (di + 20, 80, 6, 6, black)
end four_on_face
procedure five_on_face (di : int)
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.FillOval (di, 50, 6, 6, black)
Draw.FillOval (di - 20, 20, 6, 6, black)
Draw.FillOval (di + 20, 20, 6, 6, black)
Draw.FillOval (di - 20, 80, 6, 6, black)
Draw.FillOval (di + 20, 80, 6, 6, black)
end five_on_face
procedure six_on_face (di : int)
Font.Draw ("DICE 1", 15, 110, font2, red)
Font.Draw ("DICE 2", 115, 110, font2, red)
Font.Draw ("DICE 3", 215, 110, font2, red)
Font.Draw ("DICE 4", 315, 110, font2, red)
Font.Draw ("DICE 5", 415, 110, font2, red)
Draw.FillOval (di - 20, 20, 6, 6, black)
Draw.FillOval (di + 20, 20, 6, 6, black)
Draw.FillOval (di - 20, 80, 6, 6, black)
Draw.FillOval (di + 20, 80, 6, 6, black)
Draw.FillOval (di - 20, 50, 6, 6, black)
Draw.FillOval (di + 20, 50, 6, 6, black)
end six_on_face
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure roll_dice
put "Your Dice Roll"
for i : 1 .. 5
roll (i) := Rand.Int (1, 6)
put "Die ", i, " rolled ", roll (i)
end for
for i : 1 .. 5
if roll (i) = 1 then
one_on_face (100 * i - 50)
elsif roll (i) = 2 then
two_on_face (100 * i - 50)
elsif roll (i) = 3 then
three_on_face (100 * i - 50)
elsif roll (i) = 4 then
four_on_face (100 * i - 50)
elsif roll (i) = 5 then
five_on_face (100 * i - 50)
elsif roll (i) = 6 then
six_on_face (100 * i - 50)
end if
end for
end roll_dice
fcn three_ones_on (roll : array 1 .. * of int) : boolean
var count : int := 0
for i : 1 .. 5
if roll (i) = 1 then
count += 1
end if
end for
if count >= 3 then
result true
else
result false
end if
end three_ones_on
proc selecting_dice_to_reroll
put "which die do u want to reroll? (put 0 for none)"
get dice_to_reroll
if strint (dice_to_reroll) not= 0 then
for i : 1 .. length (dice_to_reroll)
roll (strint (dice_to_reroll (i))) := 0
end for
cls
Draw.Box (0, 0, 100, 100, black)
Draw.Box (100, 0, 200, 100, black)
Draw.Box (200, 0, 300, 100, black)
Draw.Box (300, 0, 400, 100, black)
Draw.Box (400, 0, 500, 100, black)
put "Your Dice Roll"
for i : 1 .. 5
if roll (i) = 0 then
roll (i) := Rand.Int (1, 6)
end if
end for
Draw.Box (0, 0, 100, 100, black)
Draw.Box (100, 0, 200, 100, black)
Draw.Box (200, 0, 300, 100, black)
Draw.Box (300, 0, 400, 100, black)
Draw.Box (400, 0, 500, 100, black)
for i : 1 .. 5
if roll (i) = 1 then
one_on_face (100 * i - 50)
elsif roll (i) = 2 then
two_on_face (100 * i - 50)
elsif roll (i) = 3 then
three_on_face (100 * i - 50)
elsif roll (i) = 4 then
four_on_face (100 * i - 50)
elsif roll (i) = 5 then
five_on_face (100 * i - 50)
elsif roll (i) = 6 then
six_on_face (100 * i - 50)
end if
end for
for i : 1 .. 5
put "Die ", i, " rolled ", roll (i)
end for
end if
end selecting_dice_to_reroll
function straight_on (roll : array 1 .. * of int) : boolean
var one, two, three, four, five, six : boolean := false
for i : 1 .. 5
case roll (i) of
label 1 :
one := true
label 2 :
two := true
label 3 :
three := true
label 4 :
four := true
label 5 :
five := true
label 6 :
six := true
end case
end for
if (one and two and three and four and five) or (two and three and four and five and six) then
result true
else
result false
end if
end straight_on
fcn one_one_on (roll : array 1 .. * of int) : boolean
var count : int := 0
for i : 1 .. 5
if roll (i) = 1 then
count += 1
end if
end for
if count >= 1 then
result true
else
result false
end if
end one_one_on
fcn two_ones_on (roll : array 1 .. * of int) : boolean
var count : int := 0
for i : 1 .. 5
if roll (i) = 1 then
count += 1
end if
end for
if count >= 2 then
result true
else
result false
end if
end two_ones_on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
put "Please enter the number of turns"
get numroll
put "Please enter the number of players, 4 max"
get numply
loop
for i : 1 .. numply
name += 1
put "enter player ", i, "'s name."
get players (name) : *
end for
exit when name = 4 or name = numply
end loop
for r : 1 .. numroll
name += 1
cls
Draw.Box (0, 0, 100, 100, black)
Draw.Box (100, 0, 200, 100, black)
Draw.Box (200, 0, 300, 100, black)
Draw.Box (300, 0, 400, 100, black)
Draw.Box (400, 0, 500, 100, black)
for p : 1 .. numply
roll_dice
put "\nIt is ", players (p), "'s turn"
if three_ones_on (roll) then
count += 800
end if
loop
selecting_dice_to_reroll
if straight_on (roll) then
count += 1000
end if
if one_one_on (roll) then
count += 100
end if
if two_ones_on (roll) then
count += 100
end if
put players (p), "'s count is at ", count, ""
put "Currently ", players (p), "score is ", score (p), "."
put "Do you want to add count to score. Y or N"
getch (answer)
if answer = "y" then
score (p) += count
exit
else
count := 0
end if
put "Currently ", players (p), "score is ", score (p), "."
end loop
for i : 1 .. numply
put "player ", i, "s current score is ", score (i), "."
end for
cls
Draw.Box (0, 0, 100, 100, black)
Draw.Box (100, 0, 200, 100, black)
Draw.Box (200, 0, 300, 100, black)
Draw.Box (300, 0, 400, 100, black)
Draw.Box (400, 0, 500, 100, black)
count := 0
end for
put "\n\tScore"
for i : 1 .. numply
put players (i) : 20, score (i)
end for
end for
|