コード例 #1
0
        public bool DoHit(model.Player a_dealer)
        {
            int[] cardScores = a_dealer.getCardScoreArray();
            total = 0;

            if (a_dealer.CalcScore() < 17)
            {
                return true;
            }

            if (a_dealer.CalcScore() == 17){

                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() != Card.Value.Ace)
                    {
                        total += cardScores[(int)c.GetValue()];
                    }
                }
                //if this is true a soft 17 is active.
                if (total <= 6)
                {
                    return true;
                }
            }

            return false;
        }
コード例 #2
0
ファイル: PlayGame.cs プロジェクト: ad222kr/1dv607
 public PlayGame(model.Game a_game, view.IView a_view)
 {
     m_game = a_game;
     m_view = a_view;
     m_view.DisplayWelcomeMessage();
     m_game.Subsribe(this);
 }
コード例 #3
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            //Initialize fields
            m_view = a_view;
            m_game = a_game;

            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            view.Input input = a_view.GetInput();

            if (input == view.Input.Play)
            {
                a_game.NewGame();
            }
            else if (input == view.Input.Hit)
            {
                a_game.Hit();
            }
            else if (input == view.Input.Stand)
            {
                a_game.Stand();
            }

            return input != view.Input.Quit;
        }
コード例 #4
0
ファイル: PlayGame.cs プロジェクト: jt222ic/Blackjack_jt22ic
 public PlayGame(model.Game A_game,
     view.IView A_view)
 {
     a_game = A_game;
       a_view = A_view;
       a_game.addSub(this);
 }
コード例 #5
0
ファイル: BoatView.cs プロジェクト: fh222dt/OOAD
        public int BoatMenu(model.Boat a_boat)
        {
            Console.Clear();
            Console.WriteLine("");
            Console.WriteLine("-----Boat specifics-----");
            Console.WriteLine("Type: {0}", a_boat.GetType());
            Console.WriteLine("Length: {0}", a_boat.GetLength());

            Console.WriteLine("");
            Console.WriteLine("---------------");
            Console.WriteLine("");
            Console.WriteLine("(D) to Delete boat (U) to Update boat");
            ConsoleKeyInfo input = Console.ReadKey();
            if (input.Key == ConsoleKey.D)
            {
                return 1;
            }

            else if (input.Key == ConsoleKey.U)
            {
                return 2;
            }

            else return 0;          //returnera nåt annat
        }
コード例 #6
0
 public void DrawCard(model.Card card)
 {
     m_view.DisplayWelcomeMessage();
     m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
     m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
     Thread.Sleep(750);
 }
コード例 #7
0
ファイル: PlayGame.cs プロジェクト: AndreasAnemyrLNU/1dv607
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            this.a_game = a_game;
            this.m_view = a_view;

            a_game.AddSubscriber(this);
        }
コード例 #8
0
        public bool DoHit(model.Player a_dealer)
        {
            int score = a_dealer.CalcScore();

            if (score < g_hitLimit)
            {
                return true;
            }

            if (score == g_hitLimit)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    //If Ace is in the hand, checks if score without Ace is 6
                    if ((c.GetValue() == Card.Value.Ace) && (score - 11 == 6))
                    {
                        score -= 10;
                    }
                }

                return score < g_hitLimit;
            }

            return false;
        }
コード例 #9
0
        public bool DoHit(model.Player a_dealer)
        {
            int[] cardScores = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };
            var score = 0;
            var cards = a_dealer.GetHand();
            var numberOfAces = 0;
            foreach (var c in cards)
            {
                
                if (c.GetValue() != Card.Value.Hidden)
                {
                    score += cardScores[(int)c.GetValue()];

                    if (c.GetValue() == Card.Value.Ace)
                    {
                        numberOfAces++;
                    }
                }
            }

            while ((score == g_hitLimit || score > 21) && numberOfAces > 0)
            {
                numberOfAces--;
                score -= 10;
            }

            return score < g_hitLimit;
        }
