当前位置: 首页>>代码示例>>C#>>正文


C# Game.AddPlayer方法代码示例

本文整理汇总了C#中Game.AddPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# Game.AddPlayer方法的具体用法?C# Game.AddPlayer怎么用?C# Game.AddPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game的用法示例。


在下文中一共展示了Game.AddPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MyTestInitialize

 public void MyTestInitialize()
 {
     game = new Game(120000);
     game.AddPlayer(new Player("P1"));
     game.AddPlayer(new Player("P2"));
     game.StartGame();
 }
开发者ID:ArnoldOverwater,项目名称:INFDAT01,代码行数:7,代码来源:GameTest.cs

示例2: Main

        public static void Main(String[] args)
        {
            Game aGame = new Game();

            aGame.AddPlayer("Chet");
            aGame.AddPlayer("Pat");
            aGame.AddPlayer("Sue");

            Random rand = new Random();

            do
            {
                aGame.UpdateLocationBasedOnPenaltyBoxStateAndAskQuestionWhenNotInPenaltyBox(rand.Next(5) + 1);

                if (rand.Next(9) == 7)
                {
                    notAWinner = aGame.HandleIncorrectAnswerFromPlayer();
                }
                else
                {
                    notAWinner = aGame.HandleCorrectAnswerFromPlayer();
                }

            } while (notAWinner);
        }
开发者ID:stefanvr,项目名称:LegacyCode,代码行数:25,代码来源:GameRunner.cs

示例3: AddPlayer_PlayerExists_ThrowsArgumentException

        public void AddPlayer_PlayerExists_ThrowsArgumentException()
        {
            var game = new Game(RaceClass.FiftyCc);
            game.AddPlayer(Character.Mario, "Player 1");

            Action action = () => game.AddPlayer(Character.Luigi, "Player 1");
            action.ShouldThrow<ArgumentException>().And.Message.Contains("Player already entered");
        }
开发者ID:shealey,项目名称:CodeKatas,代码行数:8,代码来源:GameTests.cs

示例4: testPlayGame

 public void testPlayGame()
 {
     Game game = new Game();
     game.AddPlayer(new ComputerPlayer("player 1", new GreedyAIStrategy()));
     game.AddPlayer(new ComputerPlayer("player 2", new GreedyAIStrategy()));
     game.PlayGame();
     // test that there's a winner and the winning score is greater than 0
     Assert.IsTrue(game.GetWinnerName() == "player 1" | game.GetWinnerName() == "player 2");
     Assert.IsTrue(game.GetWinningScore() > 0);
 }
开发者ID:jsgalla,项目名称:YahtzeeNetwork,代码行数:10,代码来源:GameTests.cs

示例5: GetGame

    protected Game GetGame()
    {
        Game game = new Game(new Deck());

        game.AddPlayer(new Player());
        game.AddPlayer(new Player());
        game.AddPlayer(new Player());
        game.AddPlayer(new Player());
        game.AddPlayer(new Player());
        game.StartGame();
        return game;
    }
开发者ID:Roonerelli,项目名称:Shithead,代码行数:12,代码来源:BaseGameTest.cs

示例6: AddPlayer_PlayerNullOrWhiteSpace_ThrowsArgumentNullException

        public void AddPlayer_PlayerNullOrWhiteSpace_ThrowsArgumentNullException(string playerName)
        {
            var game = new Game(RaceClass.FiftyCc);

            Action action = () => game.AddPlayer(Character.Mario, playerName);
            action.ShouldThrow<ArgumentNullException>().And.Message.Contains("Player cannot be empty");
        }
开发者ID:shealey,项目名称:CodeKatas,代码行数:7,代码来源:GameTests.cs

示例7: AddPlayer_PlayerDoesntExist_AddsPlayer

        public void AddPlayer_PlayerDoesntExist_AddsPlayer()
        {
            var game = new Game(RaceClass.FiftyCc);
            game.AddPlayer(Character.Mario, "player 1");

            game.Players.Should().HaveCount(1).And.ContainKey(Character.Mario);
        }
