当前位置: 首页>>代码示例>>C#>>正文


C# TableData.DoDouble方法代码示例

本文整理汇总了C#中ZyGames.Doudizhu.Model.TableData.DoDouble方法的典型用法代码示例。如果您正苦于以下问题:C# TableData.DoDouble方法的具体用法?C# TableData.DoDouble怎么用?C# TableData.DoDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZyGames.Doudizhu.Model.TableData的用法示例。


在下文中一共展示了TableData.DoDouble方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CallCard

        /// <summary>
        /// 叫地主
        /// </summary>
        /// <param name="positionId"></param>
        /// <param name="tableData"></param>
        /// <param name="isCall">true:叫,false:不叫</param>
        public void CallCard(int positionId, TableData tableData, bool isCall)
        {
            if (positionId != tableData.CallLandlordPos)
            {
                TraceLog.WriteComplement("桌子:{0}未轮到位置{1}叫地主", tableData.TableId, positionId);
                return;
            }
            if (tableData.CallTimes < tableData.CallOperation.Length)
            {
                if (isCall)
                {
                    tableData.DoDouble();
                    TraceLog.WriteComplement("桌子:{0}叫地主加倍{1}", tableData.TableId, tableData.MultipleNum);
                }
                tableData.CallOperation[tableData.CallTimes] = isCall;
                tableData.CallTimes++;
            }
            if (tableData.CallTimes > tableData.PlayerNum - 1 &&
                !Array.Exists(tableData.CallOperation, op => op))
            {
                //都不叫时重新发牌接口
                TraceLog.WriteComplement("桌子:{0}重新发牌,CallTimes:{1},Log:{2}", tableData.TableId, tableData.CallTimes, string.Join(",", tableData.CallOperation));
                CheckStart(tableData);
                return;
            }

            int noCallNum = 0;
            int calledNum = 0;
            int preCallIndex = 0;//上次操作的索引
            //计算叫地主记录中,不叫次数
            int endIndex = tableData.CallTimes - 1;
            for (int i = endIndex; i >= 0; i--)
            {
                bool called = tableData.CallOperation[i];
                if (!called)
                {
                    noCallNum++;
                }
                else
                {
                    calledNum++;
                }
                if (called && calledNum == 1)
                {
                    preCallIndex = i;
                }
            }
            TraceLog.WriteComplement("桌子:{0}位置:{1},前一个:{2},最后一个:{3}叫地主", tableData.TableId, positionId, preCallIndex, endIndex);
            if ((tableData.CallTimes == tableData.PlayerNum && noCallNum == tableData.PlayerNum - 1) ||
                tableData.CallTimes > tableData.PlayerNum)
            {
                int index = endIndex - preCallIndex;
                index = (positionId + tableData.PlayerNum - index) % tableData.PlayerNum;
                PositionData pos = index >= 0 && index < tableData.Positions.Length ? tableData.Positions[index] : null;
                if (pos != null)
                {
                    //确定地主
                    pos.IsLandlord = true;
                    tableData.LandlordPos = pos.Id;
                    tableData.LandlordId = pos.UserId;
                    tableData.IsCallEnd = true;
                    tableData.OutCardPos = pos.Id;
                    tableData.OutCardUserId = pos.UserId;
                    //增加底牌
                    pos.CardData.AddRange(tableData.BackCardData);
                    _cardRole.SortCard(pos.CardData);
                }
            }
            else
            {
                //取下个叫地主玩家
                int nextPos = (positionId + 1) % tableData.PlayerNum;
                PositionData pos = tableData.Positions[nextPos];
                if (pos != null)
                {
                    tableData.CallLandlordPos = pos.Id;
                    tableData.CallLandlordId = pos.UserId;
                    tableData.CallLandlordName = pos.NickName;
                }
            }
            var param = new Parameters();
            param.Add("IsCall", isCall ? 1 : 0);
            param.Add("IsRob", (calledNum == 1 && isCall) || calledNum == 0 ? 0 : 1);
            SyncNotifyAction(ActionIDDefine.Cst_Action2006, tableData, param, null);

            TraceLog.WriteComplement("桌子:{0}叫地主通知成功,地主是:{1},是否结束{2}",
                tableData.TableId,
                tableData.IsCallEnd ? (tableData.LandlordId + "") : (tableData.CallLandlordId + tableData.CallLandlordName),
                tableData.IsCallEnd);
        }
