示例#1
0
        public void AddPlayer(Card card, CardPlayer cardPlayer)
        {
            var existing = card.CardPlayers.SingleOrDefault(x => x.Id.Equals(cardPlayer.Id));

            if (existing != null)
            {
                // have anything of importance changed?
                if (existing.TeeType != cardPlayer.TeeType && existing.RoundHandicap == cardPlayer.RoundHandicap)
                {
                    // re-calculate
                    existing.RoundHandicap = GetRoundHandicap(existing.Player, cardPlayer.TeeType);
                    existing.TeeType       = cardPlayer.TeeType;
                }
                else if (existing.RoundHandicap != cardPlayer.RoundHandicap)
                {
                    existing.RoundHandicap = cardPlayer.RoundHandicap;
                    existing.TeeType       = cardPlayer.TeeType;
                }
            }
            else
            {
                // new
                if (!cardPlayer.RoundHandicap.HasValue)
                {
                    cardPlayer.RoundHandicap = GetRoundHandicap(cardPlayer.Player, cardPlayer.TeeType);
                }
                card.CardPlayers.Add(cardPlayer);
            }
        }
示例#2
0
 public CardPlayerScore(CardPlayer cardPlayer)
 {
     Id = Guid.NewGuid();
     this.CardPlayer = cardPlayer;
 }