Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # http://zetcode.com/lang/tcl/io/
- # http://wiki.tcl.tk/1549
- # https://fr.wikipedia.org/wiki/Tool_Command_Language
- # ---------
- # Fonctions
- # ---------
- # Récupérer une valeur au hasard dans une liste
- proc lpick list {
- lindex $list [ expr { int(rand() * [ llength $list ]) } ]
- }
- # Donner la valeur d'une carte
- proc card_value card {
- switch $card {
- valet - dame - roi { return 10 }
- as { return 11 }
- default { return $card }
- }
- }
- proc pick_card {game i} {
- upvar $game a_game
- set card [ lreplace $a_game $i $i ]
- set a_game $card
- return [ lindex $card $i ]
- }
- # ---
- # Jeu
- # ---
- # Noms
- set names {
- Yannick Aurélie Guillaume Benoît Hugo Aymeric
- George Jérémy Matthieu Romain Elisa Corentin
- }
- # Cartes
- set cards { 2 3 4 5 6 7 8 9 10 valet dame roi as }
- # Types
- set types { coeur pique trèfle carreau }
- # Création du jeu de cartes
- set game [ list ]
- foreach card $cards {
- foreach type $types {
- lappend game "$card de $type"
- }
- }
- set player(Yannick) [ list ]
- for { set i 0 } { $i < 3 } { incr i } {
- lappend player(Yannick) [ pick_card game [ lsearch $game [ lpick $game ] ] ]
- }
- puts $player(Yannick)
- # puts $player(Yannick)
- # gets stdin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement