Example #1
0
        public enuCoraType CheckCoraRule(JGPlayer jGPlayer)
        {
            if ((this.ControlCard.Value != 3) || (!this.m_GameStart) || (this.Tour == 5))
            {
                return(enuCoraType.None);
            }
            JGGameHand.JGGameHandInfo[] dd = this.m_gameHand.GetPlayerGameHandInfo(jGPlayer);
            int j = 0;

            for (int i = dd.Length - 2; i >= 1; i--)
            {
                if (dd[i].Card.Value != 3)
                {
                    break;
                }
                j++;
            }
            switch (j)
            {
            case 2:
                return(enuCoraType.Double);

            case 3:
                return(enuCoraType.Triple);

            case 4:
                return(enuCoraType.Impossible);
            }
            return(enuCoraType.Simple);
        }
Example #2
0
 /// <summary>
 /// add a player to the party
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public bool AddPlayer(JGPlayer p)
 {
     if (this.m_players.Count < JGConstant.MAX_PLAYER_GAME)
     {
         return(this.m_players.Add(p));
     }
     return(false);
 }
Example #3
0
 internal void AddCard(JGPlayer item, JGCard[] jGCard)
 {
     if (!this.m_playerHands.ContainsKey(item))
     {
         this.m_playerHands.Add(item, new JGHand(this.jGParty, item));
     }
     this.m_playerHands[item].AddCard(jGCard);
 }
Example #4
0
 internal bool  Add(JGPlayer player)
 {
     if ((player != null) && !this.m_players.Contains(player) && (this.Count < JGConstant.MAX_PLAYER_GAME))
     {
         this.m_players.Add(player);
         return(true);
     }
     return(false);
 }
Example #5
0
        public static JGPlayer CreatePlayer(string name)
        {
            JGPlayer c = null;
            Type     t = Type.GetType("JamboGame.JG" + name + "Player");

            if (t != null)
            {
                c = t.Assembly.CreateInstance(t.FullName) as JGPlayer;
            }
            return(c);
        }
