Пример #1
0
        /// <summary>
        ///
        /// </summary>
        internal protected void MixCard()
        {
            //
            JGCard[] t = new JGCard[this.m_cards.Count];
            int[]    i = new int[t.Length];

            Random     rnd = new Random();
            List <int> tl  = new List <int>();
            int        b   = 0;

            do
            {
                b = rnd.Next(i.Length);
                if (tl.Contains(b))
                {
                    continue;
                }
                i[tl.Count] = b;
                tl.Add(b);
            }while (tl.Count < t.Length);


            int a = 0;

            for (int j = 0; j < i.Length; j++)
            {
                t[j] = this.m_cards[i[a++]];
            }

            this.m_cards.Clear();
            this.m_cards.AddRange(t);
        }
Пример #2
0
        internal protected override void CutAt(int position)
        {
            if ((position >= 0) && (position < this.m_cards.Count))
            {
                JGCard[] t  = new JGCard[this.m_cards.Count];
                int      LP = t.Length - position;
                this.m_cards.CopyTo(position, t, 0, LP);
                this.m_cards.CopyTo(0, t, LP, position);

                this.m_cards.Clear();
                this.m_cards.AddRange(t);
            }
        }
Пример #3
0
        public void Play(JGPlayer player, JGCard card)
        {
            if ((player == this.jGParty.SelectedPlayer) && (card != null))
            {
                JGHand hand = this.jGParty.Hands.GetHand(player);
                if (hand.Contains(card))
                {
                    if (
                        (this.ControlCard == null) ||
                        (this.m_ControlUser == player) ||
                        (card.CardType == this.ControlCard.CardType) ||
                        !hand.ContainsCardType(this.ControlCard.CardType)
                        )
                    {
#if DEBUG
                        Console.WriteLine("card : " + card);
#endif
                        //peux jouer
                        int vtour = m_count / this.jGParty.Players.Count;
                        if (!this.m_dic.ContainsKey(vtour))
                        {
                            this.m_dic.Add(vtour, new List <JGGameHandInfo>());
                        }
                        this.m_dic[vtour].Add(new JGGameHandInfo()
                        {
                            Player  = player,
                            Card    = card,
                            JGParty = jGParty,
                            Tour    = vtour,
                            Index   = m_count
                        });

                        if ((this.ControlUser == null) || (this.ControlUser == player))
                        {
                            this.m_ControlUser = player;
                            this.m_ControlCard = card;
                        }
                        else if
                        ((card.CardType == this.ControlCard.CardType) &&
                         (card.Value > this.ControlCard.Value))
                        {
                            this.m_ControlCard = card;
                            this.m_ControlUser = player;
                        }
                        m_count++;
                        int tt = m_count / this.jGParty.Players.Count;

                        hand.Remove(card);

                        if (tt != vtour)
                        {
                            this.m_tour = tt;
                            Console.WriteLine();
                            this.jGParty.SelectedPlayer = this.m_ControlUser;
                        }
                        else
                        {
                            this.jGParty.SelectedPlayer = this.jGParty.Players[((this.jGParty.Players.IndexOf(player) + 1) % this.jGParty.Players.Count)];
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Ne pas pue jouer la carte " + card.ToString());
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Ne possède pas la carte");
                }
            }
        }
Пример #4
0
 public void Play(JGParty party, JGCard jGCard)
 {
     party.Play(this, jGCard);
 }
Пример #5
0
 /// <summary>
 /// play the player card
 /// </summary>
 /// <param name="player"></param>
 /// <param name="card"></param>
 internal void Play(JGPlayer player, JGCard card)
 {
     this.m_gameHand.Play(player, card);
 }
Пример #6
0
 public static JGCard[] CopyFrom(this JGCard[] t, int index, int length)
 {
     JGCard[] tab = new JGCard[length];
     Array.Copy(t, index, tab, 0, length);
     return(tab);
 }