public GamePlayerCard(Entities.Card card, Int32 gameID, Int32 userId) { this.Card = card; this.CardID = card.CardID; this.GameID = gameID; this.UserId = userId; }
public static Entities.Card ToEntity(this CardModel request) { var s = new Entities.Card(); s.Number = request.CardNumber; return(s); }
/// <summary> /// Calculate the number of cards each player needs to draw in order to have a full hand /// </summary> /// <param name="question">The question card for the round</param> /// <param name="players">List of players in the game</param> /// <returns>A Dictionary that uses UserId as keys and number of cards needed as values</returns> public Dictionary <Int32, Int32> Execute(Entities.Card question, List <Entities.GamePlayer> players) { Dictionary <Int32, Int32> drawCount = new Dictionary <Int32, Int32>(); foreach (Entities.GamePlayer player in players) { drawCount.Add(player.User.UserId, Execute(question, player.CardCount)); } return(drawCount); }
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); }
/// <summary> /// Calculates the number of cards needed for a single player /// </summary> /// <param name="question">The question card</param> /// <param name="playerCardCount">The number of cards the player currently has</param> /// <returns>The number of cards the current player needs in order to have a valid hand</returns> private Int32 Execute(Entities.Card question, Int32 playerCardCount) { Int32 numberToDraw = HAND_SIZE - playerCardCount; if (question == null || question.Instructions == Entities.Enums.Card.Instructions.Draw2Pick3) { numberToDraw += 2; } if (numberToDraw < 0) { numberToDraw = 0; } return(numberToDraw); }