Beispiel #1
0
    public void DisplayColor(object o, Card.CardColor color)
    {
        colorDisplay.enabled = true;
        showColorForOneTurn  = false;
        switch (color)
        {
        case Card.CardColor.Kule: {
            colorDisplay.sprite = kule;
            break;
        }

        case Card.CardColor.Listy: {
            colorDisplay.sprite = listy;
            break;
        }

        case Card.CardColor.Srdce: {
            colorDisplay.sprite = srdce;
            break;
        }

        case Card.CardColor.Zaludy: {
            colorDisplay.sprite = zaludy;
            break;
        }
        }
    }
Beispiel #2
0
 /// <summary>
 /// Check if the body has a body item corresponding to this color.
 /// </summary>
 /// <param name="color">Color that want to check</param>
 /// <returns>True if the body has a body item of this color.</returns>
 public bool HaveThisOrgan(Card.CardColor color)
 {
     foreach (var item in Items)
     {
         if (item.Organ.Color.Equals(color))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
 /// <summary>
 /// Check if two color are the same or wildcard color.
 /// </summary>
 /// <param name="color1">Color 1</param>
 /// <param name="color2">Color 2</param>
 /// <returns>True if they are equal or some of them is wildcard</returns>
 public static bool SameColorOrWildcard(Card.CardColor color1, Card.CardColor color2)
 {
     if (color1 == color2 ||
         color1 == Card.CardColor.Wildcard ||
         color2 == Card.CardColor.Wildcard)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Returns all possible sets which can be created using joker cards.
        /// </summary>
        private static List <Set> GetPossibleJokerSets(List <Card> PlayerCards, List <Card> LaidDownCards)
        {
            var jokerCards = PlayerCards.Where(c => c.IsJoker());

            if (!jokerCards.Any())
            {
                return(new List <Set>());
            }

            var thoughts = new List <string>();
            var duoSets  = GetAllDuoSets(PlayerCards, LaidDownCards, ref thoughts);

            if (duoSets.Count == 0)
            {
                return(new List <Set>());
            }

            var possibleJokerSets = new List <Set>();

            // First, create trios out of duos where both cards have the same color
            // for each trio, save all possible combinations with available jokers
            for (int i = 0; i < 2; i++)
            {
                Card.CardColor color         = (Card.CardColor)i;
                var            sameColorDuos = duoSets.Where(duo => duo.A.Color == color && duo.B.Color == color);

                foreach (var duo in sameColorDuos)
                {
                    // Find all available jokers with the opposite color
                    var possibleJokers = jokerCards.Where(j => j.Color != color);
                    foreach (var joker in possibleJokers)
                    {
                        var newSet = new Set(duo.A, duo.B, joker);
                        possibleJokerSets.Add(newSet);
                    }
                }
            }

            // Now finish all red-black duos with all possible joker cards
            var mixedDuos = duoSets.Where(duo => duo.A.Color != duo.B.Color);

            foreach (var duo in mixedDuos)
            {
                foreach (var jokerCard in jokerCards)
                {
                    var newSet = new Set(duo.A, duo.B, jokerCard);
                    possibleJokerSets.Add(newSet);
                }
            }
            return(possibleJokerSets);
        }
Beispiel #5
0
    public void ColorSelected(object sender, Card.CardColor color)
    {
        waitingForInput           = false;
        Controls.OnColorSelected -= ColorSelected;
        workingCard.cardColor     = color;
        workingCard = null;
        OnColorSelected?.Invoke(this, color);

        if (controlledByLocal)
        {
            manager.SendExtraAction(new ExtraCardArgs(color, index));
        }
        turnInProgress = false;

        OnEndTurn(this, this);
    }
        /// <summary>
        /// Generate a Uno deck of cards
        /// </summary>
        /// <returns></returns>
        public static List <Card> GenerateUnoDeck()
        {
            List <Card> deck = new List <Card>(Game.MAXUNOCARDS);


            // Loop to go through each colour
            for (int i = 0; i < 5; i++)
            {
                Card.CardColor color = (Card.CardColor)i;

                if (color != Card.CardColor.Wild)
                {
                    // Loop to make 2 of each face card for the selected color, but only one 0 (standard Uno deck)
                    // only count from 0-12 to exclude draw 4
                    for (int k = 0; k < 16; k++)
                    {
                        deck.Add(new Card(color, (Card.CardFace)k));

                        // Add the second idenical card, except for 0s
                        if (k != 0)
                        {
                            deck.Add(new Card(color, (Card.CardFace)k));
                        }
                    }
                }
                else
                {
                    // Generate wild cards

                    for (int k = 0; k < 4; k++)
                    {
                        deck.Add(new Card(color, Card.CardFace.None));
                        deck.Add(new Card(color, Card.CardFace.Draw4));
                    }
                }
            }


            return(deck);
        }
Beispiel #7
0
 private void red_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Red;
 }
Beispiel #8
0
 public ExtraCardArgs(Card.CardColor color, byte playerId)
 {
     cardColor     = color;
     this.playerId = playerId;
 }
Beispiel #9
0
        public bool PutCardOnMainStack(Player player, int choice)
        {
            // Peek top card from off stack:
            Card peeked = null;

            if (_offStack.Count > 0)
            {
                peeked = _offStack.Peek();
            }

            // Validate correct card index was given:
            if ((player.PlayerHand.Count > 0 && (player.PlayerHand.Count - 1) >= choice) && choice >= 0)
            {
                Card.CardColor currentColorOfDeck = Card.CardColor.NONE;

                if (_offStack.Count > 0)
                {
                    currentColorOfDeck = _offStack.Peek().Color;
                }



                //If Joker card player can set the color...:
                if (player.PlayerHand[choice].Special == Card.CardSpecial.JOKER_CHOOSE_COLOR ||
                    player.PlayerHand[choice].Special == Card.CardSpecial.JOKER_CHOOSE_COLOR_AND_DRAW_4_CARDS)
                {
                    Console.WriteLine("JOKER SÆT FARVE");
                    Console.WriteLine("R = RØD, G = GRØN, B = BLÅ, Y = GUL: ");
                    string input = Console.ReadLine();

                    if (input != null)
                    {
                        switch (input.ToLower())
                        {
                        case "r":
                            player.PlayerHand[choice].Color = Card.CardColor.RED;
                            currentColorOfDeck = Card.CardColor.RED;
                            break;

                        case "g":
                            player.PlayerHand[choice].Color = Card.CardColor.GREEN;
                            currentColorOfDeck = Card.CardColor.GREEN;
                            break;

                        case "b":
                            player.PlayerHand[choice].Color = Card.CardColor.BLUE;
                            currentColorOfDeck = Card.CardColor.BLUE;
                            break;

                        case "y":
                            player.PlayerHand[choice].Color = Card.CardColor.YELLOW;
                            currentColorOfDeck = Card.CardColor.YELLOW;
                            break;

                        default:
                            //TODO: Can't handle bad color joker input yet.
                            break;
                        }
                    }
                }

                // Handle special effects:: (TAKE TWO & JOKER 4 CARDS).
                if (player.PlayerHand[choice].Special == Card.CardSpecial.JOKER_CHOOSE_COLOR_AND_DRAW_4_CARDS)
                {
                    Player next = GetNextPlayer();
                    for (int i = 0; i < 4; i++)
                    {
                        next.PlayerHand.Add(DrawCardFromMainStack());
                    }
                }

                if (player.PlayerHand[choice].Special == Card.CardSpecial.TAKE_TWO)
                {
                    Player next = GetNextPlayer();
                    next.PlayerHand.Add((DrawCardFromMainStack()));
                    next.PlayerHand.Add((DrawCardFromMainStack()));
                }

                if (peeked != null)
                {
                    if (player.PlayerHand[choice].Value == PeekOffStack().Value || player.PlayerHand[choice].Color == currentColorOfDeck || (player.PlayerHand[choice].Special == PeekOffStack().Special&& player.PlayerHand[choice].Special != Card.CardSpecial.NORMAL))
                    {
                        PutCardInOffStack(player.PlayerHand[choice]);
                        player.PlayerHand.RemoveAt(choice);

                        return(true);
                    }
                }
                else // peeked will be null first round of the game.
                {
                    PutCardInOffStack(player.PlayerHand[choice]);
                    player.PlayerHand.RemoveAt(choice);

                    return(true);
                }
            }

            // If a valid input was not chosen output error messages.
            Console.WriteLine("Du har valgt et forkert index eller et ugyldigt kort.");
            Console.WriteLine("Kortet skal have samme farve, værdi eller symbol");



            return(false);
        }
Beispiel #10
0
 public void SetWildCardColor(Card.CardColor color)
 {
     wildCardColor = color;
 }
Beispiel #11
0
 public CardInfo(Card.CardColor color, Card.CardValue value)
 {
     this.color = color;
     this.value = value;
 }
 private void green_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Green;
 }
 private void blue_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Blue;
 }
 private void red_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Red;
 }
 private void yellow_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Yellow;
 }
Beispiel #16
0
 public void SetWildCardColorRed()
 {
     wildCardColor = Card.CardColor.Red;
     Debug.Log("wildCardColor = " + wildCardColor);
 }
Beispiel #17
0
 private void yellow_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Yellow;
 }
Beispiel #18
0
 private void green_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Green;
 }
Beispiel #19
0
 private void blue_Click(object sender, EventArgs e)
 {
     color = Card.CardColor.Blue;
 }
Beispiel #20
0
 public void SetWildCardColorBlue()
 {
     wildCardColor = Card.CardColor.Blue;
     Debug.Log("wildCardColor = " + wildCardColor);
 }
Beispiel #21
0
 public void SetWildCardColorYellow()
 {
     wildCardColor = Card.CardColor.Yellow;
     Debug.Log("wildCardColor = " + wildCardColor);
 }
Beispiel #22
0
 public void SetWildCardColorGreen()
 {
     wildCardColor = Card.CardColor.Green;
     Debug.Log("wildCardColor = " + wildCardColor);
 }