All pastes #31390 Raw Edit

triple triad

public text v1 · immutable
#31390 ·published 2005-11-27 05:48 UTC
rendered paste body
proc drawgrid (centfont, namefont : int)
    for x : 170 .. 530 by 120
        drawline (x, 5, x, 485, black)
    end for
    for y : 5 .. 485 by 160
        drawline (170, y, 530, y, black)
    end for
    Font.Draw ("Triple Triad", 210, 230, centfont, black)
    Font.Draw ("Computer", 13, 500, namefont, red)
    Font.Draw ("Human", 616, 500, namefont, blue)
end drawgrid


proc makehands (var ch : string, var filenum, randcard : int, var top, left, right, bottom : array 0 .. *, 1 .. * of int, var namearray : array 0 .. *, 1 .. * of string)

    var count : boolean := false
    var boolcard : array 1 .. 28 of boolean

    for b : 1 .. upper (boolcard)
        boolcard (b) := true
    end for

    for j : 1 .. 2
        loop
            open : filenum, "cards.zip", get
            count := false
            randint (randcard, 1, 7)
            loop
                exit when eof (filenum)
                get : filenum, ch : *
                if (strint (ch (1)) * 10 + strint (ch (2))) = randcard and boolcard (randcard) = true then
                    top (j, 1) := strint (ch (4))
                    left (j, 1) := strint (ch (5))
                    right (j, 1) := strint (ch (6))
                    bottom (j, 1) := strint (ch (7))
                    namearray (j, 1) := ch (9 .. *)
                    boolcard (randcard) := false
                    count := true
                end if
            end loop
            close : filenum
            exit when count = true
        end loop

        for i : 2 .. 4
            loop
                open : filenum, "cards.zip", get
                count := false
                randint (randcard, 8, 21)
                loop
                    exit when eof (filenum)
                    get : filenum, ch : *
                    if (strint (ch (1)) * 10 + strint (ch (2))) = randcard and boolcard (randcard) = true then
                        top (j, i) := strint (ch (4))
                        left (j, i) := strint (ch (5))
                        right (j, i) := strint (ch (6))
                        bottom (j, i) := strint (ch (7))
                        namearray (j, i) := ch (9 .. *)
                        boolcard (randcard) := false
                        count := true
                    end if
                end loop
                close : filenum
                exit when count = true
            end loop
        end for
        loop
            open : filenum, "cards.zip", get
            count := false
            randint (randcard, 22, 28)
            loop
                exit when eof (filenum)
                get : filenum, ch : *
                if (strint (ch (1)) * 10 + strint (ch (2))) = randcard and boolcard (randcard) = true then
                    top (j, 5) := strint (ch (4))
                    left (j, 5) := strint (ch (5))
                    right (j, 5) := strint (ch (6))
                    bottom (j, 5) := strint (ch (7))
                    namearray (j, 5) := ch (9 .. *)
                    boolcard (randcard) := false
                    count := true
                end if
            end loop
            close : filenum
            exit when count = true
        end loop
    end for

end makehands


proc cardpicset (var bluearray, redarray : array 0 .. *, 1 .. * of int, namearray : array 0 .. *, 1 .. * of string)
    for i : 1 .. 2
        for j : 1 .. 5
            bluearray (i, j) := Pic.FileNew ("pics/" + namearray (i, j) + "blue.bmp")
            redarray (i, j) := Pic.FileNew ("pics/" + namearray (i, j) + "red.bmp")
        end for
    end for
end cardpicset