Example #6
0
        public bool CheckMyRules(JGPlayer player)
        {
            //check for confidition
            if (this.Tour == 0)
            {
                JGHand hand = this.m_hands.GetHand(player);
                if (hand != null)
                {
                    enuJGExceptionRule c = hand.IsSevenRule() | hand.IsTweentyOneRule();
                    if (c != enuJGExceptionRule.None)
                    {
                        this.m_GameStart            = false;
                        this.m_gameHand.ControlUser = player;
                        this.Winner = player;
                        JGPartyEndEventArgs e = new JGPartyEndEventArgs();
                        e.Winner = Winner;
                        foreach (JGCard item in hand)
                        {
                            Console.WriteLine("CARD " + item);
                        }
                        switch (c)
                        {
                        case enuJGExceptionRule.None:
                            break;

                        case enuJGExceptionRule.Threeseven:
                            Console.Write("ThreeSEVEN RULE");

                            break;

                        case enuJGExceptionRule.FourSeven:
                            Console.Write("FourSEVEN RULE");
                            break;

                        case enuJGExceptionRule.TwentyOneRule:

                            Console.Write("TwentyOneRule RULE");
                            break;

                        default:
                            break;
                        }
                        e.Reason = (c != enuJGExceptionRule.None) ?  enuJGPartyEndReason.ExceptionRule : enuJGPartyEndReason.Normal;
                        e.Rule   = c;
                        OnPartyEnded(e);
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #7
0
        internal void EjectPlayer(JGPlayer item, enuEjectReason enuEjectReason)
        {
            switch (enuEjectReason)
            {
            case enuEjectReason.PlayerAbort:
                break;

            case enuEjectReason.CanRemoveBalance:
                break;

            default:
                break;
            }
        }
Example #8
0
        public JGGameHandInfo[] GetPlayerGameHandInfo(JGPlayer player)
        {
            List <JGGameHandInfo> t = new List <JGGameHandInfo>();

            foreach (KeyValuePair <int, List <JGGameHandInfo> > item in m_dic)
            {
                var b = from s in item.Value where s.Player == player select s;  //.Select(from s in this select s);
                foreach (JGGameHandInfo ts in b)
                {
                    t.Add(ts);
                }
            }
            return(t.ToArray());
        }
Example #9
0
 internal static bool RemoveFromBalance(JGPlayer jGPlayer, int Balance)
 {
     //jGPlayer.P
     if (jGPlayer.Profile != null)
     {
         if (jGPlayer.Profile.Balance >= Balance)
         {
             jGPlayer.Profile.Balance -= Balance;
             StoreDb();
             return(true);
         }
     }
     return(false);
 }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="player1"></param>
        /// <param name="player2">list des player additionel seul 3 seront considéré</param>
        /// <returns>un nouvelle party</returns>
        public static JGParty CreateParty(JGPlayer player1, params JGPlayer[] player2)
        {
            if ((player2 == null) || (player2.Length == 0))
            {
                return(null);
            }
            JGParty v_p = new JGParty();

            v_p.m_players.Add(player1);
            for (int i = 0; i < player2.Length; i++)
            {
                if (!v_p.AddPlayer(player2[i]))
                {
                    break;
                }
            }

            return(v_p);
        }
Example #11
0
 public JGPartyEndEventArgs(JGPlayer player, enuJGPartyEndReason reason, enuJGExceptionRule exRule)
 {
     this.m_Winner = player;
     this.m_Reason = reason;
     this.m_Rule   = exRule;
 }
 public JGGameTablePlayerProfile(JGPlayer player, int balance)
 {
     this.m_Balance = balance;
     this.m_Player  = player;
 }
Example #13
0
 public JGHand GetHand(JGPlayer item)
 {
     return(this.m_playerHands[item]);
 }
Example #14
0
 public int IndexOf(JGPlayer player)
 {
     return(this.m_players.IndexOf(player));
 }
Example #15
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);
 }
Example #16
0
 public void Distribute21ToPlayer(JGPlayer player)
 {
     this.m_Bank.Distribute21(player);
 }
Example #17
0
        protected internal void Distribute4Seven(JGPlayer player)
        {
            JGCard[] l = this.m_cards.ToArray().GetAllCard(7);
            foreach (JGCard item in l)
            {
                this.m_cards.Remove(item);
            }
            Queue <JGCard> queue = new Queue <JGCard>(this.m_cards);

            jGParty.Hands.AddCard(player, l);
            jGParty.Hands.AddCard(player, new  JGCard[] {
                queue.Dequeue()
            });


            for (int i = 0; i < 2; i++)
            {
                switch (i)
                {
                case 0:
                    if (queue.Count >= (jGParty.Players.Count * 3))
                    {
                        foreach (JGPlayer item in jGParty.Players)
                        {
                            if (item == player)
                            {
                                continue;
                            }
                            jGParty.Hands.AddCard(item,
                                                  new JGCard[] {
                                queue.Dequeue(),
                                queue.Dequeue(),
                                queue.Dequeue()
                            }
                                                  );
                        }
                    }
                    break;

                case 1:
                    if (queue.Count >= (jGParty.Players.Count * 2))
                    {
                        foreach (JGPlayer item in jGParty.Players)
                        {
                            if (item == player)
                            {
                                continue;
                            }
                            jGParty.Hands.AddCard(item,
                                                  new JGCard[] {
                                queue.Dequeue(),
                                queue.Dequeue()
                            }
                                                  );
                        }
                    }
                    break;
                }
            }

            this.m_cards.Clear();
            this.m_cards.AddRange(queue.ToArray());
        }
Example #18
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");
                }
            }
        }
Example #19
0
 public void DistributeFourSeventToPlayer(JGPlayer player)
 {
     this.m_Bank.Distribute4Seven(player);
 }
Example #20
0
 internal JGHand(JGParty party, JGPlayer player)
 {
     m_cards       = new List <JGCard>();
     this.m_party  = party;
     this.m_player = player;
 }
Example #21
0
 public void DistributeThreeSeventToPlayer(JGPlayer player)
 {
     this.m_Bank.Distribute3Seven(player);
 }