protected override async Task Run(Room unit, Prompt_RT message, Action <Prompt_RE> reply) { Prompt_RE response = new Prompt_RE(); try { Gamer gamer = unit.Get(message.PlayerID); if (gamer != null) { List <Card> handCards = new List <Card>(gamer.GetComponent <HandCardsComponent>().GetAll()); CardsHelper.SortCards(handCards); if (gamer.Id == unit.GetComponent <OrderControllerComponent>().Biggest) { response.Cards = handCards.Where(card => card.CardWeight == handCards[handCards.Count - 1].CardWeight).ToArray(); } else { DeskCardsCacheComponent deskCardsCache = unit.GetComponent <DeskCardsCacheComponent>(); List <Card[]> result = await CardsHelper.GetPrompt(handCards, deskCardsCache, deskCardsCache.Rule); if (result.Count > 0) { response.Cards = result[RandomHelper.RandomNumber(0, result.Count)]; } } } reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
/// <summary> /// 手牌排序 /// </summary> /// <param name="self"></param> public static void Sort(this DeskCardsCacheComponent self) { CardsHelper.SortCards(self.library); }
/// <summary> /// 手牌排序 /// </summary> /// <param name="self"></param> public static void Sort(this HandCardsComponent self) { CardsHelper.SortCards(self.Library); }