Beispiel #1
0
 public void cardsToPlay_init(Card pile)
 {
     cardsToPlay.Clear();
     foreach (Card card in hand)
     {
         if ((card.colour == pile.colour) ||
              (card.colour == Colours.Wild) ||
              (card.value == pile.value))
             cardsToPlay.Add(card);
     }
 }
Beispiel #2
0
 private Image getImage(Card card)
 {
     switch (card.value)
         {
             case Values.Zero:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_0;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_0;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_0;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_0;
                     default:
                         break;
                 }
                 break;
             case Values.One:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_1;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_1;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_1;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_1;
                     default:
                         break;
                 }
                 break;
             case Values.Two:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_2;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_2;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_2;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_2;
                     default:
                         break;
                 }
                 break;
             case Values.Three:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_3;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_3;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_3;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_3;
                     default:
                         break;
                 }
                 break;
             case Values.Four:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_4;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_4;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_4;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_4;
                     default:
                         break;
                 }
                 break;
             case Values.Five:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_5;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_5;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_5;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_5;
                     default:
                         break;
                 }
                 break;
             case Values.Six:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_6;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_6;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_6;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_6;
                     default:
                         break;
                 }
                 break;
             case Values.Seven:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_7;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_7;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_7;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_7;
                     default:
                         break;
                 }
                 break;
             case Values.Eight:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_8;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_8;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_8;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_8;
                     default:
                         break;
                 }
                 break;
             case Values.Nine:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_9;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_9;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_9;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_9;
                     default:
                         break;
                 }
                 break;
             case Values.Skip:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_stop;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_stop;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_stop;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_stop;
                     default:
                         break;
                 }
                 break;
             case Values.Reverse:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_reverse;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_reverse;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_reverse;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_reverse;
                     default:
                         break;
                 }
                 break;
             case Values.DrawTwo:
                 switch (card.colour)
                 {
                     case Colours.Red:
                         return UNO_WinForms.Properties.Resources.red_draw_2;
                     case Colours.Yellow:
                         return UNO_WinForms.Properties.Resources.yellow_draw_2;
                     case Colours.Blue:
                         return UNO_WinForms.Properties.Resources.blue_draw_2;
                     case Colours.Green:
                         return UNO_WinForms.Properties.Resources.green_draw_2;
                     default:
                         break;
                 }
                 break;
             case Values.Wild:
                 return UNO_WinForms.Properties.Resources.wild;
             case Values.WildFour:
                 return UNO_WinForms.Properties.Resources.wild_four;
             default:
                 break;
         }
         // не должны попадать сюда
         return null;
 }
Beispiel #3
0
        public Dealer()
        {
            players = new List<Player>();
            pile = new Stack<Card>();

            // составляем колоду
            List<Card> items = new List<Card>();

            // добавляем в колоду дублирующиеся карты
            for (Colours i = Colours.Red;
                 i < Colours.Wild;
                 i++)
            {
                for (Values j = Values.One;
                    j < Values.Wild;
                    j++)
                {
                    Card card = new Card();
                    card.colour = (Colours)i;
                    card.value = j;
                    items.Add(card);
                    Card card1= new Card();
                    card1.colour = (Colours)i;
                    card1.value = j;
                    items.Add(card1);
                }
            }
            // добавляем в колоду остальные карты
            for (int i = 0; i < 4; i++)
            {
                // добавляем нули
                Card card = new Card();
                card.colour = (Colours)i;
                card.value = Values.Zero;
                items.Add(card);
                // дикие карты "заказать цвет"
                Card wild1 = new Card();
                wild1.colour = Colours.Wild;
                wild1.value = Values.Wild;
                items.Add(wild1);
                // дикие карты "+4"
                Card wild2 = new Card();
                wild2.value = Values.WildFour;
                wild2.colour = Colours.Wild;
                items.Add(wild2);
            }

            // перемешиваем колоду
            Random RND = new Random();
            for (int i = 0; i < items.Count; i++)
            {
                Card tmp = items[0];
                items.RemoveAt(0);
                items.Insert(RND.Next(items.Count), tmp);
            }
            deck = new Stack<Card>(items);

            //printDeck();

            // раздаём карты игрокам
            init_hands();
        }