private void setPbCards(List <int> list, int state) { if (list.Count <= 0) { return; } DealState = state; if (state == 5 && PublicCards.Count >= 4) // 转牌 { return; } else if (state == 6 && PublicCards.Count >= 5) // 河牌 { return; } if (state == 4) // 翻牌 { PublicCards.Clear(); } foreach (int pb in list) { PublicCards.Add(pb); } }
private void byJson(Dictionary <string, object> json, bool gameStart = false) { var options = json.Dict("options"); var gamers = json.Dict("gamers"); Type.Value = string2GameType(json.String("type")); Coins = json.Int("coins"); Bankroll.Value = json.Int("bankroll"); BB = options.Int("limit"); OwnerName = json.Dict("owner").String("name"); Owner = options.String("ownerid") == GameData.Shared.Uid; BankrollMul = options.IL("bankroll_multiple"); Ante.Value = options.Int("ante"); PlayerCount.Value = options.Int("max_seats"); Rake = options.Float("rake_percent"); Duration = options.Int("time_limit"); NeedAudit = options.Int("need_audit") == 1; GPSLimit.Value = options.Int("gps_limit") > 0; IPLimit.Value = options.Int("ip_limit") == 1; Award27 = options.Int("award_27") == 1; BuryCard = options.Int("bury_card") == 1; GameCode.Value = options.String("code"); Straddle.Value = options.Int("straddle") == 1; SettingThinkTime = ThinkTime = options.Int("turn_countdown"); OffScore.Value = options.Int("off_score") == 1; LimitRule = options.Int("limit_rule") == 1; LeagueID = options.String("league_id"); AllowClubs = json.List("allowclubs"); NeedInsurance.Value = options.Int("need_insurance") == 1; DealerSeat.Value = json.Int("dealer_seat"); Pot.Value = json.Int("pot"); Pots.Value = json.DL("pots"); var startTs = json.Int("begin_time"); StartTime = _.DateTimeFromTimeStamp(startTs); // 游戏是否已开始 GameStarted.OnNext(startTs != 0); if (IsMatch()) { MatchData.Type = options.Int("sub_type"); MatchData.LimitLv = options.Int("limit_level"); MatchData.Rebuy = options.Int("rebuy_count"); MatchData.Addon = options.Int("add_on"); MatchData.IsHunter = options.Int("reward_ratio") > 0; BlindLv = json.Int("blind_lv"); MatchData.JoinFee = options.Int("join_fee"); MatchData.RebuyFee = options.Int("rebuy_fee"); MatchData.MatchRoomStatus.OnNext((MatchRoomStat)json.Int("match_room_status")); var lt = MatchData.MatchRoomStatus.Value == MatchRoomStat.Rest ? json.Int("half_break_countdown") : json.Int("blind_countdown"); LeftTime.OnNext(lt); MatchData.MTTType = options.Int("blind_type") == 0 ? MTTType.Normal : MTTType.Fast; } else { LeftTime.OnNext(json.Int("left_time")); } RoomName.Value = GameData.Shared.Type.Value == GameType.MTT ? json.String("match_name") : json.String("name"); if (GameData.Shared.Type.Value == GameType.MTT) { TableNumber.Value = json.Int("name"); // MTT的牌桌名称就是牌桌号 } else { TableNumber.Value = -1; } InGame = json.Bool("is_ingame"); MaxFiveRank.Value = json.Int("maxFiveRank"); _talkLimit.Value = json.Int("talk_limit") == 1; InsuranceState.Value = false; // 这个重置应该在pause设置之前 ShowAudit.Value = json.List("un_audit").Count > 0; CreateTime = _.DateTimeFromTimeStamp(json.Int("create_time")); Paused.OnNext(json.Int("is_pause")); // 删除公共牌重新添加 var cards = json.IL("shared_cards"); PublicCards.Clear(); foreach (int value in cards) { PublicCards.Add(value); } // 先设置公共牌,再高亮 HighlightIndex.Value = Card.ExtractHighlightCards(json.IL("maxFive"), MaxFiveRank.Value); // 逐个删除,才能触发Remove事件 foreach (var key in Players.Keys.ToList()) { Players.Remove(key); } foreach (KeyValuePair <string, object> entry in gamers) { var dict = entry.Value as Dictionary <string, object>; if (dict == null) { continue; } var index = Convert.ToInt32(entry.Key); var player = new Player(dict, index); // 大小盲、抓头、补盲 if (gameStart && player.PrChips.Value != 0) { player.ChipsChange = true; } Players[index] = player; } var mySeat = MySeat; if (mySeat != -1) { var player = Players[mySeat]; AuditCD.OnNext(player.AuditCD); GameData.Shared.Rank.Value = player.Rank.Value; } else { AuditCD.OnNext(0); GameData.Shared.Rank.Value = 0; } }