コード例 #1
0
ファイル: Tournament.cs プロジェクト: longde123/grove
        private void PlayMatch()
        {
            var tournamentMatch = _matches.Single(x => !x.IsSimulated);

            var human    = tournamentMatch.HumanPlayer;
            var nonHuman = tournamentMatch.NonHumanPlayer;

            Ui.Match = new Match(MatchParameters.Default(
                                     player1: new PlayerParameters
            {
                Name     = human.Name,
                AvatarId = human.AvatarId,
                Deck     = human.Deck
            },
                                     player2: new PlayerParameters
            {
                Name     = nonHuman.Name,
                AvatarId = nonHuman.AvatarId,
                Deck     = nonHuman.Deck
            },
                                     isTournament: true));

            Ui.Match.Start();

            if (Ui.Match.WasStopped)
            {
                _shouldStop = true;
                return;
            }

            lock (_resultsLock)
            {
                if (tournamentMatch.Player1.IsHuman)
                {
                    tournamentMatch.SetMatchResults(
                        player1WinCount: Ui.Match.Player1WinCount,
                        player2WinCount: Ui.Match.Player2WinCount);
                }
                else
                {
                    tournamentMatch.SetMatchResults(
                        player1WinCount: Ui.Match.Player2WinCount,
                        player2WinCount: Ui.Match.Player1WinCount);
                }

                tournamentMatch.IsFinished = true;
            }
        }
コード例 #2
0
ファイル: Tournament.cs プロジェクト: longde123/grove
        private void FinishCurrentMatch()
        {
            if (_p.SavedTournament.HasMatchInProgress)
            {
                var mp = MatchParameters.Load(_p.SavedTournament.SavedMatch, isTournament: true);


                Ui.Match = new Match(mp);
                Ui.Match.Start();

                var humanMatch = GetHumanMatch();

                if (Ui.Match.WasStopped)
                {
                    _shouldStop = true;
                    return;
                }

                lock (_resultsLock)
                {
                    if (humanMatch.Player1.IsHuman)
                    {
                        humanMatch.SetMatchResults(
                            player1WinCount: Ui.Match.Player1WinCount,
                            player2WinCount: Ui.Match.Player2WinCount);
                    }
                    else
                    {
                        humanMatch.SetMatchResults(
                            player1WinCount: Ui.Match.Player2WinCount,
                            player2WinCount: Ui.Match.Player1WinCount
                            );
                    }


                    humanMatch.IsFinished = true;
                }
            }
        }
コード例 #3
0
ファイル: Match.cs プロジェクト: longde123/grove
 public Match(MatchParameters p)
 {
     _p = p;
     Application.Current.Exit += delegate { Stop(); };
 }
コード例 #4
0
ファイル: Match.cs プロジェクト: leloulight/magicgrove
 public Match(MatchParameters p)
 {
     _p = p;
       Application.Current.Exit += delegate { Stop(); };
 }