Exemple #1
0
        public void newHand()
        {
            numOfHands = (numOfHands + 1) % Players.Count;
            piles.Clear();
            piles.Add(0);
            lastRasePlayer = 0;
            currentRaise   = 0;
            deck           = shuffle();
            cardsOnTable.Clear();

            CurrentHand.Clear();

            Hand = new Business.DomainModel.Hand();

            foreach (KeyValuePair <int, Player> player in Players)
            {
                if (player.Value.currentMoney < this.table.BuyInMin)
                {
                    UserRepository rep  = new UserRepository();
                    User           user = rep.ReadByUsername(player.Value.username);

                    if (user.money >= table.BuyInMax)
                    {
                        player.Value.currentMoney += table.BuyInMax;
                        user.money -= table.BuyInMax;
                        rep.UpdateMoney(user.username, user.money);
                    }
                    else if (user.money > table.BuyInMin)
                    {
                        player.Value.currentMoney += table.BuyInMin;
                        user.money -= table.BuyInMin;
                        rep.UpdateMoney(user.username, user.money);
                    }
                    else
                    {
                        continue;
                    }
                }

                player.Value.stakesMoney = 0;
                CurrentHand.Add(player.Key);

                Hand.username.Add(player.Key.ToString(), player.Value.username);
            }

            //for (int j = 0; j < numOfHands; j++)
            //{
            //    int tmp = CurrentHand[0];
            //    for (int i = 0; i < CurrentHand.Count - 1; i++)
            //        CurrentHand[i] = CurrentHand[i + 1];
            //    CurrentHand[CurrentHand.Count - 1] = tmp;
            //}
        }
Exemple #2
0
        // 게임 시작되면 현재 덱으로 게임 플레이
        public bool OnEvent(IEvent e)
        {
            Type eventType = e.GetType();

            if (eventType == typeof(BattleStageStartEvent))
            {
                BattleStageStartEvent battleStateStartEvent = e as BattleStageStartEvent;
                Init();
                GameManager.Instance.AddUpdate(this);
                return(true);
            }
            else if (eventType == typeof(BattleStageEndEvent))
            {
                for (int i = 0; i < CurrentHand.Count; i++)
                {
                    CurrentHand[i].Dispose();
                    i--;
                }
                CurrentHand.Clear();
                return(true);
            }
            return(false);
        }