proc drawcards (cardback, cardfont : int, bluearray, top, left, right, bottom : array 0 .. *, 1 .. * of int, namearray : array 0 .. *, 1 .. * of string)
    for decreasing i : 5 .. 1
        Pic.Draw (cardback, 20, i * 55, picCopy)
    end for

    Pic.Draw (bluearray (2, 4), 544, 2, picCopy)
    Font.Draw (intstr (top (2, 4)), 556, 142, cardfont, black)
    Font.Draw (intstr (left (2, 4)) + "  " + intstr (right (2, 4)), 548, 132, cardfont, black)
    Font.Draw (intstr (bottom (2, 4)), 556, 122, cardfont, black)
    Font.Draw (namearray (2, 4), 575, 142, cardfont, black)

    Pic.Draw (bluearray (2, 5), 666, 2, picCopy)
    Font.Draw (intstr (top (2, 5)), 678, 142, cardfont, black)
    Font.Draw (intstr (left (2, 5)) + "  " + intstr (right (2, 5)), 670, 132, cardfont, black)
    Font.Draw (intstr (bottom (2, 5)), 678, 122, cardfont, black)
    Font.Draw (namearray (2, 5), 697, 142, cardfont, black)

    Pic.Draw (bluearray (2, 2), 544, 164, picCopy)
    Font.Draw (intstr (top (2, 2)), 556, 304, cardfont, black)
    Font.Draw (intstr (left (2, 2)) + "  " + intstr (right (2, 2)), 548, 294, cardfont, black)
    Font.Draw (intstr (bottom (2, 2)), 556, 284, cardfont, black)
    Font.Draw (namearray (2, 2), 575, 304, cardfont, black)

    Pic.Draw (bluearray (2, 3), 666, 164, picCopy)
    Font.Draw (intstr (top (2, 3)), 678, 304, cardfont, black)
    Font.Draw (intstr (left (2, 3)) + "  " + intstr (right (2, 3)), 670, 294, cardfont, black)
    Font.Draw (intstr (bottom (2, 3)), 678, 284, cardfont, black)
    Font.Draw (namearray (2, 3), 697, 304, cardfont, black)

    Pic.Draw (bluearray (2, 1), 605, 326, picCopy)
    Font.Draw (intstr (top (2, 1)), 617, 466, cardfont, black)
    Font.Draw (intstr (left (2, 1)) + "  " + intstr (right (2, 1)), 609, 456, cardfont, black)
    Font.Draw (intstr (bottom (2, 1)), 617, 446, cardfont, black)
    Font.Draw (namearray (2, 1), 636, 466, cardfont, black)

end drawcards


proc selectcard (var selectnum, mx, my, mb : int, var cardboolean : array 1 .. * of boolean)
    mousewhere (mx, my, mb)
    if mb = 1 and mx >= 544 and mx <= 664 and my >= 2 and my <= 162 and cardboolean (4) = true then
        loop
            mousewhere (mx, my, mb)
            exit when mb = 0
        end loop
        if selectnum = 0 then
            drawbox (543, 1, 664, 162, yellow)
        elsif selectnum = 1 then
            drawbox (604, 325, 725, 486, brown)
            drawbox (543, 1, 664, 162, yellow)
        elsif selectnum = 2 then
            drawbox (543, 163, 664, 324, brown)
            drawbox (543, 1, 664, 162, yellow)
        elsif selectnum = 3 then
            drawbox (665, 163, 786, 324, brown)
            drawbox (543, 1, 664, 162, yellow)
        elsif selectnum = 4 then
        elsif selectnum = 5 then
            drawbox (665, 1, 786, 162, brown)
            drawbox (543, 1, 664, 162, yellow)
        end if
        selectnum := 4
    elsif mb = 1 and mx >= 665 and mx <= 786 and my >= 2 and my <= 162 and cardboolean (5) = true then
        loop
            mousewhere (mx, my, mb)
            exit when mb = 0
        end loop
        if selectnum = 0 then
            drawbox (665, 1, 786, 162, yellow)
        elsif selectnum = 1 then
            drawbox (604, 325, 725, 486, brown)
            drawbox (665, 1, 786, 162, yellow)
        elsif selectnum = 2 then
            drawbox (543, 163, 664, 324, brown)
            drawbox (665, 1, 786, 162, yellow)
        elsif selectnum = 3 then
            drawbox (665, 163, 786, 324, brown)
            drawbox (665, 1, 786, 162, yellow)
        elsif selectnum = 4 then
            drawbox (543, 1, 664, 162, brown)
            drawbox (665, 1, 786, 162, yellow)
        elsif selectnum = 5 then
        end if
        selectnum := 5
    elsif mb = 1 and mx >= 544 and mx <= 664 and my >= 163 and my <= 324 and cardboolean (2) = true then
        loop
            mousewhere (mx, my, mb)
            exit when mb = 0
        end loop
        if selectnum = 0 then
            drawbox (543, 163, 664, 324, yellow)
        elsif selectnum = 1 then
            drawbox (604, 325, 725, 486, brown)
            drawbox (543, 163, 664, 324, yellow)
        elsif selectnum = 2 then
        elsif selectnum = 3 then
            drawbox (665, 163, 786, 324, brown)
            drawbox (543, 163, 664, 324, yellow)
        elsif selectnum = 4 then
            drawbox (543, 1, 664, 162, brown)
            drawbox (543, 163, 664, 324, yellow)
        elsif selectnum = 5 then
            drawbox (665, 1, 786, 162, brown)
            drawbox (543, 163, 664, 324, yellow)
        end if
        selectnum := 2
    elsif mb = 1 and mx >= 665 and mx <= 786 and my >= 163 and my <= 324 and cardboolean (3) = true then
        loop
            mousewhere (mx, my, mb)
            exit when mb = 0
        end loop
        if selectnum = 0 then
            drawbox (665, 163, 786, 324, yellow)
        elsif selectnum = 1 then
            drawbox (604, 325, 725, 486, brown)
            drawbox (665, 163, 786, 324, yellow)
        elsif selectnum = 2 then
            drawbox (543, 163, 664, 324, brown)
            drawbox (665, 163, 786, 324, yellow)
        elsif selectnum = 3 then
        elsif selectnum = 4 then
            drawbox (543, 1, 664, 162, brown)
            drawbox (665, 163, 786, 324, yellow)
        elsif selectnum = 5 then
            drawbox (665, 1, 786, 162, brown)
            drawbox (665, 163, 786, 324, yellow)
        end if
        selectnum := 3
    elsif mb = 1 and mx >= 604 and mx <= 725 and my >= 325 and my <= 486 and cardboolean (1) = true then
        loop
            mousewhere (mx, my, mb)
            exit when mb = 0
        end loop
        if selectnum = 0 then
            drawbox (604, 325, 725, 486, yellow)
        elsif selectnum = 1 then
        elsif selectnum = 2 then
            drawbox (543, 163, 664, 324, brown)
            drawbox (604, 325, 725, 486, yellow)
        elsif selectnum = 3 then
            drawbox (665, 163, 786, 324, brown)
            drawbox (604, 325, 725, 486, yellow)
        elsif selectnum = 4 then
            drawbox (543, 1, 664, 162, brown)
            drawbox (604, 325, 725, 486, yellow)
        elsif selectnum = 5 then
            drawbox (665, 1, 786, 162, brown)
            drawbox (604, 325, 725, 486, yellow)
        end if
        selectnum := 1
    end if
