示例#1
0
        public static Image GetCard(MusCard card)
        {
            Image retVal = null;
            int   x = 0, y = 0;
            int   numCard = (int)card;

            x = numCard > 9 ? numCard % 10 : numCard;
            x = x * cardSize.Width;

            y = numCard > 9 ? numCard / 10 : 0;
            y = y * cardSize.Height;

            retVal = MainImage.Clone(new Rectangle(x, y, cardSize.Width, cardSize.Height), MainImage.PixelFormat);
            return(retVal);
        }
示例#2
0
        static List <MusCard> GetCards(string gameName, string teamName, string userName, int numCards)
        {
            List <MusCard> retVal = new List <MusCard>();


            try
            {
                var game = MusDatabase.Games.FirstOrDefault(x => x.GameName == gameName);
                if (game != null)
                {
                    var team = game.Teams.FirstOrDefault(x => x.TeamName == teamName);
                    if (team == null)
                    {
                        mySource.TraceMessage(TraceEventType.Error, 58, $"ERROR No leo el Team {teamName} del user {userName} en GetCards");
                    }

                    var user = team.Users.FirstOrDefault(x => x.UserName == userName);
                    if (user == null)
                    {
                        mySource.TraceMessage(TraceEventType.Error, 58, $"ERROR No leo el User {userName} del equipo {teamName} en GetCards");
                    }
                    for (int i = 0; i < numCards; i++)
                    {
                        if (game.Cards.CardsToPlay.Count == 0)
                        {
                            AddTrace(game, "Se vuelven a barajar las cartas descartadas");
                            game.Cards.CardsToPlay.AddRange(game.Cards.CardsDiscarded);
                            game.Cards.CardsDiscarded.Clear();
                        }
                        int     randomIndex = rnd.Next(game.Cards.CardsToPlay.Count - 1);
                        MusCard card        = game.Cards.CardsToPlay[randomIndex];
                        retVal.Add(card);
                        user.Cards.Add(card);
                        game.Cards.CardsToPlay.Remove(card);
                    }
                }
            }
            catch (Exception ex)
            {
                mySource.TraceMessage(TraceEventType.Information, 58, $"ERROR {ex.ToString()}");
            }
            return(retVal);
        }
示例#3
0
        private void card1_DragDrop(object sender, DragEventArgs e)
        {
            CardControl cardDest       = sender as CardControl;
            string      hashCodeOrigin = e.Data.GetData(DataFormats.Text).ToString();

            if (cardDest.GetHashCode().ToString() != hashCodeOrigin)
            {
                CardControl cardOrigin  = this.Controls.OfType <CardControl>().First(x => x.GetHashCode().ToString() == hashCodeOrigin);
                MusCard     musCardDest = cardDest.Card;
                cardDest.Card   = cardOrigin.Card;
                cardOrigin.Card = musCardDest;
            }
            else
            {
                if ((DateTime.Now - lastTimeDown).TotalMilliseconds < 600)
                {
                    lastTimeDown = DateTime.MinValue;
                    CardControl card = sender as CardControl;
                    card.CheckCard = !card.CheckCard;
                }
            }
        }