if 0 { <> ---- **Introduction** [MiHa] 2015-06-24: One of the example-programs on my [HelloWorld]-page creates a deck of cards, <
> so I had the idea to expand that into a simple cardgame. https://en.wikipedia.org/wiki/Blackjack%|%Blackjack%|% is quite simple, and with (debug-)options still in place to show the cards "in the open", <
> this would nicely double as a tcl-tutorial and a Blackjack-trainer. With ideas and code from the following pages: * http://wiki.tcl.tk/41268%|%HelloWorld%|% ([MiHa]) - the examples using foreach, unicode and list * ... } ---- **Program** ======tcl # Whitejack.tcl - MiHa - 2015-06-24 # http://wiki.tcl.tk/41565 # http://ideone.com/jVxnHV puts "Whitejack:" --------- set deckList {} ;# create empty list set i 0 # For unicode, see also: http://wiki.tcl.tk/26403 : [HTML character entity references] # Spades Hearts Diamonds Clubs foreach {suit sym} { S \u2660 H \u2665 D \u2666 C \u2663 } { foreach rank { A 2 3 4 5 6 7 8 9 10 J Q K } { ;# Ace 2 .. 10 Jack Queen King incr i set card "$rank$sym" puts -nonewline " $rank$suit=$card " while { $cmd ne "q" } { lappend deckList $card ;# add card to list } puts "" } set maxCard $i puts "\ndeckList : $deckList" set cmd "." set cmd [gets stdin] puts -nonewline "Enter command, q to quit: " if {$cmd=="h"} { help } if {$cmd=="q"} { puts "Bye!"; exit } puts "card #3 : [lindex $deckList 2]" ;# index is zero-based #. puts "Bye!" #... # EOF # ---- **Output** ======none Whitejack: Start with 'n' to get a fresh pack of cards. ---- **Comments** [MiHa] 2015-06-26: The most basic functionality is done, **Remarks** This is the Alpha-version, there ''will'' be bugs, so use with caution <
> ... with regard to changing values outside the proc. <
> * http://wiki.tcl.tk/41210%|%ClockDemo%|% * [HelloWorld] * ... <> Example | Cardgames | Application <> Example | Cardgame | Application