end selectcard


proc gridcard (var turn : boolean, var mx, my, mb, selectnum, cardfont, cardcount, hscore, cscore : int, var spotstatus : array 0 .. *, 0 .. * of string, namearray : array 0 .. *, 1 .. * of string,
        top, left, right, bottom, bluearray : array 0 .. *, 1 .. * of int,
        x, y : array 1 .. * of int, var cardboolean : array 1 .. * of boolean)

    for a : 1 .. 3
        for b : 1 .. 3
            mousewhere (mx, my, mb)
            if mb = 1 and mx > x (a) and mx < x (a + 1) and my < y (b) and my > y (b + 1) and selectnum not= 0 and spotstatus (a, b) = "free50" then
                loop
                    mousewhere (mx, my, mb)
                    exit when mb = 0
                end loop
                if selectnum = 1 then
                    drawfillbox (604, 325, 725, 486, brown)
                elsif selectnum = 2 then
                    drawfillbox (543, 163, 664, 324, brown)
                elsif selectnum = 3 then
                    drawfillbox (665, 163, 786, 324, brown)
                elsif selectnum = 4 then
                    drawfillbox (543, 1, 664, 162, brown)
                elsif selectnum = 5 then
                    drawfillbox (665, 1, 786, 162, brown)
                end if
                cardboolean (selectnum) := false
                for i : 1 .. 5
                    if selectnum = i then
                        Pic.Draw (bluearray (2, i), x (a), y (b + 1), picCopy)
                        Font.Draw (intstr (top (2, i)), x (a) + 12, y (b + 1) + 140, cardfont, black)
                        Font.Draw (intstr (left (2, i)) + "  " + intstr (right (2, i)), x (a) + 4, y (b + 1) + 130, cardfont, black)
                        Font.Draw (intstr (bottom (2, i)), x (a) + 12, y (b + 1) + 120, cardfont, black)
                        Font.Draw (namearray (2, i), x (a) + 31, y (b + 1) + 140, cardfont, black)
                        spotstatus (a, b) := "blue" + intstr (selectnum) + "2"
                        selectnum := 0
                    end if
                end for
                View.Update
                Music.PlayFile ("snap.wav")
                if spotstatus (a, b + 1) (1 .. 4) = "redd" and bottom (strint (spotstatus (a, b) (6)), strint (spotstatus (a, b) (5))) > top (strint (spotstatus (a, b + 1) (6)),
                        strint (spotstatus (a, b + 1) (5))) then
                    Pic.Draw (bluearray (strint (spotstatus (a, b + 1) (6)), strint (spotstatus (a, b + 1) (5))), x (a), y (b + 2), picCopy)
                    Font.Draw (intstr (top (strint (spotstatus (a, b + 1) (6)), strint (spotstatus (a, b + 1) (5)))), x (a) + 12, y (b + 2) + 140, cardfont, black)
                    Font.Draw (intstr (left (strint (spotstatus (a, b + 1) (6)), strint (spotstatus (a, b + 1) (5)))) + "  " + intstr (right (strint (spotstatus (a, b + 1) (6)),
                        strint (spotstatus (a, b + 1) (5)))), x (a) + 4, y (b + 2) + 130, cardfont, black)
                    Font.Draw (intstr (bottom (strint (spotstatus (a, b + 1) (6)), strint (spotstatus (a, b + 1) (5)))), x (a) + 12, y (b + 2) + 120, cardfont, black)
                    Font.Draw (namearray (strint (spotstatus (a, b + 1) (6)), strint (spotstatus (a, b + 1) (5))), x (a) + 31, y (b + 2) + 140, cardfont, black)
                    hscore += 1
                    cscore -= 1
                    spotstatus (a, b + 1) := "blue" + spotstatus (a, b + 1) (5 .. 6)
                    View.Update
                    Music.PlayFile ("swish.wav")
                end if
                if spotstatus (a, b - 1) (1 .. 4) = "redd" and top (strint (spotstatus (a, b) (6)), strint (spotstatus (a, b) (5))) > bottom (strint (spotstatus (a, b - 1) (6)),
                        strint (spotstatus (a, b - 1) (5))) then
                    Pic.Draw (bluearray (strint (spotstatus (a, b - 1) (6)), strint (spotstatus (a, b - 1) (5))), x (a), y (b), picCopy)
                    Font.Draw (intstr (top (strint (spotstatus (a, b - 1) (6)), strint (spotstatus (a, b - 1) (5)))), x (a) + 12, y (b) + 140, cardfont, black)
                    Font.Draw (intstr (left (strint (spotstatus (a, b - 1) (6)), strint (spotstatus (a, b - 1) (5)))) + "  " + intstr (right (strint (spotstatus (a, b - 1) (6)),
                        strint (spotstatus (a, b - 1) (5)))), x (a) + 4, y (b) + 130, cardfont, black)
                    Font.Draw (intstr (bottom (strint (spotstatus (a, b - 1) (6)), strint (spotstatus (a, b - 1) (5)))), x (a) + 12, y (b) + 120, cardfont, black)
                    Font.Draw (namearray (strint (spotstatus (a, b - 1) (6)), strint (spotstatus (a, b - 1) (5))), x (a) + 31, y (b) + 140, cardfont, black)
                    hscore += 1
                    cscore -= 1
                    spotstatus (a, b - 1) := "blue" + spotstatus (a, b - 1) (5 .. 6)
                    View.Update
                    Music.PlayFile ("swish.wav")
                end if
                if spotstatus (a + 1, b) (1 .. 4) = "redd" and right (strint (spotstatus (a, b) (6)), strint (spotstatus (a, b) (5))) > left (strint (spotstatus (a + 1, b) (6)),
                        strint (spotstatus (a + 1, b) (5))) then
                    Pic.Draw (bluearray (strint (spotstatus (a + 1, b) (6)), strint (spotstatus (a + 1, b) (5))), x (a + 1), y (b + 1), picCopy)
                    Font.Draw (intstr (top (strint (spotstatus (a + 1, b) (6)), strint (spotstatus (a + 1, b) (5)))), x (a + 1) + 12, y (b + 1) + 140, cardfont, black)
                    Font.Draw (intstr (left (strint (spotstatus (a + 1, b) (6)), strint (spotstatus (a + 1, b) (5)))) + "  " + intstr (right (strint (spotstatus (a + 1, b) (6)),
                        strint (spotstatus (a + 1, b) (5)))), x (a + 1) + 4, y (b + 1) + 130, cardfont, black)
                    Font.Draw (intstr (bottom (strint (spotstatus (a + 1, b) (6)), strint (spotstatus (a + 1, b) (5)))), x (a + 1) + 12, y (b + 1) + 120, cardfont, black)
                    Font.Draw (namearray (strint (spotstatus (a + 1, b) (6)), strint (spotstatus (a + 1, b) (5))), x (a + 1) + 31, y (b + 1) + 140, cardfont, black)
                    hscore += 1
                    cscore -= 1
                    spotstatus (a + 1, b) := "blue" + spotstatus (a + 1, b) (5 .. 6)
                    View.Update
                    Music.PlayFile ("swish.wav")
                end if
                if spotstatus (a - 1, b) (1 .. 4) = "redd" and left (strint (spotstatus (a, b) (6)), strint (spotstatus (a, b) (5))) > right (strint (spotstatus (a - 1, b) (6)),
                        strint (spotstatus (a - 1, b) (5))) then
                    Pic.Draw (bluearray (strint (spotstatus (a - 1, b) (6)), strint (spotstatus (a - 1, b) (5))), x (a - 1), y (b + 1), picCopy)
                    Font.Draw (intstr (top (strint (spotstatus (a - 1, b) (6)), strint (spotstatus (a - 1, b) (5)))), x (a - 1) + 12, y (b + 1) + 140, cardfont, black)
                    Font.Draw (intstr (left (strint (spotstatus (a - 1, b) (6)), strint (spotstatus (a - 1, b) (5)))) + "  " + intstr (right (strint (spotstatus (a - 1, b) (6)),
                        strint (spotstatus (a - 1, b) (5)))), x (a - 1) + 4, y (b + 1) + 130, cardfont, black)
                    Font.Draw (intstr (bottom (strint (spotstatus (a - 1, b) (6)), strint (spotstatus (a - 1, b) (5)))), x (a - 1) + 12, y (b + 1) + 120, cardfont, black)
                    Font.Draw (namearray (strint (spotstatus (a - 1, b) (6)), strint (spotstatus (a - 1, b) (5))), x (a - 1) + 31, y (b + 1) + 140, cardfont, black)
                    hscore += 1
                    cscore -= 1
                    spotstatus (a - 1, b) := "blue" + spotstatus (a - 1, b) (5 .. 6)
                    View.Update
                    Music.PlayFile ("swish.wav")
                end if
                turn := false
                cardcount += 1
            end if
        end for
    end for
