SetIndex() 공개 메소드

public SetIndex ( int idx ) : void
idx int
리턴 void
예제 #1
0
        public void MoveCardAt(Player player, Card card, int x, int y, int idx, bool faceUp)
        {
            // Get the table control
            Table table = Program.GameEngine.Table;
            // Because every player may manipulate the table at the same time, the index may be out of bound
            if (card.Group == table)
            { if (idx >= table.Count) idx = table.Count - 1; }
            else
                if (idx > table.Count) idx = table.Count;

            // Ignore cards moved by the local player (already done, for responsiveness)
            if (player == Player.LocalPlayer)
            {
                // See remark in MoveCard
                if (card.Group == table)
                    card.SetIndex(idx); // This is done to preserve stack order consistency with other players (should be a noop most of the time)
                return;
            }
            // Find the old position on the table, if any
            //bool onTable = card.Group == table;
            //double oldX = card.X, oldY = card.Y;
            // Do the move
            new MoveCard(player, card, x, y, idx, faceUp).Do();
        }
예제 #2
0
 public void MoveCard(Player player, Card card, Group to, int idx, bool faceUp)
 {
     // Ignore cards moved by the local player (already done, for responsiveness)
     if (player != Player.LocalPlayer)
         new MoveCard(player, card, to, idx, faceUp).Do();
     else
     {
         // Fix: cards may move quickly locally from one group to another one, before we get a chance
         // to execute this handler, during game actions scripts (e.g. Mulligan with one player -
         // shuffling happens locally). The result is that we are going to receive two messages,
         // one for the move to group A, then the move to group B; while the card already is in group B.
         // In this case, trying to set index inside group B with an index coming from the time the card
         // was in group A is just plain wrong and may crash depending on the index.
         if (card.Group == to)
             card.SetIndex(idx); // This is done to preserve stack order consistency with other players (should be a noop most of the time)
     }
 }