Exemplo n.º 1
0
        /// <summary>
        /// Starts turn by adding a card from the main deck to the player's board.
        /// If the player has stood, instead they skip they're turn
        /// also sets IsActive to true
        /// </summary>
        public void BeginTurn()
        {
            if (HasStood)
            {
                EndTurn();
            }
            else
            {
                //MessageBox.Show("Click OK when you are ready to start your turn", "Next Turn", MessageBoxButton.OK);
                TurnTransitionControl ttc = new TurnTransitionControl();

                ttc.StartCountDown(2);
                ttc.ShowDialog();

                IsActive = true;

                Board.AddCard(MainDeck.DrawNextCard());

                if (Board.Sum == 20)
                {
                    HasStood = true;
                    EndTurn();
                }
            }
        }
Exemplo n.º 2
0
        public void Clear()
        {
            switch (CurrentZone)
            {
            case Zone.SampleHand:
                SampleHand.Clear();
                break;

            case Zone.Side:
                SideDeck.Clear();
                break;

            case Zone.Main:
                MainDeck.Clear();
                SideDeck.Clear();
                break;

            default:
                return;
            }

            lock (DataSource)
                DataSource.Clear();

            DeckChanged?.Invoke(
                listChanged: true,
                countChanged: true,
                card: null,
                touchedChanged: false,
                changedZone: CurrentZone,
                changeTerminatesBatch: true);
        }
Exemplo n.º 3
0
    public void Generate()
    {
        maindeck_CS = GetComponent <MainDeck>();
        deckList    = new List <CardTemplate> (maindeck_CS.mainDeckList);

        DrawStartCards();
    }
Exemplo n.º 4
0
        private Card TakeTopOfMainDeck()
        {
            Card c = MainDeck[0];

            MainDeck.RemoveAt(0);
            return(c);
        }
Exemplo n.º 5
0
 public void Sort(SortField[] sortFields)
 {
     MainDeck.Sort(sortFields);
     SideDeck.Sort(sortFields);
     ExtraDeck.Sort(sortFields);
     TempDeck.Sort(sortFields);
 }
Exemplo n.º 6
0
 public void DealAllCard()
 {
     MainDeck.Clear();
     SubPrimaryDeck.Clear();
     Console.WriteLine("No cards left any more");
     Console.WriteLine("You may quit the app now");
 }
Exemplo n.º 7
0
        public void DealACard(IPlayer PlayerBeingDealtTo)
        {
            IPlayer _player = PlayerBeingDealtTo;
            //deal card to player
            ICard _card = MainDeck.First();

            _player.Hand.CardsInHand.Add(_card); //add card dealt to the player's cards
            MainDeck.Remove(_card);              //remove the card dealt from the deck
        }
Exemplo n.º 8
0
 /// <summary>
 /// Called at the start of the game to make each player's hand 5 cards.
 /// </summary>
 internal void draw5Cards()
 {
     for (int i = 0; i < 5; i++)
     {
         Cards.Card cardOnTopOfDeck = MainDeck.drawTopCard();
         Hand.Add(cardOnTopOfDeck);
         MeReadOnly.NumberOfCardsInHand = MeReadOnly.NumberOfCardsInHand + 1;
     }
 }
