Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

An older card game by Ignatz (needs updating)...

edited September 2017 in General Posts: 117

Trying to figure out a card game made by Ignatz....
The code was written long ago and seems to be outdated...
I see a green background and three buttons on the left side...
No cards are dealt, can anyone help ?...
It seems to be a version of BlackJack....
I would like to figure this out so I could put in
my own spin and get my own card games rolling...

-- 21 card game
-- Use this function to perform your initial setup
function setup()
    img=readImage("Documents:cardback") 
    --image for back of card
    deal21() 
end

function touched(touch)        
end
--===== 21 ========
function deal21()
    parameter.watch("Score")
    parameter.watch("bankScore")
    parameter.action("Hold", function() playBank() end)
    parameter.action("Another card", function() AddMyCard() end) 
    parameter.action("Play again",function() play21Again() end) 
    c=Card(200,img)  -- card back
    t=CardTable(10,HEIGHT-10,c,false,1,2.1)
    p=Pack()
    p:shuffle()
    Score=0
    bankScore=0
    cards=2
    for i=1,2 do
        local crd=t:dealCard(p,i,3.2,true) 
--lay out cards at fractional row intervals to look nice
        Score=GetScore(Score,crd)
    end 
    status="PLAY"
end

function playBank()
    bankCards=2
    bankScore=0
    for i=1,2 do
        local crd=t:dealCard(p,i,1,true)
        bankScore=GetScore(bankScore,crd)
    end
    while bankScore<16 do
        bankScore=addBankCard()
    end
    if bankScore>=Score and bankScore<=21 then status="LOSE" else status ="WIN" end
end

function GetScore(score,crd)
    local i,j,v,s=c:SuitValue(crd.c)
    if v==1 then 
        if score<=10 then score=score+11 else score=score+1 end
    else
        score=score+math.min(10,v)
    end
    return score
end

function AddMyCard()
    cards = cards + 1
    local crd=t:dealCard(p,cards,3.2,true)
    Score=GetScore(Score,crd)
    if Score>21 then status="LOSE" end
end

function addBankCard()
    bankCards = bankCards + 1
    local crd=t:dealCard(p,bankCards,1,true)
    bankScore=GetScore(bankScore,crd)
    return bankScore
end

function play21Again()
    deal21()
end

-- This function gets called once every frame
function draw()
    background(69, 146, 59, 255)
    t:draw()
    if status=="LOSE" or status=="WIN" then 
        pushStyle()
        font("Copperplate")
        fontSize(48)
        fill(255)
        text("You "..status.."!",300,50)
        popStyle() 
    end
end
Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,613

    @kendog400 There's code missing, so this is never going to work as is. Also, when you post code, put only 3 tildes ~~~ on a line before and after the code. What was the name and date of the discussion you got the above code from. Maybe the original discussion has more code.

  • dave1707dave1707 Mod
    Posts: 7,613

    @kendog400 I found the original link and the code for the card game works but is incomplete.

  • Looks kike it was posted 8/3/13....4yrs is a long time when it comes to computing....can be found at : http://pastebin.com/qs7sASJX....

  • it seems that the link just died..

  • I have yet another card game from Ignatz, from the year 2013,
    it seems as though it is 6080 characters to long to even post on the codea web site...

  • @kendog400, use gist.

    It's a free feature available at GitHub and it's the most common way people on these forums share larger code.

    Post the code in a gist and then post the gist link here. It's really easy!

Sign In or Register to comment.