Ejemplo n.º 1
0
 public void Shuffled(Group group, int[] card, short[] pos)
 {
     // Check the args
     if (card.Length != pos.Length)
     {
         Program.TraceWarning("[Shuffled] Cards and positions lengths don't match.");
         return;
     }
     group.filledShuffleSlots += card.Length;
     if (group.filledShuffleSlots > group.Count)
     {
         Program.TraceWarning("[Shuffled] Too many card positions received.");
         return;
     }
     // If it's the first packet we receive for this shuffle, clear all Types
     if (!group.hasReceivedFirstShuffledMessage)
         foreach (Card c in group) c.Type = null;
     group.hasReceivedFirstShuffledMessage = true;
     // Check that the server didn't change our positions
     if (card[0] >> 16 == Player.LocalPlayer.Id && group.myShufflePos != null)
     {
         for (int i = 0; i < pos.Length; i++)
             if (pos[i] != group.myShufflePos[i])
             {
                 Program.TraceWarning("[Shuffled] The server has changed the order of the cards.");
                 break;
             }
         group.myShufflePos = null;
     }
     // Insert the cards
     for (int j = 0; j < card.Length; j++)
     {
         // Get the wished position
         int i = pos[j];
         // Get the card
         CardIdentity ci = CardIdentity.Find(card[j]);
         if (ci == null)
         {
             Program.TraceWarning("[Shuffled] Card not found.");
             continue;
         }
         // Check if the slot is free, otherwise choose the first free one
         if (group[i].Type != null) i = group.FindNextFreeSlot(i);
         // Set the type
         group[i].Type = ci;
         group[i].SetVisibility(ci.visible ? GroupVisibility.Everybody : GroupVisibility.Nobody, null);
     }
     if (group.filledShuffleSlots == group.Count)
         group.OnShuffled();
 }