LandLord.cs
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
namespace GameServer.Script.CsScript.Action
{
#region
///
/// 扑克牌的数据类
/// http://wenku.baidu.com/link?url=FYqoqOlcz25NbwBARplHJBUrJphrvuW7818vzqodndwgmTDtlhaef-a1rAyM1oHEBc81yH8JS1SFuT_xVS8e1QYpMuRrp8yOSFFWfaBptzq
///
public clast LandLord
{
///
/// 红
///
private static int[] arrHeart = { 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115 };
///
/// 黑 215,
///
private static int[] arrSpade = { 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215 };
///
/// 梅 315,
///
private static int[] arrClub = { 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315 };
///
/// 方
///
private static int[] arrDiamond = { 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415 };
///
/// 大王17 ,小王16
///
private static int[] arrKing = { 16, 17 };
///
/// 一付Poker 52张
///
private Queue ALLPoker;
private const int mNumALLPoker = 54;
///
/// 单个用户牌的个数 临汾地方规则
///
private static int _NumPerUser = 17;
#region 洗牌 分牌
///
/// 洗牌, 让所有纸牌,随机顺序
///
private void Shuffle()
{
ALLPoker = new Queue();
List arrPoker = new List();
arrPoker.AddRange(arrHeart);
arrPoker.AddRange(arrSpade);
arrPoker.AddRange(arrClub);
arrPoker.AddRange(arrDiamond);
arrPoker.AddRange(arrKing);
////TDisruptedHelper _thelper = new TDisruptedHelper(arrPoker.ToArray());
////arrPoker = _thelper.GetDisruptedItems().ToList();
////for (int i = 0; i < arrPoker.Count; i++)
////{
//// ALLPoker.Enqueue(arrPoker[i]);
////}
//随机生成排序这x张牌
ALLPoker = new Queue(ToolsEx.DisrupteList(arrPoker));
if (ALLPoker.Count != mNumALLPoker)
{
TraceLogEx.Error("201610212116ll ALLPoker.Count != mNumALLPoker 即扑克初始不正确");
}
}
///
/// 初始化后 把纸牌分给三家
///
///
public Dictionary DistributePoker(out Queue LeftCard, int userCount)
{
if (userCount != 3)
{
TraceLogEx.Error("201610212210ll userCount > 6 || userCount < 2 " + userCount);
LeftCard = null;
return null;
}
Shuffle();
if (ALLPoker.Count != mNumALLPoker)
{
TraceLogEx.Error("20120824154401 ALLPoker!= " + mNumALLPoker);
LeftCard = null;
return null;
}
Dictionary retDic = new Dictionary();
// 1 号的数组 牌
List firstArr = new List();
// 2 号的数组 牌
List secondArr = new List();
// 3 号的数组 牌
List thirdArr = new List();
for (int i = 0; i < _NumPerUser; i++)
{
firstArr.Add(ALLPoker.Dequeue());
secondArr.Add(ALLPoker.Dequeue());
thirdArr.Add(ALLPoker.Dequeue());
}
retDic.Add(1, firstArr);
retDic.Add(2, secondArr);
retDic.Add(3, thirdArr);
LeftCard = ALLPoker;
if (ALLPoker.Count != 3)
{
TraceLogEx.Error(" 20120824154501ll 给地主抓的牌ALLPoker!= 3. 分牌都分错了");
}
return retDic;
}
#endregion
#region 排序
///
/// 去掉花色 从大到小排序
///
///
///
public static List OrderPaiLord(List paiarr)
{
List _tempList = new List(paiarr);
for (int i = 0; i < _tempList.Count; i++)
{
if (_tempList[i] > 100) _tempList[i] %= 100;
}
int[] temparr = _tempList.ToArray();
Array.Sort(temparr);
List _ASCList = temparr.ToList();
_ASCList.Reverse();//默认是升序反转一下就降序了
return _ASCList;
}
///
/// 从大到小排序 保留花色
///
///
///
public static List OrderPaiLordWithColor(List paiarr)
{
List _tempList = new List(paiarr);
for (int i = 0; i < _tempList.Count; i++)
{
if (_tempList[i] > 100) _tempList[i] %= 100;
}
int[] temparr = _tempList.ToArray();
Array.Sort(temparr);
List _ASCList = temparr.ToList();
_ASCList.Reverse();//默认是升序反转一下就降序了
//带上花色,有点小复杂
Dictionary _dicPoker2Count = GetPoker_Count(_ASCList);
Dictionary _dicPoker2CountUsed = new Dictionary();
for (int j = 0; j < _ASCList.Count; j++)
{
if (!_dicPoker2CountUsed.ContainsKey(_ASCList[j])) _dicPoker2CountUsed.Add(_ASCList[j], 1);
for (int c = _dicPoker2CountUsed[_ASCList[j]]; c PG.Count - amount; i--) //从小到大比较相邻牌是否相同
{
if (PG[i] == PG[i - 1]) IsSame2 = true;
else
{
IsSame2 = false;
break;
}
}
if (IsSame1 || IsSame2) return true;
else return false;
}
///
/// 判断牌组是否为顺子
///
/// 牌组
/// 是否为顺子
public static bool IsStraight(List PG)
{
bool IsStraight = false;
foreach (int poker in PG)//不能包含2、小王、大王
{
if (poker == (int)LordPokerValueNoColorEnum.p15 || poker == (int)LordPokerValueNoColorEnum.jokers16 || poker == (int)LordPokerValueNoColorEnum.jokersb17)
{
IsStraight = false;
return IsStraight;
}
}
for (int i = 0; i < PG.Count - 1; i++)
{
if (PG[i] - 1 == PG[i + 1]) IsStraight = true;
else
{
IsStraight = false;
break;
}
}
return IsStraight;
}
///
/// 判断牌组是否为连对
///
/// 牌组
/// 是否为连对
public static bool IsLinkPair(List PG)
{
bool IsLinkPair = false;
foreach (int poker in PG) //不能包含2、小王、大王
{
if (poker == (int)LordPokerValueNoColorEnum.p15 || poker == (int)LordPokerValueNoColorEnum.jokers16 || poker == (int)LordPokerValueNoColorEnum.jokersb17)
{
IsLinkPair = false;
return IsLinkPair;
}
}
//首先比较是否都为对子,再比较第一个对子的点数-1是否等于第二个对子,最后检察最小的两个是否为对子(这里的for循环无法检测到最小的两个,所以需要拿出来单独检查)
for (int i = 0; i < PG.Count - 2; i += 2)
{
if (PG[i] == PG[i + 1] && PG[i] - 1 == PG[i + 2] && PG[i + 2] == PG[i + 3]) IsLinkPair = true;
else
{
IsLinkPair = false;
break;
}
}
return IsLinkPair;
}
///
/// 判断牌组是否为连续三张牌,飞机,飞机带翅膀
/// //判断三张牌方法为判断两两相邻的牌,如果两两相邻的牌相同,则count自加1.最后根据count的值判断牌的类型为多少个连续三张
///
/// 牌组
/// 是否为连续三张牌
public static bool IsThreeLinkPokers(List PG, out int _threeCount)
{
bool IsThreeLinkPokers = false;
_threeCount = 0; //飞机的数量
PG = SameThreeSort(PG); //排序,把飞机放在前面
for (int i = 2; i < PG.Count; i++) //得到牌组中有几个飞机
{
if (PG[i] == PG[i - 1] && PG[i] == PG[i - 2]) _threeCount++;
}
if (_threeCount > 0) //当牌组里面有三个时
{
if (_threeCount > 1) //当牌组为飞机时
{
for (int i = 0; i < _threeCount * 3 - 3; i += 3) //判断飞机之间的点数是否相差1
{//2点不能当飞机出 -------------特殊规则 ------------------
if (PG[i] != (int)LordPokerValueNoColorEnum.p15 && PG[i] - 1 == PG[i + 3]) IsThreeLinkPokers = true;
else
{
IsThreeLinkPokers = false;
break;
}
}
}
else IsThreeLinkPokers = true; //牌组为普通三个,直接返回true
}
else IsThreeLinkPokers = false;
return IsThreeLinkPokers;
}
///
/// 对飞机和飞机带翅膀进行排序,把飞机放在前面,翅膀放在后面.
///
/// 牌组
/// 是否为连续三张牌
public static List SameThreeSort(List PG)
{
int _theFourPoker = 0; //如果把4张当三张出并且带4张的另外一张,就需要特殊处理,这里记录出现这种情况的牌的点数.
bool FindedThree = false; //已找到三张相同的牌
List tempPokerGroup = new List(); //记录三张相同的牌
//write by jsw tempPokerGroup = new tempPokerGroup()
int count = 0; //记录在连续三张牌前面的翅膀的张数
int Four = 0; // 记录是否连续出现三三相同,如果出现这种情况则表明出现把4张牌(炸弹)当中的三张和其他牌配成飞机带翅膀,并且翅膀中有炸弹牌的点数.
// 比如有如下牌组: 998887777666 玩家要出的牌实际上应该为 888777666带997,但是经过从大到小的排序后变成了998887777666 一不美观,二不容易比较.
for (int i = 2; i < PG.Count; i++) //直接从2开始循环,因为PG[0],PG[1]的引用已经存储在其他变量中,直接比较即可
{
if (PG[i] == PG[i - 2] && PG[i] == PG[i - 1])// 比较PG[i]与PG[i-1],PG[i]与PG[i-2]是否同时相等,如果相等则说明这是三张相同牌
{
if (Four >= 1) //默认的Four为0,所以第一次运行时这里为false,直接执行else
//一旦连续出现两个三三相等,就会执行这里的if
{
_theFourPoker = PG[i]; //当找到四张牌时,记录下4张牌的点数
int _tempchangePoker;
for (int k = i; k > 0; k--) //把四张牌中的一张移动到最前面.
{
_tempchangePoker = PG[k];
PG[k] = PG[k - 1];
PG[k - 1] = _tempchangePoker;
}
count++; //由于此时已经找到三张牌,下面为count赋值的程序不会执行,所以这里要手动+1
}
else
{
Four++; //记录本次循环,因为本次循环找到了三三相等的牌,如果连续两次找到三三相等的牌则说明找到四张牌(炸弹)
tempPokerGroup.Add(PG[i]); //把本次循环的PG[i]记录下来,即记录下三张牌的点数
}
FindedThree = true; //标记已找到三张牌
}
else
{
Four = 0; //没有找到时,连续找到三张牌的标志Four归零
if (!FindedThree) //只有没有找到三张牌时才让count增加.如果已经找到三张牌,则不再为count赋值.
{
count = i - 1;
}
}
}
foreach (int tempPoker in tempPokerGroup) //迭代所有的三张牌点数
{
int _tempchangePoker; //临时交换Poker
for (int i = 0; i < PG.Count; i++) //把所有的三张牌往前移动
{
if (PG[i] == tempPoker) //当PG[i]等于三张牌的点数时
{
if (PG[i] == _theFourPoker) //由于上面已经把4张牌中的一张放到的最前面,这张牌也会与tempPoker相匹配所以这里进行处理
// 当第一次遇到四张牌的点数时,把记录四张牌的FourPoker赋值为null,并中断本次循环.由于FourPoker已经为Null,所以下次再次遇到四张牌的点数时会按照正常情况执行.
{
_theFourPoker = 0;
continue;
}
_tempchangePoker = PG[i - count];
PG[i - count] = PG[i];
PG[i] = _tempchangePoker;
}
}
}
return PG;
}
public static Dictionary GetPoker_Count(List paiList)
{
Dictionary _dicPoker2Count = new Dictionary();
foreach (int poke in paiList)
{
if (_dicPoker2Count.ContainsKey(poke)) _dicPoker2Count[poke]++;
else _dicPoker2Count.Add(poke, 1);
}
return _dicPoker2Count;
}
///
/// 获取三带一,飞机牌列中的三张的牌
///
/// 无花色
/// 结果 会从大到小排序
private static List GetSameMoreThan3(List paiList)
{
Dictionary _dicPoker2Count = GetPoker_Count(paiList);
List _temp = new List();
foreach (int key in _dicPoker2Count.Keys)
{
if (_dicPoker2Count[key] >= 3) _temp.Add(key);
}
_temp = OrderPaiLord(_temp);
if (_temp.Count == 0) TraceLogEx.Error("201701262114 fetal error!");
return _temp;
}
//无序的牌组通过以上代码的洗礼,已经变成了非常容易比较的牌组了。
//比较牌组的大小就非常简单了。首先排除特殊牌组炸弹,双王。
//然后再比较普通牌组的第一张牌就可以了。下面是牌组比较的代码,重写了PokerGroup的大于号运算符
///
/// shoupaiList > targetList 返回True
/// 1.确保牌是符合基本规范的才有效,
/// 2.不炸弹要确保牌型相同
///
///
///
///
public static bool ComparePoker(List shoupaiList, List targetList)
{
bool IsGreater = false;
LordPokerTypeEnum _shoupaiType = GetLordType(shoupaiList);
LordPokerTypeEnum _targetType = GetLordType(targetList);
if (_shoupaiType == LordPokerTypeEnum.Error || _targetType == LordPokerTypeEnum.Error) return false;
if (_shoupaiType != _targetType)
{ //先比类型
int _shoupaitypevalue = 0;
if (_diclordvalue.ContainsKey(_shoupaiType)) _shoupaitypevalue = _diclordvalue[_shoupaiType];
int _targettypevalue = 0;
if (_diclordvalue.ContainsKey(_targetType)) _targettypevalue = _diclordvalue[_targetType];
IsGreater = _shoupaitypevalue > _targettypevalue;
}
else
{
List _tempShouPaiList = OrderPaiLord(shoupaiList);
List _tempTargetList = OrderPaiLord(targetList);
//三不带只能最后一手出,所以不做比较
//三带一 , 2飞机带翅, 3飞机带翅, 4飞机带翅 , 5飞机带翅
//四带二 , 移除小于3张相同的牌进行大小排序 比较第一个
switch (_shoupaiType)
{
case LordPokerTypeEnum.PlaneWing1_4:
case LordPokerTypeEnum.PlaneWing2_8:
case LordPokerTypeEnum.PlaneWing3_12: //12张可能会有BUG,暂时不处理
case LordPokerTypeEnum.PlaneWing4_16:
case LordPokerTypeEnum.PlaneWing5_20:
case LordPokerTypeEnum.FourWithTwo_6:
List _tempShouPaiBig3List = GetSameMoreThan3(_tempShouPaiList);
List _tempTargetBig3List = GetSameMoreThan3(_tempTargetList);
IsGreater = _tempShouPaiBig3List[0] > _tempTargetBig3List[0];
break;
default:
IsGreater = _tempShouPaiList[0] > _tempTargetList[0]; //single, double, bomb, linkPair, straight
break;
}
}
return IsGreater;
}
///
/// 大小比值
///
public static Dictionary _diclordvalue = new Dictionary();
public static void InitRate()
{
if (_diclordvalue.Count >= 2) return;
_diclordvalue.Add(LordPokerTypeEnum.DoubleKing_2, 1000);
////_diclordvalue.Add(LordPokerTypeEnum.BombBombBombBomb, 80); //四连炸
////_diclordvalue.Add(LordPokerTypeEnum.BombBombBomb, 70); //三连炸
////_diclordvalue.Add(LordPokerTypeEnum.BombBomb, 60); //二连炸
_diclordvalue.Add(LordPokerTypeEnum.Bomb_4, 50);
InitWeight();
}
public static Dictionary _dicLordWeight = new Dictionary();
private static void InitWeight()
{
_dicLordWeight.Add(LordPokerTypeEnum.Single_1, 1);
_dicLordWeight.Add(LordPokerTypeEnum.Double_2, 2);
_dicLordWeight.Add(LordPokerTypeEnum.Three_3, 2);
_dicLordWeight.Add(LordPokerTypeEnum.Straight5_5, 5);
_dicLordWeight.Add(LordPokerTypeEnum.Straight6_6, 6);
_dicLordWeight.Add(LordPokerTypeEnum.Straight7_7, 7);
_dicLordWeight.Add(LordPokerTypeEnum.Straight8_8, 8);
_dicLordWeight.Add(LordPokerTypeEnum.Straight9_9, 9);
_dicLordWeight.Add(LordPokerTypeEnum.Straight10_10, 10);
_dicLordWeight.Add(LordPokerTypeEnum.Straight11_11, 11);
_dicLordWeight.Add(LordPokerTypeEnum.Straight12_12, 12);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair3_6, 6);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair4_8, 8);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair5_10, 10);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair6_12, 12);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair7_14, 14);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair8_16, 16);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair9_18, 18);
_dicLordWeight.Add(LordPokerTypeEnum.LinkPair10_20, 20);
_dicLordWeight.Add(LordPokerTypeEnum.PlaneWing1_4, 4);
_dicLordWeight.Add(LordPokerTypeEnum.PlaneWing2_8, 8);
_dicLordWeight.Add(LordPokerTypeEnum.PlaneWing3_12, 12);
_dicLordWeight.Add(LordPokerTypeEnum.PlaneWing4_16, 16);
_dicLordWeight.Add(LordPokerTypeEnum.PlaneWing5_20, 20);
_dicLordWeight.Add(LordPokerTypeEnum.FourWithTwo_6, 7);
////_dicLordWeight.Add(LordPokerTypeEnum.Bomb33_2, 8);
////_dicLordWeight.Add(LordPokerTypeEnum.Bomb22_2, 9);
_dicLordWeight.Add(LordPokerTypeEnum.Bomb_4, 10);
_dicLordWeight.Add(LordPokerTypeEnum.DoubleKing_2, 11);
}
#endregion
#region tip 相关功能
///
/// 提示功能 根据传入的牌找到可以接起的最小牌型,可能接不起的
///
/// 手牌要带花色
///
///
public static List GetTipList(List _shoupai, List _lastPaiArr)
{
//剩余牌的数量小于 只能用炸了 //等于上手出牌的数量 //剩余牌的数量大于上手出牌的数量
List _tiplist = new List();
LordPokerSplitHelper _splitHelper = new LordPokerSplitHelper();
_splitHelper.Split(_shoupai);
if (_lastPaiArr.Count == 0)
{//没有上家牌,直接按AI规则出牌
//最大牌型,考虑春天 再最多牌数
if (_splitHelper._straight.Count != 0)
{
_tiplist = _splitHelper._straight[0];
}
else if (_splitHelper._linkerPair.Count != 0)
{
_tiplist = _splitHelper._linkerPair[0];
if (_tiplist.Count != 0) _tiplist.AddRange(_tiplist);
}
else if (_splitHelper._planeWith.Count != 0)
{
List _planeList = _splitHelper._planeWith[0];
List _existoneList = new List();
foreach (int _plane in _planeList)
{
_tiplist.Add(_plane);
_tiplist.Add(_plane);
_tiplist.Add(_plane);
int _tempwithone = _splitHelper.GetSingleToPlaneWith(_planeList, _existoneList);
if (_tempwithone != -1)
{
_tiplist.Add(_tempwithone);
_existoneList.Add(_tempwithone);
}
}
if (_tiplist.Count != _planeList.Count * 4) _tiplist = new List();//重置========可能会出现全三带没的带的情况而可以把3张拆成
}
else if (_splitHelper._double.Count != 0)
{
int _double = _splitHelper._double[_splitHelper._double.Count - 1];
_tiplist.Add(_double);
_tiplist.Add(_double);
}
////else if (_splitHelper._bomb22.Count != 0)
////{
//// _tiplist.Add(_splitHelper._bomb22[0]);
//// _tiplist.Add(_splitHelper._bomb22[0]);
////}
////else if (_splitHelper._bomb33.Count != 0)
////{
//// _tiplist.Add(_splitHelper._bomb33[0]);
//// _tiplist.Add(_splitHelper._bomb33[0]);
////}
else if (_splitHelper._bomb4List.Count != 0)
{
int _bomb = _splitHelper._bomb4List[_splitHelper._bomb4List.Count - 1];
_tiplist.Add(_bomb);
_tiplist.Add(_bomb);
_tiplist.Add(_bomb);
_tiplist.Add(_bomb);
}
else if (_splitHelper._doubleKing.Count != 0)
{
_tiplist.AddRange(_splitHelper._doubleKing);
}
else
{
_tiplist.Add(_splitHelper._single[_splitHelper._single.Count - 1]);
}
_tiplist = GetPaiColor(_shoupai, _tiplist);
return _tiplist;
}
List _templastPoker = OrderPaiLord(_lastPaiArr);
LordPokerTypeEnum _lordtype = GetLordType(_templastPoker);
switch (_lordtype)
{
case LordPokerTypeEnum.DoubleKing_2: return new List();//如果上手出了王炸,直接要不起
case LordPokerTypeEnum.Bomb_4:
_tiplist = UseBomb(_splitHelper, _templastPoker[0]);
if (_tiplist.Count != 0) _tiplist = GetPaiColor(_shoupai, _tiplist);
return _tiplist;
case LordPokerTypeEnum.Single_1:// 单张
_tiplist = GetSingleBig(_templastPoker, _splitHelper);
break;
case LordPokerTypeEnum.Double_2:
_tiplist = GetDoubleBig(_templastPoker, _splitHelper);
break;
case LordPokerTypeEnum.Three_3:
_tiplist = GetThreeBig(_templastPoker, _splitHelper);
break;
case LordPokerTypeEnum.PlaneWing1_4:
case LordPokerTypeEnum.PlaneWing2_8:
case LordPokerTypeEnum.PlaneWing3_12:
case LordPokerTypeEnum.PlaneWing4_16:
case LordPokerTypeEnum.PlaneWing5_20:
_tiplist = GetPlaneBig(_templastPoker, _splitHelper);
break;
case LordPokerTypeEnum.Straight5_5:
case LordPokerTypeEnum.Straight6_6:
case LordPokerTypeEnum.Straight7_7:
case LordPokerTypeEnum.Straight8_8:
case LordPokerTypeEnum.Straight9_9:
case LordPokerTypeEnum.Straight10_10:
case LordPokerTypeEnum.Straight11_11:
case LordPokerTypeEnum.Straight12_12:
_tiplist = GetStraightBig(_templastPoker, _splitHelper);
break;
case LordPokerTypeEnum.LinkPair3_6:
case LordPokerTypeEnum.LinkPair4_8:
case LordPokerTypeEnum.LinkPair5_10:
case LordPokerTypeEnum.LinkPair6_12:
case LordPokerTypeEnum.LinkPair7_14:
case LordPokerTypeEnum.LinkPair8_16:
case LordPokerTypeEnum.LinkPair9_18:
case LordPokerTypeEnum.LinkPair10_20:
_tiplist = GetLinkerPairBig(_templastPoker, _splitHelper);
break;
case LordPokerTypeEnum.FourWithTwo_6:
_tiplist = GetFourWithTwoBig(_templastPoker, _splitHelper);
break;
default:
TraceLogEx.Error(_lordtype + ":...............................lllllllllllllllllllllll");
break;
}
if (_tiplist.Count == 0)
{
_tiplist = UseBomb(_splitHelper, 0);
}
if (_tiplist.Count != 0) _tiplist = GetPaiColor(_shoupai, _tiplist);
return _tiplist;
}
///
///
///
///
/// 0表示只能炸弹就行,1表示是33,2表示是22,大于等于3表示是四个一样的炸弹3333,4444
///
private static List UseBomb(LordPokerSplitHelper _splitHelper, int lv)
{
List _tiplist = new List();
switch (lv)
{
case 0: //接小于炸弹的
////if (_splitHelper._bomb33.Count != 0)
////{
//// _tiplist = new List() { _splitHelper._bomb33[0], _splitHelper._bomb33[0] };
////}
////else if (_splitHelper._bomb22.Count != 0)
////{
//// _tiplist = new List() { _splitHelper._bomb22[0], _splitHelper._bomb22[0] };
////}
////else
if (_splitHelper._bomb4List.Count != 0)
{
_tiplist = new List() { _splitHelper._bomb4List[0], _splitHelper._bomb4List[0], _splitHelper._bomb4List[0], _splitHelper._bomb4List[0] };
}
else if (_splitHelper._doubleKing.Count != 0)
{
_tiplist = new List() { (int)LordPokerValueNoColorEnum.jokers16, (int)LordPokerValueNoColorEnum.jokersb17 };
}
break;
default:
//case 3: //bomb4 以上的 lv 为对应炸的值
if (_splitHelper._bomb4List.Count != 0)
{
foreach (int poker in _splitHelper._bomb4List)
{
if (poker > lv) _tiplist = new List() { poker, poker, poker, poker };
}
}
else if (_splitHelper._doubleKing.Count != 0)
{
_tiplist = new List() { (int)LordPokerValueNoColorEnum.jokers16, (int)LordPokerValueNoColorEnum.jokersb17 };
}
break;
}
return _tiplist;
}
private static List GetSingleBig(List _lastPoker, LordPokerSplitHelper _splitHelper)
{
List _ret = new List();
if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
for (int i = _splitHelper._one.Count - 1; i >= 0; i--)
{
if (_splitHelper._one[i] > _lastPoker[0])
{
_ret.Add(_splitHelper._one[i]);
break;
}
}
return _ret;
}
private static List GetDoubleBig(List _lastPoker, LordPokerSplitHelper _splitHelper)
{
List _ret = new List();
if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
for (int i = _splitHelper._double.Count - 1; i >= 0; i--)
{
if (_splitHelper._double[i] > _lastPoker[0])
{
_ret.Add(_splitHelper._double[i]);
_ret.Add(_splitHelper._double[i]);
break;
}
}
return _ret;
}
///
/// 获取三不带的提示
///
///
///
///
private static List GetThreeBig(List _lastPoker, LordPokerSplitHelper _splitHelper)
{
List _ret = new List();
if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
for (int i = _splitHelper._threeList.Count - 1; i >= 0; i--)
{
if (_splitHelper._threeList[i] > _lastPoker[0])
{
_ret.Add(_splitHelper._threeList[i]);
_ret.Add(_splitHelper._threeList[i]);
_ret.Add(_splitHelper._threeList[i]);
break;
}
}
return _ret;
}
///
/// 获取三带一 或飞机的的最小值
///
///
///
///
private static List GetPlaneBig(List _lastPoker, LordPokerSplitHelper _splitHelper)
{
List _lastThreeList = GetSameMoreThan3(_lastPoker);
if (_lastPoker.Count == 4)
{
List _ret = new List();
if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
if (_splitHelper._three.Count < 1) return _ret;
for (int i = _splitHelper._three.Count - 1; i >= 0; i--)
{
if (_splitHelper._three[i] > _lastThreeList[0])
{
_ret.Add(_splitHelper._three[i]);
_ret.Add(_splitHelper._three[i]);
_ret.Add(_splitHelper._three[i]);
int _tempwithone = _splitHelper.GetSingleToPlaneWith(new List() { _splitHelper._three[i] });
if (_tempwithone != -1) _ret.Add(_tempwithone);
break;
}
}
if (_ret.Count == 4) return _ret;
return new List();
}
else
{
List _tiplist = new List();
if (_splitHelper._planeWith.Count < 1) return _tiplist;
foreach (List _planeList in _splitHelper._planeWith)
{
if (_planeList.Count < _lastThreeList.Count) continue;//个数不够
if (_planeList[0] < _lastThreeList[0]) continue;//大小不对 ==================需要写在从最小值取值 ,现在直接从最大值开取的=======
foreach (int _plane in _planeList)
{
_tiplist.Add(_plane);
_tiplist.Add(_plane);
_tiplist.Add(_plane);
int _tempwithone = _splitHelper.GetSingleToPlaneWith(_planeList);
if (_tempwithone != -1) _tiplist.Add(_tempwithone);
}
if (_tiplist.Count != _planeList.Count * 4) _tiplist = new List();//重置========可能会出现全三带没的带的情况而可以把3张拆成
}
return _tiplist;
}
}
///
/// 获取四带二 的最小值
///
///
///
///
private static List GetFourWithTwoBig(List _lastPoker, LordPokerSplitHelper _splitHelper)
{
List _lastThreeList = GetSameMoreThan3(_lastPoker);
List _ret = new List();
if (_lastPoker.Count != 6) return _ret;
if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
if (_splitHelper._four.Count < 1) return _ret;
for (int i = _splitHelper._four.Count - 1; i >= 0; i--)
{
if (_splitHelper._four[i] > _lastThreeList[0])
{
_ret.Add(_splitHelper._four[i]);
_ret.Add(_splitHelper._four[i]);
_ret.Add(_splitHelper._four[i]);
_ret.Add(_splitHelper._four[i]);
List _tempwithone = _splitHelper.GetSingleToFourWith(new List() { _splitHelper._four[i] });
_ret.AddRange(_tempwithone);
break;
}
}
if (_ret.Count == 6) return _ret;
return new List();
}
///
/// 直接取最大的连子,
///
///
///
///
private static List GetStraightBig(List _lastPoker, LordPokerSplitHelper _splitHelper)
{
List _ret = new List();
if (_lastPoker.Count < 5) return _ret;
if (_splitHelper._shouPai.Count < _lastPoker.Count) return _ret;
if (_splitHelper._straight.Count < 0) return _ret;
foreach (var _onestraight in _splitHelper._straight)
{
if (_onestraight.Count < _lastPoker.Count) continue;
int _tempfirstindex = -1;
for (int i = 0; i = 5) _straight.Add(_minStraight);//最后一组必须加进去 不然一个长连子没搜索到
}
///
/// 只存了单个牌 好处理
///
public void SearchLinkerPair()
{
if (_shouPai.Count < 6) return;//不足6个牌就不处理的
List _temptwo = new List(_two);
if (_temptwo.Contains((int)LordPokerValueNoColorEnum.p15)) _temptwo.Remove((int)LordPokerValueNoColorEnum.p15); // ,2 不能组成连子
if (_temptwo.Count < 3) return;//不足6个牌就不处理的
List _minLinker = new List();
for (int i = 0; i < _temptwo.Count - 1; i++)
{
if (_temptwo[i] - 1 == _temptwo[i + 1])
{
_minLinker.Add(_temptwo[i]);
if (i + 1 == _temptwo.Count - 1) _minLinker.Add(_temptwo[i + 1]);//最后一个要加上
}
else
{//可能会出现刚才好3个,而后还有牌,搜索不到
_minLinker.Add(_temptwo[i]);
if (_minLinker.Count >= 3) _linkerPair.Add(_minLinker);
_minLinker = new List();
}
}
if (_minLinker.Count >= 3) _linkerPair.Add(_minLinker);
}
///
/// 只存了单个牌 好处理
///
public void SearchPlaneWithone()
{
if (_shouPai.Count < 4) return;//不足4个牌就不处理的
if (_three.Count < 2) return;//不足两个三带一
List _tempthree = new List(_three);
List _minPlane = new List();
for (int i = 0; i < _tempthree.Count - 1; i++)
{
if (_tempthree[i] - 1 == _tempthree[i + 1])
{
_minPlane.Add(_tempthree[i]);
if (i + 1 == _tempthree.Count - 1) _minPlane.Add(_tempthree[i + 1]);//最后一个要加上
}
else
{//可能会出现刚才好2个,而后还有牌,搜索不到
_minPlane.Add(_tempthree[i]);
if (_minPlane.Count >= 2) _planeWith.Add(_minPlane);
_minPlane = new List();
}
}
if (_minPlane.Count >= 2) _planeWith.Add(_minPlane);
}
///
/// 获取三带一中的单牌
///
///
///
public int GetSingleToPlaneWith(List planeList)
{
if (_single.Count == 0) return -1;
int _tempSingle = 0;
for (int i = _single.Count - 1; i >= 0; i--)
{//不能是三带一中的牌
if (_single[i] == (int)LordPokerValueNoColorEnum.p15) continue;//2不带用于三带1 只有最后一个手三带一可以用
if (_single[i] == (int)LordPokerValueNoColorEnum.jokers16 || _single[i] == (int)LordPokerValueNoColorEnum.jokersb17)
{
continue;//王不带用于三带1 只有最后一个手三带一可以用
}
bool _issametoPlane = false;
foreach (int plane in planeList)
{
if (plane == _single[i]) _issametoPlane = true;
}
if (_issametoPlane) continue;
_tempSingle = _single[i];
break;
}
if (_tempSingle != -1)
{
_single.Remove(_tempSingle);
}
return _tempSingle;
}
///
/// 获取三带一中的单牌
///
///
///
public int GetSingleToPlaneWith(List planeList, List _existonelist)
{
if (_single.Count == 0) return -1;
int _tempSingle = 0;
for (int i = _single.Count - 1; i >= 0; i--)
{//不能是三带一中的牌
if (_single[i] == (int)LordPokerValueNoColorEnum.p15) continue;//2不带用于三带1 只有最后一个手三带一可以用
if (_single[i] == (int)LordPokerValueNoColorEnum.jokers16 || _single[i] == (int)LordPokerValueNoColorEnum.jokersb17)
{
continue;//王不带用于三带1 只有最后一个手三带一可以用
}
bool _issametoPlane = false;
foreach (int plane in planeList)
{
if (plane == _single[i]) _issametoPlane = true;
}
if (_issametoPlane) continue;
_tempSingle = _single[i];
if (_existonelist.Contains(_tempSingle))
{
_tempSingle = -1;
continue;
}
break;
}
return _tempSingle;
}
///
/// 获取四带二中的两个单牌
///
///
///
public List GetSingleToFourWith(List planeList)
{
List _withtwo = new List();
if (_single.Count == 0) return _withtwo;
for (int i = _single.Count - 1; i >= 0; i--)
{//不能是四带二中的牌 可以带2,带王
////if (_single[i] == (int)LordPokerValueNoColorEnum.p15) continue;//2不带用于三带1 只有最后一个手三带一可以用
////if (_single[i] == (int)LordPokerValueNoColorEnum.jokers16 || _single[i] == (int)LordPokerValueNoColorEnum.jokersb17)
////{
//// continue;//王不带用于三带1 只有最后一个手三带一可以用
////}
bool _issametoPlane = false;
foreach (int plane in planeList)
{
if (plane == _single[i]) _issametoPlane = true;
}
if (_issametoPlane) continue;
_withtwo.Add(_single[i]);
if (_withtwo.Count >= 2) break;
}
return _withtwo;
}
}
#endregion
}