//让后面的农民跑 private static List <Card> letFarmerGo(List <Card>[] peoplesCard, int whoOut, int nowPerson, int whoCanOut) { List <Card> curOutCards = nextRemindCard[0]; //如果是自己出牌(必须要出),想办法放农民跑 if (whoOut == nowPerson) { OutCardStyle nextCardStyle = OutCardStyle.judgeCardStyle(nextRemindCard[whoCanOut]); //如果后面的农民出的是炸弹或者是四大天王,自己就随便出 if (nextCardStyle.outCardStyleEnum == OutCardStyleEnum.BOMB || nextCardStyle.outCardStyleEnum == OutCardStyleEnum.FOUR_GHOST) { } //如果是单支或者是对子,拆任意牌,放农民走 else if (nextCardStyle.outCardStyleEnum == OutCardStyleEnum.ONE || nextCardStyle.outCardStyleEnum == OutCardStyleEnum.TWO) { List <Card> tempOutCards = new List <Card>(); switch (nextCardStyle.outCardStyleEnum) { case OutCardStyleEnum.ONE: tempOutCards = CrushPreCard.findMinOneTwo(peoplesCard[nowPerson], 1); break; case OutCardStyleEnum.TWO: tempOutCards = CrushPreCard.findMinOneTwo(peoplesCard[nowPerson], 2); break; } if (tempOutCards.Count > 0 && tempOutCards[0].cardSize < nextCardStyle.firstCardSize) { curOutCards = tempOutCards; } } //如果是其他类型的牌 else { //找同类型自己能出的最小的牌(可以拆)(利用玩家的提示) People people = new People(); people.deck = peoplesCard[nowPerson]; people.htStyle = nextCardStyle.outCardStyleEnum; PlayerRemindCard.peopleFirstHint(people, true); //判断当前出了以后,后面的农民能不能跑 OutCardStyle myCardOutStyle = OutCardStyle.judgeCardStyle(people.htCards); //不能出证明放不了,就随便出 if (myCardOutStyle.outCardStyleEnum == nextCardStyle.outCardStyleEnum && myCardOutStyle.firstCardSize < nextCardStyle.firstCardSize) { curOutCards = people.htCards; } } } //如果可以不出,则不出 else { curOutCards.Clear(); } return(curOutCards); }
//玩家任意出牌的游戏提示,记录上次找的牌 private static List <Card> remindCard(List <Card> deck, List <Card> prevCard) { //判断上家的卡组样式 OutCardStyle preOutCardStyle = OutCardStyle.judgeCardStyle(prevCard); //如果想出什么牌就出什么牌 if (preOutCardStyle.outCardStyleEnum == OutCardStyleEnum.CANT_OUT) { return(Robort_Free_Remind(deck)); } //要不住,提示炸弹 else { return(CrushPreCard.crushPreCard(deck, preOutCardStyle, true, false)); } }
//玩家任意出牌的游戏提示,记录上次找的牌 public static void remindCard(People people, List <Card> prevCard, bool canOutBoom) { //判断上家的卡组样式 OutCardStyle preOutCardStyle = OutCardStyle.judgeCardStyle(prevCard); //如果想出什么牌就出什么牌 if (preOutCardStyle.outCardStyleEnum == OutCardStyleEnum.CANT_OUT) { people.htCards = new List <Card>(); peopleFirstHint(people, true); } //打上一家出的牌(如果是打自己出的牌,canOutBoom=false) else { people.htCards = CrushPreCard.crushPreCard(people.deck, preOutCardStyle, canOutBoom, true); } }
//玩家想出什么牌出什么牌的提示 // 按各种可能性提示,第i+1次提示比第i次提示要不同类型大,要不提示下一种类型 // 算法思想,伪造一个cardStyle,如果当前玩家能打,则可以出 public static void peopleFirstHint(People people, bool canSplit) { List <Card> deck = people.deck; int length = people.deck.Count; OutCardStyle createOutCardStyle; //伪造一个outCardStyle,判断其能否出相应的牌 do { switch (people.htStyle) { //如果是第一次提示(大的开始提示) case OutCardStyleEnum.CANT_OUT: case OutCardStyleEnum.PLANE_TAKE_TWO: //飞机带几对(按最长的长度,最小的(不存在)构造,再依次降低长度,直到找到) if (length >= 10) { for (int cardLen = length / 5 * 5; cardLen >= 10 && people.htCards.Count == 0; cardLen -= 5) { createOutCardStyle = new OutCardStyle(OutCardStyleEnum.PLANE_TAKE_TWO, 0, cardLen); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); } } people.htStyle = OutCardStyleEnum.PLANE; break; case OutCardStyleEnum.PLANE: //飞机不带 for (int cardLen = length / 3 * 3; cardLen >= 6 && people.htCards.Count == 0; cardLen -= 3) { createOutCardStyle = new OutCardStyle(OutCardStyleEnum.PLANE, 0, cardLen); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); } people.htStyle = OutCardStyleEnum.NEXT_TWO; break; case OutCardStyleEnum.NEXT_TWO: //连对,对3-对A共24张 for (int i = Math.Min(24, length / 2 * 2); i >= 6 && people.htCards.Count == 0; i -= 2) { createOutCardStyle = new OutCardStyle(OutCardStyleEnum.NEXT_TWO, 0, i); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); } people.htStyle = OutCardStyleEnum.STRAIGHT; break; case OutCardStyleEnum.STRAIGHT: //顺子,3-A共12张 for (int cardLen = Math.Min(12, length); cardLen >= 5 && people.htCards.Count == 0; cardLen--) { createOutCardStyle = new OutCardStyle(OutCardStyleEnum.STRAIGHT, 0, cardLen); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); } people.htStyle = OutCardStyleEnum.THREE_TAKE_TWO; break; case OutCardStyleEnum.THREE_TAKE_TWO: createOutCardStyle = new OutCardStyle(OutCardStyleEnum.THREE_TAKE_TWO, 0, 5); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); people.htStyle = OutCardStyleEnum.THREE; break; case OutCardStyleEnum.THREE: createOutCardStyle = new OutCardStyle(OutCardStyleEnum.THREE, 0, 3); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); people.htStyle = OutCardStyleEnum.TWO; break; case OutCardStyleEnum.TWO: createOutCardStyle = new OutCardStyle(OutCardStyleEnum.TWO, 0, 2); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); people.htStyle = OutCardStyleEnum.ONE; break; case OutCardStyleEnum.ONE: createOutCardStyle = new OutCardStyle(OutCardStyleEnum.ONE, 0, 1); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); people.htStyle = OutCardStyleEnum.BOMB; break; case OutCardStyleEnum.BOMB: for (int i = 8; i >= 4; i--) { createOutCardStyle = new OutCardStyle(OutCardStyleEnum.BOMB, 0, i); people.htCards = CrushPreCard.crushPreCard(deck, createOutCardStyle, false, canSplit); } people.htStyle = OutCardStyleEnum.FOUR_GHOST; break; case OutCardStyleEnum.FOUR_GHOST: if (OutCardStyle.isFourGhost(people.deck) == true) { people.htCards = people.deck; } people.htStyle = OutCardStyleEnum.CANT_OUT; break; } } while (people.htCards.Count == 0 && people.htStyle != OutCardStyleEnum.CANT_OUT); }