Пример #1
0
    private void EditScore(int id)
    {
        Label   lblId       = modalDialog.FindControl("lblId") as Label;
        TextBox txtName     = modalDialog.FindControl("txtName") as TextBox;
        TextBox txtWeight   = modalDialog.FindControl("txtWeight") as TextBox;
        TextBox txtMinRange = modalDialog.FindControl("txtMinRange") as TextBox;
        TextBox txtMaxRange = modalDialog.FindControl("txtMaxRange") as TextBox;

        ScoreCategory sc = null;

        if (id > 0)
        {
            sc = ScoreService.GetScoreCategory(id);
        }
        else
        {
            sc = new ScoreCategory();
            Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
            sc.Region = region;
        }
        lblId.Text       = id.ToString();
        txtName.Text     = sc.Name;
        txtWeight.Text   = sc.Weight.ToString();
        txtMinRange.Text = sc.MinRange.ToString();
        txtMaxRange.Text = sc.MaxRange.ToString();
        modalDialog.ShowModal();
    }
Пример #2
0
        public string Score(ICollection<int> diceValues, ScoreCategory scoreCategory)
        {
            var score = "Zero!";
            switch(scoreCategory)
            {
                case ScoreCategory.ThreeOfAKind:
                    // Here we'd process the dice values to see if it was a valid three of a kind or not
                    score = "ThreeOfAKind";
                    break;
                case ScoreCategory.FourOfAKind:
                    score = "FourOfAKind";
                    break;
                case ScoreCategory.FullHouse:
                    score = "FullHouse";
                    break;
                case ScoreCategory.SmallStraight:
                    score = "SmallStraight";
                    break;
                case ScoreCategory.LargeStraight:
                    score = "LargeStraight";
                    break;
                case ScoreCategory.Yahtzee:
                    score = "Yahtzee";
                    break;
                default:
                    score = "Default";
                    break;
            }

            return score;
        }
Пример #3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.Validate("ScoreEdit");
     if (IsValid)
     {
         Label         lblId       = modalDialog.FindControl("lblId") as Label;
         TextBox       txtName     = modalDialog.FindControl("txtName") as TextBox;
         TextBox       txtWeight   = modalDialog.FindControl("txtWeight") as TextBox;
         TextBox       txtMinRange = modalDialog.FindControl("txtMinRange") as TextBox;
         TextBox       txtMaxRange = modalDialog.FindControl("txtMaxRange") as TextBox;
         ScoreCategory sc          = null;
         if (Convert.ToInt32(lblId.Text) > 0)
         {
             sc = ScoreService.GetScoreCategory(Convert.ToInt32(lblId.Text));
         }
         else
         {
             sc = new ScoreCategory();
             Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
             sc.Region = region;
         }
         sc.Name     = txtName.Text;
         sc.Weight   = Convert.ToInt32(txtWeight.Text);
         sc.MinRange = Convert.ToInt32(txtMinRange.Text);
         sc.MaxRange = Convert.ToInt32(txtMaxRange.Text);
         ScoreService.Save(sc);
         modalDialog.HideModal();
         LoadScores();
     }
 }
 public void CategoryPropertyShouldReturnSetCategory(ScoreCategory a_scoreCategory)
 {
   sut = new CategoryScore(a_scoreCategory);
   ScoreCategory expected = a_scoreCategory;
   ScoreCategory actual = sut.Category;
   Assert.Equal(expected, actual);
 }
Пример #5
0
    public int calculateScore(ScoreCategoryEnum.ScoreCategoryType t)
    {
        List <int> allDices = new List <int>(diceSaver);

        allDices.AddRange(dice);
        return(ScoreCategory.CalculateScore(allDices, t));
    }
