Beispiel #1
0
 public CardModel ChooseOneCard(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, IEnumerable<CardModel> choices)
 {
     if (choices.GroupBy(new Func<CardModel, string>(c => c.Name)).Count() <= 1)
     {
         return choices.FirstOrDefault();
     }
     else
     {
         return this.ChooseCards(choiceType, cardInfo, choiceText, source, 1, 1, choices).FirstOrDefault();
     }
 }
Beispiel #2
0
 public IEnumerable<CardModel> ChooseSeveralCards(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices)
 {
     if(choices.Count() <= minChoices)
     {
         return choices;
     }
     else if (minChoices == maxChoices && choices.GroupBy(new Func<CardModel, string>(c => c.Name)).Count() <= 1)
     {
         return choices.Take(minChoices);
     }
     else
     {
         return this.ChooseCards(choiceType, cardInfo, choiceText, source, minChoices, maxChoices, choices);
     }
 }
Beispiel #3
0
 public IEnumerable<CardModel> ChooseSeveralCards(CardChoiceType choiceType, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices)
 {
     return ChooseSeveralCards(choiceType, null, choiceText, source, minChoices, maxChoices, choices);
 }
Beispiel #4
0
 public CardModel ChooseOneCard(CardChoiceType choiceType, string choiceText, ChoiceSource source, IEnumerable<CardModel> choices)
 {
     return ChooseOneCard(choiceType, null, choiceText, source, choices);
 }
Beispiel #5
0
 public abstract IEnumerable<CardModel> ChooseCards(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices);
Beispiel #6
0
 public CardModel ChooseZeroOrOneCard(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, IEnumerable<CardModel> choices)
 {
     return this.ChooseSeveralCards(choiceType, choiceText, source, 0, 1, choices).FirstOrDefault();
 }
Beispiel #7
0
 public override IEnumerable<CardModel> ChooseCards(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices)
 {
     maxChoices = Math.Min(maxChoices, choices.Count());
     int howMany = Randomizer.Next(minChoices, maxChoices + 1);
     return choices.OrderBy(c => Randomizer.Next()).Take(howMany);
 }
Beispiel #8
0
 public override IEnumerable<CardModel> ChooseCards(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices)
 {
     return choices.Take(minChoices);
 }
            private IEnumerable<string> MakeCardPileChoice(string choiceText, IEnumerable<string> choices, int minChoices, int maxChoices, ChoiceSource choiceSource, bool card, bool order)
            {
                RequestChoiceInfo requestChoiceInfo = new RequestChoiceInfo();
                requestChoiceInfo.ChoiceType = order ? "ORDER" : card ? "CARD" : "PILE";
                requestChoiceInfo.ChoiceText = choiceText;
                requestChoiceInfo.ChoiceSource = choiceSource.ToString();
                requestChoiceInfo.MinChoices = minChoices;
                requestChoiceInfo.MaxChoices = maxChoices;
                requestChoiceInfo.Choices.AddRange(choices);

                NetworkMessage message = new NetworkMessage();
                message.MessageCategory = GameMessages.GamePrefix;
                message.MessageType = GameMessages.RequestChoice;
                message.MessageContent = NetworkSerializer.Serialize(requestChoiceInfo);

                this.Strategy.connection.SendMessage(message);

                this.Strategy.resetEvent.Reset();
                this.Strategy.resetEvent.WaitOne();
                Debug.Assert(this.Strategy.gameMessage.MessageType == GameMessages.MakeChoice);
                ChoiceInfo choiceInfo = NetworkSerializer.Deserialize<ChoiceInfo>(this.Strategy.gameMessage.MessageContent);
                return choiceInfo.Choices;
            }
 public override IEnumerable<CardModel> ChooseCards(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices)
 {
     IEnumerable<string> chosen = this.MakeCardPileChoice(choiceText, (from c in choices select c.ID), minChoices, maxChoices, source, card: true, order: false);
     List<CardModel> chosenCards = new List<CardModel>();
     Dictionary<string, int> seen = new Dictionary<string, int>();
     foreach (string c in chosen)
     {
         int skip = 0;
         seen.TryGetValue(c, out skip);
         CardModel foundCard = null;
         int counter = skip;
         foreach (CardModel card in choices)
         {
             if (c == card.ID)
             {
                 if (counter > 0)
                 {
                     counter--;
                 }
                 else
                 {
                     foundCard = card;
                     break;
                 }
             }
         }
         seen[c] = skip + 1;
         chosenCards.Add(foundCard);
     }
     return chosenCards;
 }
Beispiel #11
0
 public override IEnumerable<CardModel> ChooseCards(CardChoiceType choiceType, CardModel cardInfo, string choiceText, ChoiceSource source, int minChoices, int maxChoices, IEnumerable<CardModel> choices)
 {
     switch(choiceType)
     {
         case CardChoiceType.Discard:
             List<CardModel> choiceList = new List<CardModel>(choices);
             List<CardModel> discardList = new List<CardModel>();
             return choiceList.OrderBy(choice => this.parent.StaticEvalSimple(choice, this.parent.GetGamePhase())).Take(minChoices);
     }
     return base.ChooseCards(choiceType, cardInfo, choiceText, source, minChoices, maxChoices, choices);
 }