/// <summary> /// 王罚分 /// </summary> /// <param name="self"></param> private static void JokerScore(this GameController self) { var room = self.GetParent <Room>(); foreach (Player player in room.Players) { var cards = player.GetComponent <HandCardsComponent>().Cards; if (cards.Count == 0) { continue; } List <AnalyseResult> analyseResults = AnalyseResult.Analyse(cards); // 一旦存在炸弹,就不需要罚王了。 if (analyseResults.Any(f => f.Count >= 4 && !CardsHelper.IsJoker(f.Weight))) { continue; } int jokerCount = analyseResults.GetJokerCount(); // joker数量为4不需要罚王,算做9炸分. if (jokerCount == 4) { continue; } // 罚分 self.SetScore(player, -(jokerCount * 3)); } }
/// <summary> /// 获取Joker的数量 /// </summary> /// <param name="analyseResults"></param> /// <returns></returns> public static int GetJokerCount(this List <AnalyseResult> analyseResults) { int jokerCount = analyseResults.Sum(f => { if (CardsHelper.IsJoker(f.Weight)) { return(f.Count); } return(0); }); return(jokerCount); }
/// <summary> /// 筛选炸弹 /// </summary> /// <param name="analyseResults"></param> /// <returns></returns> public static List <AnalyseResult> GetBooms(this List <AnalyseResult> analyseResults) { return(analyseResults.Where(f => f.Count > 3 && !CardsHelper.IsJoker(f.Weight)).ToList()); }