コード例 #10
0
ファイル: User.cs プロジェクト: dv222bk/1DV607_Portfolio
 /// <summary>
 /// Add a boat menu
 /// </summary>
 /// <param name="a_member">model.Member, the member who owns the new boat</param>
 private void AddBoat(model.Member a_member)
 {
     m_console.AddBoat(a_member);
     for (int i = 0; i < (int)model.Boat.Type.Count; i += 1)
     {
         string message = string.Format("{0}: {1}", i, (model.Boat.Type)i);
         m_console.WriteMessage(message);
     }
     int type;
     while (true)
     {
         m_console.WriteMessage("Type: ");
         bool isNumeric = int.TryParse(m_console.ReadResponse(), out type);
         if (isNumeric && type >= 0 && type < (int)model.Boat.Type.Count)
         {
             break;
         }
         m_console.WriteMessage("Invalid type, type must be a number choosen from the list above");
     }
     double length;
     while (true)
     {
         m_console.WriteMessage("Length: ");
         bool isDouble = double.TryParse(m_console.ReadResponse(), out length);
         if (isDouble && length > 0)
         {
             break;
         }
         m_console.WriteMessage("Invalid length. Length must be of the format XX or XX,XX");
     }
     a_member.GetBoatList().AddBoat((model.Boat.Type)type, length);
     m_console.SetCurrentMenu(view.Console.CurrentMenu.Member);
     GoToCurrentMenu(a_member);
 }
コード例 #11
0
        public bool DoHit(model.Player a_dealer)
        {
            var cards = a_dealer.GetHand();

            // Check if limit has reached....
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (var card in cards)
                {
                    // Must hit if ace in hand. Because score IS 17!
                    //Ace turns into 1 score instead
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        return true;
                    }
                }
            }

            // No special circumstances....
            if (a_dealer.CalcScore() < g_hitLimit)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #12
0
ファイル: PlayGame.cs プロジェクト: sk222sw/blackjack
 public PlayGame(model.Game g, view.IView v)
 {
     a_game = g;
     a_view = v;
     a_view.DisplayWelcomeMessage();
     a_game.Subscribe(this);
 }
コード例 #13
0
        public void SensorDataUpdated(model.SensorData data)
        {
            lock (_lock)
            {
                List<TcpClient> clientsToDelete = new List<TcpClient>();

                foreach (TcpClient client in _clients)
                {
                    try
                    {
                        NetworkStream stream = client.GetStream();
                        BinaryFormatter formatter = new BinaryFormatter();

                        formatter.Serialize(stream, data);
                    }
                    catch (Exception)
                    {
                        clientsToDelete.Add(client);
                    }
                }

                foreach (TcpClient c in clientsToDelete)
                {
                    _clients.Remove(c);
                }
            }
        }
コード例 #14
0
 // Which member to add the boat to
 // Display views, get inputs to create/save boat to a member
 private void AddBoat(model.Member member)
 {
     try
     {
         _memberView.DisplayMember(member);
         model.Boat.BoatType type = _boatView.GetTypeFromUser();
         double length = _boatView.GetLengthFromUser();
         DateTime registrationDate = _boatView.GetRegistrationDate();
         model.Boat boat = new model.Boat(type, length, registrationDate);
         member.AddBoat(boat);
         _list.SaveMemberList();
         DoMemberView(member);
     }
     catch (Exception ex)
     {
         _memberView.DisplayMember(member);
         _boatView.DisplayErrorMessage(ex.Message);
         if (_boatView.DoesUserWantsToQuit() == true)
         {
             DoMemberView(member);
         }
         else
         {
             AddBoat(member);
         }
     }
 }
コード例 #15
0
ファイル: PlayGame.cs プロジェクト: fr222cy/IDV607-Black-Jack
        public bool Play(model.Game a_game)
        {
            m_view.DisplayWelcomeMessage();

            m_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            m_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                m_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            switch((view.Choices)m_view.GetInput())
            {
                case view.Choices.Play:
                    a_game.NewGame();
                    break;
                case view.Choices.Hit:
                    a_game.Hit();
                    break;
                case view.Choices.Stand:
                    a_game.Stand();
                    break;
                case view.Choices.Quit:
                    return false;

                default:
                    break;
            }

            return true;
        }
