Solved Help with creating simple batch game?

February 22, 2017 at 10:51:28
Specs: Windows 64
I have written a simple program to display two cards then display a flop,turn, and river. I am having a problem with getting the same card more than once in a hand. Please take a look at my code and tell me what i can do. I am very new at this and all advice is welcome.


@echo off
:start
echo generating...
goto card1
:card1
set /a card=%random% %% 13 + 1
set /a suit=%random% %% 4 + 1
if %card%==13 set card=Ace
if %card%==12 set card=King
if %card%==11 set card=Queen
if %card%==10 set card=Jack
if %card%==9 set card=Ten
if %card%==8 set card=Nine
if %card%==7 set card=Eight
if %card%==6 set card=Seven
if %card%==5 set card=Six
if %card%==4 set card=Five
if %card%==3 set card=Four
if %card%==2 set card=Three
if %card%==1 set card=Two
if %suit%==1 set suit=Spades
if %suit%==2 set suit=Clubs
if %suit%==3 set suit=Hearts
if %suit%==4 set suit=Diamonds
goto card2
:card2
set /a cardd=%random% %% 13 + 1
set /a suitt=%random% %% 4 + 1
if %cardd%==13 set cardd=Ace
if %cardd%==12 set cardd=King
if %cardd%==11 set cardd=Queen
if %cardd%==10 set cardd=Jack
if %cardd%==9 set cardd=Ten
if %cardd%==8 set cardd=Nine
if %cardd%==7 set cardd=Eight
if %cardd%==6 set cardd=Seven
if %cardd%==5 set cardd=Six
if %cardd%==4 set cardd=Five
if %cardd%==3 set cardd=Four
if %cardd%==2 set cardd=Three
if %cardd%==1 set cardd=Two
if %suitt%==1 set suitt=Spades
if %suitt%==2 set suitt=Clubs
if %suitt%==3 set suitt=Hearts
if %suitt%==4 set suitt=Diamonds
goto display
:display
echo Your cards are: %card% of %suit% and %cardd% of %suitt%
goto flop1
:flop1
set /a fcard=%random% %% 13 + 1
set /a fsuit=%random% %% 4 + 1
if %fcard%==13 set fcard=Ace
if %fcard%==12 set fcard=King
if %fcard%==11 set fcard=Queen
if %fcard%==10 set fcard=Jack
if %fcard%==9 set fcard=Ten
if %fcard%==8 set fcard=Nine
if %fcard%==7 set fcard=Eight
if %fcard%==6 set fcard=Seven
if %fcard%==5 set fcard=Six
if %fcard%==4 set fcard=Five
if %fcard%==3 set fcard=Four
if %fcard%==2 set fcard=Three
if %fcard%==1 set fcard=Two
if %fsuit%==1 set fsuit=Spades
if %fsuit%==2 set fsuit=Clubs
if %fsuit%==3 set fsuit=Hearts
if %fsuit%==4 set fsuit=Diamonds
goto flop2
:flop2
set /a fcard2=%random% %% 13 + 1
set /a fsuit2=%random% %% 4 + 1
if %fcard2%==13 set fcard2=Ace
if %fcard2%==12 set fcard2=King
if %fcard2%==11 set fcard2=Queen
if %fcard2%==10 set fcard2=Jack
if %fcard2%==9 set fcard2=Ten
if %fcard2%==8 set fcard2=Nine
if %fcard2%==7 set fcard2=Eight
if %fcard2%==6 set fcard2=Seven
if %fcard2%==5 set fcard2=Six
if %fcard2%==4 set fcard2=Five
if %fcard2%==3 set fcard2=Four
if %fcard2%==2 set fcard2=Three
if %fcard2%==1 set fcard2=Two
if %fsuit2%==1 set fsuit2=Spades
if %fsuit2%==2 set fsuit2=Clubs
if %fsuit2%==3 set fsuit2=Hearts
if %fsuit2%==4 set fsuit2=Diamonds
goto flop3
:flop3
set /a fcard3=%random% %% 13 + 1
set /a fsuit3=%random% %% 4 + 1
if %fcard3%==13 set fcard3=Ace
if %fcard3%==12 set fcard3=King
if %fcard3%==11 set fcard3=Queen
if %fcard3%==10 set fcard3=Jack
if %fcard3%==9 set fcard3=Ten
if %fcard3%==8 set fcard3=Nine
if %fcard3%==7 set fcard3=Eight
if %fcard3%==6 set fcard3=Seven
if %fcard3%==5 set fcard3=Six
if %fcard3%==4 set fcard3=Five
if %fcard3%==3 set fcard3=Four
if %fcard3%==2 set fcard3=Three
if %fcard3%==1 set fcard3=Two
if %fsuit3%==1 set fsuit3=Spades
if %fsuit3%==2 set fsuit3=Clubs
if %fsuit3%==3 set fsuit3=Hearts
if %fsuit3%==4 set fsuit3=Diamonds
goto fdisplay
:fdisplay
echo The flop is: %fcard% of %fsuit% , %fcard2% of %fsuit2% , %fcard3% of %fsuit3%
goto turn
:turn
set /a tcard=%random% %% 13 + 1
set /a tsuit=%random% %% 4 + 1
if %tcard%==13 set tcard=Ace
if %tcard%==12 set tcard=King
if %tcard%==11 set tcard=Queen
if %tcard%==10 set tcard=Jack
if %tcard%==9 set tcard=Ten
if %tcard%==8 set tcard=Nine
if %tcard%==7 set tcard=Eight
if %tcard%==6 set tcard=Seven
if %tcard%==5 set tcard=Six
if %tcard%==4 set tcard=Five
if %tcard%==3 set tcard=Four
if %tcard%==2 set tcard=Three
if %tcard%==1 set tcard=Two
if %tsuit%==1 set tsuit=Spades
if %tsuit%==2 set tsuit=Clubs
if %tsuit%==3 set tsuit=Hearts
if %tsuit%==4 set tsuit=Diamonds
echo The turn card is: %tcard% of %tsuit%
goto river
:river
set /a rcard=%random% %% 13 + 1
set /a rsuit=%random% %% 4 + 1
if %rcard%==13 set rcard=Ace
if %rcard%==12 set rcard=King
if %rcard%==11 set rcard=Queen
if %rcard%==10 set rcard=Jack
if %rcard%==9 set rcard=Ten
if %rcard%==8 set rcard=Nine
if %rcard%==7 set rcard=Eight
if %rcard%==6 set rcard=Seven
if %rcard%==5 set rcard=Six
if %rcard%==4 set rcard=Five
if %rcard%==3 set rcard=Four
if %rcard%==2 set rcard=Three
if %rcard%==1 set rcard=Two
if %rsuit%==1 set rsuit=Spades
if %rsuit%==2 set rsuit=Clubs
if %rsuit%==3 set rsuit=Hearts
if %rsuit%==4 set rsuit=Diamonds
echo The river card is: %rcard% of %rsuit%
pause



See More: Help with creating simple batch game?

Report •

#1
February 22, 2017 at 15:06:49
How do i mark this as solved/delete it i have already fixed the problem

Report •

#2
February 23, 2017 at 02:55:10
✔ Best Answer
mark someones answer as best answer

or let me mark yours as best in a week or so

gj on solving it yourself :D

Simple solutions are often the best


Report •
Related Solutions


Ask Question