开发者ID:kehaoran74,项目名称:Scut,代码行数:96,代码来源:GameTable.cs

示例2: DoOutCardEnd

 /// <summary>
 /// 出牌结束,并结算积分
 /// </summary>
 /// <param name="tableData"></param>
 private void DoOutCardEnd(TableData tableData)
 {
     int count = (tableData.CardData.Count - TableData.CardBackNum) / tableData.PlayerNum;
     int landCount = count + TableData.CardBackNum - 1;//地主只出一张
     int[] cardNums = new int[tableData.Positions.Length];
     int landIndex = 0;
     int index = 0;
     int noOutNum = 0;
     List<PositionData> posList = new List<PositionData>();
     foreach (PositionData position in tableData.Positions)
     {
         if (position.IsLandlord)
         {
             landIndex = index;
         }
         else
         {
             posList.Add(position);
         }
         if (position.CardData.Count == count)
         {
             noOutNum++;
         }
         cardNums[index] = position.CardData.Count;
         index++;
     }
     //春天判断
     if ((tableData.IsLandlordWin && noOutNum == 2) ||
         (!tableData.IsLandlordWin && cardNums[landIndex] == landCount))
     {
         tableData.DoDouble();
     }
     var pos = tableData.Positions[landIndex];
     DoSettlement(tableData, tableData.IsLandlordWin, pos, posList);
 }
开发者ID:kehaoran74,项目名称:Scut,代码行数:39,代码来源:GameTable.cs

示例3: ShowCard

        /// <summary>
        /// 明牌
        /// </summary>
        /// <param name="user"></param>
        /// <param name="tableData"></param>
        public void ShowCard(GameUser user, TableData tableData)
        {
            var pos = GetUserPosition(user, tableData);
            if (pos != null && pos.IsLandlord && !tableData.IsShow)
            {
                tableData.DoDouble();
                pos.IsShow = true;
                tableData.IsShow = true;
                SyncNotifyAction(ActionIDDefine.Cst_Action2008, tableData, null, null);

                TraceLog.WriteComplement("桌子:{0}玩家{1}明牌通知成功", tableData.TableId, user.UserId);
            }
        }
开发者ID:kehaoran74,项目名称:Scut,代码行数:18,代码来源:GameTable.cs

示例4: CheckFlee

        /// <summary>
        /// 检查逃跑,并结束当局游戏,扣分两家平分
        /// </summary>
        /// <param name="user"></param>
        /// <param name="table"></param>
        /// <param name="userPos"></param>
        private void CheckFlee(GameUser user, TableData table, PositionData userPos)
        {
            table.IsClosed = true;
            if (table.IsStarting)
            {
                int multipleMinNum = ConfigEnvSet.GetInt("Game.FleeMultipleNum", 10);
                PositionData pos = null;
                List<PositionData> posList = new List<PositionData>();
                //计算炸弹数量
                foreach (PositionData position in table.Positions)
                {
                    if (position.UserId == user.UserId)
                    {
                        pos = position;
                    }
                    else
                    {
                        posList.Add(position);
                    }
                    var obj = _cardRole.ParseCardGroup(position.CardData.ToArray());
                    for (int i = 0; i < obj.Count; i++)
                    {
                        var item = obj.GetSame(i);
                        if (item.Length == 4 || (item.Length == 2 && _cardRole.GetCardSize(item[0]) > (int)CardSize.C_2))
                        {
                            table.DoDouble();
                        }
                    }
                }
                table.IsFlee = true;
                if (table.MultipleNum < multipleMinNum)
                {
                    table.SetDouble(multipleMinNum);
                }
                DoSettlement(table, false, pos, posList);
                var param = new Parameters();
                param.Add("FleeUserId", user.UserId);
                var userList = ClientNotifier.GetUserList(table, user.UserId);
                SyncNotifyAction(ActionIDDefine.Cst_Action2013, userList, param,
                    c =>
                    {
                        DoComplatedSettlement(table);
                        //
                        TraceLog.WriteComplement("桌子:{0}玩家{1}逃跑通知", table.TableId, user.UserId);
                    });

                NotifyUserChange(user.UserId);
            }
            else
            {
                //还没有开始时,可以离开位置等待新玩家
                user.Property.InitTablePos();
                userPos.Init();
                table.IsClosed = false;
                int periodAiStart = ConfigEnvSet.GetInt("Game.Table.AIIntoTime", 5000);
                table.ReStartTimer(periodAiStart);
                var userList = ClientNotifier.GetUserList(table, user.UserId);
                SyncNotifyAction(ActionIDDefine.Cst_Action2003, userList, null, null);
            }
        }