开发者ID:shealey,项目名称:CodeKatas,代码行数:7,代码来源:GameTests.cs

示例8: AddPlayer_PlayerAlreadyExists_ThrowsException

 public void AddPlayer_PlayerAlreadyExists_ThrowsException()
 {
     var player = new Mock<IPlayer>();
     var game = new Game();
     game.PlayerPendingActions = new LoadableDictionary<IPlayer, IPendingAction> {{player.Object, null}};
     game.AddPlayer(player.Object);
 }
开发者ID:joe90p,项目名称:Telestrations,代码行数:7,代码来源:Game_Test.cs

示例9: AddPlayer_PlayerDoesNotAlreadyExists_PlayerAdded

 public void AddPlayer_PlayerDoesNotAlreadyExists_PlayerAdded()
 {
     var player = new Mock<IPlayer>();
     var game = new Game();
     game.AddPlayer(player.Object);
     Assert.IsTrue(game.PlayerPendingActions.Keys.Contains(player.Object));
 }
开发者ID:joe90p,项目名称:Telestrations,代码行数:7,代码来源:Game_Test.cs

示例10: Main

        static void Main(string[] args)
        {
            Game game = new Game();

            Player player1 = new ComputerPlayer("GreedyAI", new GreedyAIStrategy());
            Player player2 = new HumanPlayer("Test Player", new CmdLinePlayerStrategy());

            game.AddPlayer(player1);
            game.AddPlayer(player2);

            game.PlayGame();

            Console.WriteLine("The Winner Is: " + game.GetWinnerName());
            Console.WriteLine("With a score of: " + game.GetWinningScore().ToString());
            Console.ReadKey();
        }
开发者ID:jsgalla,项目名称:YahtzeeNetwork,代码行数:16,代码来源:Program.cs

示例11: CreateGame

 /// <summary>
 /// Creates a new game
 /// </summary>
 /// <param name="creator">Creator player ( uselly human)</param>
 /// <param name="numberOfAIPlayers">number of AI players (up to 3)</param>
 /// <param name="player_AI">strings representing AI players types</param>
 /// <param name="num_of_rounds">numebr of rounds to play</param>
 /// <param name="milisecs_between_turns">time to wait between each turn</param>
 /// <param name="game_name">name of game</param>
 public static void CreateGame(IAsyncPlayer creator, int numberOfAIPlayers, string[] player_AI, int num_of_rounds, int milisecs_between_turns, string game_name)
 {
     if (numberOfAIPlayers < 0 || numberOfAIPlayers > 4)
         return;
     if (game_name == null)
         game_name = "";
     Game g = new Game(num_of_rounds, milisecs_between_turns, game_name);
     g.AddPlayer(creator);
     for (int i = 0; i < numberOfAIPlayers; i++)
     {
         IAsyncPlayer p = Brain.PlayerFactory.CreatePlayer(player_AI[i]);
         if (p != null)
             g.AddPlayer(p, player_AI[i]);
     }
     Games.Add(g);
 }
开发者ID:MaozGelbart,项目名称:cs-whist-2010,代码行数:25,代码来源:GameFactory.cs

示例12: TestGame

        private static void TestGame(Random rand)
        {
            Console.WriteLine("# Test Game class");
            Game game = new Game(rand, 4);
            game.AddPlayer("Terence Hill");
            game.AddPlayer(new Player("Bud Spencer"));
            game.AddPlayer("Darth Vader");
            game.AddPlayer("Anakin Skywalker");
            game.AddPlayer("No More");

            Console.WriteLine("------ WINNER ------");
            Console.WriteLine(game.Play());
            Console.WriteLine("------ GAME ------");
            Console.WriteLine(game);

            Console.WriteLine("------ Third Player Second Card ------");
            Console.WriteLine(game[2][1]);
        }
