public override void ResetBase() { _isBanker = false; _shouPaiArr = new List <int>(); _bulltype = PokerBullFightType.Bull_No; _gambletime = DateTime.Now.AddYears(100); base.ResetBase(); }
public override void ResetBase() { _isGetBanker = false; _isBanker = false; _showCardList = new List <int>(); _bulltype = PokerBullFightType.Bull_No; _pos2Gameble = new Dictionary <int, int>(); _gambletime = DateTime.Now.AddYears(100); base.ResetBase(); }
/// <summary> /// 给机器配置胜率后,机器人拿大牌,有多个机器时,以早大POS的机器人为准 /// 如果有多个设置胜率帐号在同一桌,则会只有一个机率有效。 /// </summary> /// <param name="pos2RobotAI"></param> /// <param name="_pos2Poker"></param> /// <returns></returns> public Dictionary <int, List <int> > ChangePokerByRobotAI(Dictionary <int, int> pos2RobotAI, Dictionary <int, List <int> > _pos2Poker) { Dictionary <int, PokerBullFightType> _pbftype = new Dictionary <int, PokerBullFightType>(); _myTable.ForeashAllDo((i) => { _pbftype.Add(i, BullFight.GetBullType(_pos2Poker[i])); }); int _maxpos = _myTable._masterPos; PokerBullFightType maxvalue = PokerBullFightType.Bull_No; _myTable.ForeashAllDo((i) => { if (maxvalue < _pbftype[i]) { maxvalue = _pbftype[i]; _maxpos = i; } }); int _RobotRatePos = _maxpos; _myTable.ForeashAllDo((i) => { int _AIRate = pos2RobotAI[i]; if (_AIRate == 0) { return; } int _tempRate = ToolsEx.GetRandomSys(0, 100); if (_tempRate <= _AIRate) { _RobotRatePos = i; } }); List <int> _tempChange = new List <int>();//把最大的牌换给机器人最高胜率的人 _tempChange = _pos2Poker[_RobotRatePos]; _pos2Poker[_RobotRatePos] = _pos2Poker[_maxpos]; _pos2Poker[_maxpos] = _tempChange; return(_pos2Poker); }
/// <summary> /// /// 然后再比较普通牌组的第一张牌就可以了 /// bankercard > cardlist 返回True /// </summary> public static bool ComparePoker(List <int> bankercard, PokerBullFightType _bankeBulltype, List <int> cardlist, PokerBullFightType _bulltype) { if (_bankeBulltype > _bulltype) { return(true); } else if (_bankeBulltype < _bulltype) { return(false); } else {//相同类型 需要根据规则再处理一次, int _bankMax = GetMaxCard(bankercard); int _cmax = GetMaxCard(cardlist); switch (_bankeBulltype) { case PokerBullFightType.Bull_No: //比首张大小,如是一样大,庄win, if (_bankMax % 100 >= _cmax % 100) { return(true); } break; case PokerBullFightType.Bull_1: case PokerBullFightType.Bull_2: case PokerBullFightType.Bull_3: case PokerBullFightType.Bull_4: case PokerBullFightType.Bull_5: case PokerBullFightType.Bull_6: case PokerBullFightType.Bull_7: case PokerBullFightType.Bull_8: case PokerBullFightType.Bull_9: case PokerBullFightType.Bull_Bull: // case PokerBullFightType.Bull_Four: case PokerBullFightType.Bull_Five: //比首张大小,如是一样大,再比花色 if (_bankMax % 100 > _cmax % 100) { return(true); } else if (_bankMax % 100 < _cmax % 100) { return(false); } else { if (_bankMax < _cmax) { return(true); //花色大小:从大到小为黑桃、红桃、梅花、方块。 } else { return(false); } } ////case PokerBullFightType.Bull_Bomb: //// if (IsBomb(bankercard) > IsBomb(cardlist)) return true; //// else return false; ////case PokerBullFightType.Bull_SmallSmall: //// if (_bankMax % 100 > _cmax % 100) return true; //// else if (_bankMax % 100 < _cmax % 100) return false; //// else //// { //// if (_bankMax > _cmax) return true; //// else return false; //// } } } return(false); }
/// <summary> /// 根据牛牛类型传出牛牛的值 /// </summary> /// <param name="_type">牛的类型</param> /// <returns>对应的一组牛的牌</returns> public static List <int> GetPokerbyBullFightType(PokerBullFightType _type) { int type = _type.GetHashCode(); int[] allCards = new int[5]; int[] bullcrads = new int[3]; int[] spotcrads = new int[2]; if (type >= 1 && type <= 10) { Random rd = new Random(); bullcrads[0] = rd.Next(1, 11); bullcrads[1] = rd.Next(1, 11); int remainnum = (bullcrads[0] + bullcrads[1]) % 10; bullcrads[2] = 10 - remainnum; spotcrads[0] = rd.Next(1, 11); if (type > spotcrads[0]) { spotcrads[1] = type - spotcrads[0]; } else { spotcrads[1] = 10 + type - spotcrads[0]; } } else if (type == 11) { bullcrads = new int[] { 10, 10, 10 }; spotcrads = new int[] { 10, 10 }; } else if (type == 0) { Random rd = new Random(); bullcrads[0] = rd.Next(1, 11); bullcrads[1] = rd.Next(1, 11); List <int> havaNum = new List <int>(); havaNum.Add(bullcrads[0]); havaNum.Add(bullcrads[1]); List <int> filterNum = new List <int>(); //// 生成第三个数 filterNum = GetFilterList(havaNum); bullcrads[2] = GetNullNum(filterNum); havaNum.Add(bullcrads[2]); //// 生成第四个数 filterNum = GetFilterList(havaNum); spotcrads[0] = GetNullNum(filterNum); havaNum.Add(spotcrads[0]); //// 生成第五个数,注意无牛的时候可能出现五个一样的数字 filterNum = GetFilterList(havaNum); if (havaNum.FindAll(p => p == havaNum[0]).Count == 4) { filterNum.Add(havaNum[0]); } spotcrads[1] = GetNullNum(filterNum); } bullcrads.CopyTo(allCards, 0); spotcrads.CopyTo(allCards, bullcrads.Length); //// 替换10, 注意牛牛替换以后不能是五花牛,也不能出现5个10;五花牛替换以后不能出现10,也不能出现5个一样的数字 List <int> flowerCards = new List <int>(); for (int i = 0; i < 5; i++) { //// 替换 10 if (allCards[i] == 10) { if (type < 10) { allCards[i] = ToolsEx.GetRandomSys(10, 14); } else if (type == 10) { if (i == 4 && allCards.ToList().FindAll(p => p > 10).Count == 4) { allCards[i] = 10; } else { allCards[i] = ToolsEx.GetRandomSys(10, 14); } } else if (type == 11) { if (i == 4 && allCards.ToList().FindAll(p => p == allCards[0]).Count == 4) { int fivenum = allCards[0]; while (fivenum == allCards[0]) { allCards[i] = ToolsEx.GetRandomSys(11, 14); } } else { allCards[i] = ToolsEx.GetRandomSys(11, 14); } } } //// 替换花色 int num = ToolsEx.GetRandomSys(1, 5) * 100 + allCards[i]; flowerCards[i] = num; while (flowerCards.Contains(num)) { num = ToolsEx.GetRandomSys(1, 5) * 100 + allCards[i]; } flowerCards[i] = num; } flowerCards = ListRandom(flowerCards); return(flowerCards);; }
/// <summary> /// 不同游戏类型结算方法不一样 /// </summary> /// <returns></returns> public ShowDownSD100 GetShowDownList(int _pos) { int _bankerPos = _myTable._bankpos; List <CommonPosValListSD> _pos2CardList = new List <CommonPosValListSD>(); foreach (var pokerlist in _myTable._dicPokerList) { _pos2CardList.Add(new CommonPosValListSD() { pos = pokerlist.Key, vallist = pokerlist.Value }); } ShowDownSD100 _tempdicpos2SD = new ShowDownSD100() { bulltype = (int)_myTable._DicPos2User[_pos]._bulltype, gamble = _myTable._DicPos2User[_pos]._gambleTotal, money = 0, pos = _pos, _pos2CardList = _pos2CardList }; BullFight100User _tempBankerUser = _myTable._DicPos2User[_bankerPos]; List <int> _bankerCardList = _myTable._dicPokerList[1]; PokerBullFightType _bankderType = _myTable._dicPokerBFType[1]; foreach (int key in _myTable._dicPokerList.Keys) { if (key == 1) { continue; //固定1号位为庄 } bool _tempBankerWin = BullFight.ComparePoker(_bankerCardList, _bankderType, _myTable._dicPokerList[key], _myTable._dicPokerBFType[key]); int _gambleRate = 1; if (_tempBankerWin) { _gambleRate = BullFight._dicbullfightRate[_bankderType]; } else { _gambleRate = BullFight._dicbullfightRate[_myTable._dicPokerBFType[key]]; } _myTable.ForeashAllDo((i) => { if (_myTable._masterPos == i) { return; //房主不计算 } if (_myTable._bankpos == i) { return; //庄家不计算 } if (_tempBankerWin) { int _tempvar = _myTable._baseMoney * _myTable._DicPos2User[i].GetGambleByPos(key) * _gambleRate; _myTable._DicPos2User[_bankerPos]._CurrentGold += _tempvar; //扣出5%费用 只要是赢了的人 _myTable._DicPos2User[i]._CurrentGold -= _tempvar; } else { int _tempvar = _myTable._baseMoney * _myTable._DicPos2User[i].GetGambleByPos(key) * _gambleRate; _myTable._DicPos2User[_bankerPos]._CurrentGold -= _tempvar; _myTable._DicPos2User[i]._CurrentGold += _tempvar;//扣出5%费用 只要是赢了的人 } }); } return(_tempdicpos2SD); }