开发者ID:kehaoran74,项目名称:Scut,代码行数:66,代码来源:GameTable.cs

示例5: DoOutCard

        /// <summary>
        /// 出牌
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="positionId"></param>
        /// <param name="tableData"></param>
        /// <param name="cardsStr"></param>
        /// <param name="errorCode">0:正常,1:不合规则,2:不存在牌,3:离开桌位</param>
        public bool DoOutCard(int userId, int positionId, TableData tableData, string cardsStr, out int errorCode)
        {
            errorCode = 0;
            int[] cards = new int[0];
            if (!string.IsNullOrEmpty(cardsStr.Trim()))
            {
                string[] tempArray = cardsStr.Split(new char[] { ',' });
                List<int> tempList = new List<int>();
                for (int i = 0; i < tempArray.Length; i++)
                {
                    if (!string.IsNullOrEmpty(tempArray[i]))
                    {
                        tempList.Add(tempArray[i].ToInt());
                    }
                }
                cards = tempList.ToArray();
            }

            var pos = GetUserPosition(positionId, tableData);
            if (pos == null)
            {
                errorCode = 3;
                return false;
            }
            if (!CheckCardEffective(pos.CardData, cards))
            {
                errorCode = 2;
                TraceLog.WriteComplement("桌子:{0}玩家{0}出牌{1}不在手中的牌内", tableData.TableId, userId, cardsStr);
                return false;
            }
            int cardSize;
            var cardType = _cardRole.GetCardType(cards, out cardSize);
            if (cardType == DeckType.Error)
            {
                errorCode = 1;
                TraceLog.WriteComplement("桌子:{0}玩家{0}出牌{1}不合规则", tableData.TableId, userId, cardsStr);
                return false;
            }
            if (cardType == DeckType.None && CheckOutCardNoneType(tableData))
            {
                //多次循环不出牌,则结束
                tableData.StopTimer();
                var param = new Parameters();
                param.Add("FleeUserId", 0);
                SyncNotifyAction(ActionIDDefine.Cst_Action2013, tableData, param,
                    c =>
                    {
                        //Console.WriteLine("Table:{0} is stop", tableData.TableId);
                        DoComplatedSettlement(tableData);
                        TraceLog.WriteError("桌子{0}多次连续不出牌并强制退出桌位", tableData.TableId);
                    });
                errorCode = 3;
                return true;
            }
            CardData cardData = new CardData(userId, positionId);
            cardData.Cards = cards;
            cardData.Type = cardType;
            cardData.CardSize = cardSize;

            if (tableData.PreCardData != null)
            {
                //压牌
                CardData tempData = tableData.PreCardData;
                if (cardData.Type != DeckType.None &&
                    tempData.Type != DeckType.None &&
                    tempData.UserId != cardData.UserId &&
                    !_cardRole.EqualsCard(cardData, tempData))
                {
                    errorCode = 1;
                    return false;
                }
            }
            foreach (var card in cardData.Cards)
            {
                pos.CardData.Remove(card);
            }
            tableData.OutCardList.Add(cardData);
            if (cardData.Type != DeckType.None)
            {
                tableData.PreCardData = cardData;
            }

            if (cardData.Type == DeckType.Bomb ||
                cardData.Type == DeckType.WangBomb)
            {
                tableData.DoDouble();
            }
            if (pos.CardData.Count > 0)
            {
                int index = (pos.Id + 1) % tableData.PlayerNum;
                var nextPos = tableData.Positions[index];
                tableData.OutCardPos = nextPos.Id;
//.........这里部分代码省略.........
开发者ID:kehaoran74,项目名称:Scut,代码行数:101,代码来源:GameTable.cs


注:本文中的ZyGames.Doudizhu.Model.TableData.DoDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。