开发者ID:davidbedok,项目名称:oeprog1,代码行数:18,代码来源:Program.cs

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        /*
         * http://replays.heroesofnewerth.com/match_replay.php?mid=10956260
         * player data for a match
         * replays.heroesofnewerth.com/player_pop.php
            Content-Type: application/x-www-form-urlencoded; charset=UTF-8

            mid=10956260&aid=566479
        */
        HoNEntities context;
        Games myGames;
        context = new HoNEntities();
        context.SaveChanges();
        context.Dispose();

        Chart1.Series.Add("kills");
        Chart1.Series.Add("deaths");
        Chart1.Series.Add("assists");

        Chart1.Series["kills"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
        Chart1.Series["deaths"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
        Chart1.Series["assists"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;

        Chart1.Series["kills"].Points.AddXY(1.0, 1.0);
        Chart1.Series["kills"].Points.AddXY(2.0, 2.0);
        Chart1.Series["deaths"].Points.AddXY(3.0, 3.0);
        Chart1.Series["deaths"].Points.AddXY(1.2, 1.0);
        Chart1.Series["assists"].Points.AddXY(1.5, 2.0);

        Chart1.Legends.Add("Heros");
        return;

        Game curGame = new Game();
        curGame.Id = "10956260";
        string matchText = HttpRequest("http://replays.heroesofnewerth.com/match_replay.php?mid=" + curGame.Id.ToString());
        //string matchText = HttpRequest("http://localhost:4655/HoN/match.html?mid=" + curGame.Id.ToString());

        MatchCollection playerNames = Regex.Matches(matchText, @"id=[""]player\d+[""]>([^<]+)[\s\S]+?getMatchStats\(\d+\,\s*(\d+)");
        foreach (Match playerName in playerNames)
        {
            string heroText = HttpRequest("POST", "http://replays.heroesofnewerth.com/player_pop.php", "mid=" + curGame.Id.ToString() + "&aid=" + playerName.Groups[2].Value);
            //string heroText = HttpRequest("http://localhost:4655/HoN/hero.html");
            Match killSet = Regex.Match(heroText, @"<div id=[""]kills_history[""][\s\S]*?</div>");
            string killText = killSet.Value;
            MatchCollection kills = Regex.Matches(killText, @"<li class=[""]cat[""][^>]+>([^<]+)(?:(?!\[)[^>]+>)+\[([^]]+)");
            foreach (Match kill in kills)
            {
                curGame.AddEvent("kill", kill.Groups[2].Value, kill.Groups[1].Value);
            }

            string heroName = Regex.Match(heroText, @"Hero Played[^>]+>[^>]+>[^>]+>([^<]+)").Groups[1].Value;

            curGame.AddPlayer(playerName.Groups[1].Value, heroName);
            break;
        }
    }
开发者ID:aldrinmg,项目名称:SadPanda-1,代码行数:57,代码来源:Default.aspx.cs

示例14: GetUnusedPlayers_PlayersExist_GetsRemainingCharacters

        public void GetUnusedPlayers_PlayersExist_GetsRemainingCharacters()
        {
            var game = new Game(RaceClass.FiftyCc);
            int numCharacters = Enum.GetNames(typeof(Character)).Length;

            game.AddPlayer(Character.Mario, "Player 1");
            game.GetUnusedCharacters();

            game.GetUnusedCharacters().Should().OnlyHaveUniqueItems().And.HaveCount(numCharacters - 1);
        }
开发者ID:shealey,项目名称:CodeKatas,代码行数:10,代码来源:GameTests.cs

示例15: GetPlaySession_LongestChainForPlayerIsNull_GetNewGameSession

 public void GetPlaySession_LongestChainForPlayerIsNull_GetNewGameSession()
 {
     var player = new Mock<IPlayer>();
     var game = new Game();
     var chains = new Mock<IChainList>();
     chains.Setup(cl => cl.GetLongestChainForPlayer(It.IsAny<IPlayer>())).Returns<IInPlayChain>(null);
     game.Chains = chains.Object;
     game.PendingActionFactory = new Mock<IPendingActionFactory>().Object;
     game.AddPlayer(player.Object);
     var playSession = game.GetPlaySession(player.Object);
     Assert.IsTrue(playSession.Type==PlayType.NewGame);
 }
开发者ID:joe90p,项目名称:Telestrations,代码行数:12,代码来源:Game_Test.cs


注:本文中的Game.AddPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。