コード例 #16
0
ファイル: PlayGame.cs プロジェクト: henceee/1DV607
        public bool Play(model.Game a_game)
        {
            //a_game.AddSubscriber(this);
            m_view.DisplayWelcomeMessage();

               // m_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            //m_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());//

            if (a_game.IsGameOver())
            {
                m_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            model.Game.Status input = m_view.GetInput();

            if (input == model.Game.Status.NewGame)
            {
                a_game.NewGame();
            }
            else if (input == model.Game.Status.Hit)
            {
                a_game.Hit();
            }
            else if (input == model.Game.Status.Stand)
            {
                a_game.Stand();
            }

            return input != model.Game.Status.Quit;
        }
コード例 #17
0
ファイル: PlayGame.cs プロジェクト: henceee/1DV607
        public bool Play(model.Game a_game, view.IView a_view)
        {
            a_view.DisplayWelcomeMessage();
            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            //int input = a_view.GetInput(); removed due to hidden depencendy.
            int input = System.Console.In.Read();

            if (input == 'p')
            {
                a_game.NewGame();
            }
            else if (input == 'h')
            {
                a_game.Hit();
            }
            else if (input == 's')
            {
                a_game.Stand();
            }

            return input != 'q';
        }
コード例 #18
0
ファイル: PlayGame.cs プロジェクト: kk222hk/blackjack_csharp
        public bool Play(model.Game a_game, view.IView a_view)
        {
            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            int input = a_view.GetInput();

            if (input == 'p')
            {
                a_game.NewGame();
            }
            else if (input == 'h')
            {
                a_game.Hit();
            }
            else if (input == 's')
            {
                a_game.Stand();
            }

            return input != 'q';
        }
コード例 #19
0
ファイル: r_sky.cs プロジェクト: sbrown345/quakejs
        int r_skydirect; // not used?

        #endregion Fields

        #region Methods

        //  of newsky on the left of each scan, 128 bytes
        //  of topsky on the right, because the low-level
        //  drawers need 256-byte scan widths
        /*
        =============
        R_InitSky

        A sky texture is 256*128, with the right side being a masked overlay
        ==============
        */
        public static void R_InitSky(model.texture_t mt)
        {
            int     i, j;
            int     src;

            src = (int)mt.offsets[0];

            for (i = 0; i < 128; i++)
            {
                for (j = 0; j < 128; j++)
                {
                    newsky[(i * 256) + j + 128] = mt.pixels[src+i * 256 + j + 128];
                }
            }

            for (i = 0; i < 128; i++)
            {
                for (j = 0; j < 131; j++)
                {
                    if (mt.pixels[src + i * 256 + (j & 0x7F)] != 0)
                    {
                        bottomsky[(i * 131) + j] = mt.pixels[src + i * 256 + (j & 0x7F)];
                        bottommask[(i * 131) + j] = 0;
                    }
                    else
                    {
                        bottomsky[(i * 131) + j] = 0;
                        bottommask[(i * 131) + j] = 0xff;
                    }
                }
            }

            r_skysource = newsky;
        }
        public void ShowCard(model.Card a_card)
        {
            //first do some randomize
            RandomizeCard();

            DoShowCard(a_card);
        }
コード例 #21
0
ファイル: PlayGame.cs プロジェクト: DevRobDev/1DV407
 public bool Play(model.Game a_game)
 {            
     m_view.DisplayWelcomeMessage();
     if (a_game.GetPlayerScore() != 0)
     {
         m_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
         m_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
     }
     if (a_game.IsGameOver())
     {
         m_view.DisplayGameOver(a_game.IsDealerWinner());
     }
     gameAction input = m_view.GetInput();
     if (input == gameAction.play)
     {
         m_view.DisplayWelcomeMessage();
         var test = a_game.NewGame();
     }
     else if (input == gameAction.hit)
     {
         a_game.Hit();
     }
     else if (input == gameAction.stand)
     {
         a_game.Stand();
     }
     return input != gameAction.quit;
 }
コード例 #22
0
        public bool Play(model.Game a_game, view.IView a_view)
        {
            m_view = a_view;
            m_game = a_game;
            a_view.DisplayWelcomeMessage();

            a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
            a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());

            if (a_game.IsGameOver())
            {
                a_view.DisplayGameOver(a_game.IsDealerWinner());
            }

            BlackJack.view.Events input = (BlackJack.view.Events)a_view.GetInput();

            if (input == view.Events.Play)
            {
                a_game.NewGame();
            }
            else if (input == view.Events.Hit)
            {
                a_game.Hit();
            }
            else if (input == view.Events.Stand)
            {
                a_game.Stand();
            }

            return input != view.Events.Quit;
        }
