Exemple #1
0
        public static JGPartyTable CreateTable(int Mise, JGGameTablePlayerProfile human, params JGGameTablePlayerProfile[] players)
        {
            if (Mise <= 0)
            {
                return(null);
            }
            if ((human == null) || (players == null) || (players.Length <= 0))
            {
                return(null);
            }

            var t = from s in players where (s != null) select s.Player;

            JGPlayer[] tp = t.ToArray();

            ArrayList st = new ArrayList();

            st.Add(human);
            st.AddRange(players);
            int v_pot = 0;

            foreach (JGGameTablePlayerProfile item in st)
            {
                if (!item.RemoveFromBalance(Mise))
                {
                    //party.EjectPlayer(item.Player, enuEjectReason.CanRemoveBalance);

                    return(null);
                }
                else
                {
                    v_pot += Mise;
                }
            }



            JGParty party = JGParty.CreateParty(human.Player, tp);

            if (party == null)
            {
                return(null);
            }



            JGPartyTable p = new JGPartyTable();

            //p.Register(human, players);
            p.m_party           = party;
            p.m_party.PartyEnd += p.m_party_PartyBetEnd;
            p.m_profiles        = (JGGameTablePlayerProfile[])st.ToArray(typeof(JGGameTablePlayerProfile));
            p.m_Pot             = v_pot;
            return(p);
        }
Exemple #2
0
        public static void Main(params string[] args)
        {
            try
            {
#if WINDOWS
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                StartForm v_start = new StartForm();
                v_start.Show();
                while (v_start.Created)
                {
                    Application.DoEvents();
                }
#elif ANDROID
#elif LINUX
#elif CONSOLE
                //   JGDB db = null;
                JGDB.StoreDb();

                Console.WriteLine("Demonstration : Welcome to JAMBO GAME");
                JGHumanPlayer player1 = new JGHumanPlayer();
                player1.Name    = "Bertrand";
                player1.Profile = JGDB.GetProfile("*****@*****.**");

                JGGameTablePlayerProfile prof1 = player1.CreateGameProfile(180);
                JGGameTablePlayerProfile prof2 =
                    new JGComputerPlayer()
                {
                    Name    = "Comp2",
                    Profile = JGDB.GetProfile("*****@*****.**")
                }.CreateGameProfile(60);

                JGPartyTable table = JGPartyTable.CreateTable(50, prof1, prof2);
                if (table != null)
                {
                    table.Party.Start();
                    JGParty party = table.Party;
                    JGHand  hand  = null;
                    while (!party.End)
                    {
                        hand = party.Hands.GetHand(party.SelectedPlayer);


                        Console.WriteLine("Tour: " + party.Tour);
                        Console.WriteLine("Jeu: " + party.SelectedPlayer);
                        if (party.Tour == 0)
                        {
                            if ((hand.IsSevenRule() | hand.IsTweentyOneRule()) != enuJGExceptionRule.None)
                            {
                                //Console.WriteLine (" REGLE DES 7 : "+ hand.IsSevenRule ());
                                party.CheckMyRules(party.SelectedPlayer);
                            }
                        }
                        if ((party.ControlCard == null) || (party.ControlUser == party.SelectedPlayer))
                        {
                            party.SelectedPlayer.Play(party, hand[0]);
                        }
                        else if (hand.ContainsCardType(party.ControlCard.CardType))
                        {
                            hand.SortByType();
                            party.SelectedPlayer.Play(party, hand.GetFirstCard(party.ControlCard.CardType));
                        }
                        else
                        {
                            party.SelectedPlayer.Play(party, hand[0]);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("can't create a table .table mis error");
                }
                JGDB.Restore(prof1, prof2);
                Console.WriteLine("Party end");


                /*
                 *
                 * JGComputerPlayer player1 = new JGComputerPlayer();
                 * player1.Name = "Comp1";
                 * JGParty party = JGParty.CreateParty(player1,
                 *  new JGComputerPlayer[]{
                 *  new JGComputerPlayer(){
                 *      Name = "Comp2"
                 *  }
                 *  ,
                 *  new JGComputerPlayer(){
                 *      Name = "Comp3"
                 *  }
                 *  });
                 *
                 * Console.WriteLine("nouvelle party " + party.Players.Count);
                 *
                 * party.MixCard();
                 * party.CutAt(21);
                 *
                 * party.Start();
                 * JGHand hand = null;// party.Hands.GetHand(party.SelectedPlayer);
                 *
                 *
                 *
                 * while (!party.End)
                 * {
                 *  hand = party.Hands.GetHand(party.SelectedPlayer);
                 *
                 *
                 *  Console.WriteLine("Tour: " + party.Tour);
                 *  Console.WriteLine("Jeu: "+party.SelectedPlayer);
                 *  if (party.Tour== 0)
                 *  {
                 *      if ((hand.IsSevenRule() | hand.IsTweentyOneRule ()) != enuJGExceptionRule.None)
                 *      {
                 *          //Console.WriteLine (" REGLE DES 7 : "+ hand.IsSevenRule ());
                 *          party.CheckMyRules(party.SelectedPlayer );
                 *      }
                 *  }
                 *  if ((party.ControlCard == null) || (party.ControlUser == party.SelectedPlayer ))
                 *  {
                 *      party.SelectedPlayer.Play(party, hand[0]);
                 *  }
                 *  else if (hand.ContainsCardType (party.ControlCard.CardType))
                 *  {
                 *      hand.SortByType();
                 *      party.SelectedPlayer.Play(party, hand.GetFirstCard(party.ControlCard.CardType));
                 *  }
                 *  else {
                 *          party.SelectedPlayer.Play(party, hand[0]);
                 *  }
                 *
                 * }
                 * Console.WriteLine("party teminer:  ");
                 * Console.WriteLine ("Winner : "+ party.Winner);
                 * Console.WriteLine ("Card : "+ party.ControlCard );
                 *
                 *
                 *
                 * if ((party.Tour == 5))
                 * {
                 *  party.CheckCoraRule(party.Winner);
                 * }
                 */

                //Console.WriteLine("party teminer " + party.Winner);


                //  JGHand hand = party.Hands.GetHand(player1);

                // Console.WriteLine ("jour 1 jouer");

                //player1.Play(party, hand[0]);



                //Console.WriteLine("Couleur Rouge : " + GetColor(hand, enuJGCardColor.Red ));
                //Console.WriteLine("Couleur Black : " + GetColor(hand, enuJGCardColor.Black));

                //foreach (enuJGCardType item in Enum.GetValues (typeof (enuJGCardType)))
                //{
                //    Console.WriteLine("Carte " + item.ToString() + " " + GetCardType(hand, item));
                //}



                //party.Hands.SortHand(player1, enuJGSortType.Color   );
                //hand.SortByValue();



                Console.ReadLine();
#endif
            }
            catch (Exception ex) {
                MessageBox.Show("L'application s'est malheureusement arrêter : " + ex.Message);
            }
        }
 public JGHumanObserverCollection(JGPartyTable table)
 {
     this.m_table     = table;
     this.m_observers = new List <JGHumanPlayer>();
 }