Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off
- Setlocal EnableDelayedExpansion
- REM initialize reference strings
- REM Ace at array indices 49 - 52 to allow exclusion
- Set "Type[11]=Jack"
- Set "Type[12]=Queen"
- Set "Type[13]=King"
- Set "Type[14]=Ace"
- Rem Assign starting values
- Set "Count=0"
- Set "Deck="
- Rem Define Deck List and Card Array
- For %%n in (Hearts Diamonds Clubs Spades)Do (
- For /l %%i in (2 1 14)Do (
- Set /A Count+=1
- Set "Deck=!Deck! !Count!,"
- If defined Type[%%i] (
- Set "Card[!Count!]=!Type[%%i]! of %%n"
- )Else (
- Set "Card[!Count!]=%%i of %%n"
- )
- )
- )
- Rem call deal function for number of 'players', deal a number of cards
- For /L %%n in (1 1 3)Do (
- For /l %%i in (1 1 5)Do Call:Deal Player[%%n][%%i] && Echo(Player %%n Card %%i: !Player[%%n][%%i]!
- Echo(
- )
- Endlocal & Goto:Eof
- :Deal <returnVar>
- REM flag if entire deck has been dealt
- If "!Deck!"=="" Exit /B 1
- REM select random array index from all possible cards
- Set /A Rand=!Random! %%52 + 1
- REM test if selected index has been dealt previously
- If not "!Deck: %Rand%,=!"=="!Deck!" (
- REM 'deal' card.
- Set "Deck=!Deck: %Rand%,=!"
- Set "%1=!Card[%Rand%]!" || Echo(missing arg 1.
- Exit /B 0
- )Else (
- REM select new index
- Goto:Deal
- )
- Exit /B 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement