以下代码保存为Fighting.bat- @echo off&setlocal enabledelayedexpansion
- title FIGHTING 1.0 作者:vincentzhou
- set /p nam1=输入自己的角色名:
- set /p nam2=输入对手的角色名:
- set /a marka=0
- for /f "tokens=1,2 delims=-" %%a in (attack.txt) do (
- set "attack!marka!=%%a"
- set /a kill!marka!=%%b
- set /a marka+=1
- )
- set /a markd=0
- for /f "tokens=1,2 delims=-" %%d in (defence.txt) do (
- set "defence!markd!=%%d"
- set /a protect!markd!=%%e
- set /a markd+=1
- )
- set /a n=0
- set /a !nam1!HP=100
- set /a !nam2!HP=100
- ping -n 1 127.1>nul
- echo.
- for %%q in (战 斗 开 始 ! ! ! ) do <nul set/p= %%q&ping -n 1 127.1>nul
- echo.
- :fight
- set /a who=%random%%%2
- if "%who%"=="0" (
- set "A=%nam1%"
- set "B=%nam2%"
- ) else (
- set "A=%nam2%"
- set "B=%nam1%"
- )
- set /a m=n+1
- echo Round【%m%】
- ping -n 1 127.1>nul
- set /a ran=%random%%%5
- set /a ran1=%random%%%5
- for /f %%i in ('echo !attack%ran%!') do echo %%i
- ping -n 1 127.1>nul
- for /f %%i in ('echo !defence%ran1%!') do echo %%i
- ping -n 1 127.1>nul
- set /a jianshao=0
- if !protect%ran1%! neq 0 (
- set /a jianshao=kill%ran%-protect%ran1%
- set /a %B%HP=%B%HP-kill%ran%+protect%ran1% )
- if !%B%HP! leq 0 goto end
- echo %B%减少HP !jianshao! 剩余HP !%B%HP!
- echo.
- ping -n 2 127.1>nul
- set /a n+=1
- goto fight
- :end
- echo %B%剩余HP 0
- echo.
- for /f %%a in ('echo 战斗结束%B%光荣滴挂掉了!!!') do (set k=%%a
- call:loop
- )
- pause>nul&exit
- :loop
- set /a n=0
- :x
- set wenzi=!k:~%n%,1!
- if "%wenzi%"=="" goto:eof
- <nul set /p=%wenzi%
- ping -n 1 127.1>nul
- set /a n+=1
- goto x
复制代码 以下内容保存为attack.txt- %A%使出赤焰拳,熊熊烈火照亮整个天际,拳头带着劲风直击%B%-20
- %A%一脚横扫千军踢向%B%-20
- %A%使出了瞬间移动,来到%B%后面,毫不客气一脚踢去-30
- %A%使出了失传已久的如来神掌-30
- %A%召唤出了一大群僵尸,僵尸疯狂的向%B%攻击-50
复制代码 以下内容保存为defence.txt- %B%召唤出水盾来防御,但劲气还是让%B%身体一震-5
- %B%召唤出火盾,防住了大半攻击-5
- %B%完美的一个侧身躲过%A%的攻击-0
- %B%召唤出土盾,厚重的土墙拔地而起阻挡了大部分攻击-8
- %B%举横手中巨剑格挡-8
复制代码 正如大家看到的,所有游戏招式都是自己可以看见可以修改的……而且招式的数量也可以增减,只需在程序中改变相应的=%random%%%5
中的数字就可以了。有兴趣的自己改改玩玩,有点像Q宠大乐斗了……不足的地方还望指教 |