public static GamePlayer JoinGame(Game game, string currentUserID, string name) { GamePlayer player = new GamePlayer(); player.Name = name; player.Game = game; player.Notes = string.Empty; player.Position = 0; player.PublicTeamID = player.PrivateTeamID = 1; // humans, default team player.UserID = currentUserID; game.GamePlayers.Add(player); return player; }
private static void StartTurn(this Game game, GamePlayer player, int turnNumber) { // deal cards to this player, bringing them up to the number of players in the game var num = 0; var cardsNeeded = game.GamePlayers.Count - player.GameCards.Count; foreach (var card in game.DrawCards(false, cardsNeeded)) { card.GamePlayer = player; card.Position = ++num; // position in player's hand } GameTurn turn = new GameTurn(); turn.Game = game; turn.ActivePlayer = player; turn.Number = turnNumber; turn.Timestamp = DateTime.Now; turn.Message = "This is the first turn of the game. This text should probably come from the event card or something!"; // pick an event card for this turn turn.EventCard = game.DrawCards(true).First(); turn.EventCard.Discarded = true; game.GameTurns.Add(turn); }
private static GamePlayer GetNextPlayer(this Game game, GamePlayer previous) { var next = game.GamePlayers.Where(gp => gp.Position > previous.Position).OrderBy(gp => gp.Position).FirstOrDefault(); if (next == null) next = game.GamePlayers.OrderBy(gp => gp.Position).First(); return next; }