/// <summary> /// </summary> /// <param name="game"> Reference to game manager. </param> /// <param name="scoreCard"> Reference to current game's score card. </param> /// <param name="category"> Score category to accept. </param> /// <param name="scores"> Reference to current turn's dice scores. </param> /// <returns></returns> public virtual bool AcceptScore(GameManager game, ScoreCard scoreCard, ScoringCategory category, Dictionary <ScoringCategory, int> scores) { scoreCard.AcceptScore(category, scores[category]); game.NextState(new FirstMoveState()); return(true); }
public int ScoreDieRoll(int[] dieArray, ScoringCategory scoringCategory) { if (!ValidateDieRollArray(dieArray)) { throw new ArgumentException(); } return(ScoringCategoryHandlerDictionary[scoringCategory].ScoreCategory(dieArray, scoringCategory)); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { for (var i = 2; i < 6; i++) { if (!dieArray.Contains(i)) { return(0); } } return(dieArray.Contains(1) ? 15 : dieArray.Contains(6) ? 20 : 0); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { var fullHousePairs = dieArray.GroupBy(g => g).Where(x => x.Count() == 2).Select(g => g.Key); var fullHouseThrees = dieArray.GroupBy(g => g).Where(x => x.Count() == 3).Select(g => g.Key); if (fullHousePairs.Count() != 0 && fullHouseThrees.Count() != 0) { return(dieArray.Sum()); } return(0); }
public ScoringCategoryDto AddScoringCategory(string categoryName, bool relative, decimal weight) { var sc = new ScoringCategory { CategoryType = relative ? (int)ScoringCategoryType.Relative : (int)ScoringCategoryType.Fix, Name = categoryName, Weight = weight }; AddAndSave(sc); return(new ScoringCategoryDto(sc)); }
/// <summary> /// Accepts the scoring category for the current roll onto the scorecard. /// </summary> /// <param name="category"> Scoring category to accept. </param> /// <returns> True is accepted; false otherwise. </returns> public bool AcceptScore(ScoringCategory category) { if (gameState.AcceptScore(this, scoreCard, category, rollScores)) { roller = new DiceRoller(); rollScores = ScoreCalculator.CalculateDice(roller.SortedDice); scoreCard.AcceptScore(ScoringCategory.Bonus, ScoreCalculator.CalculateBonus(scoreCard.Scores)); rollScores.Add(ScoringCategory.Bonus, ScoreCalculator.CalculateBonus(scoreCard.Scores)); return(true); } return(false); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { var kindNumber = CategoryToIntegerDictionary[category]; var kindList = dieArray.GroupBy(g => g).Where(x => x.Count() >= kindNumber).Select(g => g.Key).ToList(); if (kindList.Count() != 0) { return(kindList.Last() * kindNumber); } return(0); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ScoringCategory = await _context.ScoringCategory.FirstOrDefaultAsync(m => m.ScoringCategoryId == id); if (ScoringCategory == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ScoringCategory = await _context.ScoringCategory.FindAsync(id); if (ScoringCategory != null) { ScoringCategory.IsArchived = true; _context.ScoringCategory.Update(ScoringCategory); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); CurrentUserId = claim.Value; if (id == null) { return(NotFound()); } ScoringCategory = await _context.ScoringCategory.FirstOrDefaultAsync(m => m.ScoringCategoryId == id); if (ScoringCategory == null) { return(NotFound()); } return(Page()); }
public void AddScore(ScoringCategory category, int score) { ScoreCategoryToScoreDictionary[category] = score; }
public int getScore(ScoringCategory category) { return(1); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { var categoryInt = CategoryToIntegerDictionary[category]; return(categoryInt * dieArray.Count(x => x == categoryInt)); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { var pairValues = dieArray.GroupBy(g => g).Where(x => x.Count() >= 2).Select(g => g.Key).ToList(); return(pairValues.Count() == 2 ? 2 * pairValues.Sum() : 0); }
/// <summary> /// Determine if the scorecard category has been accepted. /// </summary> /// <param name="category"> Category to check. </param> /// <returns> True if score category has been accepted; false otherwise. </returns> public bool IsScoreAccepted(ScoringCategory category) { return(scoreCard.IsScoreAccepted(category)); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { return(dieArray.Sum()); }
/// <summary> /// Whether or not the score for a scoring category has been accepted; or locked in. /// </summary> /// <param name="category"> The scoring category to check for acceptance. </param> /// <returns> True if the score for the category has been accepted; false otherwise. </returns> public bool IsScoreAccepted(ScoringCategory category) { return(scoreAccepted[category]); }
public int ScoreCategory(int[] dieArray, ScoringCategory category) { return(dieArray.All(x => x == dieArray[0]) ? 50 : 0); }
public override bool AcceptScore(GameManager game, ScoreCard scoreCard, ScoringCategory category, Dictionary <ScoringCategory, int> scores) { return(false); }
public ScoringCategoryDto(ScoringCategory category) { Id = category.Id; Name = category.Name; Weight = category.Weight; }
/// <summary> /// Indexer to return the score of a scoring category. /// </summary> /// <param name="category"> Scoring category to return the score for. </param> /// <returns> The score of the scoring category. </returns> public int this[ScoringCategory category] { get { return(scores[category]); } }
/// <summary> /// Accepts a score for a specific scoring category. /// </summary> /// <param name="category"> The category to accept the score for. </param> /// <param name="score"> The value of the score. </param> public void AcceptScore(ScoringCategory category, int score) { scores[category] = score; scoreAccepted[category] = true; }