Пример #6
0
        /// <summary>
        /// Get score board
        /// If not exists create new
        /// </summary>
        /// <param name="id"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public async static Task <ScoreBoard> GetScoreBoardAsync(int id, ScoreCategory category)
        {
            try
            {
                return(await _client.ReadDocumentAsync <ScoreBoard>(UriFactory.CreateDocumentUri(DatabaseName, CollectionName, GetScoreBoardId(category, id))));
            }
            catch (DocumentClientException de)
            {
                if (de.StatusCode == HttpStatusCode.NotFound)
                {
                    var scoreBoard = new ScoreBoard()
                    {
                        ServerId = id,
                        Category = category,
                        Scores   = new List <Score>()
                    };
                    await CreateScoreBoardIfNotAExistsAsync(scoreBoard);

                    return(scoreBoard);
                }
                else
                {
                    throw;
                }
            }
        }
        public void ShouldReturnACalculatorBasedOnEnum(ScoreCategory a_scoreCategory, Type a_type)
        {
            sut = new ScoreCalculatorFactory();
            IScoreCalculator actual = sut.GetScoreCalculator(a_scoreCategory);

            Assert.True(actual.GetType() == a_type);
        }
Пример #8
0
    public IEnumerator Test21_UpperScoreCategory()
    {
        yield return(LoadScene("Scene05"));

        yield return(Press("English Button"));

        yield return(LoadScene("Scene01"));

        yield return(Press("LoadSceneButton"));

        // Choose two category in the upper section
        yield return(LoadScene("Scene02"));

        Setup(1);
        yield return(Press("LoadGameButton"));

        yield return(LoadScene("Scene03"));

        yield return(Press("RollDice"));

        System.Threading.Thread.Sleep(1000);
        List <int> dices = new List <int>();

        dices.AddRange(GetDices().Values);
        // Choose ones
        yield return(Press("ACE"));

        System.Threading.Thread.Sleep(1000);
        // Check scoresheet
        int calculatedScore = ScoreCategory.CalculateScore(dices, ScoreCategoryEnum.ScoreCategoryType.ACE);
        // Get ACE score of player 1
        int scoreAce = getScoreFromScoresheet("01");

        Assert.AreEqual(calculatedScore, scoreAce);
        yield return(Press("Next Turn"));

        yield return(Press("RollDice"));

        System.Threading.Thread.Sleep(1000);
        dices.Clear();
        dices.AddRange(GetDices().Values);
        // Choose six
        yield return(Press("SIX"));

        System.Threading.Thread.Sleep(1000);
        calculatedScore = ScoreCategory.CalculateScore(dices, ScoreCategoryEnum.ScoreCategoryType.SIX);
        // Get SIX score of player 1
        int scoreSix = getScoreFromScoresheet("06");

        Assert.AreEqual(scoreSix, calculatedScore);
        // Check Upper section score
        int upperScore = getScoreFromScoresheet("08");

        Assert.AreEqual(upperScore, scoreSix + scoreAce);
        // Total score
        Assert.AreEqual(getScoreFromScoresheet("019"), upperScore);
        // Button ace and six not clickable
        Assert.False(clickable("ACE"));
        Assert.False(clickable("SIX"));
    }
Пример #9
0
        public void RegisterScore(IPlayer a_player, ScoreCategory a_scoreCatagory, List <int> a_faceValues)
        {
            if (a_player == null)
            {
                throw new ArgumentNullException();
            }

            rules.IScoreCalculator calculator = m_scoreFactory.GetScoreCalculator(a_scoreCatagory);
            int score = calculator.CalculateScore(a_faceValues);

            CategoryScore categoryScore = new CategoryScore(a_scoreCatagory);

            categoryScore.Set(score, a_faceValues);

            bool playerAlreadyExists = m_playerScores.ContainsKey(a_player);

            Dictionary <ScoreCategory, CategoryScore> playerScore = playerAlreadyExists ? GetPlayerScore(a_player) : new Dictionary <ScoreCategory, CategoryScore>();

            playerScore.Add(a_scoreCatagory, categoryScore);

            if (!playerAlreadyExists)
            {
                m_playerScores.Add(a_player, playerScore);
            }
        }
Пример #10
0
        private CategoryScore BuildCategoryScore(ScoreCategory a_scoreCategory, int a_score, List <int> a_faceValues)
        {
            CategoryScore categoryScore = new CategoryScore(a_scoreCategory);

            categoryScore.Set(a_score, a_faceValues);
            return(categoryScore);
        }
