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();
}