erlang-麻将胡牌

 最近休息在家还没时间工作,闲来晚上写写服务端开发,还是使用之前比较有熟悉的erlang,最近棋牌挺火爆!使用erlang实现下麻将胡牌,测试已经可以!

 下面是部分代码(写不好不要吐槽!哈哈):全部代码到git https://github.com/StartHua/erlang-- 记住后面加--(不改了程序本是坑)

checkHu(UserPai) ->
T = getMyPaisForRecord(UserPai,#r_userMyPai{}),
%第一步检查AAA(减少检查,代码难看)
{A1,B1} = validHu_AAA(T#r_userMyPai.wan,0),
M = case (A1 and (B1 =< 1)) of
true  ->
{A2,B2} = validHu_AAA(T#r_userMyPai.tiao,0),
case (A2 and (B2 =< 1)) of
true  ->
{A3,B3} = validHu_AAA(T#r_userMyPai.bing,0),
case (A3 and (B3 =< 1)) of
true  ->
{A4,B4} = validHu_AAA(T#r_userMyPai.feng,0),
case (A4 and (B4 =< 1)) of
true  ->
{A5,B5} = validHu_AAA(T#r_userMyPai.zfb,0),
Count = B1+B2+B3+B4+B5,
(A5 and (Count == 1));
false ->
false
end;
false ->
false
end;
false ->
false
end;
false ->
false
end,


% 第二部检查AA
MAA = case M of
true  ->
true;
false ->
{A11,B11} = validHu_AA(T#r_userMyPai.wan,0),
case (A11 and (B11 =< 1)) of
true  ->
{A22,B22} = validHu_AA(T#r_userMyPai.tiao,0),
case (A22 and (B22 =< 1)) of
true  ->
{A33,B33} = validHu_AA(T#r_userMyPai.bing,0),
case (A33 and (B33 =< 1)) of
true  ->
{A44,B44} = validHu_AA(T#r_userMyPai.feng,0),
case (A44 and (B44 =< 1)) of
true  ->
{A55,B55} = validHu_AA(T#r_userMyPai.zfb,0),
Count2 = B11+B22+B33+B44+B55,
(A55 and (Count2 == 1));
false ->
false
end;
false ->
false
end;
false ->
false
end;
false ->
false
end
end,


% 检查ABC
MABC = case MAA of
true ->
true;
false ->
{A111,B111} = validHu_AA(T#r_userMyPai.wan,0),
M111 = case (A111 and (B111 =< 1)) of
true  ->
{A222,B222} = validHu_AA(T#r_userMyPai.tiao,0),
case (A222 and (B222 =< 1)) of
true  ->
{A333,B333} = validHu_AA(T#r_userMyPai.bing,0),
case (A333 and (B333 =< 1)) of
true  ->
{A444,B444} = validHu_AA(T#r_userMyPai.feng,0),
case (A444 and (B444 =< 1)) of
true  ->
{A555,B555} = validHu_AA(T#r_userMyPai.zfb,0),
Count3 = B111+B222+B333+B444+B555,
(A555 and (Count3 == 1));
false ->
false
end;
false ->
false
end;
false ->
false
end;
false ->
false
end
end.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值