Exemplo n.º 9
0
        public void ShuffleCards()
        {
            if (CounterForShuffle == 0)
            {
                CounterForShuffle++;
                SubPrimaryDeck = new List <int>
                {
                    1, 2, 3, 4, 5, 6, 7, 8,
                    9, 10, 11, 12, 13, 14, 15,
                    16, 17, 18, 19, 20, 21, 22,
                    23, 24, 25, 26, 27, 28, 29,
                    30, 31, 32, 33, 34, 35, 36,
                    37, 38, 39, 40, 41, 42, 43,
                    44, 45, 46, 47, 48, 49, 50,
                    51, 52
                };
            }
            else
            {
                MainDeck.ForEach(p => SubPrimaryDeck.Add(p));
                MainDeck.Clear();
                SubMediumDeck.Clear();
            }



            while (SubPrimaryDeck.Count != 0)
            {
                Picker    = RdmPicker.Next(0, SubPrimaryDeck.Count);
                OneBefore = Picker - 1;
                OneAfter  = Picker + 1;

                if (OneBefore >= 0)
                {
                    SubMediumDeck.Add(SubPrimaryDeck[OneBefore]);
                    SubPrimaryDeck.RemoveAt(OneBefore);
                }
                else
                {
                    SinglePicker();
                }

                if (OneAfter < SubPrimaryDeck.Count)
                {
                    SubMediumDeck.Add(SubPrimaryDeck[OneAfter]);
                    SubPrimaryDeck.RemoveAt(OneAfter);
                }
                else
                {
                    SinglePicker();
                }

                ShuffleAgain();
            }
            Console.WriteLine($"**** Shuffled *******");
        }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        mDeck = GameObject.FindGameObjectWithTag("MainDeck").GetComponent <MainDeck>();

        fightButton = GameObject.FindGameObjectWithTag("FightButton");
        deckButton  = GameObject.FindGameObjectWithTag("DeckButton");

        fightButton.SetActive(false);
        deckButton.SetActive(false);
    }
Exemplo n.º 11
0
        public void SetDeck(Deck deck, CardRepository repo)
        {
            lock (DataSource)
                DataSource.Clear();

            MainDeck.SetDeck(deck.MainDeck);
            SideDeck.SetDeck(deck.Sideboard);

            LoadDeck(repo);
        }
Exemplo n.º 12
0
 private void CreateDeck()
 {
     for (int i = 0; i < Enum.GetNames(typeof(Ranks)).Length; i++)
     {
         for (int j = 0; j < Enum.GetNames(typeof(Suits)).Length; j++)
         {
             MainDeck.Push(new Card((Suits)j, (Ranks)i));
         }
     }
 }
Exemplo n.º 13
0
        public void DealCards(IEnumerable <Player> allPlayers)
        {
            var splittedDeck = _mainDeck.SplitCards(allPlayers.Count());

            _mainDeck = null;

            foreach (Player player in allPlayers)
            {
                player.AddCardsToHand(splittedDeck[0]);
                splittedDeck.RemoveAt(0);
            }
        }
Exemplo n.º 14
0
        public void DealCards()
        {
            for (int i = 0; i < 2; i++)
            {
                foreach (var player in Players)
                {
                    player.AddCard(MainDeck.PopCard());
                }
            }

            AddShowedCards();
        }
Exemplo n.º 15
0
 public void DealOneCard()
 {
     if (CounterForShuffle != 0)
     {
         Console.WriteLine($"You dealt: {MainDeck[0]}");
         MainDeck.RemoveAt(0);
     }
     else
     {
         Console.WriteLine($"Firstly, you have to shuffle the deck!");
     }
 }
Exemplo n.º 16
0
 private void ShuffleAgain()
 {
     while (SubMediumDeck.Count != 0)
     {
         Picker = RdmPicker.Next(0, SubMediumDeck.Count);
         if (Picker < SubMediumDeck.Count)
         {
             MainDeck.Add(SubMediumDeck[Picker]);
             SubMediumDeck.RemoveAt(Picker);
         }
     }
 }
Exemplo n.º 17
0
        private void Shuffle() // перемешивает карты в MainDeck
        {
            Random      rnd  = new Random();
            List <Card> list = new List <Card>();

            list = MainDeck.OrderBy(item => rnd.Next()).ToList();
            MainDeck.Clear();
            foreach (var card in list)
            {
                MainDeck.Push(card);
            }
        }
Exemplo n.º 18
0
 public void SetupMainDeck()
 {
     MainDeck.Clear();
     //create decks to be used and adds them to main Deck
     for (int counter = NumberOfDecksInPlay; counter > 0; counter = counter - 1)
     {
         IDeck _deck = new Deck();
         _deck.Shuffle(7); //shuffle enough times to ensure random order
         foreach (ICard card in _deck.Cards)
         {
             MainDeck.Add(card);
         }
     }
 }
Exemplo n.º 19
0
 private void DealCards()
 {
     foreach (Player p in Players)
     {
         foreach (string key in new List <string>(p.CardDict.Keys))
         {
             p.CardDict[key] = MainDeck.Take(1).First();
             if (key.Contains("V"))
             {
                 p.CardDict[key].Visibility = CardVisibilityState.Public;
             }
             MainDeck.RemoveAt(0);
         }
     }
 }
