RosettaCodeData/Task/Deal-cards-for-FreeCell/Run-BASIC/deal-cards-for-freecell.basic
2026-04-30 12:34:36 -04:00

33 lines
1.6 KiB
Text

projectDir$ = "a_project" ' project directory
imageDir$ = DefaultDir$ + "\projects\" + projectDir$ + "\image\" ' directory of deck images
imagePath$ = "../";projectDir$;"/image/" ' path of deck images
suite$ = "C,D,H,S" ' Club,Diamond,Heart,Spades
card$ = "A,2,3,4,5,6,7,8,9,T,J,Q,K" ' Cards Ace to King
dim n(55) ' make ordered deck
for i = 1 to 52 ' of 52 cards
n(i) = i
next i
for i = 1 to 52 * 3 ' shuffle deck 3 times
i1 = int(rnd(1)*52) + 1
i2 = int(rnd(1)*52) + 1
h2 = n(i1)
n(i1) = n(i2)
n(i2) = h2
next i
for yy = 1 to 8 ' display 7 across and 8 down
for xx = 1 to 7
card = card + 1
s = (n(card) mod 4) + 1 ' determine suite
c = (n(card) mod 13) + 1 ' determine card
cardId$ = word$(card$,c,",");word$(suite$,s,",");".gif"
html "<div style='position: relative; left:";(xx -1) * 80;"px; top:";(yy -1) * 20;"px; height:0px; width:0px;>"
html "<div style='width:100px; height:100px; border:solid 0px #000;'>"
html "<img src=";imagePath$;cardId$;" width=70px >"
html "</div></div>"
if card = 52 then end ' out of cards
next xx
next yy