惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
C
Check Point Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
Vercel News
Vercel News
腾讯CDC
GbyAI
GbyAI
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件

博客园 - 石曼迪

.net core web api 发布填坑 Visual Studio 2026 开发 MAUI app 记录 Windows下搭建rustdesk远程服务 nginx 二级域名配置 .NET CORE 相关配置 frps-frpc配置 使用SuperSocket开发联网斗地主(三):抢地主 使用SuperSocket开发联网斗地主(二):发牌 使用SuperSocket开发联网斗地主(一):联网 SuperSocket服务端与客户端搭建 EXCEL脚本收藏 小程序开发记录 Python练习 Python基础总结 在centos7.6上部署.netcore 3.0 web程序 最简单的centos上安装Nginx办法 七牛网数据备份 solr搜索分词优化 Ionic异常及解决 狗日的腾讯
使用SuperSocket开发联网斗地主(四):出牌
石曼迪 · 2022-01-09 · via 博客园 - 石曼迪

本节内容:

出牌和大牌逻辑。(昨天新发现了还有一个专门做游戏开发的框架cocos,后面学习下这个吧,这个就不更新了)

出牌逻辑:

1. 如果当前没人出牌,我是第一个,只需符合出牌条件就行;

2. 如果之前有人出牌,就要既符合出牌条件也要大住上家;

/// <summary>
/// 是否符合出牌规则
/// </summary>
/// <param name="userShowedList"></param>
/// <returns></returns>
private static bool WithRules(List<DouDiZhuGameCard> userShowedList)
{
     int userShowedCount = userShowedList.Count();
     bool can = true;
     //单牌,对子,三不带(连字需要5张及以上)
     if (userShowedCount <= 3)
     {
         DouDiZhuGameCard last = null;
         foreach (var item in userShowedList)
         {
             if (last == null || last.CardName == item.CardName)
             {
                 last = item;
             }
             else
             {
                 can = false;
                 break;
             }
         }
         return can;
     }
     //...其他的规则
     return can;
}

大牌

/// <summary>
/// 能否大过上家
/// </summary>
/// <param name="userShowedList"></param>
/// <param name="LastShowedList"></param>
/// <returns></returns>
private static bool IsBigger(List<DouDiZhuGameCard> userShowedList, List<DouDiZhuGameCard> LastShowedList)
{
     int userShowedCount = userShowedList.Count();
     int lastShowedCount = LastShowedList.Count();
     bool can = true;
     //单牌,对子,三不带(连字需要5张及以上)
     if (userShowedCount <= 3)
     {
         return userShowedList[0].CardValue > LastShowedList[0].CardValue;
     }
     //...其他的规则
     return can;
}

然后客户端需要通知其他人当前出的牌,思路是把出的牌放在底牌区域,用以展示

然后就是控制按钮的显示与隐藏等

//出牌成功

else if (result.Action == "show_ok") {

diPai = result.Data.CommonCards;

player_me = result.Data.MyCards;

shuaXinTangZi();

shuaXinShouPai();

if (result.Data.IsMyTurn)

        {

btnBox.children[0].style.display = 'none';

btnBox.children[1].style.display = 'none';

btnBox.children[2].style.display = 'none';

btnBox.children[3].style.display = 'inline-block';

btnBox.children[4].style.display = 'inline-block';

        }

else

        {

btnBox.children[0].style.display = 'none';

btnBox.children[1].style.display = 'none';

btnBox.children[2].style.display = 'none';

btnBox.children[3].style.display = 'none';

btnBox.children[4].style.display = 'none';

        }

    }

//出牌错误

else if (result.Action == "show_err") {

//startQiangDiZhu(result.Data);

    }

//公开广播信息

else if (result.Action == "pubInfo") {

pubUserInfo(PlayerMeInfo,result.Data);

    }

效果图:

image

image

image

image

image

代码下载