end gridcard



proc aicard (var turn, aibool : boolean, var aicount, cardfont, cardcount, hscore, cscore, diff : int, var spotstatus : array 0 .. *, 0 .. * of string, namearray : array 0 .. *, 1 .. * of string,
        top, left, right, bottom, redarray : array 0 .. *, 1 .. * of int,
        x, y : array 1 .. * of int, var ocardboolean : array 1 .. * of boolean)
    var rx, ry, cselect, intcount, count2 : int := 0

    aicount += 1
    if aicount = 1 then
        drawfillbox (20, 380, 140, 435, brown)
    elsif aicount = 2 then
        drawfillbox (20, 325, 140, 435, brown)
    elsif aicount = 3 then
        drawfillbox (20, 270, 140, 435, brown)
    elsif aicount = 4 then
        drawfillbox (20, 215, 140, 435, brown)
    elsif aicount = 5 then
        drawfillbox (20, 55, 140, 435, brown)
    end if
    View.Update
    delay (250)
    if diff <= 11 then
        loop
            randint (cselect, 1, 5)
            if ocardboolean (cselect) = true then
                ocardboolean (cselect) := false
                aibool := true
            end if
            exit when aibool = true
        end loop
        aibool := false
        loop
            randint (rx, 1, 3)
            randint (ry, 1, 3)
            if spotstatus (rx, ry) = "free50" and ((bottom (1, cselect) > top (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5))) and
                    spotstatus (rx, ry + 1) (1 .. 4) = "blue") or
                    (top (1, cselect) > bottom (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5))) and spotstatus (rx, ry - 1) (1 .. 4) = "blue") or
                    (right (1, cselect) > left (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5))) and spotstatus (rx + 1, ry) (1 .. 4) = "blue") or
                    (left (1, cselect) > right (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5))) and spotstatus (rx - 1, ry) (1 .. 4) = "blue")) or
                    (spotstatus (rx, ry) = "free50" and intcount >= diff) then
                Pic.Draw (redarray (1, cselect), x (rx), y (ry + 1), picCopy)
                Font.Draw (intstr (top (1, cselect)), x (rx) + 12, y (ry + 1) + 140, cardfont, black)
                Font.Draw (intstr (left (1, cselect)) + "  " + intstr (right (1, cselect)), x (rx) + 4, y (ry + 1) + 130, cardfont, black)
                Font.Draw (intstr (bottom (1, cselect)), x (rx) + 12, y (ry + 1) + 120, cardfont, black)
                Font.Draw (namearray (1, cselect), x (rx) + 31, y (ry + 1) + 140, cardfont, black)
                spotstatus (rx, ry) := "redd" + intstr (cselect) + "1"
                aibool := true
            end if
            intcount += 1
            exit when aibool = true
        end loop
    elsif diff >= 12 then
        loop
            loop
                randint (cselect, 1, 5)
                if ocardboolean (cselect) = true then
                    aibool := true
                    count2 += 1
                end if
                exit when aibool = true
            end loop
            aibool := false
            loop
                randint (rx, 1, 3)
                randint (ry, 1, 3)
                if spotstatus (rx, ry) = "free50" and ((bottom (1, cselect) > top (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5))) and
                        spotstatus (rx, ry + 1) (1 .. 4) = "blue") or
                        (top (1, cselect) > bottom (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5))) and spotstatus (rx, ry - 1) (1 .. 4) = "blue") or
                        (right (1, cselect) > left (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5))) and spotstatus (rx + 1, ry) (1 .. 4) = "blue") or
                        (left (1, cselect) > right (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5))) and spotstatus (rx - 1, ry) (1 .. 4) = "blue")) or
                        (spotstatus (rx, ry) = "free50" and count2 >= 7) then
                    Pic.Draw (redarray (1, cselect), x (rx), y (ry + 1), picCopy)
                    Font.Draw (intstr (top (1, cselect)), x (rx) + 12, y (ry + 1) + 140, cardfont, black)
                    Font.Draw (intstr (left (1, cselect)) + "  " + intstr (right (1, cselect)), x (rx) + 4, y (ry + 1) + 130, cardfont, black)
                    Font.Draw (intstr (bottom (1, cselect)), x (rx) + 12, y (ry + 1) + 120, cardfont, black)
                    Font.Draw (namearray (1, cselect), x (rx) + 31, y (ry + 1) + 140, cardfont, black)
                    spotstatus (rx, ry) := "redd" + intstr (cselect) + "1"
                    aibool := true
                    ocardboolean (cselect) := false
                end if
                intcount += 1
                exit when aibool = true or intcount >= diff
            end loop
            exit when aibool = true
        end loop
    end if
    View.Update
    Music.PlayFile ("snap.wav")
    if spotstatus (rx, ry + 1) (1 .. 4) = "blue" and bottom (strint (spotstatus (rx, ry) (6)), strint (spotstatus (rx, ry) (5))) > top (strint (spotstatus (rx, ry + 1) (6)),
            strint (spotstatus (rx, ry + 1) (5))) then
        Pic.Draw (redarray (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5))), x (rx), y (ry + 2), picCopy)
        Font.Draw (intstr (top (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5)))), x (rx) + 12, y (ry + 2) + 140, cardfont, black)
        Font.Draw (intstr (left (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5)))) + "  " + intstr (right (strint (spotstatus (rx, ry + 1) (6)),
            strint (spotstatus (rx, ry + 1) (5)))), x (rx) + 4, y (ry + 2) + 130, cardfont, black)
        Font.Draw (intstr (bottom (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5)))), x (rx) + 12, y (ry + 2) + 120, cardfont, black)
        Font.Draw (namearray (strint (spotstatus (rx, ry + 1) (6)), strint (spotstatus (rx, ry + 1) (5))), x (rx) + 31, y (ry + 2) + 140, cardfont, black)
        hscore -= 1
        cscore += 1
        spotstatus (rx, ry + 1) := "redd" + spotstatus (rx, ry + 1) (5 .. 6)
        View.Update
        Music.PlayFile ("swish.wav")
    end if
    if spotstatus (rx, ry - 1) (1 .. 4) = "blue" and top (strint (spotstatus (rx, ry) (6)), strint (spotstatus (rx, ry) (5))) > bottom (strint (spotstatus (rx, ry - 1) (6)),
            strint (spotstatus (rx, ry - 1) (5))) then
        Pic.Draw (redarray (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5))), x (rx), y (ry), picCopy)
        Font.Draw (intstr (top (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5)))), x (rx) + 12, y (ry) + 140, cardfont, black)
        Font.Draw (intstr (left (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5)))) + "  " + intstr (right (strint (spotstatus (rx, ry - 1) (6)),
            strint (spotstatus (rx, ry - 1) (5)))), x (rx) + 4, y (ry) + 130, cardfont, black)
        Font.Draw (intstr (bottom (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5)))), x (rx) + 12, y (ry) + 120, cardfont, black)
        Font.Draw (namearray (strint (spotstatus (rx, ry - 1) (6)), strint (spotstatus (rx, ry - 1) (5))), x (rx) + 31, y (ry) + 140, cardfont, black)
        hscore -= 1
        cscore += 1
        spotstatus (rx, ry - 1) := "redd" + spotstatus (rx, ry - 1) (5 .. 6)
        View.Update
        Music.PlayFile ("swish.wav")
    end if
    if spotstatus (rx + 1, ry) (1 .. 4) = "blue" and right (strint (spotstatus (rx, ry) (6)), strint (spotstatus (rx, ry) (5))) > left (strint (spotstatus (rx + 1, ry) (6)),
            strint (spotstatus (rx + 1, ry) (5))) then
        Pic.Draw (redarray (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5))), x (rx + 1), y (ry + 1), picCopy)
        Font.Draw (intstr (top (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5)))), x (rx + 1) + 12, y (ry + 1) + 140, cardfont, black)
        Font.Draw (intstr (left (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5)))) + "  " + intstr (right (strint (spotstatus (rx + 1, ry) (6)),
            strint (spotstatus (rx + 1, ry) (5)))), x (rx + 1) + 4, y (ry + 1) + 130, cardfont, black)
        Font.Draw (intstr (bottom (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5)))), x (rx + 1) + 12, y (ry + 1) + 120, cardfont, black)
        Font.Draw (namearray (strint (spotstatus (rx + 1, ry) (6)), strint (spotstatus (rx + 1, ry) (5))), x (rx + 1) + 31, y (ry + 1) + 140, cardfont, black)
        hscore -= 1
        cscore += 1
        spotstatus (rx + 1, ry) := "redd" + spotstatus (rx + 1, ry) (5 .. 6)
        View.Update
        Music.PlayFile ("swish.wav")
    end if
    if spotstatus (rx - 1, ry) (1 .. 4) = "blue" and left (strint (spotstatus (rx, ry) (6)), strint (spotstatus (rx, ry) (5))) > right (strint (spotstatus (rx - 1, ry) (6)),
            strint (spotstatus (rx - 1, ry) (5))) then
        Pic.Draw (redarray (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5))), x (rx - 1), y (ry + 1), picCopy)
        Font.Draw (intstr (top (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5)))), x (rx - 1) + 12, y (ry + 1) + 140, cardfont, black)
        Font.Draw (intstr (left (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5)))) + "  " + intstr (right (strint (spotstatus (rx - 1, ry) (6)),
            strint (spotstatus (rx - 1, ry) (5)))), x (rx - 1) + 4, y (ry + 1) + 130, cardfont, black)
        Font.Draw (intstr (bottom (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5)))), x (rx - 1) + 12, y (ry + 1) + 120, cardfont, black)
        Font.Draw (namearray (strint (spotstatus (rx - 1, ry) (6)), strint (spotstatus (rx - 1, ry) (5))), x (rx - 1) + 31, y (ry + 1) + 140, cardfont, black)
        hscore -= 1
        cscore += 1
        spotstatus (rx - 1, ry) := "redd" + spotstatus (rx - 1, ry) (5 .. 6)
        View.Update
        Music.PlayFile ("swish.wav")
    end if
    cardcount += 1
    aibool := false
    turn := true