Пример #11
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.Validate("ScoreEdit");
     if (IsValid)
     {
         Label lblId = modalDialog.FindControl("lblId") as Label;
         TextBox txtName = modalDialog.FindControl("txtName") as TextBox;
         TextBox txtWeight = modalDialog.FindControl("txtWeight") as TextBox;
         TextBox txtMinRange = modalDialog.FindControl("txtMinRange") as TextBox;
         TextBox txtMaxRange = modalDialog.FindControl("txtMaxRange") as TextBox;
         ScoreCategory sc = null;
         if (Convert.ToInt32(lblId.Text) > 0)
         {
             sc = ScoreService.GetScoreCategory(Convert.ToInt32(lblId.Text));
         }
         else
         {
             sc = new ScoreCategory();
             Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
             sc.Region = region;
         }
         sc.Name = txtName.Text;
         sc.Weight = Convert.ToInt32(txtWeight.Text);
         sc.MinRange = Convert.ToInt32(txtMinRange.Text);
         sc.MaxRange = Convert.ToInt32(txtMaxRange.Text);
         ScoreService.Save(sc);
         modalDialog.HideModal();
         LoadScores();
     }
 }
Пример #12
0
 public string Score(ICollection<int> diceValues, ScoreCategory scoreCategory)
 {
     Func<ICollection<int>, string> scoreFunc;
     return ScoreDict.TryGetValue(scoreCategory, out scoreFunc) ?
         scoreFunc(diceValues) :
         "Zero!";
 }
Пример #13
0
 public void TestXXXX_ConvertIntToScoreCategoryType()
 {
     for (int i = 1; i <= 19; i++)
     {
         ScoreCategoryType type = ScoreCategory.convert(i);
         Assert.AreEqual((int)type, i);
     }
 }
        public EditCategoryPage(ScoreCategory categoryInput)
        {
            InitializeComponent();
            isNew            = false;
            selectedCategory = categoryInput;

            // Load existing data
            nameEntry.Text         = selectedCategory.ScoreCategoryName;
            descriptionEditor.Text = selectedCategory.ScoreCategoryDescription;
        }
Пример #15
0
 protected void gvScore_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         ScoreCategory sc = e.Row.DataItem as ScoreCategory;
         if (null != sc)
         {
             LinkButton btnDelete = e.Row.FindControl("btnDelete") as LinkButton;
             btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this user?');");
         }
     }
 }
Пример #16
0
        public void UpdateScoreCard(ScoreCategory scoreCategory, List <IDie> diceHeld)
        {
            if (!ScoreCategories[scoreCategory].IsAvailable)
            {
                throw new ScoreCategoryAlreadyTakenException(scoreCategory);
            }

            ClearPreviewScoreCard();
            var scoreForTurn = GetScoreForCategory(scoreCategory, diceHeld);

            UpdateScoreCategory(scoreCategory, scoreForTurn);
            UpdateTotalScore(scoreForTurn);
        }
Пример #17
0
 protected void gvScore_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditScore")
     {
         int id = Convert.ToInt32(e.CommandArgument);
         EditScore(id);
     }
     if (e.CommandName == "DeleteScore")
     {
         int           id = Convert.ToInt32(e.CommandArgument);
         ScoreCategory sc = ScoreService.GetScoreCategory(id);
         ScoreService.Delete(sc);
         LoadScores();
     }
 }
Пример #18
0
    public void updateScoreText(int type)
    {
        Player     p    = g.currentPlayer();
        List <int> dice = getDice();

        ScoreCategoryEnum.ScoreCategoryType category = ScoreCategory.convert(type);
        if (p.calculateScore(dice, category) >= 0 && p.getScore(category) == -1)
        {
            p.saveScore(category, p.calculateScore(dice, category), g.isYahtzee(dice));
            updateScoreBoard();
            disableButton("category");
            disableButton("rolldice");
            enableButton("endturn");
        }
    }
Пример #19
0
        public CategoryScore GetScore(IPlayer a_player, ScoreCategory a_scoreCatagory)
        {
            if (a_player == null)
            {
                throw new ArgumentNullException();
            }

            // TODO: Error handling.
            var score = GetPlayerScore(a_player)
                        .Where(e => e.Key == a_scoreCatagory)
                        .Select(e => e.Value)
                        .First();

            return(score);
        }
