本文整理汇总了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();
}
示例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);
}
示例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");
}
示例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);
}
示例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;
}
示例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");
}
示例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);
}
示例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);
}
示例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));
}
示例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();
}
示例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);
}
示例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]);
}
示例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;
}
}
示例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);
}
示例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);
}