批量 - 按下按钮时的多个命令

时间:2016-01-06 08:07:51

标签: batch-file cmd

我编写了一个简单的游戏并需要帮助,

pcash = user cash
reshp1 = cost to restore hp
php = player health

如何将这些写入1行?

如果用户按1,检查现金是否等于或大于恢复成本hp,如果更高 - 减去现金基础恢复成本hp,然后最后将hp加20%。

这是我尝试过的,但没有按预期工作。

if "%restorer%"=="1" if %pcash% geq %reshp1c% && set /a pcash=%pcash% - %reshp1c% && set /a php=%php% * .20

1 个答案:

答案 0 :(得分:1)

if "%restorer%"=="1" if %pcash% geq %reshp1c% set /a pcash=%pcash% - %reshp1c%&set /a php=%php%*6/5

&用于分隔级联语句。批处理使用整数数学,因此*6/5将乘以6然后除以5,将先前值加上20%(您的代码,如果有效,将设置该值为20%其先前的幅度)