Esempio n. 1
0
 private void AddToDrawPile(Stack <Card> cards)
 {
     foreach (Card card in cards)
     {
         DrawPile.Push(card);
     }
 }
        public void DrawPile_PlaceAtBottomTest()
        {
            // Arrange.
            var expectedCards = new IntCard[]
            {
                // 3 (new top), 2, 1, 4 (new bottom)
                new IntCard(3), new IntCard(2), new IntCard(1), new IntCard(4)
            };
            var cards = new IntCard[]
            {
                // 1 (old bottom), 2, 3, 4 (old top)
                new IntCard(1), new IntCard(2), new IntCard(3), new IntCard(4)
            };
            var            drawPile = new DrawPile <IntCard>(cards);
            List <IntCard> actualCards;

            // Act.
            var drawnCard = drawPile.Draw();

            drawPile.PlaceAtBottom(drawnCard); // place card with value 4 at the bottom
            actualCards = new List <IntCard>(drawPile.Cards);

            // Assert.
            // Use collections assertions for lists because HashSet is unable to compare different sets.
            // Otherwise, GetHashCode and Equals methods would have to be tamed.
            CollectionAssert.AreEqual(expectedCards, actualCards, Comparer <IntCard> .Create((a, b) =>
            {
                return(a.Value - b.Value);
            }));
        }
Esempio n. 3
0
 private void AddSkipCards()
 {
     DrawPile.Push(new Skip(Game, _cardIndex++, "Evade dirty sasquatch underpants"));
     DrawPile.Push(new Skip(Game, _cardIndex++, "Sail away on your penis balloon. Be free, little buddy."));
     DrawPile.Push(new Skip(Game, _cardIndex++, "Play a game of whale boner tetherball"));
     DrawPile.Push(new Skip(Game, _cardIndex++, "Go base jumping using a pair of old lady boobs"));
 }
Esempio n. 4
0
        public Game(int numberOfPlayers = 2)
        {
            // Set the number of players
            NumberOfPlayers = numberOfPlayers;

            // Create the players
            AddPlayers(numberOfPlayers);

            // Build a new deck
            Deck deck = new Deck();
            //deck.Print();

            // Add the shuffled deck to the drawpile
            DrawPile drawPile = new DrawPile(deck);
            //drawPile.Draw(5);

            // Create a new Dealer
            Dealer dealer = new Dealer();

            // Deal the starting hands to each player
            dealer.Deal(drawPile, Players);

            // Loop through the turns of the game until someone wins
            Loop();
        }
Esempio n. 5
0
    public CardPosition PurgeCardFromDeck(string id)
    {
        if (!TotalDeckList.Where(i => i.Id == id).Any())
        {
            throw new Exception("Could not find card with ID of " + id);
        }
        var card = TotalDeckList.Where(i => i.Id == id).Single();

        if (DrawPile.Contains(card))
        {
            DrawPile.Remove(card);
            return(CardPosition.DRAW);
        }
        if (DiscardPile.Contains(card))
        {
            DiscardPile.Remove(card);
            return(CardPosition.DISCARD);
        }
        if (Hand.Contains(card))
        {
            Hand.Remove(card);
            return(CardPosition.HAND);
        }
        throw new Exception("This should be impossible");
    }
Esempio n. 6
0
        public void TestDrawPileSize()
        {
            GameSettings settings = new GameSettings(DifficultLevel.Middle);
            DrawPile     drawPile = new DrawPile(settings);

            Debug.Assert(drawPile.size == 50);
        }
Esempio n. 7
0
 private void AddFavorCards()
 {
     DrawPile.Push(new Favor(Game, _cardIndex++, "Take your friends beard-sailing on your beard boat"));
     DrawPile.Push(new Favor(Game, _cardIndex++, "Ask for a back hair shampoo"));
     DrawPile.Push(new Favor(Game, _cardIndex++, "Get inslaved by party squirrels"));
     DrawPile.Push(new Favor(Game, _cardIndex++, "Rub peanut butter on your belly button and make some new friends"));
 }
Esempio n. 8
0
 public void Clear()
 {
     Hand.Clear();
     DrawPile.Clear();
     DiscardPile.Clear();
     RemovePile.Clear();
 }
Esempio n. 9
0
 private void AddShuffleCards()
 {
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "Discover you have a toilet werewolf"));
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "An asparagus bum dragon appears"));
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "A kraken emerges and he's super upset"));
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "Smoke some crack with a baby owl"));
 }