end aicard


proc scoredisplay (cscore, hscore, centfont : int)
    drawfillbox (20, 535, 100, 580, brown)
    drawfillbox (600, 535, 800, 580, brown)
    Font.Draw (intstr (cscore), 70, 540, centfont, red)
    Font.Draw (intstr (hscore), 655, 540, centfont, blue)
end scoredisplay


proc initproc (var randcard, aicount, hscore, cscore, selectnum, cardcount : int, var cardboolean, ocardboolean : array 1 .. * of boolean,
        var turn, aibool : boolean, var spotstatus : array 0 .. *, 0 .. * of string, var top, left, right, bottom : array 0 .. *, 1 .. * of int)
    randint (randcard, 1, 2)
    if randcard = 1 then
        turn := true
    elsif randcard = 2 then
        turn := false
    end if
    for i : 1 .. 5
        cardboolean (i) := true
        ocardboolean (i) := true
        top (0, i) := 9
        left (0, i) := 9
        right (0, i) := 9
        bottom (0, i) := 9
    end for
    for i : 0 .. 4
        for j : 0 .. 4
            spotstatus (i, j) := "free50"
        end for
    end for
    aibool := true
    aicount := 0
    hscore := 5
    cscore := 5
    selectnum := 0
    cardcount := 0
end initproc


