on createDeck put "A,B,C,D" into cardSuits repeat for each item tItem in cardSuits repeat with i=1 to 13 put i & tItem & comma after temp #cards are like: 1A,2A, ..., 1B, ... end repeat end repeat delete the last char of temp set the deck of this stack to tempend createDeck
on shuffleDeck put the deck of this stack into temp put the number of items of temp into temp2 sort items of temp by random(temp2) set the deck of this stack to tempend shuffleDeck
function PickCard nCards put the deck of this stack into temp put item 1 to nCards of temp into picked delete item 1 to nCards of temp set the deck of this stack to temp return pickedend PickCard
In pratica il messaggio CreateDeck vi crea il mazzo e lo memorizza nella proprietà deck.
Il messaggio shuffleDeck mescola il mazzo.
La funzione pickCard vi estrae il numero di carte che volete dal mazzo e poi vengono anche cancellate dall'elenco del mazzo.
Nessun commento:
Posta un commento