Пример #20
0
        /// <summary>
        /// Creates and returns a Score Calculator.
        /// </summary>
        /// <param name="a_scoreCategory">Which calculator the factory should manufacture. (Get it? It's a factory)</param>
        /// <returns>a Score Calculator.</returns>
        public IScoreCalculator GetScoreCalculator(ScoreCategory a_scoreCategory)
        {
            // Like C Martin said, Switches are ugly, but they're OK in a Factory.
            switch (a_scoreCategory)
            {
            case ScoreCategory.Aces:
                return(new AcesCalculator());

            case ScoreCategory.Twos:
                return(new TwosCalculator());

            case ScoreCategory.Threes:
                return(new ThreesCalculator());

            case ScoreCategory.Fours:
                return(new FoursCalculator());

            case ScoreCategory.Fives:
                return(new FivesCalculator());

            case ScoreCategory.Sixes:
                return(new SixesCalculator());

            case ScoreCategory.ThreeOfAKind:
                return(new ThreeOfAKindCalculator());

            case ScoreCategory.FourOfAKind:
                return(new FourOfAKindCalculator());

            case ScoreCategory.FullHouse:
                return(new FullHouseCalculator());

            case ScoreCategory.SmallStraight:
                return(new SmallStraightCalculator());

            case ScoreCategory.LargeStraight:
                return(new LargeStraightCalculator());

            case ScoreCategory.Yahtzee:
                return(new YahtzeeCalculator());

            case ScoreCategory.Chance:
                return(new ChanceCalculator());

            default:
                throw new ArgumentException();
            }
        }
Пример #21
0
        public int GetScore(int[] dice, ScoreCategory category,
                            int scoringDice = 0)
        {
            var        result        = 0;
            List <int> singles       = new List <int>();
            List <int> pairs         = new List <int>();
            int        threeOfAKind  = 0;
            int        fourOfAKind   = 0;
            bool       yahtzee       = false;
            bool       smallStraight = true;
            bool       largeStraight = true;


            singles.AddRange(dice.Where(a => a == scoringDice));
            for (int x = 1; x <= 6; x++)
            {
                var matchingDice = dice.Where(a => a == x);
                if (matchingDice.Count() >= 2)
                {
                    pairs.Add(x);
                }
                if (matchingDice.Count() >= 3)
                {
                    threeOfAKind = x;
                }
                if (matchingDice.Count() >= 4)
                {
                    fourOfAKind = x;
                }
                smallStraight = smallStraight &&
                                (dice.Contains(x) || x == 6);

                largeStraight = largeStraight &&
                                (dice.Contains(x) || x == 1);
            }
            yahtzee = dice.Distinct().Count() == 1;

            return(category == ScoreCategory.Units ? singlesScore(singles, scoringDice) :
                   category == ScoreCategory.Pair ? pairsScore(pairs) :
                   category == ScoreCategory.TwoPairs ? twoPairsScore(pairs) :
                   category == ScoreCategory.ThreeOfAKind ? threeOfAKindScore(threeOfAKind) :
                   category == ScoreCategory.FourOfAKind ? fourOfAKindScore(fourOfAKind) :
                   category == ScoreCategory.FullHouse ? fullHouseScore(pairs, threeOfAKind) :
                   category == ScoreCategory.SmallStraight ? smallStraight ? 15 : 0 :
                   category == ScoreCategory.LargeStraight ? largeStraight ? 20 : 0 :
                   category == ScoreCategory.Yahtzee ? yahtzee ? 50 : 0 :
                   category == ScoreCategory.Chance ? chance(dice) : 0);
        }
Пример #22
0
        private void scoreLabel_PointerExited(object sender, PointerRoutedEventArgs e)
        {
            ScoreCategory currentCategory =
                GameBoard.getScoreCategoryByTextBlockControl(sender as TextBlock);

            if (currentCategory.status == ScoreCategory.Status.Unused)
            {
                currentCategory.descriptionTextBlock.Foreground =
                    new SolidColorBrush(Colors.Black);
            }

            // Remove possible bonus points from the display
            GameBoard.bonusScoreTextBlock.Text = String.Empty;

            return;
        }