proc splash (var splashpic, mx, my, mb, diff : int)
    Pic.Draw (splashpic, 0, 0, picCopy)
    loop
        mousewhere (mx, my, mb)
        if mb = 1 and mx >= 100 and mx <= 250 and my >= 100 and my <= 175 then
            diff := 3
        elsif mb = 1 and mx >= 325 and mx <= 475 and my >= 100 and my <= 175 then
            diff := 10
        elsif mb = 1 and mx >= 550 and mx <= 700 and my >= 100 and my <= 175 then
            diff := 20
        elsif mb = 1 and mx >= 265 and mx <= 356 and my >= 4 and my <= 41 then
            Music.PlayFileStop
            Music.PlayFileLoop ("powerrangers.mp3")
        elsif mb = 1 and mx >= 376 and mx <= 467 and my >= 4 and my <= 41 then
            Music.PlayFileStop
            Music.PlayFileLoop ("lostinspace.mp3")
        elsif mb = 1 and mx >= 484 and mx <= 575 and my >= 4 and my <= 41 then
            Music.PlayFileStop
            Music.PlayFileLoop ("endlesschallenge.mp3")
        elsif mb = 1 and mx >= 594 and mx <= 643 and my >= 4 and my <= 41 then
            Music.PlayFileStop
        end if
        exit when diff not= 0
    end loop
    loop
        mousewhere (mx, my, mb)
        exit when mb = 0
    end loop