Esempio n. 10
0
 private void AddFavorCards()
 {
     DrawPile.Push(new Favor(Game, _cardIndex++, "\"Baby Robin\" your best friend"));
     DrawPile.Push(new Favor(Game, _cardIndex++, "Teach someone a new palindrome"));
     DrawPile.Push(new Favor(Game, _cardIndex++, "Fall so deeply in love it you gives you both crazy diarrhea"));
     DrawPile.Push(new Favor(Game, _cardIndex++, "Donate your body to cat science"));
 }
Esempio n. 11
0
 public void AddExplodingKittenCards()
 {
     for (int playerIndex = 0; playerIndex < NumberOfPlayers - 1; playerIndex++)
     {
         DrawPile.Push(new ExplodingKitten(Game, _cardIndex++));
     }
 }
Esempio n. 12
0
    void drawHand()
    {
        hand = new List <Card>();

        for (int i = 0; i < HandSize; i++)
        {
            if (DrawPile.Count == 0)
            {
                DrawPile.List.AddRange(DiscardPile);
                DrawPile.List.ShuffleInPlace();
                DiscardPile.Clear();

                if (DrawPile.Count != Deck.Count)
                {
                    // we should be able to continue playing if this happens, but I absolutely want to know about it
                    Debug.LogError($"you lost {Deck.Count - DrawPile.Count} cards somewhere");
                }
            }

            var drawIndex = DrawPile.Count - 1;

            hand.Add(DrawPile[drawIndex]);
            DrawPile.RemoveAt(drawIndex);
        }
    }
Esempio n. 13
0
 private void AddAttackCards()
 {
     DrawPile.Push(new Attack(Game, _cardIndex++, "Unleash the catterwocky"));
     DrawPile.Push(new Attack(Game, _cardIndex++, "Deploy the thousand-year back hair"));
     DrawPile.Push(new Attack(Game, _cardIndex++, "Awaken the bear-o-dactyl"));
     DrawPile.Push(new Attack(Game, _cardIndex++, "Fire the crab-a-pult"));
 }
Esempio n. 14
0
 private void AddShuffleCards()
 {
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "A plague of bat farts descends from the sky"));
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "A transdimensional Litter Box materializes"));
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "Abracrab lincoln is elected president"));
     DrawPile.Push(new Shuffle(Game, _cardIndex++, "An Electromagnetic pomeranian storm rolls in"));
 }
Esempio n. 15
0
 private void AddSkipCards()
 {
     DrawPile.Push(new Skip(Game, _cardIndex++, "Crab walk with some crabs"));
     DrawPile.Push(new Skip(Game, _cardIndex++, "Don a portable cheetah butt"));
     DrawPile.Push(new Skip(Game, _cardIndex++, "Commandeer a Bunnyraptor"));
     DrawPile.Push(new Skip(Game, _cardIndex++, "Engage the Hypergoat"));
 }
Esempio n. 16
0
 private void AddAttackCards()
 {
     DrawPile.Push(new Attack(Game, _cardIndex++, "Whip out your rubber dick collection"));
     DrawPile.Push(new Attack(Game, _cardIndex++, "Grow a magnificent squid arm and start slapping fat babies"));
     DrawPile.Push(new Attack(Game, _cardIndex++, "Release the torture bunnies"));
     DrawPile.Push(new Attack(Game, _cardIndex++, "Unleash some adorable penguin diarrhea"));
 }
Esempio n. 17
0
 public void Draw(int numberToDraw = 1)
 {
     // drawing 0 cards doesn't make sense
     if (numberToDraw <= 0)
     {
         return;
     }
     // if we're able to draw multiple, do it
     if (DrawPile.Count >= numberToDraw)
     {
         List <T> drawnCards = DrawPile.Draw(numberToDraw);
         Hand.Add(drawnCards);
     }
     // not enough cards! Trigger overdraw event
     else
     {
         // track the number of remaining cards we will have, because we are about to alter data
         int undrawnCards = numberToDraw - DrawPile.Count;
         numberToDraw = DrawPile.Count;
         // draw the cards
         List <T> drawnCards = DrawPile.Draw(numberToDraw);
         // send out notifcation on remaining cards
         OnDrawPileOverdraw.Invoke(undrawnCards);
     }
 }
Esempio n. 18
0
 private void AddSeeTheFutureCards()
 {
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Attach a butterfly to your genitals and see where it takes you in life"));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Drink an entire bottle of bald eagle tears"));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Discover a boob wizard living in your boobs. Listen to the secrets he tells."));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Weave an infinity boner and live forever, foe it is the most sacred of boners."));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Crawl inside a goat butt and see many wondrous things"));
 }