Пример #23
0
        private void scoreLabel_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            ScoreCategory currentCategory =
                GameBoard.getScoreCategoryByTextBlockControl(sender as TextBlock);

            if (currentCategory.status == ScoreCategory.Status.Unused)
            {
                currentCategory.descriptionTextBlock.Foreground =
                    new SolidColorBrush(Colors.OrangeRed);

                // Display possible bonus points
                GameBoard.bonusScoreTextBlock.Text =
                    Yahtzee.calculateBonus(GameBoard.ScoreableDice,
                                           currentCategory.scoreValue).ToString();
            }

            return;
        }
Пример #24
0
        private void scoreLabel_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            #region Data
            ScoreCategory currentCategory =
                GameBoard.getScoreCategoryByTextBlockControl(sender as TextBlock);
            #endregion

            #region Logic
            if (currentCategory.status == ScoreCategory.Status.Unused)
            {
                currentCategory.status = ScoreCategory.Status.Used;

                // Apply points
                GameBoard.totalScore += currentCategory.scoreValue;
                GameBoard.totalScore +=
                    Yahtzee.calculateBonus(GameBoard.ScoreableDice, currentCategory.scoreValue);

                // Reset all the dice
                GameBoard.resetDice();
                foreach (Dice dice in GameBoard.RollableDice.Values)
                {
                    dice.roll();
                }

                // Enable the roll button
                resetRollDiceButton();

                // Calculate all the scores
                GameBoard.calculateAllScores();
            }

            if (GameBoard.isGameOver())
            {
                gameBoardMessageBox.Text = $"Game Over. Final Score: {GameBoard.totalScore.ToString()}";
                bt_rollDice.IsEnabled    = false;
                GameBoard.hideAllDice();
            }

            #endregion

            return;
        }
Пример #25
0
 public static void WriteScoreCategory(this PacketWriter writer, ScoreCategory data)
 {
     writer.WriteByte((byte)data);
 }
Пример #26
0
    public int CalculateScore(List <int> dice, ScoreCategoryEnum.ScoreCategoryType category)
    {
        if (dice.Count > 6)
        {
            return(0);
        }
        int result = 0;

        if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.ACE))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                if (dice[i] == 1)
                {
                    result += dice[i];
                }
            }
            return(result);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.TWO))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                if (dice[i] == 2)
                {
                    result += dice[i];
                }
            }
            return(result);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.THREE))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                if (dice[i] == 3)
                {
                    result += dice[i];
                }
            }
            return(result);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.FOUR))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                if (dice[i] == 4)
                {
                    result += dice[i];
                }
            }
            return(result);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.FIVE))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                if (dice[i] == 5)
                {
                    result += dice[i];
                }
            }
            return(result);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.SIX))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                if (dice[i] == 6)
                {
                    result += dice[i];
                }
            }
            return(result);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.THREE_A_KIND))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                result += dice[i];
            }
            return(ScoreCategory.isNOfKind(dice, 3) ? result : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.FOUR_A_KIND))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                result += dice[i];
            }
            return(ScoreCategory.isNOfKind(dice, 4) ? result : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.FULLHOUSE))
        {
            return(ScoreCategory.isFullHouse(dice) ? 25 : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.TINY_STRAIGHT))
        {
            return(ScoreCategory.isTinyStraight(dice) ? 20 : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.SMALL_STRAIGHT))
        {
            return(ScoreCategory.isSmallStraight(dice) ? 30 : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.LARGE_STRAIGHT))
        {
            return(ScoreCategory.isLargeStraight(dice) ? 40 : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.YAHTZEE))
        {
            return(ScoreCategory.isYahtzee(dice) ? 50 : 0);
        }
        else if (category.Equals(ScoreCategoryEnum.ScoreCategoryType.CHANCE))
        {
            for (int i = 0; i < dice.Count; i++)
            {
                result += dice[i];
            }
            return(result);
        }
        return(0);
    }
Пример #27
0
        /// <summary>
        /// Get high score in the given server
        /// </summary>
        /// <param name="serverId"></param>
        /// <returns></returns>
        public static HighScore GetHighScore(int serverId, ScoreCategory category, ScoreType type)
        {
            var serializer = new XmlSerializer(typeof(HighScore));

            return((HighScore)serializer.Deserialize(RequestAPI(serverId, highScoreApi, $"?category={(int)category}&type={(int)type}")));
        }
