本文整理汇总了C#中Entities.CurrentRound方法的典型用法代码示例。如果您正苦于以下问题:C# Entities.CurrentRound方法的具体用法?C# Entities.CurrentRound怎么用?C# Entities.CurrentRound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities
的用法示例。
在下文中一共展示了Entities.CurrentRound方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateQuestion
private Entities.GameRoundCard CreateQuestion(IEnumerable<Entities.Card> cards, Entities.Game game)
{
Entities.Card card = cards.FirstOrDefault();
Entities.GameRoundCard question = null;
if (card != null)
{
Entities.GameRound round = game.CurrentRound();
question = new Entities.GameRoundCard(card, round.CardCommander.UserId, round.GameRoundID, game.GameID);
}
return question;
}
示例2: Execute
/// <summary>
/// Handle dealing cards to players in <paramref name="game"/>
/// </summary>
/// <param name="game">The game to deal cards for</param>
/// <param name="dealQuestion">Is a question card needed</param>
public void Execute(Entities.Game game, Boolean dealQuestion)
{
List<Entities.Card> questions;
List<Entities.Card> answers;
_shuffleCards.Execute(game, out questions, out answers);
IEnumerable<Entities.Card> filteredQuestions = _excludeByCount.Execute(questions, game.QuestionShuffleCount);
Entities.GameRoundCard dealtQuestion = null;
if(dealQuestion)
{
dealtQuestion = CreateQuestion(filteredQuestions, game);
}
else
{
dealtQuestion = new Entities.GameRoundCard
{
Card = game.CurrentRound().Question
};
}
IEnumerable<Entities.Card> filteredAnswers = _excludeCurrentHands.Execute(answers);
filteredAnswers = _excludeByCount.Execute(filteredAnswers, game.AnswerShuffleCount);
Dictionary<Int32, Int32> drawCount = _calculateDrawCount.Execute(dealtQuestion.Card, game.Players);
Boolean needMoreQuestions = dealtQuestion == null && dealQuestion;
Boolean needMoreAnswers = drawCount.Values.Sum() > filteredAnswers.Count();
if (needMoreQuestions || needMoreAnswers)
{
if (needMoreQuestions)
{
//Update reshuffle counts
filteredQuestions = _excludeByCount.Execute(questions, ++game.QuestionShuffleCount);
//Reselect question card
dealtQuestion = CreateQuestion(filteredQuestions, game);
drawCount = _calculateDrawCount.Execute(dealtQuestion.Card, game.Players);
needMoreAnswers = drawCount.Values.Sum() > filteredAnswers.Count();
}
if (needMoreAnswers)
{
filteredAnswers = _excludeCurrentHands.Execute(answers);
filteredAnswers = _excludeByCount.Execute(filteredAnswers, ++game.AnswerShuffleCount);
}
_updateGame.Execute(new Entities.Filters.Game.UpdateCounts(game.GameID, game.QuestionShuffleCount, game.AnswerShuffleCount));
}
if (dealQuestion)
{
_insertGameRoundCard.Execute(new List<Entities.GameRoundCard> { dealtQuestion });
game.CurrentRound().Question = dealtQuestion.Card;
}
_createHand.Execute(filteredAnswers.ToList(), drawCount, game);
}
示例3: GameBoard
/// <summary>
/// Constructor
/// </summary>
/// <param name="game"></param>
/// <param name="userId"></param>
/// <param name="hand"></param>
/// <param name="playerType"></param>
/// <param name="voteToKickList"></param>
/// <param name="completedRounds"></param>
public GameBoard(Entities.Game game, Int32 userId, Entities.Enums.GamePlayerType playerType,
List<Models.Game.Board.VoteToKick> voteToKickList = null,
List<Entities.GameRound> completedRounds = null)
{
Game = game;
UserId = userId;
Hand = new List<GamePlayerCard>();
if (playerType == Enums.GamePlayerType.Player)
{
Entities.GamePlayer player = Game.Players.FirstOrDefault(x => x.User.UserId == userId);
if(player != null && player.Hand != null)
{
Hand = player.Hand;
}
}
Hand = playerType == Enums.GamePlayerType.Player ? Game.Players.First(x => x.User.UserId == userId).Hand : new List<GamePlayerCard>();
ActivePlayer = Hand.Count > 0;
PlayerType = playerType;
Entities.GameRound round = Game.CurrentRound();
if (Game.HasRounds() && round != null)
{
Answered = round.HasAnswer(UserId);
ShowAnswers = round.PlayedCount >= round.CurrentPlayerCount && round.Answers.Count > 0;
RoundHasWinner = round.Winner() != null;
GroupedAnswers = round.GroupedAnswers();
IsCommander = Game.IsCurrentCommander(UserId) && PlayerType == Entities.Enums.GamePlayerType.Player;
}
else
{
Answered = false;
ShowAnswers = false;
RoundHasWinner = false;
IsCommander = false;
}
ShowHand = ActivePlayer && !Answered && !IsCommander && PlayerType == Entities.Enums.GamePlayerType.Player;
ShowWaiting = (round == null || RoundHasWinner) && Game.IsWaiting();
WaitingOnAllAnswersOrWinner = !RoundHasWinner && !ShowAnswers;
ShowBoard = !ShowWaiting && !Game.HasWinner();
if (ShowBoard && round != null)
{
Question = round.Question;
}
else
{
Question = null;
}
AnswersViewModel = new Answers(RoundHasWinner, IsCommander, WaitingOnAllAnswersOrWinner, ShowAnswers, ShowHand, ShowBoard, GroupedAnswers);
GameOverViewModel = new GameOver(Game.HasWinner(), Game.GameID, Game.Players);
HandViewModel = new Board.Hand(ShowHand, Hand, ShowBoard);
LobbyViewModel = new Lobby(PlayerType, Game.Players, Game.MaxNumberOfSpectators > 0, Game.Spectators);
RoundQuestionViewModel = new RoundQuestion(round, ShowBoard);
WaitingViewModel = new Waiting(ShowWaiting);
VotesToKickViewModel = new VotesToKick(voteToKickList ?? new List<Models.Game.Board.VoteToKick>());
AllRoundsViewModel = new AllRounds(completedRounds ?? new List<GameRound>());
HeaderViewModel = new Shared.Header();
if (Game.HasWinner())
{
HeaderViewModel.SubHeaderText = "Game Over, man!";
}
else if (ShowWaiting)
{
HeaderViewModel.SubHeaderText = ArmedCards.Entities.Models.Helpers.WaitingHeader.Build(Game, UserId, PlayerType);
}
else
{
HeaderViewModel.SubHeaderText = String.Format("{0} is the Card Commander", Game.DetermineCommander().DisplayName);
}
}