end splash


process music (mx, my, mb, cardfont : int)
    Font.Draw ("Music:     Song 1     Song 2     Song 3     Off", 205, 584, cardfont, black)
    if mb = 1 and mx >= 269 and mx <= 319 and my >= 580 and my <= 597 then
        Music.PlayFileStop
        Music.PlayFileLoop ("powerrangers.mp3")
    elsif mb = 1 and mx >= 339 and mx <= 390 and my >= 580 and my <= 597 then
        Music.PlayFileStop
        Music.PlayFileLoop ("lostinspace.mp3")
    elsif mb = 1 and mx >= 408 and mx <= 460 and my >= 580 and my <= 597 then
        Music.PlayFileStop
        Music.PlayFileLoop ("endlesschallenge.mp3")
    elsif mb = 1 and mx >= 478 and mx <= 502 and my >= 580 and my <= 597 then
        Music.PlayFileStop
    end if
end music


%%%%%%%%%%%%%%%%%%%

View.Set ("graphics:800,600")
View.Set ("offscreenonly")

var mx, my, mb : int
var centfont : int := Font.New ("arial black:33")
var cardfont : int := Font.New ("arial:12")
var namefont : int := Font.New ("arial black:20")
var cardback : int := Pic.FileNew ("pics/cardback.bmp")
var splashpic : int := Pic.FileNew ("pics/splash.jpg")
var arrowfalse : int := Pic.FileNew ("pics/arrowfalse.bmp")
var arrowtrue : int := Pic.FileNew ("pics/arrowtrue.bmp")
var filenum : int
var ch : string
var turn : boolean
var randcard : int
var aicount : int
var aibool : boolean
var top, left, right, bottom, bluearray, redarray : array 0 .. 2, 1 .. 5 of int
var namearray : array 0 .. 2, 1 .. 5 of string
var cardboolean, ocardboolean : array 1 .. 5 of boolean
var selectnum, cardcount : int
var hscore, cscore : int
var diff : int := 0
var spotstatus : array 0 .. 4, 0 .. 4 of string
var x : array 1 .. 4 of int := init (170, 290, 410, 530)
var y : array 1 .. 4 of int := init (485, 325, 165, 5)