Пример #28
0
    public IEnumerator Test22_ChooseCategory()
    {
        yield return(LoadScene("Scene05"));

        yield return(Press("English Button"));

        yield return(LoadScene("Scene01"));

        yield return(Press("LoadSceneButton"));

        // Choose two category in the upper section
        yield return(LoadScene("Scene02"));

        Setup(1);
        yield return(Press("LoadGameButton"));

        yield return(LoadScene("Scene03"));

        yield return(Press("RollDice"));

        System.Threading.Thread.Sleep(1000);
        List <int> dices = new List <int>();

        dices.AddRange(GetDices().Values);
        // Choose CHANCE
        yield return(Press("CHANCE"));

        System.Threading.Thread.Sleep(1000);
        // Check scoresheet
        int calculatedScore = ScoreCategory.CalculateScore(dices, ScoreCategoryEnum.ScoreCategoryType.CHANCE);
        // Get CHANCE score of player 1
        int scoreChance = getScoreFromScoresheet("016");

        Assert.AreEqual(calculatedScore, scoreChance);
        int lowerScore = getScoreFromScoresheet("017");

        // Next turn
        yield return(Press("Next Turn"));

        yield return(Press("RollDice"));

        dices.Clear();
        dices.AddRange(GetDices().Values);
        // Choose THREE
        yield return(Press("THREE"));

        System.Threading.Thread.Sleep(1000);
        calculatedScore = ScoreCategory.CalculateScore(dices, ScoreCategoryEnum.ScoreCategoryType.THREE);
        // Get THREE score of player 1
        int scoreThree = getScoreFromScoresheet("03");

        Assert.AreEqual(scoreThree, calculatedScore);
        // Check Upper section score
        int upperScore = getScoreFromScoresheet("08");

        Assert.AreEqual(upperScore, scoreThree);
        // Total score
        Assert.AreEqual(getScoreFromScoresheet("019"), upperScore + lowerScore);
        // Button ace and six not clickable
        Assert.False(clickable("THREE"));
        Assert.False(clickable("CHANCE"));
    }
Пример #29
0
 private static string FormattedMessage(ScoreCategory scoreCategory)
 {
     return("This score category is already take: " + scoreCategory);
 }
Пример #30
0
 private void UpdateScoreCategory(ScoreCategory scoreCategory, int scoreForTurn)
 {
     ScoreCategories[scoreCategory].UpdateCategory(scoreForTurn, false);
 }
Пример #31
0
 public ScoreCategoryAlreadyTakenException(ScoreCategory scoreCategory) : base(FormattedMessage(scoreCategory))
 {
 }
Пример #32
0
        public static CategoryScoreCalculator CreateCalculator(ScoreCategory scoreCategory, List <IDie> dice) =>

        //functional inspired programming (F#)/decorative way of programming
        scoreCategory switch
        {
Пример #33
0
        private int GetScoreForCategory(ScoreCategory scoreCategory, List <IDie> diceHeld)
        {
            var categoryCalculator = CategoryCalculatorFactory.CreateCalculator(scoreCategory, diceHeld);

            return(categoryCalculator.Calculate());
        }
Пример #34
0
    private void EditScore(int id)
    {
        Label lblId = modalDialog.FindControl("lblId") as Label;
        TextBox txtName = modalDialog.FindControl("txtName") as TextBox;
        TextBox txtWeight = modalDialog.FindControl("txtWeight") as TextBox;
        TextBox txtMinRange = modalDialog.FindControl("txtMinRange") as TextBox;
        TextBox txtMaxRange = modalDialog.FindControl("txtMaxRange") as TextBox;

        ScoreCategory sc = null;
        if (id > 0)
        {
            sc = ScoreService.GetScoreCategory(id);
        }
        else
        {
            sc = new ScoreCategory();
            Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
            sc.Region = region;
        }
        lblId.Text = id.ToString();
        txtName.Text = sc.Name;
        txtWeight.Text = sc.Weight.ToString();
        txtMinRange.Text = sc.MinRange.ToString();
        txtMaxRange.Text = sc.MaxRange.ToString();
        modalDialog.ShowModal();
    }