- @echo off
- ::用于特效显示的数所初始化
- (set chu0=$
- set m1=1
- set m2=2
- set m3=3
- set m4=
-
- set a$#0= &rem 定义尾巴
- set b$#0=—=—=╮
- set c$#0= │
- set d$#0= │
- set e$#0= │
- set f$#0=批 §│
- set g$#0= 处 │
- set h$#0=§ 理│
- set i$#0=━=━=╯
-
- set a$@0=—=—=╮
- set b$@0= │
- set c$@0= │
- set d$@0= │
- set e$@0=批 §│
- set f$@0= 处 │
- set g$@0=§ 理│
- set h$@0=━=━=╯
- set i$@0=
-
- set a$#1=—=╮
- set b$#1=—=┷=╮
- set c$#1= │
- set d$#1= │
- set e$#1= │
- set f$#1=批 §│
- set g$#1= 处 │
- set h$#1=§ 理│
- set i$#1=━=━=╯
-
- set a$@1=—=—=╮
- set b$@1= │
- set c$@1= │
- set d$@1= │
- set e$@1=批 §│
- set f$@1= 处 │
- set g$@1=§ 理│
- set h$@1=━=┯=╯
- set i$@1=━=╯
-
- set a$#2=╮
- set b$#2=┷=—=╮
- set c$#2= │
- set d$#2= │
- set e$#2= │
- set f$#2=批 §│
- set g$#2= 处 │
- set h$#2=§ 理│
- set i$#2=━=━=╯
-
- set a$@2=—=—=╮
- set b$@2= │
- set c$@2= │
- set d$@2= │
- set e$@2=批 §│
- set f$@2= 处 │
- set g$@2=§ 理│
- set h$@2=┯=━=╯
- set i$@2=╯
-
- set a@00$=╭=
- set b@00$=│!ob!
- set c@00$=│!oc!
- set d@00$=│
- set e@00$=│
- set f@00$=│
- set g@00$=│
- set h@00$=╰=
- set i@00$= &rem 突出第一个,第一位
-
- set a@10=╭=
- set b@10=┥!ob!
- set c@10=┊!oc!
- set d@10=┊
- set e@10=┊
- set f@10=┊
- set g@10=┊
- set h@10=╰-
- set i@10=━=&rem 突出第N个,第N位,变换
-
- set a@12=╭=
- set b@12=┥!ob!
- set c@12=┊!oc!
- set d@12=┊
- set e@12=┊
- set f@12=┊
- set g@12=┊
- set h@12=╰-
- set i@12=━=&rem 突出第N个,第1,2位,变换
-
- set a@13=╭=
- set b@13=┥!ob!
- set c@13=┊!oc!
- set d@13=┊
- set e@13=┊
- set f@13=┊
- set g@13=┊
- set h@13=╰-
- set i@13=━=&rem 突出第N个,第3位,变换
-
- set a@0=╭=
- set b@0=┊!ob!
- set c@0=┊!oc!
- set d@0=┊
- set e@0=┊
- set f@0=┊
- set g@0=┊
- set h@0=╰=
- set i@0= &rem 突出第N个,第N位
-
- set a@2=╭=
- set b@2=┊!ob!
- set c@2=┊!oc!
- set d@2=┊
- set e@2=┊
- set f@2=┊
- set g@2=┊
- set h@2=╰-
- set i@2=━=&rem 突出第N个,第2位
-
- set a@3=╭=
- set b@3=┊!ob!
- set c@3=┊!oc!
- set d@3=┊
- set e@3=┊
- set f@3=┊
- set g@3=┊
- set h@3=╰-
- set i@3=╯ &rem 突出第N个,第3位
-
-
-
-
- set a#00$= &rem 不突第一个
- set b#00$=╭=
- set c#00$=│!ob!
- set d#00$=│!oc!
- set e#00$=│
- set f#00$=│
- set g#00$=│
- set h#00$=│
- set i#00$=╰=
-
- set a#10=—=&rem 不突第N个,第N位,变换
- set b#10=╭=
- set c#10=┊!ob!
- set d#10=┊!oc!
- set e#10=┊
- set f#10=┊
- set g#10=┊
- set h#10=┤
- set i#10=╰=
-
- set a#12=—=&rem 不突第N个,第1,2位,变换
- set b#12=╭=
- set c#12=┊!ob!
- set d#12=┊!oc!
- set e#12=┊
- set f#12=┊
- set g#12=┊
- set h#12=┤
- set i#12=╰=
-
- set a#13=—=&rem 不突第N个,第3位,变换
- set b#13=╭=
- set c#13=┊!ob!
- set d#13=┊!oc!
- set e#13=┊
- set f#13=┊
- set g#13=┊
- set h#13=┤
- set i#13=╰=
-
- set a#0= &rem 不突第N个,第1位
- set b#0=╭=
- set c#0=┊!ob!
- set d#0=┊!oc!
- set e#0=┊
- set f#0=┊
- set g#0=┊
- set h#0=┊
- set i#0=╰=
-
- set a#2=—=&rem 不突第N个,第2位
- set b#2=╭=
- set c#2=┊!ob!
- set d#2=┊!oc!
- set e#2=┊
- set f#2=┊
- set g#2=┊
- set h#2=┊
- set i#2=╰=
-
- set a#3=╮ &rem 不突第N个,第3位
- set b#3=╭=
- set c#3=┊!ob!
- set d#3=┊!oc!
- set e#3=┊
- set f#3=┊
- set g#3=┊
- set h#3=┊
- set i#3=╰=
-
- )
-
- (rem 牌型定义
- set #3-1.1=三带一
- set #3-1.2=三带二
- set #3-2.1.1=飞机
- set #3-2.2=飞机
- set #3-2.2.2=飞机
- set #3-3=三顺
- set #3-3.1.1.1=三顺拖
- set #3-3.2.2.2=三顺拖
- set #3-4=三顺
- set #3-4.1.1.1.1=三顺拖
- set #4-1.1.1=四带二
- set #4-1.2=四带二
- set #4-1.2.2=四带二
- set #2-3=连对
- set #2-4=连对
- set #2-5=连对
- set #2-6=连对
- set #2-7=连对
- set #2-8=连对
- set #2-9=连对
- set #2-10=连对
- set #1-5=顺子
- set #1-6=顺子
- set #1-7=顺子
- set #1-8=顺子
- set #1-9=顺子
- set #1-10=顺子
- set #1-11=顺子
- set #1-12=顺子
- set #1-1=n
- set #2-1=一对n
- set #3-1=三个n
- set #4-1=炸弹
- set v#1-1.1=王炸)
-
-
-
- ::定义显示缓存
- set num1=17
- set num2=17
- set num3=17
- set system=请各方叫地主
- set name1=玩家 “你”
- set name2=貂蝉
- set name3=西施
- set comm=出牌
- set comm=讲话
- set rsay1=牌真好呀!这次我赢定了。
- set rsay2=我有炸的,小心哦
- set rsay3=这么烂的牌!可怎么打呀?
- set rsay4=你是MM,还是GG?
- set rsay5=和你合作真是太愉快了
- set rsay6=我要是能抢到地主就好了。
- set rsay7=Hello! everyone.
- set rsay8=你们好呀!
- set rsay9=今天的天气不怎么样
- set rsay0=批处理也能“斗地主”,强吧!
-
- set paix=重新开始
- set paic=0
-
- set kkk=3456789pJQKA2vw#
-
- set "spac= "
-
-
- (set ec0=
- set ec1= ┌──┐ !say2!
- set ec2= │ !ain2:~-2! │
- set ec3= │ │
- set ec4= !name2!│ 张 │
- set ec5= │ │
- set ec6= ╘≡≡╛
- set ec7= !@dz2!!@bj2!
- set ec8= !say3!
- set ec9=!spac:~-80!┌──┐
- set ec10=!spac:~-80!│ !ain3:~-2! │
- set ec11=!sayp32!│ │
- set ec12=!sayp33!│ 张 │!name3!
- set ec13=!sayp34!│ │
- set ec14=!sayp35!╘≡≡╛
- set ec15=!spac:~-80!!@dz3!!@bj3!
- set ec16=玩家!pad1!
- set ec17= !paf1!
- set ec19=西施!pai3d!
- set ec20= !pai3f! !system!
- set ec21=貂蝉!pai2d!
- set ec22= !pai2f!
- set ec23=
- set ec24=
- set ec25=
- set ec26=
- set ec27= !@dz1!!@bj1! !say1!
-
- set ec37=!key!
- set key= a b c d e f g h i j k l m n o p q r s w
- )
-
- ::为了显示方便,用p代替10
-
- ::定义花色数据
- set a1=&set a2=&set a3=&set a4=&set a5=&set a6=
-
- mode con: cols=100 lines=200&color 2f
-
-
-
- :begin 开始/重新开始
- setlocal enabledelayedexpansion
- set sayp32=!spac:~,80!
- set sayp33=!spac:~,80!
- set sayp34=!spac:~,80!
- set sayp35=!spac:~,80!
-
- set n=0
- for %%a in (!key!) do (set w%%a=!n!&set/a n=n+1&set nums=!nums!%%a)
-
- ::随机排序54张牌(洗牌)
- for %%a in (3 4 5 6 7 8 9 p J Q K A 2) do (for %%b in (!a3! !a5! !a4! !a6!) do (set #p!random!.%%a-%%b=1))
- set #P!random!.v-!a1!=1
- set #P!random!.W-!a2!=1
-
- ::发牌,并留三张底
- set/a m=0,n=0
- for /f "tokens=2 delims==." %%a in ('set #p') do (
- set /a m=m%%3+1,n+=1
- if !n! leq 51 (
- for %%c in (!m!) do (
- set he%%c=!he%%c! %%a
- )
- ) else (set di=!di! %%a)
- )
-
- set/a dizu=!random!%%3+1&rem 随机定谁先叫地主
- set sub=pc!dizu!
- set/a quan=0,beis=0
- set say2=!rsay%random:~-1%!
- set say3=!rsay%random:~-1%!
-
- :jdzend 叫地主结束
-
- ::整理各家手上的牌
- for /l %%a in (1,1,3) do (
- setlocal enabledelayedexpansion
- for %%b in (!he%%a!) do (
- for /f "tokens=1,2 delims=-" %%c in ("%%b") do (
- set pd.%%c=!pd.%%c!%%c
- set pf.%%c=!pf.%%c!%%d
- )
- )
-
- for %%b in (3 4 5 6 7 8 9 p J Q K A 2 v W) do (
- set paid=!paid!!pd.%%b!
- set paif=!paif!!pf.%%b!
- )
-
- for /f "tokens=1-2 delims=." %%b in ("!paid!.!paif!") do (
- endlocal
- set pai%%ad=%%b
- set pai%%af=%%c
-
- )
- )
-
- ::电脑诂计牌大小,设定叫分值
- if "!comm!" equ "讲话" (
- set #qW=7
- set #qv=6
- set #q2=4
- set #qa=2
- set #qk=1
- set #q3=-2
- set #q4=-2
- set #q5=-1
- set #q6=-1
- for %%a in (2 3) do (
- set/a var=0,quan%%a=0
- for %%b in (W v 2 a k 3 4 5 6) do (
- if "!pai%%ad:%%b=!" neq "!pai%%ad!" set/a var+=#q%%b
- )
- if !var! gtr 0 set quan%%a=1
- if !var! gtr 4 set quan%%a=2
- if !var! gtr 8 set quan%%a=3
- )
- )
-
-
- set pad1=!pai1d: =!
- set paf1=!pai1f: =!
-
- ::玩家选择的为:@,没选为:#
- set chu=######################
-
- set ain3= !num3!
- set ain2= !num2!
-
- :loop
- set c#=@
- set c@=#
- ::显示玩家牌面部分
- set a1=
- set/a @=4,#=4
- set is@=$
- set/a n=!num1!-1
- if !num1! lss 0 goto :控制中心
-
- setlocal enabledelayedexpansion
- for /l %%a in (0,1,!n!) do (
- for %%z in (!chu:~%%a^,1!) do (
- set hu=&set var=
- if %%z neq !is@! (
- set/a var=!is@!
- set/a hu=m!var!
- set is@=%%z&set %%z=1
- if %%a equ 0 set %%z=4
- ) else (set /a !is@!+=1)
- if !is@! equ @ (set/a n@#=m!@!) else (set/a n@#=m!#!)
- set var=!n@#!!hu!
- if !n@#!!hu! equ 11 set var=12
- for /f "tokens=1-4" %%b in ("!pad1:~%%a,1! !paf1:~%%a,1! !var! !chu%%a!") do (
- set oc=%%c&set ob=%%b
-
- rem 测试用变量显示:echo b%%z%%d%%e !@!-!#! !b%%z%%d%%e! !var!
-
- for %%i in (a b c d e f g h i) do (
- for %%j in ("!%%i%%z%%d%%e!") do (
- set %%iN=!%%iN!%%~j
- ) )
-
- ))
- )
-
-
- if !n@#! equ 3 set n@#=0
- for %%i in (a b c d e f g h i) do (
- for %%j in ("%%i$!is@!!n@#!") do (
- set %%iN=!%%iN!!%%~j!
- ) )
- ::显示玩家牌面部分
-
-
- endlocal&(set ec28=%an%
- set ec29=%bn%
- set ec30=%cn%
- set ec31=%dn%
- set ec32=%en%
- set ec33=%fn%
- set ec34=%gn%
- set ec35=%hn%
- set ec36=%in%)
-
- ::把玩家的牌处理结果送到显示缓存
-
- ::转变量出牌方的显示
-
- if !sub! equ pc2 (
- cls
- for /l %%a in (0,1,37) do for %%b in ("!ec%%a!") do echo; %%~b
- set say1=
- ping -n 2 127.1>nul)
-
-
- :控制中心
- set/a "var=(%sub:~-1%+1)%%3+1"
-
- if !num%var%! leq 2 set @bj%var%=¤!num%var%!张
- if "!num%var%!" equ "0" (echo 游戏结束^^!&endlocal&pause&goto :begin)
-
- ::如果放弃记数等于2,转调用最后一个出牌者,重新出牌。
- if !ascc! geq 2 (
- set sub=!lasssub!
- set paix=重新开始
- )
- set system=轮到 !name%sub:~-1%! !comm!
- goto :%sub%
-
-
- ::AI1 动作 是叫地主,还是出牌,(状态只保持一家)
- :pc2
- if /i "!comm!" equ "讲话" (
- set say2=不叫
- if !beis! lss !quan2! set say2=叫地主&set @dz=%sub%&set/a beis+=1
- set/a quan+=1
- if !quan! gtr 3 goto :jdz
- cls
- for /l %%a in (0,1,37) do for %%b in ("!ec%%a!") do echo; %%~b
- ) else (
-
- set say2=!rsay%random:~-1%!
-
- call :IQ
- if defined bu1 (
- set ec3=!ec3:~,11!┍!bu1:~,-1!┑
- set ec4=!ec4:~,13!│!bu2:~,-1!│
- set ec5=!ec5:~,11!│!bu3:~,-1!│
- set ec6=!ec6:~,9!┕!bu4:~,-1!┙
- ) else (
- set ec3=!ec3:~,11!
- set ec4=!ec4:~,13! 不
- set ec5=!ec5:~,11! 要
- set ec6=!ec6:~,9!
- )
- cls
- for /l %%a in (0,1,37) do for %%b in ("!ec%%a!") do echo; %%~b
- set say2=
- ping -n 2 127.1>nul
- )
- set sub=pc3&goto :控制中心
-
- ::AI2 动作 是叫地主,还是出牌,
- :pc3
- if /i "!comm!" equ "讲话" (
- set say3=不叫
- if !beis! lss !quan3! set say3=叫地主&set @dz=%sub%&set/a beis+=1
- set/a quan+=1
- if !quan! gtr 3 goto :jdz
- cls
- for /l %%a in (0,1,37) do for %%b in ("!ec%%a!") do echo; %%~b
- ) else (
- set say3=!rsay%random:~-1%!
-
- call :IQ
- if defined bu1 (
- set/a var=80-5-chen*3
- for %%v in (!var!) do (
- set sayp32=!spac:~,%%v!┍!bu1:~,-1!┑
- set sayp33=!spac:~,%%v!│!bu2:~,-1!│
- set sayp34=!spac:~,%%v!│!bu3:~,-1!│
- set sayp35=!spac:~,%%v!┕!bu4:~,-1!┙
- )
- ) else (
- set sayp32=!spac:~,80!
- set sayp33=!spac:~,77!不
- set sayp34=!spac:~,77!出
- set sayp35=!spac:~,80!
- )
-
- cls
- for /l %%a in (0,1,37) do for %%b in ("!ec%%a!") do echo; %%~b
- set say3=
- ping -n 2 127.1>nul
- )
- set sub=pc1&goto :控制中心
-
- :error
- ::把显示缓存进行显示输出
- set say1=输入字串中含有不可识别字符
- :pc1
- set ec23=
- set ec24=
- set ec25=
- set ec26=
- if not defined say1 set say1=终于轮到我!comm!了
- cls
- for /l %%a in (0,1,37) do for %%b in ("!ec%%a!") do echo; %%~b
-
- set a讲话=[J]叫地主 [A]加倍 [直接回车pass]
- set a出牌=[U]不出 [X]退出 [T]提示 [选好直接回车出牌]
-
- set input=
- echo.
- echo; !a%comm%!
- set "menu= u x t "
- set /p input= :^>
-
- ::玩家是否叫地主
- if /i "!comm!" equ "讲话" (
- if /i "!input!" equ "J" (set @dz=%sub%&set say1=叫地主&set/a beis+=1)
- set/a quan+=1
- if !quan! gtr 3 goto :jdz
- set sub=pc2
- goto :loop
- )
-
- set say1=
-
- if not defined input if "!chu:@=!" neq "!chu!" goto :chupai 如果已经选择,回车后出牌
-
- if "!menu: %input% =!" neq "!menu!" goto :menu%input% 跳到处理菜单项
-
- ::处理玩家对牌的选择,先把串打散,再一一处理。改变!chu!变量
- for %%a in (!key!) do (for %%b in (!w%%a!) do set input=!input:%%a= %%b !)
- for %%a in (!input!) do (
- if %%a gtr 20 set chu=%chu%&goto :error
- if %%a lss 0 set chu=%chu%&goto :error
- set/a var=1+%%a
- for /f "tokens=1,2" %%b in ("!chu:~%%a,1! !var!") do (
- set chu=!chu:~,%%a!!c%%b!!chu:~%%c!
- )
- )
- goto :loop
-
-
- :chupai
- setlocal enabledelayedexpansion
-
- set var1=
- set var2=
- set chp1=
- set chp2=
- set chpn=0
- for /l %%a in (0,1,!n!) do (
- if "!chu:~%%a,1!" equ "@" (
- set/a num1-=1,chpn+=1
- set chp1=!chp1!!pad1:~%%a,1!
- set chp2=!chp2!!paf1:~%%a,1!
-
- ) else (
- set var1=!var1!!pad1:~%%a,1!
- set var2=!var2!!paf1:~%%a,1!
- )
- )
- ::把选择的牌提取出来
-
-
- set /a var=chpn-1
- set pad=!chp1!
- set paf=!chp2!
- for /l %%a in (0,1,!var!) do (
- for %%b in ("!pad:~%%a,1!") do (
- set/a pd.%%~b+=1
- set pds.%%~b=!pds.%%~b!!pad:~%%a,1!
- set pfs.%%~b=!pfs.%%~b!!paf:~%%a,1!
- )
- )
-
- for %%a in (3 4 5 6 7 8 9 p J Q K A 2 v w) do (
- for %%b in (!pd.%%a!) do (
- set pd.#%%b=!pd.#%%b! %%a
- )
- )
-
- for /l %%a in (4,-1,1) do (
- set vkk=0!kkk:~,-4!
- set pstr=
- set n=1
- if defined pd.#%%a (
- for %%b in (!pd.#%%a!) do (
- if not defined ptop (
- if "!vkk:~,1!" equ "%%b" (set /a n+=1) else (set pstr=!pstr!.!n!&set n=1)
- set vkk=!vkk:*%%b=!
- ) else (set pstr=!pstr!.%%a)
- set chv1=!chv1!!pds.%%b!
- set chv2=!chv2!!pfs.%%b!
- )
- if not defined ptop (set ptop=#%%a-!n!!pstr:~2!) else (set pstr1=!pstr1!.%%a!pstr:~2!)
- )
- )
-
- set ppp=!ptop!!pstr1!
-
- rem 起牌检查规则 可以处理炸弹及王炸
-
- if not defined !ppp! (
- if "!chv1:~,1!!ppp!" equ "v#1-1.1" (set paix=v#1-2&set paic=v&goto :zhaid)
- endlocal&set say1=你选择的牌不符合规则!%chv1:~,1%%ppp%&goto :pc1
- )
-
-
- if "!paix!" equ "重新开始" (set paic=!kkk!) else (
- if "!ppp!" neq "!paix!" (
- if "!ppp!" equ "#4-1" (set paix=#4-1&set paic=!kkk!&goto :zhaid)
- endlocal&set say1=你选择的牌不符合规则!%chp1%&goto :pc1
- )
- )
- ::牌形不对不可以出,重新出牌任出。
-
-
- :zhaid 炸弹处理
-
-
- if "!paic:%chv1:~,1%=!" equ "!paic!" (endlocal&set say1=你选择的牌小了!%chv1%&goto :pc1)
-
- ::小于不可以出
-
- ( endlocal
- set chp1=%chv1%
- set chp2=%chv2%
- set chpn=%chpn%
- set pad1=%var1%
- set paf1=%var2%
-
- set chu=%chu:@=%
- set num1=%num1%
- rem 提取选好的牌到变量chp1(点) chp2(花)chpn(个数)paix(牌形)paic(关键点数)
-
- set paix=%ppp%
- set paic=!kkk:*%chv1:~,1%=!
- )
-
- set say1=!rsay%random:~-1%!
-
- call :putbuff 把要出的牌转换为显示变量
-
- ::再送显示缓存
- set ec23=┍!bu1:~,-1!┑
- set ec24=│!bu2:~,-1!│
- set ec25=│!bu3:~,-1!│
- set ec26=┕!bu4:~,-1!┙
- ::下一个人
- set sub=pc2&goto :loop
-
-
- ::系统选项处理 x u t
- :menuX
-
- start "" C:\BatMPlayer\BatMPlayer.bat G&&exit
-
- :menuU
- set ec24= Pass...
- set/a ascc+=1
- set chu=#########################
- set sub=pc2&goto :loop
-
- :menuT
- echo 暂时还不支持此功能!
- pause>nul
- goto :pc1
-
-
-
- :jdz 叫地主处理 三家均调用这里
- if not defined @dz goto :begin
- set var=%@dz:~-1%
- set sub=%@dz%
- set he%var%=!he%var%!!di!
- set num%var%=20
- set comm=出牌
- set @dz%var%=★地主★
- set lasssub=pc%var%
- set ascc=2
- goto :jdzend
-
- :IQ 电脑自动出牌
- setlocal enabledelayedexpansion
- set /a vn=%sub:~-1%
- set /a var=num!vn!-1
-
- set pad=!pai%vn%d!
- set paf=!pai%vn%f!
- ::玩家数据读入临时变量
-
- for /l %%a in (0,1,!var!) do (
- for %%b in ("!pad:~%%a,1!") do (
- set/a pd.%%~b+=1
- set pds.%%~b=!pds.%%~b!!pad:~%%a,1!
- set pfs.%%~b=!pfs.%%~b!!paf:~%%a,1!
- )
- )
- ::按点数整理
- ::pd.%%~b 同点个数
- ::pds.%%~b 同点串
- ::pds.%%~b 同花串
-
-
- for %%a in (3 4 5 6 7 8 9 p J Q K A 2 v w) do (
- for %%b in (!pd.%%a!) do (
- set pd.##%%b=!pd.##%%b!%%a
- for /l %%c in (%%b,-1,1) do (
- set pd.#%%c=!pd.#%%c!%%a
- )
- )
- )
- ::按个数统计
- ::pd##.n 分别为1到4个的点
- ::pd#.n 分别为1到4个的点,向下兼容,如有2个时,对1个也有效
-
-
-
-
- if "!paix!" equ "重新开始" (
- set paic=!kkk!
- for /l %%a in (0,1,4) do (
- for %%b in ("!pd.#1:~%%a,1!") do (
- if %%b equ "" goto :you
- set paix=#!pd.%%~b!-1&set chpn=!pd.%%~b!
- if "!pd.%%~b!" neq "4" goto :you
- )
- )
- )
-
- ::如果是发牌,则取最小的出
-
- :you
-
-
- set paid=&set paif=&set pad=&set paf=
-
-
- if defined pd.#%paix:~,2% (
- set str=!pd.#%paix:~,2%!$
- set nn=!pd.#%paix:~,2%!%nums%
- set /a nn=w!nn:~20,1!
- for /l %%a in (0,1,!nn!) do (
- for %%b in ("!str:~%%a,%paix:~3,1%!") do (
- set find=%%~b
- if "!paic:%%~b=!" neq "!paic!" (goto :ok)
- )
- )
-
- )
- ::nn 取同型串的长度
- ::paic 已经把比当前点小的丢弃,所以如果%%b不在串中则认为比当前点大,可以出牌
- ::否则清空find
-
-
- set find=
- :ok
-
- ::如果主牌型对且大,则存在find
- if defined find (
- for /l %%a in (%paix:~3,1%,-1,1) do (
- for %%b in ("!find:~-%%a,1!") do (
- set paid=!paid!!pds.%%~b:~,%paix:~1,1%!
- set paif=!paif!!pfs.%%~b:~,%paix:~1,1%!
- set pds.%%~b=!pds.%%~b:~%paix:~1,1%!
- set pfs.%%~b=!pfs.%%~b:~%paix:~1,1%!
- )
- )
- rem 根据牌型的连顺数把点及花串放到结果变量,并在原串减去
-
- set var=%paix:~5%
- if defined var (
- for %%a in ("!var:.=" "!") do (
- if defined pd.##%%~a (
- for %%b in ("!pd.##%%~a:~,1!") do (
- set paid=!paid!!pds.%%~b:~,%%~a!
- set paif=!paif!!pfs.%%~b:~,%%~a!
- set pds.%%~b=!pds.%%~b:~%%~a!
- set pfs.%%~b=!pfs.%%~b:~%%~a!
- )
- set pd.##%%~a=!pd.##%%~a:~1!
- ) else (
- if defined pd.#%%~a (
- for %%b in ("!pd.#%%~a:~,1!") do (
- set paid=!paid!!pds.%%~b:~,%%~a!
- set paif=!paif!!pfs.%%~b:~,%%~a!
- set pds.%%~b=!pds.%%~b:~%%~a!
- set pfs.%%~b=!pfs.%%~b:~%%~a!
- )
- set pd.#%%~a=!pd.#%%~a:~1!
- )
- if defined pd.##4 set paix=#4-1&set chpn=4&set paic=!kkk!&goto :you
- endlocal
- set bu1=
- set/a ascc+=1
- goto :eof
- )
-
- )
- )
- rem 处理牌型尾巴部分,没有也不能出牌
-
- for %%a in (3 4 5 6 7 8 9 p J Q K A 2 v W) do (
- set pad=!pad!!pds.%%a!
- set paf=!paf!!pfs.%%a!
- )
-
- ) else (
- if defined pd.##4 set paix=#4-1&set chpn=4&set paic=!kkk!&goto :you
- endlocal
- set bu1=
- rem 放弃记数加1
- set/a ascc+=1
- goto :eof
- )
-
- rem 可以出牌
- goto :skrem
- set pd
- set ch
- set pai
- echo !find! !kkk!
- echo !str!
- pause
- :skrem
-
-
- ::判断是否有相同的类型,paix(#3-2.1.1),有的话,取一个比当前的大的出牌。
-
- ::如果有符合的牌,则提取选好的牌到变量paig(点字符串) paif(花字符串)chpn(个数不变)paix(规则不变)最后点数(paic)
-
- ::按现出规则,如果有大的则出牌
-
- (endlocal
- set pai%vn%d=%pad%
- set pai%vn%f=%paf%
- set paic=!kkk:*%find:~,1%=!
- set chp1=%paid%
- set chp2=%paif%
- set/a num%vn%=num%vn%-%chpn%
- set chpn=%chpn%
- set paix=%paix%
- )
-
-
- set ain2= !num2!
- set ain3= !num3!
-
-
- ::出牌显示处理
- :putbuff
- set bu1=&set bu2=&set bu3=&set bu4=
- set/a chen=chpn-1
-
- if !num%sub:~-1%! equ 0 set system=这一盘 !name%sub:~-1%! 赢了!
- for /l %%a in (0,1,!chen!) do (
- set bu1=!bu1!=┯
- set bu2=!bu2!!chp1:~%%a,1!│
- set bu3=!bu3!!chp2:~%%a,1!│
- set bu4=!bu4!=┷
- )
- ::放弃记数清0,记录最后出牌者
- set ascc=0
- set lasssub=%sub%
- goto :eof
-
- :aizlp
-
-
-
- 需要解决的问题
-
- 3。电脑出牌,如何处理组合牌形,如:顺子,三带一(二),飞机,四带二,连对等。
复制代码 注:非原创 |