2016-12-27 9 views
0

バランス変数がバッチファイルが正しく

「バル」である私はそれを失う/各勝利で更新したいが、それは私ができるように、別のファイルに設定された値を持っている100 に滞在し続けるのバランスを更新しませんuは%bal%のベース開始値があるべき100

@echo off 
cls 

:menu 
echo hello and welcome to Gamble bot 2000! 
echo you start off with 100 credits and as you climb 
echo you can start to place larger and better bets! 
echo do your best to not run out of money or you will 
echo have to start over 
echo have fun :) 
echo . 
echo Version alpha 0.2.1 
echo . 
echo To start type "start" and hit enter 

set /p menu= 
if %menu% == start (
goto start) 
goto sry1 

:sry1 
cls 
echo you typed an invalid response please try agian. 
pause 
goto menu 

:start 
cls 
set /p bal=<value.txt 
echo the game is simple guess a number between 0 and 9 
echo for 3 instance for example 123, 456, 789, 111 and so on 
echo a dice will roll and if you guess the number you get a 
echo winning based on the amount of numbers you guessed correct 
echo . 
echo 1 numbers gives you a 2x win 
echo 2 numbers gives you a 3x win 
echo 3 numbers gives you a 4x win 
echo and of course no numbers means u lost 
pause 
goto g1 

:g1 
cls 
set g1=nul 
set g2=nul 
set g3=nul 
Echo please make your 1st number selection!!! 
set /p g1= 
goto g2 

:g2 
cls 
Echo please make your 2nd number selection!!! 
set /p g2= 
goto g3 

:g3 
cls 
Echo please make your 3rd number selection!!! 
set /p g3= 
goto bet 

:bet 
cls 
echo place your bet. 
echo your current balance is %bal%c 
set /p bet= 
if %bet% GTR %bal% (
goto inf) 
goto num1 

:inf 
cls 
echo you dont have enough credits for that bet, please choose another bet! 
pause 
goto bet 

:num1 
cls 
echo Getting results, please wait. 
set /a g11=%random% %% 10 
goto num2 

:num2 
cls 
echo Getting results, please wait.. 
set /a g22=%random% %% 10 
goto num3 

:num3 
cls 
echo Getting results, please wait... 
set /a g33=%random% %% 10 
goto results 

:results 
if %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w3 
if not %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w2 
if %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w2 
if %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w2 
if not %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w1 
if not %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w1 
if %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto w1 
if not %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto Lose 

:w3 
cls 
set /p win=%bet%*4 
set /p %bal%+%win% 
echo Congratulations you have guessed all three numbers correctly! 
echo the numbers were: %g1%%g2%%g3%! 
echo . 
echo You have won "%win%" credits! 
echo . 
echo Your new credit balance is %bal%C 
echo . 
echo would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto g1 
if %ha% == n goto save 

:w2 
cls 
set /p win=%bet%*3 
set /p %bal%+%win% 
echo Congratulations you have guessed two numbers correctly! 
echo the numbers were: %g1%%g2%%g3%! 
echo . 
echo You have won "%win%" credits! 
echo . 
echo Your new credit balance is %bal%C 
echo . 
echo would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto g1 
if %ha% == n goto save 

:w1 
cls 
set /p win=%bet%*2 
set /p %bal%+%win% 
echo Congratulations you have guessed one correctly! 
echo the numbers were: %g1%%g2%%g3%! 
echo . 
echo You have won "%win%" credits! 
echo . 
echo Your new credit balance is %bal%C 
echo . 
echo would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto g1 
if %ha% == n goto save 

:lose 
cls 
set /p %bal%-%bet% 
echo Im sorry but you did not guess any of the numbers correclty. 
echo . 
echo you have lost %bet% credits 
echo . 
echo your new credit balance is %bal%C 
echo would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto g1 
if %ha% == n goto save 

:save 
cls 
echo Im sorry but the save mechanic is not yet set up it will be coming 
echo in a future update, anyway thanks for playing I hope you had fun! 
pause 
end 

答えて

1
set /p %bal%-%bet% 

あるハード設定値をしたい場合は、後で保存整備士を設定

set /a bal-=%bet% 

又は

set /a bal-=bet 

又は

set /a bal=bal - bet 

等しくそうwin場合について。

+0

ありがとうございます。今すぐ完全に動作します:D – Heyo13579

0
Here is the finished code if anyone wants to check it out :D 


@echo off 
cls 

