/// <summary> /// 完成结算 /// </summary> /// <param name="tableData"></param> private void DoComplatedSettlement(TableData tableData) { //放入空桌池中RoomData roomData; RoomData roomData = GetRoomData(tableData.RoomId); if (roomData != null) { foreach (PositionData position in tableData.Positions) { var user = GetUser(position.UserId); if (user != null) { user.Property.InitTablePos(); } position.Init(); } tableData.Init(); if (roomData.Tables.Remove(tableData.TableId)) { //Console.WriteLine("Table:{0} is init", tableData.TableId); int minTableCount = ConfigEnvSet.GetInt("Game.Table.MinTableCount", 10); if (roomData.TablePool.Count < minTableCount) { roomData.TablePool.Enqueue(tableData); } else { tableData.Dispose(); } return; } } TraceLog.WriteError("TableData object {1} in {0} room has be disposed error.", tableData.RoomId, tableData.TableId); }
/// <summary> /// 检查是否开始 /// </summary> /// <param name="tableData"></param> public void CheckStart(TableData tableData) { bool started = !Array.Exists(tableData.Positions, pos => !pos.IsAI && pos.UserId == 0); if (started) { //todo TraceLog.WriteComplement("房间:{0},桌:{1}开始发牌...", tableData.RoomId, tableData.TableId); foreach (var p in tableData.Positions) { p.ReSendCard(); } tableData.Init(); //随机第一个开始叫地主 int index = RandomUtils.GetRandom(0, tableData.Positions.Length); var pos = tableData.Positions[index]; tableData.CallLandlordPos = pos.Id; tableData.CallLandlordId = pos.UserId; tableData.CallLandlordName = pos.NickName; TraceLog.WriteComplement("房间:{0},桌:{1}第一个开始叫地主{2}", tableData.RoomId, tableData.TableId, pos.Id + pos.NickName); SendCard(tableData, TableData.CardBackNum); SyncNotifyAction(ActionIDDefine.Cst_Action2004, tableData, null, t => { TraceLog.WriteComplement("桌子:{0}底牌:{1}", tableData.TableId, string.Join(",", tableData.BackCardData)); foreach (var p in tableData.Positions) { _cardRole.SortCard(p.CardData); TraceLog.WriteComplement("桌子:{0}玩家{1}-{2}牌:{3}", tableData.TableId, p.UserId, p.NickName, string.Join(",", p.CardData)); } TraceLog.WriteComplement("房间:{0},桌:{1}发牌结束", tableData.RoomId, tableData.TableId); }); } }