/// <summary> /// 检查赠送金豆 /// </summary> /// <param name="user"></param> /// <param name="roomInfo"></param> public bool CheckDailyGiffCoin(GameUser user, RoomInfo roomInfo) { UserDailyRestrain restrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(user.PersonalId); if (restrain != null) { RefreshRestrain(restrain); int dailyGiffCoinTime = ConfigEnvSet.GetInt("User.DailyGiffCoinTime", 1); if (restrain.RestrainProperty.DailyGiffCoinTime < dailyGiffCoinTime) { user.GameCoin = MathUtils.Addition(user.GameCoin, roomInfo.GiffCion); restrain.RestrainProperty.DailyGiffCoinTime = MathUtils.Addition(restrain.RestrainProperty.DailyGiffCoinTime, 1); return true; } } return false; }
/// <summary> /// 选择桌位,找不到桌子自动新开一个 /// </summary> /// <param name="user"></param> /// <param name="roomData"></param> /// <param name="roomInfo"></param> /// <returns></returns> public TableData SelectTable(GameUser user, RoomData roomData, RoomInfo roomInfo) { TableData useTable = null; roomData.Tables.Foreach((key, table) => { if (SelectPosition(user, roomData, table)) { useTable = table; //退出Foreach return false; } return true; }); if (roomData.TablePool.Count == 0) { //初始桌数 int minTableCount = ConfigEnvSet.GetInt("Game.Table.MinTableCount", 10); var pokers = PokerList; TableData tableData = null; for (int i = 0; i < minTableCount; i++) { int tableId = roomData.NewTableId; tableData = new TableData(roomData.RoomId, tableId, roomInfo.PlayerNum, roomInfo.AnteNum, roomInfo.MultipleNum, DoTableTimer, roomInfo.CardPackNum); roomData.TablePool.Enqueue(tableData); CreateCardData(tableData, pokers); } } if (useTable == null && roomData.TablePool.TryDequeue(out useTable)) { SetTablePosition(roomData.RoomId, useTable, useTable.Positions[0], user); roomData.Tables.Add(useTable.TableId, useTable); } if (useTable != null && !useTable.IsTimerStarted) { int periodAiStart = ConfigEnvSet.GetInt("Game.Table.AIIntoTime", 5000); useTable.ReStartTimer(periodAiStart); } return useTable; }
/// <summary> /// 进入房间 /// </summary> public void Enter(GameUser user, RoomInfo roomInfo) { List<PositionData> list = new List<PositionData>(); string key = roomInfo.Id.ToString(); RoomData roomData; if (_roomStruct.TryGet(key, out roomData)) { var tableData = GameTable.Current.SelectTable(user, roomData, roomInfo); if (tableData != null && tableData.Positions.Length > 0) { GameTable.Current.SyncNotifyAction(ActionIDDefine.Cst_Action2003, tableData, null, c => { GameTable.Current.CheckStart(tableData); }); } } }