%%%%%%%%%%%%%%%%%%%%

randomize
splash (splashpic, mx, my, mb, diff)
loop
    initproc (randcard, aicount, hscore, cscore, selectnum, cardcount, cardboolean, ocardboolean, turn, aibool, spotstatus, top, left, right, bottom)
    makehands (ch, filenum, randcard, top, left, right, bottom, namearray)
    cardpicset (bluearray, redarray, namearray)
    cls
    drawfill (1, 1, brown, brown)
    drawgrid (centfont, namefont)
    drawcards (cardback, cardfont, bluearray, top, left, right, bottom, namearray)
    loop
        fork music (mx, my, mb, cardfont)
        scoredisplay (cscore, hscore, centfont)
        if turn = true and cardcount not= 9 then
            selectcard (selectnum, mx, my, mb, cardboolean)
            gridcard (turn, mx, my, mb, selectnum, cardfont, cardcount, hscore, cscore, spotstatus, namearray, top, left, right, bottom, bluearray, x, y, cardboolean)
            Pic.Draw (arrowfalse, 300, 500, picCopy)
        else
            Pic.Draw (arrowtrue, 300, 500, picCopy)
            aicard (turn, aibool, aicount, cardfont, cardcount, hscore, cscore, diff, spotstatus, namearray, top, left, right, bottom, redarray, x, y, ocardboolean)
        end if
        View.Update
        exit when cardcount = 9
    end loop
    scoredisplay (cscore, hscore, centfont)
    drawfillbox (300, 500, 404, 575, brown)
    View.Update
    delay (250)
    if hscore > cscore then
        Font.Draw ("You Win!", 250, 520, centfont, yellow)
    elsif hscore = cscore then
        Font.Draw ("Tie Game", 250, 520, centfont, yellow)
    elsif hscore < cscore then
        Font.Draw ("You Lose", 250, 520, centfont, yellow)
    end if
    View.Update
    delay (2000)
end loop