Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-16-2012, 08:50 PM   PM User | #1
ChaosIntoOrder
New to the CF scene

 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ChaosIntoOrder is an unknown quantity at this point
Question Need help with batch file

So I've been working on Pokemon as a batch file.
Everything has been working fine until i made the pokeshop.

The player has a certain amount of money: %money%
Each item has a cost: %greatballcost%

But for whatever reason, certain amounts of money are incorrectly compared as less than the cost, for instance 2700, 1337, 27000, and others.

Here is the code for this area. Any help would be appreciated if you could help me fix this problem.


:m-pewterpokeshop
cls
set pokeballcost=125
set greatballcost=300
set potioncost=250
set superpotioncost=500
echo Money - $ %money%
echo Shopkeeper: "Welcome! What can I get you?"
echo 0 - Exit
echo 1 - Pokeball [$ %pokeballcost%][1]
echo 2 - Greatball [$ %greatballcost%][1]
echo 3 - Potion [$ %potioncost%][1]
echo 4 - Super Potion[$ %superpotioncost%][1]
set /p choice=
if '%choice%'=='0' goto m-PewterCity
if '%choice%'=='1' goto m-pewterpokeshop-pokeball
if '%choice%'=='2' goto m-pewterpokeshop-greatball
if '%choice%'=='3' goto m-pewterpokeshop-potion
if '%choice%'=='4' goto m-pewterpokeshop-superpotion
goto m-pewterpokeshop

:m-pewterpokeshop-superpotion
if /i '%money%' LSS '%superpotioncost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-500
set /a superpotionamount=%superpotionamount%+1
echo Received Super Potion [%superpotionamount%]
echo Thanks!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-badfunds
echo You don't have enough money!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-pokeball
if /i '%money%' LSS '%pokeballcost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-100
set /a pokeballamount=%pokeballamount%+1
echo Received Pokeball [%pokeballamount%]
echo Thanks!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-greatball
if /i '%money%' LSS '%greatballcost%' echo True
if /i not '%money%' LSS '%greatballcost%' echo False
if /i '%money%' GTR '%greatballcost%' echo True
if /i not '%money%' GTR '%greatballcost%' echo False
if /i '%money%' LSS '%greatballcost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-300
set /a greatballamount=%greatballamount%+1
echo Received Greatball [%greatballamount%]
echo Thanks!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-potion
if /i '%money%' LSS '%potioncost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-250
set potion=potion
set /a potionamount=%potionamount%+1
echo Received Potion [%potionamount%]
echo Thanks!
pause
goto m-pewterpokeshop



Also, this is only an excerpt and you would need several more large chunks to test it. if you would like, i can post those as well.

Last edited by ChaosIntoOrder; 11-16-2012 at 09:03 PM.. Reason: Icon wasn't desirable
ChaosIntoOrder is offline   Reply With Quote
Reply

Bookmarks

Tags
assistance, batch, comparison, file, pokemon

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:22 AM.


Advertisement
Log in to turn off these ads.