:menu 
echo Hello. Welcome to Gamblebot 2000! 
echo You will start off with 100 credits. As you climb, 
echo you can start to place larger and better bets! 
echo Do your best to not run out of money, or you will 
echo have to start over. 
echo Have fun :) 
echo . 
echo Version 1.2.4 
echo . 
pause 

:start 
cls 
set bal=100 
echo The game is simple. Guess a number between 0 and 9 
echo for 3 instances. (For example: 123, 456, 789, 111) 
echo A dice will be rolled. If you guess the number, you get a 
echo winning based on the amount of numbers guessed correctly. 
echo . 
echo 1 numbers gives you a 2x win. 
echo 2 numbers gives you a 3x win. 
echo 3 numbers gives you a 4x win. 
echo No numbers means you lost. 
pause 
goto curr 

:curr 
cls 
echo First, start by naming the currency. 
echo Name it whatever you like. Then press enter. 
set /p curr= 
goto g1 

:currchange 
cls 
echo Enter name of new currency. 
set /p curr= 
goto g1 

:g1 
cls 
echo Please make your first number selection!!! 
set /p g1= 
goto g2 

:g2 
cls 
echo Please make your second number selection!!! 
set /p g2= 
goto g3 

:g3 
cls 
echo Please make your third number selection!!! 
set /p g3= 
goto bet 

:bet 
cls 
echo Your balance is %bal% %curr% 
echo Place your bet. 
set /p bet= 
if %bet% GTR %bal% (
goto inf) 
goto num1 

:inf 
cls 
echo You do not have enough credits for that bet. Please choose another bet! 
pause 
goto bet 

:num1 
echo Getting results! Please wait. 
set /a g11=%random% %% 10 
goto num2 

:num2 
cls 
echo Getting results! Please wait.. 
set /a g22=%random% %% 10 
goto num3 

:num3 
cls 
echo Getting results! Please wait... 
set /a g33=%random% %% 10 
goto results 

:results 
if %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w3 
if not %g1%==%g11% if %g2%==%g22% if %g3%==%g33% goto w2 
if %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w2 
if %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w2 
if not %g1%==%g11% if not %g2%==%g22% if %g3%==%g33% goto w1 
if not %g1%==%g11% if %g2%==%g22% if not %g3%==%g33% goto w1 
if %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto w1 
if not %g1%==%g11% if not %g2%==%g22% if not %g3%==%g33% goto Lose 

:w3 
cls 
set /a win=%bet%*4 
set /a bal=%bal%+%win% 
echo Congratulations you have guessed all three numbers correctly! 
echo the numbers were: %g11%%g22%%g33%! 
echo . 
echo You have won "%win%" %curr%! 
echo . 
echo Your new credit balance is %bal% %curr%. 
echo . 
echo Would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto change 
if %ha% == Y goto change 
if %ha% == n goto save 
if %ha% == N goto save 

:w2 
cls 
set /a win=%bet%*3 
set /a bal=%bal%+%win% 
echo Congratulations you have guessed two numbers correctly! 
echo the numbers were: %g11%%g22%%g33%! 
echo . 
echo You have won "%win%" %curr%! 
echo . 
echo Your new credit balance is %bal% %curr%. 
echo . 
echo Would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto change 
if %ha% == Y goto change 
if %ha% == n goto save 
if %ha% == N goto save 

:w1 
cls 
set /a win=%bet%*2 
set /a bal=%bal%+%win% 
echo Congratulations you have guessed one correctly! 
echo the numbers were: %g11%%g22%%g33%! 
echo . 
echo You have won "%win%" %curr%! 
echo . 
echo Your new credit balance is %bal% %curr%. 
echo . 
echo Would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto change 
if %ha% 
cls 
set /a bal=%bal%-%bet% 
echo I am sorry but you did not guess any of the numbers correctly. 
echo . 
echo You have lost %bet% %curr%. 
echo . 
echo Your new credit balance is %bal% %curr%. 
echo Would you like to make another bet? 
echo (Y/N) 
set /p ha= 
if %ha% == y goto change 
if %ha% == Y goto change 
if %ha% == n goto save 
if %ha% == N goto save 

:change 
cls 
echo Would you like to change or keep the name of your currency? 
echo Type k for keep or c for change. 
set /p ha= 
if %ha% == k goto g1 
if %ha% == K goto g1 
if %ha% == c goto currchange 
if %ha% == C goto currchange 

:save 
cls 
echo Sorry. The save mechanic is not yet set up. It will be coming 
echo in a future update Thanks for playing. I hope you had fun! 
pause 
end 
+0

全体を繰り返す代わりに、変更したコードを強調表示します。 – Melebius