예제 #1
0
 public PlayerHand(Card[] cards)
 {
     foreach(var card in cards)
     {
         if (card is CardSecretRole)
             if (Role != null)
                 throw new ArgumentException("Multiple secret role cards!", nameof(cards));
             else
                 Role = card as CardSecretRole;
         else if (card is CardMembership)
             if (Membership != null)
                 throw new ArgumentException("Multiple membership cards!", nameof(cards));
             else
                 Membership = card as CardMembership;
         else if (card is CardBallotYes)
             Yes = card as CardBallotYes;
         else if (card is CardBallotNo)
             No = card as CardBallotNo;
     }
     if (Role == null)
         throw new ArgumentException("Missing a secret role card!", nameof(cards));
     if (Membership == null)
         throw new ArgumentException("Missing a membership card!", nameof(cards));
     if (Yes == null)
         Yes = new CardBallotYes();
     if (No == null)
         No = new CardBallotNo();
 }
예제 #2
0
 private void PickPolicyCard(Card obj)
 {
     var policyCards = pickPolicyCards;
     for (var i = 0; i < policyCards.Length; i++)
         if(obj == policyCards[i])
         {
             if (policyCards[i].GetType() == typeof(CardPolicyVeto))
             {
                 var j = 0;
                 pickPolicyCards = new CardPolicy[policyCards.Length - 1];
                 for (var i2 = 0; i2 < policyCards.Length; i2++)
                     if (i2 != i)
                     {
                         pickPolicyCards[j++] = policyCards[i2];
                         policyCards[i2].OnClick -= PickPolicyCard;
                     }
                 State.RequestVeto();
             }
             else
             {
                 State.ReturnPolicyCards(i);
                 pickPolicyCards = null;
             }
         }
 }
예제 #3
0
 internal void PickPolicyCard(Card[] cards, Action<Card> callback = null)
 {
     var xSpacing = 15 * (cards.Length - 1);
     var totalXSpace = cards.Length * Card.DEFAULTCARDSIZE.Width + xSpacing;
     var xOffset = (DEFAULTSIZE.Width / 2 - totalXSpace / 2);
     for (var i = 0; i < cards.Length; i++)
     {
         cards[i].Location = new Point(Location.X + xOffset + i * (Card.DEFAULTCARDSIZE.Width + 15), Location.Y);
         Action<Card> onClick;
         if (callback == null)
             onClick = PickPolicyCard;
         else
             onClick = (Card card) => { pickPolicyCards = null; callback(card); };
         cards[i].OnClick += onClick;
     }
     pickPolicyCards = cards;
 }