Esempio n. 19
0
 public void Adds(ObservableCollection <Card> cards)
 {
     foreach (Card card in cards)
     {
         DrawPile.Add(card);
     }
     OnPropertyChanged(nameof(CardsRemaining));
 }
Esempio n. 20
0
 private void AddSeeTheFutureCards()
 {
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Feast upon a unicorn enchilada and gain its enchilada powers"));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Rub the belly of a pig-a-corn"));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Summon the Mantis shrimp"));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Ask the all-seeing goat wizard"));
     DrawPile.Push(new SeeTheFuture(Game, _cardIndex++, "Deploy the special-ops bunnies"));
 }
Esempio n. 21
0
 private void AddNopeCards()
 {
     DrawPile.Push(new Nope(Game, _cardIndex++, "Feed your opponent a nope sandwich with extra Nopesause"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "Win the Nopebell peace prize"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "A Jackanope bounds into the room"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "Nopestradamus speaks the truth"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "A nope ninja delivers a wicked dragon kick"));
 }
Esempio n. 22
0
 private void AddNopeCards()
 {
     DrawPile.Push(new Nope(Game, _cardIndex++, "Awaken The Narnope"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "Feed your opponent some cantanope"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "Deliver some nope on your jump rope"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "The Pope of Nope has spoken"));
     DrawPile.Push(new Nope(Game, _cardIndex++, "Put on your necktie of nope. Holy smokes you look good."));
 }
Esempio n. 23
0
 public Deck()
 {
     while (DrawPile.Count < 20)
     {
         Console.WriteLine("Generating New Card");
         DrawPile.Add(Card.Generate());
     }
 }
Esempio n. 24
0
 public void DealCards()
 {
     foreach (Player player in Players)
     {
         IEnumerable <Card> playerHand = DrawPile.Take(3);
         DrawPile.RemoveRange(0, 3);
         player.Hand = playerHand;
     }
 }
Esempio n. 25
0
 /// <summary>
 /// Creates a CardCounter
 /// </summary>
 /// <param name="player">Player to cardcount for (player at position 0)</param>
 public CardCounter(Player player)
 {
     _player = player;
     packs   = new List <CardType>[4] {
         new List <CardType>(), new List <CardType>(), new List <CardType>(), new List <CardType>()
     };
     pile = new DrawPile(Deck.Instance().deckInfo);
     Deck.Instance().evtCardPlayed += this.OnPlayerCardPlayed;
 }
Esempio n. 26
0
 public void Shuffle()
 {
     DrawPile = DrawPile.Concat(DiscardPile).ToObservableCollection <Card>();
     DiscardPile.Clear();
     DrawPile = DrawPile.Concat(BurnPile).ToObservableCollection <Card>();
     BurnPile.Clear();
     DrawPile = Shuffler.Shuffle(DrawPile, rnd).ToObservableCollection <Card>();
     OnPropertyChanged(nameof(CardsRemaining));
 }
Esempio n. 27
0
 /// <summary>
 /// How to handle rehydration from being serialized.
 /// </summary>
 public override void Rehydrated()
 {
     base.Rehydrated();
     DrawPile.Apply(c => c.Options           = CardOptions);
     DiscardPile.Apply(c => c.Options        = CardOptions);
     Table.Apply(c => c.Options              = CardOptions);
     Tableau.Apply(c => c.Options            = CardOptions);
     Hands.Apply(h => h.Apply(c => c.Options = CardOptions));
 }
Esempio n. 28
0
 public void ShuffleDiscardIntoDrawPile()
 {
     foreach (T cardToShuffle in DiscardPile.Cards)
     {
         DrawPile.Add(cardToShuffle);
     }
     DiscardPile.Cards.Clear();
     DiscardPile.Shuffle();
 }
Esempio n. 29
0
File: Game.cs Progetto: robisoft/Uno
        private void SetupInitialGame()
        {
            CurrentPlayerIndex = 0;
            SetupGameEvents();

            var card = DrawPile.Pop(null);

            DiscardPile.Push(card);
        }
Esempio n. 30
0
    void Start()
    {
        PlayerAbilityCharges.Initialize();

        DrawPile.Clear();
        DiscardPile.Clear();

        DiscardPile.List.AddRange(Deck);
        startBuildPhase();
    }