Exemplo n.º 20
0
 public void ShowAllCards()
 {
     if (CounterForShow == 0)
     {
         CounterForShow++;
         Console.WriteLine($"***** Welcome! You have *******");
         SubPrimaryDeck.ForEach(p => Console.WriteLine($"{p}"));
         Console.WriteLine($"***** The End *******");
     }
     else
     {
         Console.WriteLine($"***** You Still have *******");
         MainDeck.ForEach(f => Console.WriteLine($"{f}"));
         Console.WriteLine($"***** The End *******");
     }
 }
Exemplo n.º 21
0
        public void AddShowedCards()
        {
            MainDeck.PopCard();

            if (OpenDeck.Length < 3)
            {
                for (int i = 0; i < 3; i++)
                {
                    OpenDeck.AddCard(MainDeck.PopCard());
                }
            }
            else
            {
                OpenDeck.AddCard(MainDeck.PopCard());
            }
        }
Exemplo n.º 22
0
    void Start()
    {
        Instance          = this;
        mainDeck.Callback = OnDeckListChanged;

        if (!isServer)
        {
            return;
        }

        mainDeck.Add(Factory.shootSpringMD); // 1
        mainDeck.Add(Factory.shootSpringMD); // 2
        mainDeck.Add(Factory.shootSpringMD); // 3
        mainDeck.Add(Factory.shootSpringMD); // 4
        mainDeck.Add(Factory.shootSpringMD); // 5
        mainDeck.Add(Factory.shootSpringMD); // 6
        mainDeck.Add(Factory.shootSpringMD); // 7
        mainDeck.Add(Factory.shootSpringMD); // 8
        mainDeck.Add(Factory.shootSpringMD); // 9
        mainDeck.Add(Factory.shootSpringMD); // 10
        mainDeck.Add(Factory.shootSpringMD); // 11
        mainDeck.Add(Factory.shootSpringMD); // 12
        mainDeck.Add(Factory.shootSpringMD); // 13
        mainDeck.Add(Factory.shootSpringMD); // 14
        mainDeck.Add(Factory.shootSpringMD); // 15
        mainDeck.Add(Factory.shootSpringMD); // 16

        mainDeck.Add(Factory.grazeSpringMD); // 1
        mainDeck.Add(Factory.grazeSpringMD); // 2
        mainDeck.Add(Factory.grazeSpringMD); // 3
        mainDeck.Add(Factory.grazeSpringMD); // 4
        mainDeck.Add(Factory.grazeSpringMD); // 5
        mainDeck.Add(Factory.grazeSpringMD); // 6
        mainDeck.Add(Factory.grazeSpringMD); // 7
        mainDeck.Add(Factory.grazeSpringMD); // 8
        mainDeck.Add(Factory.grazeSpringMD); // 9
        mainDeck.Add(Factory.grazeSpringMD); // 10
        mainDeck.Add(Factory.grazeSpringMD); // 11
        mainDeck.Add(Factory.grazeSpringMD); // 12
        mainDeck.Add(Factory.grazeSpringMD); // 13
        mainDeck.Add(Factory.grazeSpringMD); // 14
        mainDeck.Add(Factory.grazeSpringMD); // 15
        mainDeck.Add(Factory.grazeSpringMD); // 16

        mainDeck.Shuffle();
    }
Exemplo n.º 23
0
        public void StartGame()
        {
            MainDeck.Mix();
            h_GetCards();
            Card pMainCard = GetNextCard();

            if (pMainCard == null)
            {
                throw new GameOverException();
            }
            MainCard = pMainCard;
            MainDeck.CardList.Insert(0, pMainCard);

            Master = 0;
            Slave  = h_GetNextSide(Master);

            h_SetDefaultRights();
        }
Exemplo n.º 24
0
 public void Deal()
 {
     //Deal two cards to each player
     for (int counter = 2; counter > 0; counter = counter - 1)
     {
         foreach (IPlayer _player in PlayersInGame)
         {
             //Deal card to player
             ICard _card = MainDeck.First();
             _player.Hand.CardsInHand.Add(_card); //add card dealt, to the player's cards
             MainDeck.Remove(_card);              //remove the card dealt from the deck
         }
         //Deal card to Dealer
         ICard _dearlersCard = MainDeck.First();
         DealerPlayer.Hand.CardsInHand.Add(_dearlersCard); //add card dealt, to the dealer's cards
         MainDeck.Remove(_dearlersCard);                   //remove the card dealt from the deck
     }
 }
