标题: [游戏娱乐] 批处理游戏21点 [打印本页]
作者: yslyxqysl 时间: 2008-12-1 09:58 标题: 批处理游戏21点
- @echo off
- if "%1"=="/?" call :help
- mode con lines=16 cols=40
- title 21点 by yslyxqysl&color 0e
- setlocal ENABLEDELAYEDEXPANSION
- set "f="&set "poker= "&set /a pw=0,cw=0
- set "b=(set begin=o&goto :eof)"
- set "c=call :give p&(if ^!begin^!a==oa set begin=&goto shuffle)"
- :shuffle
- cls&echo 洗牌中...
- :shuffle
- set /a tp=%random%%%52+4
- if "!poker: %tp% = !"=="%poker%" set "poker=%poker%%tp% "&set /a num+=1
- if "%num%"=="52" (set num=0) else goto shuffle
- :reset
- for %%i in (p c) do set /a %%in=0,%%in=0,%%ia=0,%%ib=0
- (%c%)&(%c:p=c%)&(%c%)&(%c:p=c%)
- if %pa% equ 21 goto show
- if %ca% equ 21 goto show
- :player
- cls&echo 电脑:%cw%盘
- echo ┏━┓┏┳┓
- set /p =┃!c1f!<nul&(if "!c1f:~1,1!"=="" set /p = <nul)&echo ┃┣╋┫
- set /p =┃!c1n!<nul&(if "!c1n:~1,1!"=="" set /p = <nul)&echo ┃┣╋┫
- echo ┗━┛┗┻┛
- echo 和:*&for /l %%i in (1 1 20) do set /p =─<nul
- echo 玩家:%pw%盘
- for /l %%a in (1 1 %pn%) do set /p =┏━┓<nul
- echo.&for /l %%b in (1 1 %pn%) do set /p =┃!p%%bf! ┃<nul
- echo.&for /l %%c in (1 1 %pn%) do ^
- set /p =┃!p%%cn!<nul&(if "!p%%cn:~1,1!"=="" set /p = <nul)&set /p =┃<nul
- echo.&for /l %%d in (1 1 %pn%) do set /p =┗━┛<nul
- echo.&echo 和:%pa%&echo.&set do=&set /p "do=要吗?:"
- if "!do!"=="" %c%
- if /i "!do!"=="c" set /a pw=0,cw=0&goto player
- if /i "!do!"=="r" set "poker= "&goto shuffle
- if /i "!do!"=="e" exit
- if /i "!do!"=="h" call :help&goto player
- if "!do!"==" " goto cpu
- if %pa% gtr 21 (goto show) else if %pa% neq 21 goto player
- :cpu
- if %ca% lss %pa% %c:p=c%&if !ca! geq 21 (goto show) else goto cpu
- :show
- if %pa% gtr %ca% set winner=p
- if %pa% lss %ca% set winner=c
- if %pa% gtr 21 set winner=c
- if %ca% gtr 21 set winner=p
- if "%winner%"=="p" (set /a pw+=1) else set /a cw+=1
- cls&echo 电脑:%cw%盘
- for /l %%a in (1 1 %cn%) do set /p =┏━┓<nul
- echo.&for /l %%b in (1 1 %cn%) do ^
- set /p =┃!c%%bf!<nul&if "!c%%bf:~1,1!"=="" (set /p = ┃<nul) else set /p =┃<nul
- echo.&for /l %%c in (1 1 %cn%) do ^
- set /p =┃!c%%cn!<nul&if "!c%%cn:~1,1!"=="" (set /p = ┃<nul) else set /p =┃<nul
- echo.&for /l %%d in (1 1 %cn%) do set /p =┗━┛<nul
- echo.&echo 和:%ca%&(for /l %%i in (1 1 20) do set /p =─<nul)&echo 玩家:%pw%盘
- for /l %%a in (1 1 %pn%) do set /p =┏━┓<nul
- echo.&for /l %%b in (1 1 %pn%) do ^
- set /p =┃!p%%bf!<nul&if "!p%%bf:~1,1!"=="" (set /p = ┃<nul) else set /p =┃<nul
- echo.&for /l %%c in (1 1 %pn%) do ^
- set /p =┃!p%%cn!<nul&if "!p%%cn:~1,1!"=="" (set /p = ┃<nul) else set /p =┃<nul
- echo.&(for /l %%d in (1 1 %pn%) do set /p =┗━┛<nul)&echo.&echo 和:%pa%&echo.
- if "%winner%"=="p" (set /p =玩家胜^^!<nul) else ^
- if "%winner%"=="c" (set /p =电脑胜^^!<nul) else set /p =平^^!<nul
- set winner=&ping /n 4 127.^1>nul&cls&goto reset
- :give
- set /a %1n+=1
- if "%poker:~2,1%"==" " (set "tp=%poker:~1,1%"&set "poker=%poker:~2%") else ^
- set tp=%poker:~1,2%&set "poker=%poker:~3%"
- set /a %1!%1n!n=%tp%/4
- set /a tp=%tp%%%4
- set %1!%1n!f=!f:~%tp%,1!
- call set tp=%%%1!%1n!n%%
- if %tp%==1 (set /a %1a+=11&set %1!%1n!n=A&set %1b=1) else (
- if %tp%==11 (set /a %1a+=10&set %1!%1n!n=J) else (
- if %tp%==12 (set /a %1a+=10&set %1!%1n!n=Q) else (
- if %tp%==13 (set /a %1a+=10&set %1!%1n!n=K) else (
- set /a %1a+=!tp!
- ))))
- if !%1a! gtr 21 if !%1b!==1 set /a %1a-=10,%1b=0
- if "!poker!"==" " if %1==p %b% else if %cn%==1 %b% else ^
- if %pa% lss 21 if %ca% lss 21 if %ca% lss %pa% %b%
- goto :eof
- :help
- cls
- echo Page 1/2
- echo 游戏规则:
- echo ^
- 游戏开始,玩家和庄家每人得到两张牌,如果^
- 其中一人拿到A和一张代表10点的牌将获胜,^
- 两人都拿到则平局;如果不是,选择要牌与否^
- 使牌的点数和接近21又不超过21。当点数和大^
- 与或等于21时自动停止要牌。双方要完牌后,^
- 谁的点数和最接近21又不超过21就胜出。当双^
- 方点数和一样时,庄家获胜。
- echo 请注意,庄家看得到玩家要牌的全过程。
- echo.
- echo 牌的点数:
- echo 2-10 2-10
- echo A 1或11(自动判断)
- echo J Q K 10
- pause>nul&cls
- echo Page 2/2
- echo 操作方法:
- echo 回车 要牌
- echo 空格+回车 不要牌
- echo C 成绩清零
- echo R 洗牌
- echo E 退出
- echo H 帮助
- echo.
- echo 声明:电脑绝对不会作弊。
- pause>nul&goto :eof
复制代码
作者: youxi01 时间: 2008-12-1 10:50
颜色搭配不太好,看起来眼睛有些不舒服
作者: wxcute 时间: 2008-12-1 11:05 标题: 以下建议仅供参考
可在第二句下面加上这些,让花色显示大些。既然是交互形式的,把牌居中显示是不是要好些呢?
你的帮助部分好像还没写,呵呵。- if "%1"=="21" goto 21
- set CMDval="HKCU\Console\%%SystemRoot%%_system32_cmd.exe"
- reg add %CMDval% /v "FontSize" /t REG_DWORD /d 0x0014000a /f>nul
- start cmd /c %0 21&exit
- :21
- mode con lines=17 cols=40
- reg delete %CMDval% /f>nul
复制代码
作者: Batcher 时间: 2008-12-1 11:24
建议删除附件,直接贴代码。
作者: mayunwei 时间: 2008-12-2 15:02
能写出来都太利害了!!!!!
作者: jt10086 时间: 2009-4-30 01:24
好东西啊 谢谢LZ辣
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |