Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
47
Task/Playing-cards/MiniScript/playing-cards.mini
Normal file
47
Task/Playing-cards/MiniScript/playing-cards.mini
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
suits = ["Spades", "Clubs", "Hearts", "Diamonds"]
|
||||
pips = ["Ace","Two","Three","Four","Five","Six","Seven",
|
||||
"Eight","Nine","Ten","Jack","Queen","King"]
|
||||
|
||||
Card = {}
|
||||
Card.str = function()
|
||||
return self.pip + " of " + self.suit + " (value: " + self.value + ")"
|
||||
end function
|
||||
|
||||
//Build Deck
|
||||
deck = []
|
||||
for s in suits.indexes
|
||||
for p in pips.indexes
|
||||
card = new Card
|
||||
card.suit = suits[s]
|
||||
card.pip = pips[p]
|
||||
card.value = s * 100 + p
|
||||
deck.push card
|
||||
end for
|
||||
end for
|
||||
|
||||
draw = function(count=7)
|
||||
hand = []
|
||||
for i in range(1, count)
|
||||
hand.push deck.pop
|
||||
end for
|
||||
return hand
|
||||
end function
|
||||
|
||||
display = function(stack)
|
||||
for card in stack
|
||||
print card.str
|
||||
end for
|
||||
end function
|
||||
|
||||
print "Deck created. Cards in Deck: " + deck.len
|
||||
|
||||
deck.shuffle
|
||||
print "Deck Shuffled"
|
||||
|
||||
hand = draw
|
||||
print "First hand: "
|
||||
display hand
|
||||
|
||||
print
|
||||
print deck.len + " cards left in deck:"
|
||||
display deck
|
||||
Loading…
Add table
Add a link
Reference in a new issue