Ejemplo n.º 1
0
 public PokerGameRound(IPokerBanker banker, List <IPokerPlayer> players)
 {
     this.gamebanker  = banker;
     this.gameplayers = players;
     InitGame();
 }
Ejemplo n.º 2
0
        private void InitRound()
        {
            LoadScript();
            flag_LeaveOfCurrentPot = false;
            flag_HalfOfTotalPot    = false;

            RoundStartPot = PotJetton;
            banker        = new PokerBanker();
            pokerplayers  = new List <IPokerPlayer>();
            for (int i = 0; i < 4; i++)
            {
                pokerplayers.Add(new PokerPlayer());
            }
            players = new List <IPlayer>();
            players.Add(banker as IPlayer);//设定第0个是庄家
            foreach (var item in pokerplayers)
            {
                players.Add(item as IPlayer);//闲家依次入链表
            }
            ucList[0].BetJettons = 0;
            pgr = new PokerGameRound(banker, pokerplayers);

            for (int i = 0; i < players.Count; i++)
            {
                ucList[i].Player = players[i];
                ucList[i].DrawPlayerHandCard();
                ucList[i].EndBet();
                ucList[i].ClearCallBack();
                ucList[i].BetJettons = 0;
            }

            //Script
            if (firstBetIndex == 0)
            {
                pgr.Deal();
                //Save First Card
                for (int i = 0; i < players.Count; i++)
                {
                    if (ucListScript[i].Player != null)
                    {
                        scriptCardList_First[i] = ucListScript[i].Player.GetCards()[0];
                    }
                }
            }
            else if (firstBetIndex == 1)
            {
                for (int i = 0; i < players.Count; i++)
                {
                    //ScriptCardList[i] = ucListScript[i].Player.GetCards()[0];
                    var currentScript = scriptObj.PlayerCardScripts[i].ScriptItems.Where(d => d.ReferCard == scriptCardList_First[i].ToFileName()).OrderBy(d => Guid.NewGuid()).First();
                    var card1Str      = currentScript.Card1;
                    var card2Str      = currentScript.Card2;

                    //var watToRemoveCardList=
                    scriptObj.PlayerCardScripts.ForEach(pcs =>
                    {
                        pcs.ScriptItems = pcs.ScriptItems.Where(d =>
                                                                d.Card1 != card1Str &&
                                                                d.Card2 != card2Str &&
                                                                d.Card1 != card1Str &&
                                                                d.Card2 != card2Str).ToList();
                    });

                    PokerCard card1 = new PokerCard((CardSuit)Enum.Parse(typeof(CardSuit), card1Str.Substring(0, 3)), Convert.ToInt32(card1Str.Substring(3, 2)));
                    PokerCard card2 = new PokerCard((CardSuit)Enum.Parse(typeof(CardSuit), card2Str.Substring(0, 3)), Convert.ToInt32(card2Str.Substring(3, 2)));

                    //Save Second Card
                    scriptCardList_Second[i, 0] = card1;
                    scriptCardList_Second[i, 1] = card2;
                    ucListScript[i].Player.ClearCards();
                    ucListScript[i].Player.GiveCard(card1);
                    ucListScript[i].Player.GiveCard(card2);
                }
            }
            else if (firstBetIndex == 2)
            {
                //pgr.ScriptedDeal(6);
                for (int i = 0; i < players.Count; i++)
                {
                    var point = scriptObj.PlayerCardScripts[i].ScriptItems.FirstOrDefault(d => d.ReferCard == scriptCardList_First[i].ToFileName() &&
                                                                                          d.Card1 == scriptCardList_Second[i, 0].ToFileName() &&
                                                                                          d.Card2 == scriptCardList_Second[i, 1].ToFileName()).NextValue;

                    var cards = pgr.ScriptedDeal(Convert.ToInt32(point));

                    ucListScript[i].Player.ClearCards();
                    ucListScript[i].Player.GiveCard(cards[0]);
                    ucListScript[i].Player.GiveCard(cards[1]);
                }
            }
            else
            {
                pgr.Deal();
            }
            DealCount++;


            ucList.ForEach(uc =>
            {
                uc.DrawPlayerHandCard();
            });
        }