public DealT(DealT other) { CardIdx = other.CardIdx; CardName = other.CardName; Count = other.Count; SharedCardsPlayer = other.SharedCardsPlayer; }
static void OnCombin(ref CardSet cards, EnumParams ep) { DealT deal; string cardName = ep.GameDef.DeckDescr.GetCardNames(cards); int cardId = ep.GameDef.DeckDescr.GetIndexesAscending(cards)[0]; if (!ep.uniqueActions.TryGetValue(cardName, out deal)) { // Add new action deal = new DealT { CardIdx = cardId, CardName = cardName, SharedCardsPlayer = ep.SharedCardsPlayer }; ep.Deals.Add(deal); ep.uniqueActions[cardName] = deal; } deal.Count++; }
static List <DealT> DealCards(GameContext context) { GameDefinition gd = context.Global.GameDef; List <DealT> deals = new List <DealT>(); // If this a shared card - duplicate the deal for all players if (context.Deal != null && context.Deal.SharedCardsPlayer != -1) { if (context.Deal.SharedCardsPlayer < gd.MinPlayers - 1) { DealT copyDeal = new DealT(context.Deal); deals.Add(copyDeal); copyDeal.SharedCardsPlayer++; return(deals); } } int playerCardsCount = gd.PrivateCardsCount[context.GameState.NextDealRound] + gd.PublicCardsCount[context.GameState.NextDealRound]; int sharedCardsCount = gd.SharedCardsCount[context.GameState.NextDealRound]; if (playerCardsCount > 0 && sharedCardsCount > 0) { throw new ApplicationException("Only deals with either player or shared cards are supported now."); } int cardsCount = playerCardsCount + sharedCardsCount; if (cardsCount != 1) { throw new ApplicationException("Only one card in round is supported."); } EnumParams ep = new EnumParams { GameDef = gd, Deals = deals, SharedCardsPlayer = sharedCardsCount == 0 ? -1 : 0 }; CardEnum.Combin(gd.DeckDescr, cardsCount, CardSet.Empty, context.DealtCards, OnCombin, ep); return(deals); }