コード例 #1
0
        public PlayerHistory(Player p, PlayerHistory prev, Dart dart)
        {
            _player = p;
            _dart = dart;
            _prev = prev;
            bool dn = (_prev.Response == DartReturn.Dead || _prev.Response == DartReturn.Next);

            Dart = (dn) ? 0 : _prev.Dart + 1;
            Response = DartResponse();

            _turn = _prev._turn;
            if (dn)
                _turn++;
            _historyGroup = GetHistoryGroup();

            if (Response == DartReturn.Dead)
            {
                PlayerHistory ph = _prev;
                while (_turn == ph._turn)
                    ph = ph._prev;
                Score = ph.Score;
            }
            else Score = _prev.Score - _dart.TotalScore;
        }
コード例 #2
0
ファイル: Darts.cs プロジェクト: XGDragon/DartsScoring
        private void Board_TargetHit(object sender, EventArgs e)
        {
            Dart d = sender as Dart;

            PlayerHistory ph = new PlayerHistory(ActivePlayer, ActivePlayer.History.Peek(), d);
            ActivePlayer.History.Push(ph);
            ActivePlayer.UpdateScoreTree();

            switch (ph.Response)
            {
                case Player.DartReturn.Next:
                case Player.DartReturn.Dead:
                    NextActivePlayer();
                    break;
                case Player.DartReturn.Win:
                    ActivePlayer.ShowWin();
                    EnableGroupBoxes(false);
                    newGame.Text = END_GAME;
                    break;
            }
        }