

-----------------------------------

KONjbnj

Thu May 11, 2006 1:54 pm


BlackJack Help

-----------------------------------

So far, it is running smoothly, but the only problem I have is the ace being counted as 11 or 1. If you have an ace and the total is under 21, it automatically sets to 11. The problem I have is that around the third card, the numbers stop adding up. But when it gets to the fifth or so card, it goes again. How do I get around that?

var pos_x_player : int := 0
var pos_x_dealer : int := 0
var player, dealer : int
var c1, c2, c3 : int
var d1, d2, d3 : int
var acecount : int := 0
var doneace, doneace2 : int := 0
%Dealer Cards
proc dealercards
    d1 := Rand.Int (1, 52)
    d2 := Rand.Int (1, 52)
    if d2 = d1 then
        d2 := Rand.Int (1, 52)
    end if
    dealer := cardtotal (d1)
    locate (4, 30)
    colorback (120)
    color (40)
    put dealer ..
    Pic.Draw (cards (d1), 250, 320, picCopy)
    Pic.Draw (cards (53), 300, 320, picCopy)
end dealercards
%Player Cards
proc playercards
    c1 := Rand.Int (1, 52)
    c2 := Rand.Int (1, 1)
    if c2 = c1 then
        c2 := Rand.Int (1, 52)
    end if
    player := cardtotal (c1) + cardtotal (c2)
    locate (15, 37)
    colorback (120)
    color (40)
    put player ..
    Pic.Draw (cards (c1), 250, 120, picCopy)
    Pic.Draw (cards (c2), 300, 120, picCopy)
end playercards
%Player Hit Cards
proc playerhit
    c3 := Rand.Int (1, 52)
    pos_x_player := pos_x_player + 50
    player := player + cardtotal (c3)
    locate (15, 37)
    colorback (120)
    color (40)
    put player ..
    Pic.Draw (cards (c3), 300 + pos_x_player, 120, picCopy)
end playerhit
%Dealer Hit Cards
proc dealerhit
    var d1 : int
    d1 := Rand.Int (1, 52)
    pos_x_dealer := pos_x_dealer + 50
    dealer := dealer + cardtotal (d1)
    locate (4, 30)
    colorback (120)
    color (40)
    put dealer ..
    Pic.Draw (cards (d1), 300 + pos_x_dealer, 320, picCopy)
end dealerhit
%Setting the Ace value at 1 and 11
proc oneor11c1
    if c1 = 1 or c1 = 14 or c1 = 27 or c1 = 40 then
        acecount := 1
        player := 11 + cardtotal (c2)
    end if
    locate (15, 37)
    colorback (120)
    color (40)
    put player ..
end oneor11c1
proc oneor11c2
    if c2 = 1 or c2 = 14 or c2 = 27 or c2 = 40 and acecount not= 1 then
        player := cardtotal (c1) + 11
    end if
    locate (15, 37)
    colorback (120)
    color (40)
    put player ..
end oneor11c2
%Turning 11 to 1 if total > 21
proc acecheck1
    if player > 21 and c1 = 1 or c1 = 14 or c1 = 27 or c1 = 40 and doneace = 1then
        player := player - 10
        doneace := 0
    end if
    locate (15, 37)
    colorback (120)
    color (40)
    put player ..
end acecheck1
proc acecheck2
    if player > 21 and c2 = 1 or c2 = 14 or c2 = 27 or c2 = 40 and doneace2 = 1 then
        player := player - 10
        doneace2 := 0
    end if
    locate (15, 37)
    colorback (120)
    color (40)
    put player ..
end acecheck2

%Main Program
proc main
    var x, y, button : int
    loop
        mousewhere (x, y, button)
        if x >= 400 and x = 10 and y = 450 and x = 10 and y = 500 and x = 10 and y = 550 and x = 10 and y 