Exemplo n.º 25
0
 protected void StartupPhase()
 {
     if (this.IsTurn == false)
     {
         return;
     }
     if (this.Hand.IsAction == true)
     {
         return;
     }
     if (Hand.Count == 5)
     {
         Phase = ePhase.END;
     }
     else
     {
         MainDeck.DrawCard();
     }
 }
Exemplo n.º 26
0
 /// <summary>
 /// Сбрасывает одну карту из основной колоды в сброшенную. Если основная колода пуста перекладывает все карты из сброшенной калоды в основную.
 /// </summary>
 public void FoldCard()
 {
     if (MainDeck.Count > 0) // если в колоде есть карты, то сбрасываем одну
     {
         Card temp = MainDeck.Pop();
         temp.FaceUp = true;
         DumpedDeck.Push(temp);
     }
     else // иначе(колода пуста) перемещаем все сброшенные карты назад в колоду
     {
         Card temp;
         while (DumpedDeck.Count > 0)
         {
             temp        = DumpedDeck.Pop();
             temp.FaceUp = false;
             MainDeck.Push(temp);
         }
     }
 }
Exemplo n.º 27
0
 public void NewCards() // to display new cards in hand
 {
     noOfPlayers = 2;
     if (noOfPlayers > 5)
     {
         noOfDecks = 3;
     }
     else
     {
         noOfDecks = 2;
     }
     deck     = new MainDeck();
     gameHand = new RummyHand(deck);
     gameHand.pullCards();
     gameHand.AssignHands();
     showCards();
     gameHand.AssignClosedDeck();
     WrittingIntoTextFile();
 }
Exemplo n.º 28
0
 // Use this for initialization
 void Start()
 {
     noOfPlayers = 2;
     if (noOfPlayers > 5)
     {
         noOfDecks = 3;
     }
     else
     {
         noOfDecks = 2;
     }
     deck     = new MainDeck();
     gameHand = new RummyHand(deck);
     gameHand.pullCards();
     gameHand.AssignHands();
     showCards();
     gameHand.AssignClosedDeck();
     WrittingIntoTextFile();
 }
Exemplo n.º 29
0
        /// <summary>
        /// Logic for when a new round begins
        /// </summary>
        void BeginRound()
        {
            MainDeck.Shuffle();
            playerOne.SideDeck.Shuffle();
            playerTwo.SideDeck.Shuffle();

            playerOne.HasStood = false;
            playerOne.Board.Cards.Clear();
            playerOne.Board.UpdateSum();

            playerTwo.HasStood = false;
            playerTwo.Board.Cards.Clear();
            playerTwo.Board.UpdateSum();

            if (playerOneGoesFirst)
            {
                playerOne.BeginTurn();
            }
            else
            {
                playerTwo.BeginTurn();
            }
        }
Exemplo n.º 30
0
        public RummyHand(MainDeck deck)
        {
            RummyHand.deck = deck;
            //RummyHand.gameDeck = new Card[noOfCards];
            //RummyHand.hand1 = new Card[handSize];
            //RummyHand.hand2 = new Card[handSize];
            //RummyHand.hand3 = new Card[handSize];
            //RummyHand.hand4 = new Card[handSize];
            //RummyHand.hand5 = new Card[handSize];
            //RummyHand.hand6 = new Card[handSize];

            RummyHand.gameDeck   = new List <Card>();//[noOfCards];
            RummyHand.hand1      = new List <Card>();
            RummyHand.hand2      = new List <Card>();
            RummyHand.hand3      = new List <Card>();
            RummyHand.hand4      = new List <Card>();
            RummyHand.hand5      = new List <Card>();
            RummyHand.hand6      = new List <Card>();
            RummyHand.closedDeck = new List <Card>();
            RummyHand.openDeck   = new List <Card>();

            randomvalues = new int[noOfCards];
        }