コード例 #23
0
        public bool DoHit(model.Player a_dealer)
        {
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                int otherValue = 0;
                bool aceFound = false;
                int[] cardScores = new int[(int)model.Card.Value.Count] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };

                foreach (Card card in a_dealer.GetHand())
                {
                    if (card.GetValue() == Card.Value.Ace && !aceFound)
                    {
                        aceFound = true;
                    } else {
                        otherValue += cardScores[(int)card.GetValue()];
                        if (otherValue > 6)
                        {
                            return false;
                        }
                    }
                }
                if (otherValue == 6 && aceFound)
                {
                    return true;
                }
            }
            return a_dealer.CalcScore() < g_hitLimit;
        }
コード例 #24
0
ファイル: MemberView.cs プロジェクト: dt222cc/1dv607-dt222cc
        // With some validation to confirm the delete
        public bool ConfirmDelete(model.Member m)
        {
            Console.WriteLine("-----------------------------------");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(" Repeat the memberId to confirm: ");

            try
            {
                int memberId = int.Parse(Console.ReadLine());
                Console.WriteLine("");
                if (memberId == m.MemberId)
                {
                    PressKeyToContinue();
                    return true;
                }
                else
                {
                    Console.WriteLine(" MemberId missmatched!");
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("\n Invalid ID!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            PressKeyToContinue();
            return false;
        }
コード例 #25
0
ファイル: Player.cs プロジェクト: tobias-dv-lnu/1dv607_2015
        public bool PlayGame(view.Console a_view, model.GameFacade a_game)
        {
            a_view.PresentInstructions();
            a_view.DisplayHands(a_game.GetDealerHand(), a_game.GetDealerScore(), a_game.GetPlayerHand(), a_game.GetPlayerScore());
            if (a_game.IsGameOver())
            {
                a_view.DisplayWinner(a_game.IsPlayerWinner());
            }

            view.Console.Event e;

            e = a_view.GetEvent();
            if (e == view.Console.Event.Quit)
            {
                return false;
            }
            if (e == view.Console.Event.Start)
            {
                a_game.StartNewRound();

            }
            if (e == view.Console.Event.Hit)
            {
                a_game.Hit();
            }
            if (e == view.Console.Event.Stand)
            {
                a_game.Stand();
            }

            return true;
        }
コード例 #26
0
ファイル: ContractDAL.cs プロジェクト: rongxiong/Scut
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(model.ContractModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Contract(");
            strSql.Append("ID,Descption,ParentID,SlnID,Complated,AgreementID)");
            strSql.Append(" values (");
            strSql.Append("@ID,@Descption,@ParentID,@SlnID,@Complated,@AgreementID)");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4),
                    new SqlParameter("@Descption", SqlDbType.VarChar,100),
                    new SqlParameter("@ParentID", SqlDbType.Int,4),
                    new SqlParameter("@SlnID", SqlDbType.Int,4),
                    new SqlParameter("@Complated", SqlDbType.Bit,0),
                    new SqlParameter("@AgreementID", SqlDbType.Int,4)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Descption;
            parameters[2].Value = model.ParentID;
            parameters[3].Value = model.SlnID;
            parameters[4].Value = model.Complated;
            parameters[5].Value = model.AgreementID;
            int rows = SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #27
0
ファイル: Class.cs プロジェクト: frankie13/Dogs
 public Class(String name, String judgeName, model.Size size, List<model.Grade> grades)
 {
     this.Name = name;
     this.judgeName = judgeName;
     this.size = size;
     this.grades = grades;
 }
コード例 #28
0
ファイル: PlayGame.cs プロジェクト: la222tc/blackjack_csharp
        public PlayGame(model.Game a_game, view.IView a_view)
        {
            m_game = a_game;
            m_view = a_view;

            m_game.AddObserver(this);
        }
コード例 #29
0
 public bool DoHit(model.Player a_dealer)
 {
     //if (a_dealer.CalcScore() == g_hitLimit)
     //{
     //    return DealerHasAce(a_dealer.GetHand());
     //}
     return a_dealer.CalcScore() < g_hitLimit;
 }
コード例 #30
0
        public PlayGame(view.IView a_view, model.Game a_game)
        {
            m_view = a_view;
            m_game = a_game;

            // Subscribe to observer
            m_game.AddSubscribtionToCards(this);
        }